From 9dd50a29e1e8b975e09172b19b303063a96ba20f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 4 Aug 2014 12:59:22 +0200 Subject: update shaders and backport some collision changes --- include/mbgl/geometry/icon_buffer.hpp | 8 ++--- include/mbgl/renderer/symbol_bucket.hpp | 42 +++++++++++++++++--------- include/mbgl/shader/icon_shader.hpp | 53 +++++++++++++++++++++++---------- include/mbgl/text/collision.hpp | 14 +++++---- include/mbgl/util/rect.hpp | 3 +- 5 files changed, 80 insertions(+), 40 deletions(-) (limited to 'include') diff --git a/include/mbgl/geometry/icon_buffer.hpp b/include/mbgl/geometry/icon_buffer.hpp index 346b3b5f06..bc9901afb6 100644 --- a/include/mbgl/geometry/icon_buffer.hpp +++ b/include/mbgl/geometry/icon_buffer.hpp @@ -6,13 +6,13 @@ namespace mbgl { class IconVertexBuffer : public Buffer< - 4 + // int16 x/y coordinates per vertex (== 4 bytes) - 4 // uint16 x/y coordinates of icon in sprite (== 4 bytes) + 20 > { public: - typedef int16_t vertex_type; + static const double angleFactor; + + size_t add(int16_t x, int16_t y, float ox, float oy, int16_t tx, int16_t ty, float angle, float minzoom, std::array range, float maxzoom, float labelminzoom); - void add(vertex_type x, vertex_type y, uint16_t tx, uint16_t ty); }; } diff --git a/include/mbgl/renderer/symbol_bucket.hpp b/include/mbgl/renderer/symbol_bucket.hpp index b1917a93b2..c2a8b14f38 100644 --- a/include/mbgl/renderer/symbol_bucket.hpp +++ b/include/mbgl/renderer/symbol_bucket.hpp @@ -4,6 +4,8 @@ #include "bucket.hpp" #include #include +#include +#include #include #include #include @@ -16,9 +18,6 @@ namespace mbgl { class Style; -class TextVertexBuffer; -class IconVertexBuffer; -class TriangleElementsBuffer; class TextShader; class IconShader; class DotShader; @@ -29,9 +28,14 @@ class GlyphAtlas; class GlyphStore; class FontStack; -class SymbolBucket : public Bucket { - typedef ElementGroup triangle_group_type; +class SymbolFeature { +public: + pbf geometry; + std::u32string label; + std::string sprite; +}; +class SymbolBucket : public Bucket { public: SymbolBucket( TextVertexBuffer &textVertexBuffer, @@ -57,6 +61,14 @@ public: void drawIcons(DotShader& shader); private: + + std::vector processFeatures(const VectorTileLayer &layer, const FilterExpression &filter, GlyphStore &glyphStore, const Sprite &sprite); + void addFeature(const pbf &geom_pbf, const Shaping &shaping, const Rect &image); + void addFeature(const std::vector &line, const Shaping &shaping, const Rect &image); + + + + void addGlyph(uint64_t tileid, const std::string stackname, const std::u32string &string, const FontStack &fontStack, GlyphAtlas &glyphAtlas, GlyphPositions &face); void addFeature(const pbf &geom_pbf, const GlyphPositions &face, const Shaping &shaping); @@ -65,18 +77,20 @@ public: const StyleBucketSymbol &properties; private: - TextVertexBuffer& textVertexBuffer; - IconVertexBuffer& iconVertexBuffer; - TriangleElementsBuffer& triangleElementsBuffer; Placement &placement; - const size_t text_vertex_start; - const size_t icon_vertex_start; - const size_t triangle_elements_start; - size_t icon_vertex_end = 0; - VertexArrayObject array; + struct { + TextVertexBuffer vertices; + TriangleElementsBuffer triangles; + std::vector groups; + } text; + + struct { + IconVertexBuffer vertices; + TriangleElementsBuffer triangles; + std::vector groups; + } icon; - std::vector triangleGroups; }; } diff --git a/include/mbgl/shader/icon_shader.hpp b/include/mbgl/shader/icon_shader.hpp index b97b3c2be3..eab4843877 100644 --- a/include/mbgl/shader/icon_shader.hpp +++ b/include/mbgl/shader/icon_shader.hpp @@ -11,30 +11,53 @@ public: void bind(char *offset); - void setImage(int32_t image); - void setColor(const std::array& color); - void setDimension(const std::array& dimension); - void setSize(float size); - void setRatio(float ratio); + void setExtrudeMatrix(const std::array& exmatrix); + void setAngle(float angle); + void setZoom(float zoom); + void setFlip(float flip); + void setFadeDist(float fadedist); + void setMinFadeZoom(float minfadezoom); + void setMaxFadeZoom(float maxfadezoom); + void setFadeZoom(float fadezoom); + void setOpacity(float opacity); private: int32_t a_pos = -1; + int32_t a_offset = -1; int32_t a_tex = -1; + int32_t a_angle = -1; + int32_t a_minzoom = -1; + int32_t a_maxzoom = -1; + int32_t a_rangeend = -1; + int32_t a_rangestart = -1; + int32_t a_labelminzoom = -1; - int32_t image = -1; - int32_t u_image = -1; + std::array exmatrix = {{}}; + int32_t u_exmatrix = -1; - std::array color = {{}}; - int32_t u_color = -1; + float angle = 0; + int32_t u_angle = -1; - std::array dimension = {{}}; - int32_t u_dimension = -1; + float zoom = 0; + int32_t u_zoom = -1; - float size = 0; - int32_t u_size = -1; + float flip = 0; + int32_t u_flip = -1; - float ratio = 0; - int32_t u_ratio = -1; + float fadedist = 0; + int32_t u_fadedist = -1; + + float minfadezoom = 0; + int32_t u_minfadezoom = -1; + + float maxfadezoom = 0; + int32_t u_maxfadezoom = -1; + + float fadezoom = 0; + int32_t u_fadezoom = -1; + + float opacity = 0; + int32_t u_opacity = -1; }; } diff --git a/include/mbgl/text/collision.hpp b/include/mbgl/text/collision.hpp index 31103a7439..8911b3b4c6 100644 --- a/include/mbgl/text/collision.hpp +++ b/include/mbgl/text/collision.hpp @@ -8,13 +8,12 @@ namespace mbgl { class Collision { public: - Collision(); + Collision(float zoom, float tileExtent, float tileSize, float placementDepth = 1); ~Collision(); - PlacementProperty place(const GlyphBoxes &boxes, - const CollisionAnchor &anchor, - float minPlacementScale, float maxPlacementScale, - float padding, bool horizontal, bool alwaysVisible); + PlacementProperty place(const GlyphBoxes &boxes, const CollisionAnchor &anchor, + float minPlacementScale, float maxPlacementScale, float padding, + bool horizontal, bool allowOverlap, bool ignorePlacement); float getPlacementScale(const GlyphBoxes &glyphs, float minPlacementScale, float maxPlacementScale, float pad); PlacementRange getPlacementRange(const GlyphBoxes &glyphs, @@ -24,8 +23,11 @@ public: bool horizontal, float padding); private: - void *cTree; void *hTree; + void *cTree; + const float tilePixelRatio; + const float zoom; + const float maxPlacementScale; }; } diff --git a/include/mbgl/util/rect.hpp b/include/mbgl/util/rect.hpp index a216b8e145..4e524b4156 100644 --- a/include/mbgl/util/rect.hpp +++ b/include/mbgl/util/rect.hpp @@ -5,7 +5,8 @@ namespace mbgl { template struct Rect { - explicit Rect(T x, T y, T w, T h) : x(x), y(y), w(w), h(h) {} + inline Rect() {} + inline Rect(T x, T y, T w, T h) : x(x), y(y), w(w), h(h) {} T x = 0, y = 0; T w = 0, h = 0; -- cgit v1.2.1