diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-01-23 15:33:00 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-01-23 15:33:00 +0100 |
commit | d153bdeff459cf1acc9b76e894386a15e79a976f (patch) | |
tree | 97f245f8e962ae739f9f51af3883adc011b2cb7b /src | |
parent | dba3be98292ac9aa5afda9c73336a67bfb842a2a (diff) | |
download | qtlocation-mapboxgl-d153bdeff459cf1acc9b76e894386a15e79a976f.tar.gz |
add style object
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/map/map.cpp | 6 | ||||
-rw-r--r-- | src/renderer/fill_bucket.cpp | 8 | ||||
-rw-r--r-- | src/renderer/painter.cpp | 14 | ||||
-rw-r--r-- | src/style/style.cpp | 15 |
5 files changed, 33 insertions, 11 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b4e3557643..7593877d91 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,6 +12,7 @@ SET(llmr_SOURCES renderer/shader.cpp renderer/fill_bucket.cpp shader/shaders.cpp + style/style.cpp util/animation.cpp util/mat4.cpp ) diff --git a/src/map/map.cpp b/src/map/map.cpp index 913dd7e4aa..8470af8a45 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -14,6 +14,7 @@ Map::Map(Settings& settings) : settings(settings), transform(), painter(transform, settings), + style(), min_zoom(0), max_zoom(14) { } @@ -25,6 +26,11 @@ void Map::setup() { painter.setup(); } +void Map::loadStyle(const uint8_t *data, uint32_t bytes) { + style.load(pbf(data, bytes)); + update(); +} + void Map::loadSettings() { transform.setAngle(settings.angle); transform.setScale(settings.scale); diff --git a/src/renderer/fill_bucket.cpp b/src/renderer/fill_bucket.cpp index 24de51df50..3af3495c92 100644 --- a/src/renderer/fill_bucket.cpp +++ b/src/renderer/fill_bucket.cpp @@ -91,9 +91,9 @@ void FillBucket::addGeometry(pbf& geom) { void FillBucket::render(Painter& painter) { // TODO: obtain the correct style information for this layer - FillStyle style; - style.fill_color = {{ 0, 0, 1, 0.5 }}; - style.stroke_color = style.fill_color; + FillProperties properties; + properties.fill_color = {{ 0, 0, 1, 0.5 }}; + properties.stroke_color = properties.fill_color; - painter.renderFill(*this, style); + painter.renderFill(*this, properties); } diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 8f1d4f1c9d..b1fd196d09 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -179,7 +179,7 @@ void Painter::render(const Tile::Ptr& tile) { renderBackground(); } -void Painter::renderFill(const FillBucket& bucket, const FillStyle& style) { +void Painter::renderFill(const FillBucket& bucket, const FillProperties& properties) { // Draw the stencil mask. { // We're only drawing to the first seven bits (== support a maximum of @@ -193,7 +193,7 @@ void Painter::renderFill(const FillBucket& bucket, const FillStyle& style) { // orientation, while all holes (see below) are in CW orientation. glStencilFunc(GL_NOTEQUAL, 0x80, 0x80); - if (style.winding == EvenOdd) { + if (properties.winding == EvenOdd) { // When we draw an even/odd winding fill, we just invert all the bits. glStencilOp(GL_INVERT, GL_KEEP, GL_KEEP); } else { @@ -234,17 +234,17 @@ void Painter::renderFill(const FillBucket& bucket, const FillStyle& style) { // Because we're drawing top-to-bottom, and we update the stencil mask // below, we have to draw the outline first (!) - if (style.antialiasing) { + if (properties.antialiasing) { switchShader(outlineShader); glUniformMatrix4fv(outlineShader->u_matrix, 1, GL_FALSE, matrix); glLineWidth(2); - if (style.stroke_color != style.fill_color) { + if (properties.stroke_color != properties.fill_color) { // If we defined a different color for the fill outline, we are // going to ignore the bits in 0x3F and just care about the global // clipping mask. glStencilFunc(GL_EQUAL, 0x80, 0x80); - glUniform4fv(outlineShader->u_color, 1, style.stroke_color.data()); + glUniform4fv(outlineShader->u_color, 1, properties.stroke_color.data()); } else { // Otherwise, we only want to draw the antialiased parts that are // *outside* the current shape. This is important in case the fill @@ -252,7 +252,7 @@ void Painter::renderFill(const FillBucket& bucket, const FillStyle& style) { // the current shape, some pixels from the outline stroke overlapped // the (non-antialiased) fill. glStencilFunc(GL_EQUAL, 0x80, 0xBF); - glUniform4fv(outlineShader->u_color, 1, style.fill_color.data()); + glUniform4fv(outlineShader->u_color, 1, properties.fill_color.data()); } glUniform2f(outlineShader->u_world, transform.fb_width, transform.fb_height); @@ -292,7 +292,7 @@ void Painter::renderFill(const FillBucket& bucket, const FillStyle& style) { // Draw filling rectangle. switchShader(fillShader); glUniformMatrix4fv(fillShader->u_matrix, 1, GL_FALSE, matrix); - glUniform4fv(fillShader->u_color, 1, style.fill_color.data()); + glUniform4fv(fillShader->u_color, 1, properties.fill_color.data()); } // Only draw regions that we marked diff --git a/src/style/style.cpp b/src/style/style.cpp new file mode 100644 index 0000000000..a999289a04 --- /dev/null +++ b/src/style/style.cpp @@ -0,0 +1,15 @@ +#include <llmr/style/style.hpp> + +using namespace llmr; + +Style::Style() { + +} + +void Style::reset() { + +} + +void Style::load(pbf data) { + +} |