#ifndef MBGL_RENDERER_PAINTER #define MBGL_RENDERER_PAINTER #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { class Style; class StyleLayer; class Tile; class SpriteAtlas; class GlyphAtlas; class LineAtlas; class Source; struct FrameData; class DebugBucket; class FillBucket; class FillLayer; class LineBucket; class LineLayer; class CircleBucket; class CircleLayer; class SymbolBucket; class SymbolLayer; class RasterBucket; class RasterLayer; class BackgroundLayer; class SDFShader; class PlainShader; class OutlineShader; class LineShader; class LinejoinShader; class LineSDFShader; class LinepatternShader; class CircleShader; class PatternShader; class IconShader; class RasterShader; class SDFGlyphShader; class SDFIconShader; class DotShader; class CollisionBoxShader; struct ClipID; namespace util { class GLObjectStore; } class Painter : private util::noncopyable { public: Painter(MapData&, TransformState&, gl::GLObjectStore&); ~Painter(); void render(const Style& style, const FrameData& frame, SpriteAtlas& annotationSpriteAtlas); // Renders debug information for a tile. void renderTileDebug(const Tile& tile); // Renders the red debug frame around a tile, visualizing its perimeter. void renderDebugFrame(const mat4 &matrix); void renderDebugText(TileData&, const mat4&); void renderFill(FillBucket&, const FillLayer&, const TileID&, const mat4&); void renderLine(LineBucket&, const LineLayer&, const TileID&, const mat4&); void renderCircle(CircleBucket&, const CircleLayer&, const TileID&, const mat4&); void renderSymbol(SymbolBucket&, const SymbolLayer&, const TileID&, const mat4&); void renderRaster(RasterBucket&, const RasterLayer&, const TileID&, const mat4&); void renderBackground(const BackgroundLayer&); float saturationFactor(float saturation); float contrastFactor(float contrast); std::array spinWeights(float spin_value); void drawClippingMasks(const std::map&); bool needsAnimation() const; private: mat4 translatedMatrix(const mat4& matrix, const std::array &translation, const TileID &id, TranslateAnchorType anchor); std::vector determineRenderOrder(const Style& style); template void renderPass(RenderPass, Iterator it, Iterator end, GLsizei i, int8_t increment); void prepareTile(const Tile& tile); template void renderSDF(SymbolBucket &bucket, const TileID &id, const mat4 &matrixSymbol, const BucketProperties& bucketProperties, const StyleProperties& styleProperties, float scaleDivisor, std::array texsize, SDFShader& sdfShader, void (SymbolBucket::*drawSDF)(SDFShader&, gl::GLObjectStore&)); void setDepthSublayer(int n); mat4 projMatrix; mat4 nativeMatrix; mat4 extrudeMatrix; // used to composite images and flips the geometry upside down const mat4 flipMatrix = []{ mat4 flip; matrix::ortho(flip, 0, util::EXTENT, -util::EXTENT, 0, 0, 1); matrix::translate(flip, flip, 0, -util::EXTENT, 0); return flip; }(); const mat4 identityMatrix = []{ mat4 identity; matrix::identity(identity); return identity; }(); MapData& data; TransformState& state; gl::GLObjectStore& glObjectStore; FrameData frame; int indent = 0; gl::Config config; RenderPass pass = RenderPass::Opaque; int numSublayers = 3; GLsizei currentLayer; float depthRangeSize; const float depthEpsilon = 1.0f / (1 << 16); SpriteAtlas* spriteAtlas; GlyphAtlas* glyphAtlas; LineAtlas* lineAtlas; FrameHistory frameHistory; std::unique_ptr plainShader; std::unique_ptr outlineShader; std::unique_ptr lineShader; std::unique_ptr linesdfShader; std::unique_ptr linepatternShader; std::unique_ptr patternShader; std::unique_ptr iconShader; std::unique_ptr rasterShader; std::unique_ptr sdfGlyphShader; std::unique_ptr sdfIconShader; std::unique_ptr dotShader; std::unique_ptr collisionBoxShader; std::unique_ptr circleShader; StaticVertexBuffer backgroundBuffer = { { -1, -1 }, { 1, -1 }, { -1, 1 }, { 1, 1 } }; VertexArrayObject backgroundArray; // Set up the stencil quad we're using to generate the stencil mask. StaticVertexBuffer tileStencilBuffer = { // top left triangle { 0, 0 }, { util::EXTENT, 0 }, { 0, util::EXTENT }, // bottom right triangle { util::EXTENT, 0 }, { 0, util::EXTENT }, { util::EXTENT, util::EXTENT }, }; VertexArrayObject coveringPlainArray; VertexArrayObject coveringRasterArray; // Set up the tile boundary lines we're using to draw the tile outlines. StaticVertexBuffer tileBorderBuffer = { { 0, 0 }, { util::EXTENT, 0 }, { util::EXTENT, util::EXTENT }, { 0, util::EXTENT }, { 0, 0 }, }; VertexArrayObject tileBorderArray; }; } // namespace mbgl #endif