-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Enable property functions for "fill-color" and "fill-outline-color" #2629
Conversation
} | ||
} | ||
|
||
}); |
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.
This is not an ideal long term architecture. I'm thinking on how to improve this...
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.
You could DRY up the code by something like this:
FillStyleLayer.prototype.fallbackMapping = {'fill-outline-color': 'fill-color'};
And then using this object to map properties in StyleLayer
, avoiding code duplication.
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.
I'm not sold on that design
- Similar branching logic would still need to be written, but it'd be in
StyleLayer
rather thanFillLayer
- I can't think of many (any?) other style properties that have fallback behaviour like this
My preferred solution would be to factor out all the per-paint-property methods in StyleLayer
into a StyleValue
class (that might replace StyleDeclaration
and/or StyleTransition
)
type StyleValue<T> {
isZoomConstant: boolean;
isFeatureConstant: boolean;
calculate(zoom:number, featureProperties: {}) => T;
getInterpolationT(zoom: number) =>;
...
}
Then, FillStyleLayer
's implementation would only have one overriden method:
getStyleValue: function(name) {
if (name === 'fill-outline-color' && this.getPaintProperty('fill-outline-color') === undefined) {
return StyleLayer.prototype.getStyleValue.call(this, 'fill-color');
} else {
return StyleLayer.prototype.getStyleValue.call(this, name);
}
}
All that said, I'd be happy to 🚢 with the code in this PR for now. It may be verbose and non-DRY but it is clear, robust, and well-contained.
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.
The proposed refactor sounds great! Yeah, we can follow-up on that later. I'd make sure to run benchmarks before merging though because things like this make things slower if they're in hot path.
'fill', | ||
bucket.paintAttributes.fill[layer.id].defines, | ||
bucket.paintAttributes.fill[layer.id].vertexPragmas, | ||
bucket.paintAttributes.fill[layer.id].fragmentPragmas |
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.
var attributes = bucket.paintAttributes.fill[layer.id];
Ready to 🚢 @jfirebaugh @mourner? |
I'm not caught up on gl-js buffer architecture so I don't think I can meaningfully review here. |
Main thread perf seems to have taken a hit: BenchmarksBufferthis branch: 854 ms FPSthis branch: 48fps Frame Durationthis branch: 19.7 ms per frame. 72% of frames took longer than 16ms. |
@lucaswoj whoa, 2.5x slower frame is a blocker for merging. I guess we'll have to refactor this. |
@mourner the perf regression was due to a bug in BenchmarksBufferthis branch: 809 ms FPSthis branch: 60fps Frame Durationthis branch: 9.7 ms per frame. 1% of frames took longer than 16ms. |
That looks much better. If you can't find a way to fight back that 2ms within a reasonable timeframe (say half an hour), let's 🚢 and figure out later. |
@mourner I suspect that 2ms is just measurement error. I'll try to create a cleaner testing environment and see if the discrepancy goes away. |
I was wrong -- the difference is definitely significant. this branch9.7 ms per frame. 1% of frames took longer than 16ms. master8.3 ms per frame. 0% of frames took longer than 16ms. |
I got a smidgen of perf back by optimizing This is something we can and should optimize later but will require some bigger architectural work. |
In context of frame performance, even 2ms is 20% difference. Let's make sure we don't loose track of this, maybe ticket? |
➡️ #2640 |
ref mapbox/mapbox-gl-shaders#3
ref mapbox/mapbox-gl-test-suite#99
cc @jakepruitt @jfirebaugh @mourner @tmcw