summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2014-09-05 14:43:52 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2014-09-08 15:12:32 -0700
commiteb4f53cbed1953d4016975d14424fb2bc6bbf3d3 (patch)
tree7fb5a502641ed762a7579165408678bf8a51c0a2 /include
parent2033eb94941496ac12fa3af21fb75764af17e4b9 (diff)
downloadqtlocation-mapboxgl-eb4f53cbed1953d4016975d14424fb2bc6bbf3d3.tar.gz
SDF icon support (fixes #404)
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/map/sprite.hpp3
-rw-r--r--include/mbgl/renderer/painter.hpp15
-rw-r--r--include/mbgl/renderer/symbol_bucket.hpp6
-rw-r--r--include/mbgl/shader/sdf_shader.hpp15
4 files changed, 33 insertions, 6 deletions
diff --git a/include/mbgl/map/sprite.hpp b/include/mbgl/map/sprite.hpp
index 7bc6665570..6461a5e33d 100644
--- a/include/mbgl/map/sprite.hpp
+++ b/include/mbgl/map/sprite.hpp
@@ -19,7 +19,7 @@ class FileSource;
class SpritePosition {
public:
explicit SpritePosition() {}
- explicit SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t height, float pixelRatio = 1.0f);
+ explicit SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t height, float pixelRatio, bool sdf);
operator bool() const {
return !(width == 0 && height == 0 && x == 0 && y == 0);
@@ -28,6 +28,7 @@ public:
uint16_t x = 0, y = 0;
uint16_t width = 0, height = 0;
float pixelRatio = 1.0f;
+ bool sdf = false;
};
class Sprite : public std::enable_shared_from_this<Sprite>, private util::noncopyable {
diff --git a/include/mbgl/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp
index af50a6b52a..75529d1136 100644
--- a/include/mbgl/renderer/painter.hpp
+++ b/include/mbgl/renderer/painter.hpp
@@ -120,12 +120,24 @@ public:
void discardFramebuffers();
bool needsAnimation() const;
+
private:
void setupShaders();
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);
@@ -176,7 +188,8 @@ public:
std::unique_ptr<PatternShader> patternShader;
std::unique_ptr<IconShader> iconShader;
std::unique_ptr<RasterShader> rasterShader;
- std::unique_ptr<SDFShader> sdfShader;
+ std::unique_ptr<SDFGlyphShader> sdfGlyphShader;
+ std::unique_ptr<SDFIconShader> sdfIconShader;
std::unique_ptr<DotShader> dotShader;
std::unique_ptr<GaussianShader> gaussianShader;
diff --git a/include/mbgl/renderer/symbol_bucket.hpp b/include/mbgl/renderer/symbol_bucket.hpp
index 23de5e6e5a..c71d276456 100644
--- a/include/mbgl/renderer/symbol_bucket.hpp
+++ b/include/mbgl/renderer/symbol_bucket.hpp
@@ -51,7 +51,7 @@ typedef std::vector<Symbol> Symbols;
class SymbolBucket : public Bucket {
typedef ElementGroup<1> TextElementGroup;
- typedef ElementGroup<1> IconElementGroup;
+ typedef ElementGroup<2> IconElementGroup;
public:
SymbolBucket(const StyleBucketSymbol &properties, Collision &collision);
@@ -68,7 +68,8 @@ public:
void addGlyphs(const PlacedGlyphs &glyphs, float placementZoom, PlacementRange placementRange,
float zoom);
- void drawGlyphs(SDFShader &shader);
+ void drawGlyphs(SDFShader& shader);
+ void drawIcons(SDFShader& shader);
void drawIcons(IconShader& shader);
private:
@@ -90,6 +91,7 @@ private:
public:
const StyleBucketSymbol &properties;
+ bool sdfIcons = false;
private:
Collision &collision;
diff --git a/include/mbgl/shader/sdf_shader.hpp b/include/mbgl/shader/sdf_shader.hpp
index ba1937d3c3..0737c25ee1 100644
--- a/include/mbgl/shader/sdf_shader.hpp
+++ b/include/mbgl/shader/sdf_shader.hpp
@@ -10,7 +10,7 @@ class SDFShader : public Shader {
public:
SDFShader();
- void bind(char *offset);
+ virtual void bind(char *offset) = 0;
UniformMatrix<4> u_matrix = {"u_matrix", *this};
UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this};
@@ -26,7 +26,7 @@ public:
Uniform<float> u_maxfadezoom = {"u_maxfadezoom", *this};
Uniform<float> u_fadezoom = {"u_fadezoom", *this};
-private:
+protected:
int32_t a_pos = -1;
int32_t a_offset = -1;
int32_t a_tex = -1;
@@ -37,6 +37,17 @@ private:
int32_t a_rangestart = -1;
int32_t a_labelminzoom = -1;
};
+
+class SDFGlyphShader : public SDFShader {
+public:
+ void bind(char *offset);
+};
+
+class SDFIconShader : public SDFShader {
+public:
+ void bind(char *offset);
+};
+
}
#endif