diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-03-21 17:36:29 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-03-21 17:36:29 +0100 |
commit | ea6b24d02d9d7a2a24a97f29c60f485f331e9e79 (patch) | |
tree | e701517bcc6433633515453a4c37bb850f6850da /include | |
parent | a7b9b96d4de44d8f8bf87f5fc5104190c3233945 (diff) | |
download | qtlocation-mapboxgl-ea6b24d02d9d7a2a24a97f29c60f485f331e9e79.tar.gz |
add text rendering code
Diffstat (limited to 'include')
-rw-r--r-- | include/llmr/geometry/glyph_atlas.hpp | 6 | ||||
-rw-r--r-- | include/llmr/map/map.hpp | 2 | ||||
-rw-r--r-- | include/llmr/renderer/frame_history.hpp | 29 | ||||
-rw-r--r-- | include/llmr/renderer/painter.hpp | 6 | ||||
-rw-r--r-- | include/llmr/shader/text_shader.hpp | 12 | ||||
-rw-r--r-- | include/llmr/style/properties.hpp | 12 |
6 files changed, 54 insertions, 13 deletions
diff --git a/include/llmr/geometry/glyph_atlas.hpp b/include/llmr/geometry/glyph_atlas.hpp index b97b79f086..312572f5ef 100644 --- a/include/llmr/geometry/glyph_atlas.hpp +++ b/include/llmr/geometry/glyph_atlas.hpp @@ -34,10 +34,12 @@ public: void removeGlyphs(uint64_t tile_id); void bind(); -private: - std::mutex mtx; +public: const uint16_t width = 0; const uint16_t height = 0; + +private: + std::mutex mtx; BinPack<uint16_t> bin; std::map<std::string, std::map<uint32_t, GlyphValue>> index; char *const data = nullptr; diff --git a/include/llmr/map/map.hpp b/include/llmr/map/map.hpp index b24a7bc5ae..90cd95c01e 100644 --- a/include/llmr/map/map.hpp +++ b/include/llmr/map/map.hpp @@ -78,8 +78,8 @@ private: Transform transform; Texturepool texturepool; Style style; - Painter painter; GlyphAtlas glyphAtlas; + Painter painter; int32_t min_zoom; int32_t max_zoom; diff --git a/include/llmr/renderer/frame_history.hpp b/include/llmr/renderer/frame_history.hpp new file mode 100644 index 0000000000..7326f627b1 --- /dev/null +++ b/include/llmr/renderer/frame_history.hpp @@ -0,0 +1,29 @@ +#ifndef LLMR_RENDERER_FRAME_HISTORY +#define LLMR_RENDERER_FRAME_HISTORY + +#include <deque> +#include <cassert> +#include <cmath> + +#include <llmr/platform/platform.hpp> + +namespace llmr { + +struct FrameSnapshot { + explicit inline FrameSnapshot(float time, float z) : time(time), z(z) {} + float time; + float z; +}; + +class FrameHistory { +public: + // Record frame history that will be used to calculate fading params + void record(float zoom); + +public: + std::deque<FrameSnapshot> history; +}; + +} + +#endif diff --git a/include/llmr/renderer/painter.hpp b/include/llmr/renderer/painter.hpp index 71973aba08..027c7e215a 100644 --- a/include/llmr/renderer/painter.hpp +++ b/include/llmr/renderer/painter.hpp @@ -6,6 +6,7 @@ #include <llmr/geometry/vertex_buffer.hpp> #include <llmr/util/mat4.hpp> #include <llmr/util/noncopyable.hpp> +#include <llmr/renderer/frame_history.hpp> #include <llmr/shader/plain_shader.hpp> #include <llmr/shader/outline_shader.hpp> @@ -30,7 +31,7 @@ class TextBucket; class Painter : private util::noncopyable { public: - Painter(Transform& transform, Settings& settings, Style& style); + Painter(Transform& transform, Settings& settings, Style& style, GlyphAtlas& glyphAtlas); void setup(); void clear(); @@ -68,8 +69,9 @@ private: Transform& transform; Settings& settings; Style& style; + GlyphAtlas& glyphAtlas; - + FrameHistory frameHistory; uint32_t gl_program = 0; float gl_lineWidth = 0; diff --git a/include/llmr/shader/text_shader.hpp b/include/llmr/shader/text_shader.hpp index 7edf10d235..db3028cf87 100644 --- a/include/llmr/shader/text_shader.hpp +++ b/include/llmr/shader/text_shader.hpp @@ -15,15 +15,15 @@ public: void setColor(const std::array<float, 4> &color); void setBuffer(float buffer); void setGamma(float gamma); - void setExmatrix(const std::array<float, 16> &exmatrix); + 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 setTexsize(const std::array<float, 2> &texsize); + void setFadeDist(float fadedist); + void setMinFadeZoom(float minfadezoom); + void setMaxFadeZoom(float maxfadezoom); + void setFadeZoom(float fadezoom); + void setTextureSize(const std::array<float, 2> &texsize); private: int32_t a_pos = -1; diff --git a/include/llmr/style/properties.hpp b/include/llmr/style/properties.hpp index f3bc1054cd..3fae1537ce 100644 --- a/include/llmr/style/properties.hpp +++ b/include/llmr/style/properties.hpp @@ -113,11 +113,19 @@ struct FillProperties { }; struct TextClass { - Color color = {{ 1, 1, 1, 1 }}; + FunctionProperty<bool> hidden; + Color color = {{ 0, 0, 0, 1 }}; + Color halo = {{ 1, 1, 1, 0.75 }}; + FunctionProperty<float> haloRadius = 0.25f; + FunctionProperty<float> size = 12.0f; }; struct TextProperties { - Color color = {{ 1, 1, 1, 1 }}; + bool hidden = false; + Color color = {{ 0, 0, 0, 1 }}; + Color halo = {{ 1, 1, 1, 0.75 }}; + float haloRadius = 0.25f; + float size = 12.0f; }; struct BackgroundClass { |