#pragma once #include #include #include #include #include #include #include #include namespace mbgl { namespace gfx { class Drawable; class UniformBuffer; using UniformBufferPtr = std::shared_ptr; } // namespace gfx namespace style { class LayerProperties; enum class TranslateAnchorType : bool; } // namespace style class LayerGroupBase; class PaintParameters; class RenderTree; class TransformState; class UnwrappedTileID; /** Base class for layer tweakers, which manipulate layer group per frame */ class LayerTweaker { protected: LayerTweaker(std::string id, Immutable properties); public: LayerTweaker() = delete; virtual ~LayerTweaker() = default; const std::string& getID() const { return id; } virtual void execute(LayerGroupBase&, const PaintParameters&) = 0; void updateProperties(Immutable); /// Calculate matrices for this tile. /// @param nearClipped If true, the near plane is moved further to enhance depth buffer precision. /// @param inViewportPixelUnits If false, the translation is scaled based on the current zoom. static mat4 getTileMatrix(const UnwrappedTileID&, const PaintParameters&, const std::array& translation, style::TranslateAnchorType, bool nearClipped, bool inViewportPixelUnits, const gfx::Drawable& drawable, bool aligned = false); protected: /// Determine whether this tweaker should apply to the given drawable bool checkTweakDrawable(const gfx::Drawable&) const; /// Multiplies with the projection matrix (either default, near clipped or aligned) for the given drawable static void multiplyWithProjectionMatrix(/*in-out*/ mat4& matrix, const PaintParameters& parameters, const gfx::Drawable& drawable, bool nearClipped, bool aligned); std::string id; Immutable evaluatedProperties; // Indicates that the evaluated properties have changed bool propertiesUpdated = true; }; } // namespace mbgl