-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix icon-fit with variable label placement #8755
Conversation
debug/8583.html
Outdated
@@ -0,0 +1,133 @@ | |||
<!DOCTYPE html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you planning to commit this file? It would be more useful for the next developer if it was named more appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for adding the render test @arindam1993 , both that & the debug page (on Linux Firefox/Chrome) look good 💚
One question below, and relatedly: do we need tests that this works also when combined with multi-line and/or vertical labels?
Some of those (currently ignored) tests are failing, for example text-writing-mode/point_label/mixed-multiline-vertical-horizontal-mode-icon-text-fit
, and the failure doesn't look to me like it has to do with the 1px issue addressed in #8741. Thoughts?
updateVariableAnchors(bucket, rotateWithMap, pitchWithMap, variableOffsets, symbolSize, | ||
tr, labelPlaneMatrix, coord.posMatrix, tileScale, size); | ||
} else if (isText && size && bucket.allowVerticalPlacement) { | ||
} else if (isText && size && bucket.allowVerticalPlacement && !variablePlacement) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I'm missing something but why the && !variablePlacement
here? IIRC we can have both vertical & variable placement enabled at the same time, are we accounting for that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we're not. In the interest of time time this PR only handles icon-text-fit
rendering for horizontal variable anchor labels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌 Maybe we should ticket that out
const variablePlacement = layer.layout.get('text-variable-anchor'); | ||
|
||
//Compute variable-offsets before painting since icons and text data positioning | ||
//depend on each other in this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
Yes, will address that and shifting of icon collision boxes in a separate PR. This was intended as a fix to the biggest visual glitch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 since we're not attempting to resolve the combo-vertical-variable-placement issue in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few additional notes:
- This PR does not change the behavior for multi-line labels - that case remains broken.
- Works well with CJK characters
- Needs follow up issues for fixing icon-text-fit with vertical symbols and fixing collision boxes
src/symbol/symbol_layout.js
Outdated
const verticalTextBoxStartIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length; | ||
const verticalTextBoxEndIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length; | ||
|
||
//Place icon first, so text can have a reference it its index in the placed symbol array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: typo in reference it its index
src/render/draw_symbol.js
Outdated
const size = symbolSize.evaluateSizeForZoom(sizeData, tr.zoom); | ||
|
||
const s = pixelsToTileUnits(tile, 1, painter.transform.zoom); | ||
const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Avoid temporary variable buffers
and s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intention to fix text-writing-mode/point_label/cjk-variable-anchors-vertical-horizontal-mode-icon-text-fit
as well? Regardless of the icon-text-fit
aspect, it seems like the
Here's the native version with collision boxes activated (which arguably seems wrong too):
And this is the JS version in this branch:
for reference, this is the JS version before this patch:
It looks like there are no tests that are unignored, which means there are render test cases missing that were broken in the old behavior, but work with this patch applied. Could you please add some?
No I didn't intend to fix that, this change only ensures that the offset thats calculated and applied to
I have added one(see original PR body), but its not fully representative of this fix since its doing collision. Updating so |
@asheemmamoowala
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking at the vertical icons!
This is an attempt to isolate and cherry pick just the fix required for #8583 from #8737 .
The issue seems to be caused by the fact that
draw_symbol.js:#updateVariableAnchors
applies an offset to the text glyphs , but never touches the icon buffer at all.This PR adds an attribute to the
placedSymbol
buffers, calledassociatedSymbolIndex
, this lets the textplacedSymbol
instances know which icon they're associated with.So at render time the offsets can be applied in both buffers.
It also moves the offset calculation out of the paint loop, since icons and text need to share the same data.
This still leaves out making
icon-text-fit
update the collision box (#8722) and making it work with vertical labels.UPDATE:
![2019-09-17 13 41 22](https://user-images.githubusercontent.com/1449257/65077963-e4c15f80-d950-11e9-9720-af27ca7d12c9.gif)
demo, 1 frame desynch fixed
Added a render test
![actual](https://user-images.githubusercontent.com/1449257/65077776-81373200-d950-11e9-9c63-8d44ad4ac2c3.png)
Before (on master):
After:
![expected](https://user-images.githubusercontent.com/1449257/65077797-8c8a5d80-d950-11e9-8cd1-0f248c1de655.png)
Launch Checklist
document any changes to public APIstagged@mapbox/studio
and/or@mapbox/maps-design
if this PR includes style spec changestagged@mapbox/gl-native
if this PR includes shader changes or needs a native port