-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[core] data-driven styling support for *-pattern properties #12284
Conversation
22b5a65
to
03986b9
Compare
d31d3c2
to
0fa5cfd
Compare
1b307e2
to
e064984
Compare
still a few things to do but this is working for the most part and ready for review
|
3e45622
to
0ab9b7b
Compare
include/mbgl/util/tuple.hpp
Outdated
@@ -2,18 +2,20 @@ | |||
|
|||
// Polyfill needed by Windows because MSVC STL | |||
// is not compatible with our IndexedTuple code | |||
#if defined(_WINDOWS) | |||
#if 0 |
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.
We should remove the polyfill from the code and tao from cmake if it is no longer needed.
Mean't to request a change, not approve.
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.
Wow, what a pull request! This already looks fairly polished to me; I didn't notice any changes that still need to happen on a code level; all my comments are about code formatting.
@jfirebaugh, do you have any ideas for how we could reduce the code size increase of this PR?
@@ -48,6 +49,18 @@ class IndexedTuple<TypeList<Is...>, TypeList<Ts...>> : public tuple_polyfill<Ts. | |||
other.template get<Js>()... | |||
}; | |||
} | |||
|
|||
// Help out MSVC++ | |||
bool operator==(const IndexedTuple<TypeList<Is...>, TypeList<Ts...>>& other) const { |
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.
why is the second parameter not const
here?
src/mbgl/gl/uniform.hpp
Outdated
@@ -42,18 +35,19 @@ ActiveUniforms activeUniforms(ProgramID); | |||
template <class Tag, class T> | |||
class Uniform { | |||
public: | |||
using Value = UniformValue<Tag, T>; | |||
// TODO should maybe remove this altogether bc it is now redundant? | |||
using Value = T; |
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.
👍
@@ -39,7 +39,8 @@ bool CircleBucket::hasData() const { | |||
} | |||
|
|||
void CircleBucket::addFeature(const GeometryTileFeature& feature, | |||
const GeometryCollection& geometry) { | |||
const GeometryCollection& geometry, | |||
const ImagePositions&) { |
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: indentation
@@ -18,7 +18,8 @@ class CircleBucket : public Bucket { | |||
CircleBucket(const BucketParameters&, const std::vector<const RenderLayer*>&); | |||
|
|||
void addFeature(const GeometryTileFeature&, | |||
const GeometryCollection&) override; | |||
const GeometryCollection&, | |||
const mbgl::ImagePositions&) override; |
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: indentation
template <class T, class A1, class A2> | ||
class CompositeCrossFadedPaintPropertyBinder : public PaintPropertyBinder<T, std::array<uint16_t, 4>, PossiblyEvaluatedPropertyValue<Faded<T>>, A1, A2> { | ||
public: | ||
// to fix -- we will want to use both attributes |
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.
Does this still need addressing?
@@ -328,7 +338,16 @@ void GeometryTileWorker::parse() { | |||
} | |||
} | |||
|
|||
std::vector<std::string> patternOrder; | |||
for (auto it = layers->rbegin(); it != layers->rend(); it++) { |
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.
Why are we iterating backwards here?
Here's bloaty size diff output for the macOS dynamic framework: https://gist.github.com/jfirebaugh/40eeb26948d13076990952441401de39 |
06d0fc6
to
b16e36c
Compare
@jfirebaugh would you mind taking a look specifically at the changes in |
9594235
to
5d0d582
Compare
using FillPatternLayout = PatternLayout<FillBucket>; | ||
using FillExtrusionPatternLayout = PatternLayout<FillExtrusionBucket>; | ||
|
||
std::vector<variant<std::unique_ptr<LinePatternLayout>, std::unique_ptr<FillPatternLayout>, std::unique_ptr<FillExtrusionPatternLayout>>> patternLayouts; |
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 an instance where we'd be better off with an abstract Layout
base class rather than using variant
. Both SymbolLayout
and PatternLayout
should inherit from it. The goal should be that GeometryTileWorker
can treat layouts uniformly:
- Replace
symbolLayouts
andpatternLayouts
with a singlestd::vector<std::unique_ptr<Layout>> layouts
member, and a single loop over alllayouts
inperformSymbolLayout
. GeometryTileWorker
has two steps, currently namedparse
andperformSymbolLayout
. Let's come up with better names. Perhapsprepare
andfinalize
? While we're at it, we should also take theSymbol
out ofhasPendingSymbolDependencies
. Symbols aren't so special anymore.- Make
createLayout
a virtual method inRenderLayer
. It can return a nullunique_ptr<Layout>
, indicating thatcreateBucket
should be used instead. (Or should we make things completely uniform, and have a simpleLayout
subclass for every layer type, even those that don't have dependencies? Then we could call the two worker stepscreateLayouts
andcreateBuckets
, and have only a singleRenderLayer::createLayout
method. This approach would be more work, but sounds cleaner.)
You'll need to do some design work to figure out what the Layout
interface should look like. It looks like it might be a single method createBucket
(name open for discussion):
- For the concrete subclass
SymbolLayout
, this would be a combination of the methodsprepare
andplace
. - For pattern layouts, there's already a
createBucket
method. Is it possible to remove the conditional incheckPatternLayout
, always create the layout, and have it do the work thatcheckPatternLayout
is doing now in the case that a pattern isn't being used? - To avoid
GeometryTileWorker
needing to iterate over concretelayerPaintProperties
types, it's fine ifcreateBucket
takes as a mutable input parameter thebuckets
map and emplaces into it in a loop itself. createBucket
will need a lot of input parameters, not all of which are used by every subclass. That's okay. One pattern that's been effective in situations like this is to package all the parameters into a struct (BucketParameters
,PropertyEvaluationParameters
, etc.). This allows us to add or remove arguments without needing to modify the parameter list in every subclass.
I think these changes will make GeometryTileWorker
easier to understand and modify, and hopefully it will help reduce the binary size impact as well.
59566b9
to
d26d7c0
Compare
e21b240
to
3292677
Compare
…ure expressions in `*-pattern` properties
* The worker no longer needs to maintain symbol layer order. * No need for separate symbolLayoutsNeedPreparation state. That dates back to when we had "two phase" symbol layout. Now we can just check symbolLayouts.empty(). (Similarly for pattern layouts.) * No need to loop over symbol layouts twice in performSymbolLayout. Same reason as above. * Simplify iconAtlas initialization. It initialized via every possible branch, so just do it up front.
3292677
to
4e48ca1
Compare
corresponding PR to mapbox/mapbox-gl-js#6289
TODO:
Faded
valuesline-pattern
support to other-pattern
propertiesthanks to @kkaefer, @anandthakker, and @jfirebaugh for all the help wrangling the gnarly templating challenges in this one!