[core] Convert style properties to a tuple-based approach
This converts the style property classes (CirclePaintProperties and so on) to the same tuple-based approach as gl::Attribute and gl::Uniform. The approach is outlined in https://github.com/mapbox/cpp/blob/master/C%2B%2B%20Structural%20Metaprogramming.md. The main advantage of this approach is it allows writing algorithms that work on sets of style properties, without resorting to code generation or manually repetitive code. This lets us iterate on approaches to data-driven properties more easily. Another advantage is that the cascading, unevaluated, and evaluated states of a set of properties exist as independent structures, instead of individual properties holding their own state. This is a more functional approach that makes data flow clearer and reduces state.
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
PositionedIcon shapeIcon(const SpriteAtlasElement& image, const style::SymbolLayoutProperties& layout) {
|
||||
float dx = layout.iconOffset.value[0];
|
||||
float dy = layout.iconOffset.value[1];
|
||||
using namespace style;
|
||||
|
||||
PositionedIcon shapeIcon(const SpriteAtlasElement& image, const SymbolLayoutProperties::Evaluated& layout) {
|
||||
float dx = layout.get<IconOffset>()[0];
|
||||
float dy = layout.get<IconOffset>()[1];
|
||||
float x1 = dx - image.spriteImage->getWidth() / 2.0f;
|
||||
float x2 = x1 + image.spriteImage->getWidth();
|
||||
float y1 = dy - image.spriteImage->getHeight() / 2.0f;
|
||||
|
||||
Reference in New Issue
Block a user