summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llmr/map/tile.hpp2
-rw-r--r--include/llmr/renderer/bucket.hpp1
-rw-r--r--include/llmr/renderer/fill_bucket.hpp5
-rw-r--r--include/llmr/style/style.hpp1
-rw-r--r--src/map/tile.cpp2
-rw-r--r--src/renderer/fill_bucket.cpp24
-rw-r--r--src/renderer/painter.cpp35
7 files changed, 30 insertions, 40 deletions
diff --git a/include/llmr/map/tile.hpp b/include/llmr/map/tile.hpp
index d70675be9c..b1aac9a67a 100644
--- a/include/llmr/map/tile.hpp
+++ b/include/llmr/map/tile.hpp
@@ -68,7 +68,7 @@ public:
linevertexbuffer lineVertex;
debug_font_buffer debugFontVertex;
- std::shared_ptr<FillBuffer> fillBuffer;
+ FillBuffer fillBuffer;
std::forward_list<Layer> layers;
diff --git a/include/llmr/renderer/bucket.hpp b/include/llmr/renderer/bucket.hpp
index 8970ca7e3e..adf1c8ed0c 100644
--- a/include/llmr/renderer/bucket.hpp
+++ b/include/llmr/renderer/bucket.hpp
@@ -10,7 +10,6 @@ class Painter;
class Bucket {
public:
- virtual void draw(const Style& style, const std::string& layerName) = 0;
virtual void render(Painter& painter) = 0;
};
diff --git a/include/llmr/renderer/fill_bucket.hpp b/include/llmr/renderer/fill_bucket.hpp
index c1c844e859..fc34e54511 100644
--- a/include/llmr/renderer/fill_bucket.hpp
+++ b/include/llmr/renderer/fill_bucket.hpp
@@ -13,15 +13,14 @@ struct pbf;
class FillBucket : public Bucket {
public:
- FillBucket(const std::shared_ptr<FillBuffer>& buffer);
+ FillBucket(FillBuffer& buffer);
void addGeometry(pbf& data);
- virtual void draw(const Style& style, const std::string& layerName);
virtual void render(Painter& painter);
public:
- std::shared_ptr<FillBuffer> buffer;
+ FillBuffer& buffer;
struct group {
uint32_t vertex_length;
diff --git a/include/llmr/style/style.hpp b/include/llmr/style/style.hpp
index 44d2ee7fce..fd0e4a06e1 100644
--- a/include/llmr/style/style.hpp
+++ b/include/llmr/style/style.hpp
@@ -34,7 +34,6 @@ struct FillStyle {
float stroke_width = 1;
};
-
class Style {
public:
StrokeStyle strokeStyle(const std::string& layer_name) const;
diff --git a/src/map/tile.cpp b/src/map/tile.cpp
index 983ccff947..4dac3e82f1 100644
--- a/src/map/tile.cpp
+++ b/src/map/tile.cpp
@@ -42,7 +42,7 @@ std::forward_list<Tile::ID> Tile::children(const ID& id, int32_t z) {
Tile::Tile(ID id)
: id(id),
state(initial),
- fillBuffer(std::make_shared<FillBuffer>()),
+ fillBuffer(),
data(0),
bytes(0) {
diff --git a/src/renderer/fill_bucket.cpp b/src/renderer/fill_bucket.cpp
index 73e6d8d029..24de51df50 100644
--- a/src/renderer/fill_bucket.cpp
+++ b/src/renderer/fill_bucket.cpp
@@ -11,10 +11,10 @@ struct geometry_too_long_exception : std::exception {};
using namespace llmr;
-FillBucket::FillBucket(const std::shared_ptr<FillBuffer>& buffer)
+FillBucket::FillBucket(FillBuffer& buffer)
: buffer(buffer),
- vertex_start(buffer->vertex_length()),
- elements_start(buffer->elements_length()),
+ vertex_start(buffer.vertex_length()),
+ elements_start(buffer.elements_length()),
length(0) {
}
@@ -41,14 +41,14 @@ void FillBucket::addGeometry(pbf& geom) {
}
for (const std::vector<std::pair<int16_t, int16_t>>& line : lines) {
- uint32_t vertex_start = buffer->vertex_length();
+ uint32_t vertex_start = buffer.vertex_length();
- buffer->addDegenerate();
+ buffer.addDegenerate();
for (const std::pair<int16_t, int16_t>& coord : line) {
- buffer->addCoordinate(coord.first, coord.second);
+ buffer.addCoordinate(coord.first, coord.second);
}
- uint32_t vertex_end = buffer->vertex_length();
+ uint32_t vertex_end = buffer.vertex_length();
if (vertex_end - vertex_start > 65535) {
throw geometry_too_long_exception();
@@ -76,23 +76,19 @@ void FillBucket::addGeometry(pbf& geom) {
assert(firstIndex + vertex_count - 1 < 65536);
- uint32_t elements_start = buffer->elements_length();
+ uint32_t elements_start = buffer.elements_length();
for (uint32_t i = 2; i < vertex_count; i++) {
- buffer->addElements(firstIndex, firstIndex + i - 1, firstIndex + i);
+ buffer.addElements(firstIndex, firstIndex + i - 1, firstIndex + i);
}
- uint32_t elements_end = buffer->elements_length();
+ uint32_t elements_end = buffer.elements_length();
uint32_t elements_count = elements_end - elements_start;
group.vertex_length += vertex_count;
group.elements_length += elements_count;
}
}
-void FillBucket::draw(const Style& style, const std::string& layerName) {
-
-}
-
void FillBucket::render(Painter& painter) {
// TODO: obtain the correct style information for this layer
FillStyle style;
diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp
index 6b71b3031d..8f1d4f1c9d 100644
--- a/src/renderer/painter.cpp
+++ b/src/renderer/painter.cpp
@@ -157,19 +157,16 @@ void Painter::render(const Tile::Ptr& tile) {
drawClippingMask();
- switchShader(outlineShader);
- glUniformMatrix4fv(outlineShader->u_matrix, 1, GL_FALSE, matrix);
+ // switchShader(outlineShader);
+ // glUniformMatrix4fv(outlineShader->u_matrix, 1, GL_FALSE, matrix);
- // glStencilFunc(GL_EQUAL, 0x80, 0x80);
- // glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
-
- // draw lines:
- tile->lineVertex.bind();
- glVertexAttribPointer(outlineShader->a_pos, 2, GL_SHORT, GL_FALSE, 0, BUFFER_OFFSET(0));
- glUniform4f(outlineShader->u_color, 0.0f, 0.0f, 0.0f, 1.0f);
- glUniform2f(outlineShader->u_world, transform.fb_width, transform.fb_height);
- glLineWidth(2.0f);
- glDrawArrays(GL_LINE_STRIP, 0, tile->lineVertex.length());
+ // // draw lines:
+ // tile->lineVertex.bind();
+ // glVertexAttribPointer(outlineShader->a_pos, 2, GL_SHORT, GL_FALSE, 0, BUFFER_OFFSET(0));
+ // glUniform4f(outlineShader->u_color, 0.0f, 0.0f, 0.0f, 1.0f);
+ // glUniform2f(outlineShader->u_world, transform.fb_width, transform.fb_height);
+ // glLineWidth(2.0f);
+ // glDrawArrays(GL_LINE_STRIP, 0, tile->lineVertex.length());
for (Layer& layer : tile->layers) {
layer.bucket->render(*this);
@@ -218,7 +215,7 @@ void Painter::renderFill(const FillBucket& bucket, const FillStyle& style) {
// Draw all groups
char *vertex_index = BUFFER_OFFSET(bucket.vertex_start * 2 * sizeof(uint16_t));
char *elements_index = BUFFER_OFFSET(bucket.elements_start * 3 * sizeof(uint16_t));
- bucket.buffer->bind();
+ bucket.buffer.bind();
for (const auto& group : bucket.groups) {
glVertexAttribPointer(fillShader->a_pos, 2, GL_SHORT, GL_FALSE, 0, vertex_index);
glDrawElements(GL_TRIANGLES, group.elements_length * 3, GL_UNSIGNED_SHORT, elements_index);
@@ -247,8 +244,7 @@ void Painter::renderFill(const FillBucket& bucket, const FillStyle& style) {
// going to ignore the bits in 0x3F and just care about the global
// clipping mask.
glStencilFunc(GL_EQUAL, 0x80, 0x80);
- const Color& color = style.stroke_color;
- glUniform4f(outlineShader->u_color, color[0], color[1], color[2], color[3]);
+ glUniform4fv(outlineShader->u_color, 1, style.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
@@ -256,8 +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);
- const Color& color = style.fill_color;
- glUniform4f(outlineShader->u_color, color[0], color[1], color[2], color[3]);
+ glUniform4fv(outlineShader->u_color, 1, style.fill_color.data());
}
glUniform2f(outlineShader->u_world, transform.fb_width, transform.fb_height);
@@ -297,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);
- glUniform4f(fillShader->u_color, style.fill_color[0], style.fill_color[1], style.fill_color[2], style.fill_color[3]);
+ glUniform4fv(fillShader->u_color, 1, style.fill_color.data());
}
// Only draw regions that we marked
@@ -345,10 +340,12 @@ void Painter::renderBackground() {
switchShader(fillShader);
glUniformMatrix4fv(fillShader->u_matrix, 1, GL_FALSE, matrix);
+ Color white = {{ 1, 1, 1, 1 }};
+
// Draw the clipping mask
glBindBuffer(GL_ARRAY_BUFFER, tile_stencil_buffer);
glVertexAttribPointer(fillShader->a_pos, 2, GL_SHORT, false, 0, BUFFER_OFFSET(0));
- glUniform4f(fillShader->u_color, 0.5f, 0.5f, 0.5f, 1.0f);
+ glUniform4fv(fillShader->u_color, 1, white.data());
glDrawArrays(GL_TRIANGLES, 0, sizeof(tile_stencil_vertices));
}