summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-08-04 12:59:22 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-08-04 12:59:22 +0200
commit9dd50a29e1e8b975e09172b19b303063a96ba20f (patch)
tree0f35c1d304aafcf465762484848d33e58342c391 /include
parent19e51e8bd89f0e627045b623a2a57b6702bca896 (diff)
downloadqtlocation-mapboxgl-9dd50a29e1e8b975e09172b19b303063a96ba20f.tar.gz
update shaders and backport some collision changes
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/geometry/icon_buffer.hpp8
-rw-r--r--include/mbgl/renderer/symbol_bucket.hpp42
-rw-r--r--include/mbgl/shader/icon_shader.hpp53
-rw-r--r--include/mbgl/text/collision.hpp14
-rw-r--r--include/mbgl/util/rect.hpp3
5 files changed, 80 insertions, 40 deletions
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<float, 2> 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 <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>
@@ -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<SymbolFeature> processFeatures(const VectorTileLayer &layer, const FilterExpression &filter, GlyphStore &glyphStore, const Sprite &sprite);
+ void addFeature(const pbf &geom_pbf, const Shaping &shaping, const Rect<uint16_t> &image);
+ void addFeature(const std::vector<Coordinate> &line, const Shaping &shaping, const Rect<uint16_t> &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<ElementGroup> groups;
+ } text;
+
+ struct {
+ IconVertexBuffer vertices;
+ TriangleElementsBuffer triangles;
+ std::vector<ElementGroup> groups;
+ } icon;
- std::vector<triangle_group_type> 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<float, 4>& color);
- void setDimension(const std::array<float, 2>& dimension);
- void setSize(float size);
- void setRatio(float ratio);
+ void setExtrudeMatrix(const std::array<float, 16>& 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<float, 16> exmatrix = {{}};
+ int32_t u_exmatrix = -1;
- std::array<float, 4> color = {{}};
- int32_t u_color = -1;
+ float angle = 0;
+ int32_t u_angle = -1;
- std::array<float, 2> 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 <typename T>
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;