diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-12-04 18:29:42 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-12-04 20:02:50 +0100 |
commit | abafb52f37beb5659efc2105ccd1568e1f754898 (patch) | |
tree | 6a60636d3497560ca61e5aae5f6d7061c4f18553 /include/mbgl/renderer | |
parent | bff6aeb4da41dee1f5f1cfa0be81b6c257257253 (diff) | |
download | qtlocation-mapboxgl-abafb52f37beb5659efc2105ccd1568e1f754898.tar.gz |
make most headers private
Diffstat (limited to 'include/mbgl/renderer')
-rw-r--r-- | include/mbgl/renderer/bucket.hpp | 24 | ||||
-rw-r--r-- | include/mbgl/renderer/debug_bucket.hpp | 35 | ||||
-rw-r--r-- | include/mbgl/renderer/fill_bucket.hpp | 88 | ||||
-rw-r--r-- | include/mbgl/renderer/frame_history.hpp | 40 | ||||
-rw-r--r-- | include/mbgl/renderer/line_bucket.hpp | 62 | ||||
-rw-r--r-- | include/mbgl/renderer/painter.hpp | 259 | ||||
-rw-r--r-- | include/mbgl/renderer/prerendered_texture.hpp | 37 | ||||
-rw-r--r-- | include/mbgl/renderer/raster_bucket.hpp | 38 | ||||
-rw-r--r-- | include/mbgl/renderer/symbol_bucket.hpp | 114 |
9 files changed, 0 insertions, 697 deletions
diff --git a/include/mbgl/renderer/bucket.hpp b/include/mbgl/renderer/bucket.hpp deleted file mode 100644 index 696bfb1110..0000000000 --- a/include/mbgl/renderer/bucket.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MBGL_RENDERER_BUCKET -#define MBGL_RENDERER_BUCKET - -#include <mbgl/map/tile.hpp> -#include <mbgl/util/noncopyable.hpp> - -#include <string> - -namespace mbgl { - -class Painter; -class StyleLayer; - -class Bucket : private util::noncopyable { -public: - virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) = 0; - virtual bool hasData() const = 0; - virtual ~Bucket() {} - -}; - -} - -#endif diff --git a/include/mbgl/renderer/debug_bucket.hpp b/include/mbgl/renderer/debug_bucket.hpp deleted file mode 100644 index fb6cfb4cae..0000000000 --- a/include/mbgl/renderer/debug_bucket.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef MBGL_RENDERER_DEBUGBUCKET -#define MBGL_RENDERER_DEBUGBUCKET - -#include <mbgl/renderer/bucket.hpp> -#include <mbgl/geometry/debug_font_buffer.hpp> -#include <mbgl/geometry/vao.hpp> - -#include <vector> - -#ifndef BUFFER_OFFSET -#define BUFFER_OFFSET(i) ((char *)nullptr + (i)) -#endif - -namespace mbgl { - -class PlainShader; - -class DebugBucket : public Bucket { -public: - DebugBucket(DebugFontBuffer& fontBuffer); - - virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); - virtual bool hasData() const; - - void drawLines(PlainShader& shader); - void drawPoints(PlainShader& shader); - -private: - DebugFontBuffer& fontBuffer; - VertexArrayObject array; -}; - -} - -#endif diff --git a/include/mbgl/renderer/fill_bucket.hpp b/include/mbgl/renderer/fill_bucket.hpp deleted file mode 100644 index ae766ec28d..0000000000 --- a/include/mbgl/renderer/fill_bucket.hpp +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef MBGL_RENDERER_FILLBUCKET -#define MBGL_RENDERER_FILLBUCKET - -#include <mbgl/renderer/bucket.hpp> -#include <mbgl/geometry/elements_buffer.hpp> -#include <mbgl/geometry/fill_buffer.hpp> -#include <mbgl/style/style_bucket.hpp> - -#include <clipper/clipper.hpp> -#include <libtess2/tesselator.h> - -#include <vector> -#include <memory> - -#ifndef BUFFER_OFFSET -#define BUFFER_OFFSET(i) ((char *)nullptr + (i)) -#endif - -namespace mbgl { - -class Style; -class FillVertexBuffer; -class TriangleElementsBuffer; -class LineElementsBuffer; -class BucketDescription; -class OutlineShader; -class PlainShader; -class PatternShader; -struct pbf; - -class FillBucket : public Bucket { - - static void *alloc(void *data, unsigned int size); - static void *realloc(void *data, void *ptr, unsigned int size); - static void free(void *userData, void *ptr); - - typedef ElementGroup<2> triangle_group_type; - typedef ElementGroup<1> line_group_type; - -public: - FillBucket(FillVertexBuffer& vertexBuffer, - TriangleElementsBuffer& triangleElementsBuffer, - LineElementsBuffer& lineElementsBuffer, - const StyleBucketFill& properties); - ~FillBucket(); - - virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); - virtual bool hasData() const; - - void addGeometry(pbf& data); - void tessellate(); - - void drawElements(PlainShader& shader); - void drawElements(PatternShader& shader); - void drawVertices(OutlineShader& shader); - -public: - const StyleBucketFill &properties; - -private: - TESSalloc *allocator; - TESStesselator *tesselator; - ClipperLib::Clipper clipper; - - FillVertexBuffer& vertexBuffer; - TriangleElementsBuffer& triangleElementsBuffer; - LineElementsBuffer& lineElementsBuffer; - - // hold information on where the vertices are located in the FillBuffer - const size_t vertex_start; - const size_t triangle_elements_start; - const size_t line_elements_start; - VertexArrayObject array; - - std::vector<triangle_group_type> triangleGroups; - std::vector<line_group_type> lineGroups; - - std::vector<ClipperLib::IntPoint> line; - bool hasVertices = false; - - static const int vertexSize = 2; - static const int stride = sizeof(TESSreal) * vertexSize; - static const int vertices_per_group = 3; -}; - -} - -#endif diff --git a/include/mbgl/renderer/frame_history.hpp b/include/mbgl/renderer/frame_history.hpp deleted file mode 100644 index 61bb59da33..0000000000 --- a/include/mbgl/renderer/frame_history.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef MBGL_RENDERER_FRAME_HISTORY -#define MBGL_RENDERER_FRAME_HISTORY - -#include <deque> -#include <cassert> -#include <cmath> - -#include <mbgl/platform/platform.hpp> -#include <mbgl/util/time.hpp> - -namespace mbgl { - -struct FrameSnapshot { - explicit inline FrameSnapshot(timestamp t_, float z_) : t(t_), z(z_) {} - float t; - float z; -}; - -struct FadeProperties { - float fadedist; - float minfadezoom; - float maxfadezoom; - float bump; -}; - -class FrameHistory { -public: - // Record frame history that will be used to calculate fading params - void record(timestamp now, float zoom); - - bool needsAnimation(timestamp duration) const; - FadeProperties getFadeProperties(timestamp duration); - -public: - std::deque<FrameSnapshot> history; -}; - -} - -#endif diff --git a/include/mbgl/renderer/line_bucket.hpp b/include/mbgl/renderer/line_bucket.hpp deleted file mode 100644 index 7337ca80ad..0000000000 --- a/include/mbgl/renderer/line_bucket.hpp +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef MBGL_RENDERER_LINEBUCKET -#define MBGL_RENDERER_LINEBUCKET - -#include <mbgl/renderer/bucket.hpp> -#include <mbgl/geometry/vao.hpp> -#include <mbgl/geometry/elements_buffer.hpp> -#include <mbgl/geometry/line_buffer.hpp> -#include <mbgl/style/style_bucket.hpp> - -#include <vector> - -namespace mbgl { - -class Style; -class LineVertexBuffer; -class TriangleElementsBuffer; -class LineShader; -class LinejoinShader; -class LinepatternShader; -struct pbf; - -class LineBucket : public Bucket { - typedef ElementGroup<2> triangle_group_type; - typedef ElementGroup<1> point_group_type; - -public: - LineBucket(LineVertexBuffer& vertexBuffer, - TriangleElementsBuffer& triangleElementsBuffer, - PointElementsBuffer& pointElementsBuffer, - const StyleBucketLine& properties); - - virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); - virtual bool hasData() const; - - void addGeometry(pbf& data); - void addGeometry(const std::vector<Coordinate>& line); - - bool hasPoints() const; - - void drawLines(LineShader& shader); - void drawLinePatterns(LinepatternShader& shader); - void drawPoints(LinejoinShader& shader); - -public: - const StyleBucketLine &properties; - -private: - LineVertexBuffer& vertexBuffer; - TriangleElementsBuffer& triangleElementsBuffer; - PointElementsBuffer& pointElementsBuffer; - - const size_t vertex_start; - const size_t triangle_elements_start; - const size_t point_elements_start; - - std::vector<triangle_group_type> triangleGroups; - std::vector<point_group_type> pointGroups; -}; - -} - -#endif diff --git a/include/mbgl/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp deleted file mode 100644 index be4bd12710..0000000000 --- a/include/mbgl/renderer/painter.hpp +++ /dev/null @@ -1,259 +0,0 @@ -#ifndef MBGL_RENDERER_PAINTER -#define MBGL_RENDERER_PAINTER - -#include <mbgl/map/tile_data.hpp> -#include <mbgl/geometry/vao.hpp> -#include <mbgl/geometry/static_vertex_buffer.hpp> -#include <mbgl/util/mat4.hpp> -#include <mbgl/util/noncopyable.hpp> -#include <mbgl/renderer/frame_history.hpp> -#include <mbgl/style/types.hpp> - -#include <mbgl/shader/plain_shader.hpp> -#include <mbgl/shader/outline_shader.hpp> -#include <mbgl/shader/pattern_shader.hpp> -#include <mbgl/shader/line_shader.hpp> -#include <mbgl/shader/linejoin_shader.hpp> -#include <mbgl/shader/linepattern_shader.hpp> -#include <mbgl/shader/icon_shader.hpp> -#include <mbgl/shader/raster_shader.hpp> -#include <mbgl/shader/sdf_shader.hpp> -#include <mbgl/shader/dot_shader.hpp> -#include <mbgl/shader/gaussian_shader.hpp> - -#include <mbgl/map/transform_state.hpp> -#include <mbgl/util/ptr.hpp> - -#include <map> -#include <unordered_map> -#include <set> - -namespace mbgl { - -enum class RenderPass : bool { Opaque, Translucent }; - -class Transform; -class Style; -class Tile; -class Sprite; -class SpriteAtlas; -class GlyphAtlas; -class Source; -class StyleSource; -class StyleLayerGroup; - -class FillBucket; -class LineBucket; -class SymbolBucket; -class RasterBucket; -class PrerenderedTexture; - -struct FillProperties; -struct RasterProperties; - -class LayerDescription; -class RasterTileData; - -class Painter : private util::noncopyable { -public: - Painter(SpriteAtlas&, GlyphAtlas&); - ~Painter(); - - void setup(); - - // Perform cleanup tasks that prepare shutting down the app. This doesn't mean that the - // app will be shut down. That means all operations must be automatically be reversed (e.g. through - // lazy initialization) in case rendering continues. - void cleanup(); - - void terminate(); - - // Renders the backdrop of the OpenGL view. This also paints in areas where we don't have any - // tiles whatsoever. - void clear(); - - // Updates the default matrices to the current viewport dimensions. - void changeMatrix(); - - void render(const Style& style, - const std::set<util::ptr<StyleSource>>& sources, - TransformState state, - timestamp time); - - void renderLayers(util::ptr<StyleLayerGroup> group); - void renderLayer(util::ptr<StyleLayer> layer_desc, const Tile::ID* id = nullptr, const mat4* matrix = nullptr); - - // Renders a particular layer from a tile. - void renderTileLayer(const Tile& tile, util::ptr<StyleLayer> layer_desc, const mat4 &matrix); - - // 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(DebugBucket& bucket, const mat4 &matrix); - void renderDebugText(const std::vector<std::string> &strings); - void renderFill(FillBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); - void renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); - void renderSymbol(SymbolBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); - void renderRaster(RasterBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); - void renderBackground(util::ptr<StyleLayer> layer_desc); - - float saturationFactor(float saturation); - float contrastFactor(float contrast); - std::array<float, 3> spinWeights(float spin_value); - - void preparePrerender(RasterBucket &bucket); - - void renderPrerenderedTexture(RasterBucket &bucket, const mat4 &matrix, const RasterProperties& properties); - - void createPrerendered(RasterBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id); - - void resize(); - - // Changes whether debug information is drawn onto the map - void setDebug(bool enabled); - - // Opaque/Translucent pass setting - void setOpaque(); - void setTranslucent(); - - // Configures the painter strata that is used for early z-culling of fragments. - void setStrata(float strata); - - void drawClippingMasks(const std::set<util::ptr<StyleSource>> &sources); - void drawClippingMask(const mat4& matrix, const ClipID& clip); - - void resetFramebuffer(); - void bindFramebuffer(); - void pushFramebuffer(); - GLuint popFramebuffer(); - void discardFramebuffers(); - - bool needsAnimation() const; - -private: - void setupShaders(); - void deleteShaders(); - mat4 translatedMatrix(const mat4& matrix, const std::array<float, 2> &translation, const Tile::ID &id, TranslateAnchorType anchor); - - void prepareTile(const Tile& tile); - - template <typename BucketProperties, typename StyleProperties> - void renderSDF(SymbolBucket &bucket, - const Tile::ID &id, - const mat4 &matrixSymbol, - const BucketProperties& bucketProperties, - const StyleProperties& styleProperties, - float scaleDivisor, - std::array<float, 2> texsize, - SDFShader& sdfShader, - void (SymbolBucket::*drawSDF)(SDFShader&)); - -public: - void useProgram(uint32_t program); - void lineWidth(float lineWidth); - void depthMask(bool value); - void depthRange(float near, float far); - -public: - 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, 4096, -4096, 0, 0, 1); - matrix::translate(flip, flip, 0, -4096, 0); - return flip; - }(); - - const mat4 identityMatrix = []{ - mat4 identity; - matrix::identity(identity); - return identity; - }(); - -private: - TransformState state; - - bool debug = false; - int indent = 0; - - uint32_t gl_program = 0; - float gl_lineWidth = 0; - bool gl_depthMask = true; - std::array<uint16_t, 2> gl_viewport = {{ 0, 0 }}; - std::array<float, 2> gl_depthRange = {{ 0, 1 }}; - float strata = 0; - RenderPass pass = RenderPass::Opaque; - const float strata_epsilon = 1.0f / (1 << 16); - -public: - FrameHistory frameHistory; - - SpriteAtlas& spriteAtlas; - GlyphAtlas& glyphAtlas; - - std::unique_ptr<PlainShader> plainShader; - std::unique_ptr<OutlineShader> outlineShader; - std::unique_ptr<LineShader> lineShader; - std::unique_ptr<LinejoinShader> linejoinShader; - std::unique_ptr<LinepatternShader> linepatternShader; - std::unique_ptr<PatternShader> patternShader; - std::unique_ptr<IconShader> iconShader; - std::unique_ptr<RasterShader> rasterShader; - std::unique_ptr<SDFGlyphShader> sdfGlyphShader; - std::unique_ptr<SDFIconShader> sdfIconShader; - std::unique_ptr<DotShader> dotShader; - std::unique_ptr<GaussianShader> gaussianShader; - - 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 }, - { 4096, 0 }, - { 0, 4096 }, - - // bottom right triangle - { 4096, 0 }, - { 0, 4096 }, - { 4096, 4096 }, - }; - - VertexArrayObject coveringPlainArray; - VertexArrayObject coveringRasterArray; - VertexArrayObject coveringGaussianArray; - - // Set up the tile boundary lines we're using to draw the tile outlines. - StaticVertexBuffer tileBorderBuffer = { - { 0, 0 }, - { 4096, 0 }, - { 4096, 4096 }, - { 0, 4096 }, - { 0, 0 }, - }; - - VertexArrayObject tileBorderArray; - - // Framebuffer management - std::vector<GLuint> fbos; - std::vector<GLuint> fbos_color; - GLuint fbo_depth_stencil; - int fbo_level = -1; - bool fbo_depth_stencil_valid = false; - -}; - -} - -#endif diff --git a/include/mbgl/renderer/prerendered_texture.hpp b/include/mbgl/renderer/prerendered_texture.hpp deleted file mode 100644 index e4dc610418..0000000000 --- a/include/mbgl/renderer/prerendered_texture.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef MBGL_RENDERER_PRERENDERED_TEXTURE -#define MBGL_RENDERER_PRERENDERED_TEXTURE - -#include <mbgl/util/noncopyable.hpp> -#include <mbgl/platform/gl.hpp> - -namespace mbgl { - -class StyleBucketRaster; -class Painter; - -class PrerenderedTexture : private util::noncopyable { -public: - PrerenderedTexture(const StyleBucketRaster &properties); - ~PrerenderedTexture(); - - void bindTexture(); - void bindFramebuffer(); - void unbindFramebuffer(); - - inline GLuint getTexture() const { return texture; } - - void blur(Painter& painter, uint16_t passes); - -public: - const StyleBucketRaster &properties; - -private: - GLint previous_fbo = 0; - GLuint fbo = 0; - GLuint texture = 0; - GLuint fbo_depth_stencil = 0; -}; - -} - -#endif diff --git a/include/mbgl/renderer/raster_bucket.hpp b/include/mbgl/renderer/raster_bucket.hpp deleted file mode 100644 index 0a7651d7cc..0000000000 --- a/include/mbgl/renderer/raster_bucket.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef MBGL_RENDERER_RASTERBUCKET -#define MBGL_RENDERER_RASTERBUCKET - -#include <mbgl/renderer/bucket.hpp> -#include <mbgl/util/raster.hpp> -#include <mbgl/renderer/prerendered_texture.hpp> -#include <mbgl/style/style_bucket.hpp> - - - -namespace mbgl { - -class RasterShader; -class StaticVertexBuffer; -class VertexArrayObject; - -class RasterBucket : public Bucket { -public: - RasterBucket(TexturePool&, const StyleBucketRaster&); - - virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); - virtual bool hasData() const; - - bool setImage(const std::string &data); - - const StyleBucketRaster &properties; - PrerenderedTexture texture; - - void drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array); - - void drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array, GLuint texture); - - Raster raster; -}; - -} - -#endif diff --git a/include/mbgl/renderer/symbol_bucket.hpp b/include/mbgl/renderer/symbol_bucket.hpp deleted file mode 100644 index 9a5da1d012..0000000000 --- a/include/mbgl/renderer/symbol_bucket.hpp +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef MBGL_RENDERER_SYMBOLBUCKET -#define MBGL_RENDERER_SYMBOLBUCKET - -#include "bucket.hpp" -#include <mbgl/geometry/vao.hpp> -#include <mbgl/geometry/elements_buffer.hpp> -#include <mbgl/geometry/text_buffer.hpp> -#include <mbgl/geometry/icon_buffer.hpp> -#include <mbgl/map/vector_tile.hpp> -#include <mbgl/text/types.hpp> -#include <mbgl/text/glyph.hpp> -#include <mbgl/style/style_bucket.hpp> - -#include <memory> -#include <map> -#include <vector> - -namespace mbgl { - -class Style; -class SDFShader; -class IconShader; -class DotShader; -class Collision; -class SpriteAtlas; -class Sprite; -class GlyphAtlas; -class GlyphStore; -class FontStack; - -class SymbolFeature { -public: - pbf geometry; - std::u32string label; - std::string sprite; -}; - - -class Symbol { -public: - vec2<float> tl, tr, bl, br; - Rect<uint16_t> tex; - float angle; - float minScale = 0.0f; - float maxScale = std::numeric_limits<float>::infinity(); - CollisionAnchor anchor; -}; - -typedef std::vector<Symbol> Symbols; - - -class SymbolBucket : public Bucket { - typedef ElementGroup<1> TextElementGroup; - typedef ElementGroup<2> IconElementGroup; - -public: - SymbolBucket(const StyleBucketSymbol &properties, Collision &collision); - - virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix); - virtual bool hasData() const; - virtual bool hasTextData() const; - virtual bool hasIconData() const; - - void addFeatures(const VectorTileLayer &layer, const FilterExpression &filter, - const Tile::ID &id, SpriteAtlas &spriteAtlas, Sprite &sprite, - GlyphAtlas &glyphAtlas, GlyphStore &glyphStore); - - void addGlyphs(const PlacedGlyphs &glyphs, float placementZoom, PlacementRange placementRange, - float zoom); - - void drawGlyphs(SDFShader& shader); - void drawIcons(SDFShader& shader); - void drawIcons(IconShader& shader); - -private: - - std::vector<SymbolFeature> processFeatures(const VectorTileLayer &layer, const FilterExpression &filter, GlyphStore &glyphStore, const Sprite &sprite); - - - void addFeature(const pbf &geom_pbf, const Shaping &shaping, const GlyphPositions &face, const Rect<uint16_t> &image); - void addFeature(const std::vector<Coordinate> &line, const Shaping &shaping, const GlyphPositions &face, const Rect<uint16_t> &image); - - - // Adds placed items to the buffer. - template <typename Buffer> - void addSymbols(Buffer &buffer, const PlacedGlyphs &symbols, float scale, PlacementRange placementRange); - - // Adds glyphs to the glyph atlas so that they have a left/top/width/height coordinates associated to them that we can use for writing to a buffer. - static void addGlyphsToAtlas(uint64_t tileid, const std::string stackname, const std::u32string &string, - const FontStack &fontStack, GlyphAtlas &glyphAtlas, GlyphPositions &face); - -public: - const StyleBucketSymbol &properties; - bool sdfIcons = false; - -private: - Collision &collision; - - struct { - TextVertexBuffer vertices; - TriangleElementsBuffer triangles; - std::vector<TextElementGroup> groups; - } text; - - struct { - IconVertexBuffer vertices; - TriangleElementsBuffer triangles; - std::vector<IconElementGroup> groups; - } icon; - -}; -} - -#endif |