summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-03-04 16:34:23 +0100
committerKonstantin Käfer <mail@kkaefer.com>2015-03-06 13:26:11 +0100
commit0151fe6c01367ef03a2ff282b90e32dd3785a7c2 (patch)
tree25ef4ed68fa401c47d9c31298405cb4ec490565b
parentd161e0c3c39b4466ae94f4f7bee556017aec0f10 (diff)
downloadqtlocation-mapboxgl-0151fe6c01367ef03a2ff282b90e32dd3785a7c2.tar.gz
pass StyleLayer objects as const ref instead of a shared pointer
-rw-r--r--src/mbgl/map/raster_tile_data.cpp2
-rw-r--r--src/mbgl/map/raster_tile_data.hpp6
-rw-r--r--src/mbgl/map/source.cpp6
-rw-r--r--src/mbgl/map/source.hpp4
-rw-r--r--src/mbgl/map/tile_data.hpp5
-rw-r--r--src/mbgl/map/vector_tile_data.cpp8
-rw-r--r--src/mbgl/map/vector_tile_data.hpp6
-rw-r--r--src/mbgl/renderer/bucket.hpp3
-rw-r--r--src/mbgl/renderer/debug_bucket.cpp3
-rw-r--r--src/mbgl/renderer/debug_bucket.hpp5
-rw-r--r--src/mbgl/renderer/fill_bucket.cpp3
-rw-r--r--src/mbgl/renderer/fill_bucket.hpp7
-rw-r--r--src/mbgl/renderer/line_bucket.cpp3
-rw-r--r--src/mbgl/renderer/line_bucket.hpp7
-rw-r--r--src/mbgl/renderer/painter.cpp67
-rw-r--r--src/mbgl/renderer/painter.hpp18
-rw-r--r--src/mbgl/renderer/painter_fill.cpp4
-rw-r--r--src/mbgl/renderer/painter_line.cpp4
-rw-r--r--src/mbgl/renderer/painter_raster.cpp4
-rw-r--r--src/mbgl/renderer/painter_symbol.cpp4
-rw-r--r--src/mbgl/renderer/raster_bucket.cpp3
-rw-r--r--src/mbgl/renderer/raster_bucket.hpp5
-rw-r--r--src/mbgl/renderer/symbol_bucket.cpp4
-rw-r--r--src/mbgl/renderer/symbol_bucket.hpp11
-rw-r--r--src/mbgl/style/style_layer.hpp2
25 files changed, 100 insertions, 94 deletions
diff --git a/src/mbgl/map/raster_tile_data.cpp b/src/mbgl/map/raster_tile_data.cpp
index 524475f30c..1ca9ef8041 100644
--- a/src/mbgl/map/raster_tile_data.cpp
+++ b/src/mbgl/map/raster_tile_data.cpp
@@ -25,7 +25,7 @@ void RasterTileData::parse() {
}
}
-void RasterTileData::render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) {
+void RasterTileData::render(Painter &painter, const StyleLayer &layer_desc, const mat4 &matrix) {
bucket.render(painter, layer_desc, id, matrix);
}
diff --git a/src/mbgl/map/raster_tile_data.hpp b/src/mbgl/map/raster_tile_data.hpp
index a3c9f08cde..9a8578a61e 100644
--- a/src/mbgl/map/raster_tile_data.hpp
+++ b/src/mbgl/map/raster_tile_data.hpp
@@ -20,9 +20,9 @@ public:
RasterTileData(Tile::ID const& id, TexturePool&, const SourceInfo&, FileSource &);
~RasterTileData();
- virtual void parse();
- virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix);
- virtual bool hasData(StyleLayer const& layer_desc) const;
+ void parse() override;
+ void render(Painter &painter, const StyleLayer &layer_desc, const mat4 &matrix) override;
+ bool hasData(StyleLayer const &layer_desc) const override;
protected:
StyleLayoutRaster layout;
diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp
index 508bbe4137..d9236b19b3 100644
--- a/src/mbgl/map/source.cpp
+++ b/src/mbgl/map/source.cpp
@@ -95,8 +95,8 @@ void Source::drawClippingMasks(Painter &painter) {
}
}
-void Source::render(Painter &painter, util::ptr<StyleLayer> layer_desc) {
- gl::group group(std::string { "layer: " } + layer_desc->id);
+void Source::render(Painter &painter, const StyleLayer &layer_desc) {
+ gl::group group(std::string { "layer: " } + layer_desc.id);
for (const std::pair<const Tile::ID, std::unique_ptr<Tile>> &pair : tiles) {
Tile &tile = *pair.second;
if (tile.data && tile.data->state == TileData::State::parsed) {
@@ -105,7 +105,7 @@ void Source::render(Painter &painter, util::ptr<StyleLayer> layer_desc) {
}
}
-void Source::render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) {
+void Source::render(Painter &painter, const StyleLayer &layer_desc, const Tile::ID &id, const mat4 &matrix) {
auto it = tiles.find(id);
if (it != tiles.end() && it->second->data && it->second->data->state == TileData::State::parsed) {
painter.renderTileLayer(*it->second, layer_desc, matrix);
diff --git a/src/mbgl/map/source.hpp b/src/mbgl/map/source.hpp
index 3649837a58..2c0e444225 100644
--- a/src/mbgl/map/source.hpp
+++ b/src/mbgl/map/source.hpp
@@ -45,8 +45,8 @@ public:
void updateMatrices(const mat4 &projMatrix, const TransformState &transform);
void drawClippingMasks(Painter &painter);
size_t getTileCount() const;
- void render(Painter &painter, util::ptr<StyleLayer> layer_desc);
- void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix);
+ void render(Painter &painter, const StyleLayer &layer_desc);
+ void render(Painter &painter, const StyleLayer &layer_desc, const Tile::ID &id, const mat4 &matrix);
void finishRender(Painter &painter);
std::forward_list<Tile::ID> getIDs() const;
diff --git a/src/mbgl/map/tile_data.hpp b/src/mbgl/map/tile_data.hpp
index a83a4648dd..fcd741a1f8 100644
--- a/src/mbgl/map/tile_data.hpp
+++ b/src/mbgl/map/tile_data.hpp
@@ -62,9 +62,8 @@ public:
// Override this in the child class.
virtual void parse() = 0;
- virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) = 0;
- virtual bool hasData(StyleLayer const& layer_desc) const = 0;
-
+ virtual void render(Painter &painter, const StyleLayer &layer_desc, const mat4 &matrix) = 0;
+ virtual bool hasData(StyleLayer const &layer_desc) const = 0;
public:
const Tile::ID id;
diff --git a/src/mbgl/map/vector_tile_data.cpp b/src/mbgl/map/vector_tile_data.cpp
index 5f6b249070..40fc7badf0 100644
--- a/src/mbgl/map/vector_tile_data.cpp
+++ b/src/mbgl/map/vector_tile_data.cpp
@@ -59,9 +59,9 @@ void VectorTileData::parse() {
}
}
-void VectorTileData::render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) {
- if (state == State::parsed && layer_desc->bucket) {
- auto databucket_it = buckets.find(layer_desc->bucket->name);
+void VectorTileData::render(Painter &painter, const StyleLayer &layer_desc, const mat4 &matrix) {
+ if (state == State::parsed && layer_desc.bucket) {
+ auto databucket_it = buckets.find(layer_desc.bucket->name);
if (databucket_it != buckets.end()) {
assert(databucket_it->second);
databucket_it->second->render(painter, layer_desc, id, matrix);
@@ -69,7 +69,7 @@ void VectorTileData::render(Painter &painter, util::ptr<StyleLayer> layer_desc,
}
}
-bool VectorTileData::hasData(StyleLayer const& layer_desc) const {
+bool VectorTileData::hasData(const StyleLayer &layer_desc) const {
if (state == State::parsed && layer_desc.bucket) {
auto databucket_it = buckets.find(layer_desc.bucket->name);
if (databucket_it != buckets.end()) {
diff --git a/src/mbgl/map/vector_tile_data.hpp b/src/mbgl/map/vector_tile_data.hpp
index 9ed0e25cd6..feb3c6238b 100644
--- a/src/mbgl/map/vector_tile_data.hpp
+++ b/src/mbgl/map/vector_tile_data.hpp
@@ -37,9 +37,9 @@ public:
const SourceInfo&, FileSource &);
~VectorTileData();
- virtual void parse();
- virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix);
- virtual bool hasData(StyleLayer const& layer_desc) const;
+ void parse() override;
+ void render(Painter &painter, const StyleLayer &layer_desc, const mat4 &matrix) override;
+ bool hasData(StyleLayer const& layer_desc) const override;
protected:
// Holds the actual geometries in this tile.
diff --git a/src/mbgl/renderer/bucket.hpp b/src/mbgl/renderer/bucket.hpp
index 696bfb1110..f59ae65be0 100644
--- a/src/mbgl/renderer/bucket.hpp
+++ b/src/mbgl/renderer/bucket.hpp
@@ -13,7 +13,8 @@ class StyleLayer;
class Bucket : private util::noncopyable {
public:
- virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) = 0;
+ virtual void render(Painter &painter, const StyleLayer &layer_desc, const Tile::ID &id,
+ const mat4 &matrix) = 0;
virtual bool hasData() const = 0;
virtual ~Bucket() {}
diff --git a/src/mbgl/renderer/debug_bucket.cpp b/src/mbgl/renderer/debug_bucket.cpp
index b7fa1b605e..3c56401e1e 100644
--- a/src/mbgl/renderer/debug_bucket.cpp
+++ b/src/mbgl/renderer/debug_bucket.cpp
@@ -13,7 +13,8 @@ DebugBucket::DebugBucket(DebugFontBuffer& fontBuffer_)
: fontBuffer(fontBuffer_) {
}
-void DebugBucket::render(Painter& painter, util::ptr<StyleLayer> /*layer_desc*/, const Tile::ID& /*id*/, const mat4 &matrix) {
+void DebugBucket::render(Painter &painter, const StyleLayer & /*layer_desc*/,
+ const Tile::ID & /*id*/, const mat4 &matrix) {
painter.renderDebugText(*this, matrix);
}
diff --git a/src/mbgl/renderer/debug_bucket.hpp b/src/mbgl/renderer/debug_bucket.hpp
index fb6cfb4cae..d23248841b 100644
--- a/src/mbgl/renderer/debug_bucket.hpp
+++ b/src/mbgl/renderer/debug_bucket.hpp
@@ -19,8 +19,9 @@ class DebugBucket : public Bucket {
public:
DebugBucket(DebugFontBuffer& fontBuffer);
- virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
- virtual bool hasData() const;
+ void render(Painter &painter, const StyleLayer &layer_desc, const Tile::ID &id,
+ const mat4 &matrix) override;
+ bool hasData() const override;
void drawLines(PlainShader& shader);
void drawPoints(PlainShader& shader);
diff --git a/src/mbgl/renderer/fill_bucket.cpp b/src/mbgl/renderer/fill_bucket.cpp
index fca4ee3135..c632244d77 100644
--- a/src/mbgl/renderer/fill_bucket.cpp
+++ b/src/mbgl/renderer/fill_bucket.cpp
@@ -213,7 +213,8 @@ void FillBucket::tessellate() {
lineGroup.vertex_length += total_vertex_count;
}
-void FillBucket::render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) {
+void FillBucket::render(Painter &painter, const StyleLayer &layer_desc, const Tile::ID &id,
+ const mat4 &matrix) {
painter.renderFill(*this, layer_desc, id, matrix);
}
diff --git a/src/mbgl/renderer/fill_bucket.hpp b/src/mbgl/renderer/fill_bucket.hpp
index 0e3f38cd50..b674f104e4 100644
--- a/src/mbgl/renderer/fill_bucket.hpp
+++ b/src/mbgl/renderer/fill_bucket.hpp
@@ -43,10 +43,11 @@ public:
FillVertexBuffer &vertexBuffer,
TriangleElementsBuffer &triangleElementsBuffer,
LineElementsBuffer &lineElementsBuffer);
- ~FillBucket();
+ ~FillBucket() override;
- virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
- virtual bool hasData() const;
+ void render(Painter &painter, const StyleLayer &layer_desc, const Tile::ID &id,
+ const mat4 &matrix) override;
+ bool hasData() const override;
void addGeometry(pbf& data);
void tessellate();
diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp
index e181ac77b4..fc9482d1d6 100644
--- a/src/mbgl/renderer/line_bucket.cpp
+++ b/src/mbgl/renderer/line_bucket.cpp
@@ -351,7 +351,8 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
}
}
-void LineBucket::render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) {
+void LineBucket::render(Painter &painter, const StyleLayer &layer_desc, const Tile::ID &id,
+ const mat4 &matrix) {
painter.renderLine(*this, layer_desc, id, matrix);
}
diff --git a/src/mbgl/renderer/line_bucket.hpp b/src/mbgl/renderer/line_bucket.hpp
index 3f022ce0ef..1059cee71d 100644
--- a/src/mbgl/renderer/line_bucket.hpp
+++ b/src/mbgl/renderer/line_bucket.hpp
@@ -31,10 +31,11 @@ public:
LineVertexBuffer &vertexBuffer,
TriangleElementsBuffer &triangleElementsBuffer,
PointElementsBuffer &pointElementsBuffer);
- ~LineBucket();
+ ~LineBucket() override;
- virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
- virtual bool hasData() const;
+ void render(Painter &painter, const StyleLayer &layer_desc, const Tile::ID &id,
+ const mat4 &matrix) override;
+ bool hasData() const override;
void addGeometry(pbf& data);
void addGeometry(const std::vector<Coordinate>& line);
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index 044604f5b4..9f66d6c446 100644
--- a/src/mbgl/renderer/painter.cpp
+++ b/src/mbgl/renderer/painter.cpp
@@ -235,7 +235,9 @@ void Painter::render(const Style& style, const std::set<util::ptr<StyleSource>>&
// Actually render the layers
if (debug::renderTree) { std::cout << "{" << std::endl; indent++; }
- renderLayers(style.layers);
+ if (style.layers) {
+ renderLayers(*style.layers);
+ }
if (debug::renderTree) { std::cout << "}" << std::endl; indent--; }
// Finalize the rendering, e.g. by calling debug render calls per tile.
@@ -247,14 +249,9 @@ void Painter::render(const Style& style, const std::set<util::ptr<StyleSource>>&
}
}
-void Painter::renderLayers(util::ptr<StyleLayerGroup> group) {
- if (!group) {
- // Make sure that we actually do have a layer group.
- return;
- }
-
+void Painter::renderLayers(const StyleLayerGroup &group) {
// TODO: Correctly compute the number of layers recursively beforehand.
- float strata_thickness = 1.0f / (group->layers.size() + 1);
+ float strata_thickness = 1.0f / (group.layers.size() + 1);
// - FIRST PASS ------------------------------------------------------------
// Render everything top-to-bottom by using reverse iterators. Render opaque
@@ -264,10 +261,10 @@ void Painter::renderLayers(util::ptr<StyleLayerGroup> group) {
std::cout << std::string(indent++ * 4, ' ') << "OPAQUE {" << std::endl;
}
int i = 0;
- for (auto it = group->layers.rbegin(), end = group->layers.rend(); it != end; ++it, ++i) {
+ for (auto it = group.layers.rbegin(), end = group.layers.rend(); it != end; ++it, ++i) {
setOpaque();
setStrata(i * strata_thickness);
- renderLayer(*it);
+ renderLayer(**it);
}
if (debug::renderTree) {
std::cout << std::string(--indent * 4, ' ') << "}" << std::endl;
@@ -280,40 +277,40 @@ void Painter::renderLayers(util::ptr<StyleLayerGroup> group) {
std::cout << std::string(indent++ * 4, ' ') << "TRANSLUCENT {" << std::endl;
}
--i;
- for (auto it = group->layers.begin(), end = group->layers.end(); it != end; ++it, --i) {
+ for (auto it = group.layers.begin(), end = group.layers.end(); it != end; ++it, --i) {
setTranslucent();
setStrata(i * strata_thickness);
- renderLayer(*it);
+ renderLayer(**it);
}
if (debug::renderTree) {
std::cout << std::string(--indent * 4, ' ') << "}" << std::endl;
}
}
-void Painter::renderLayer(util::ptr<StyleLayer> layer_desc, const Tile::ID* id, const mat4* matrix) {
- if (layer_desc->bucket->visibility == VisibilityType::None) return;
- if (layer_desc->type == StyleLayerType::Background) {
+void Painter::renderLayer(const StyleLayer &layer_desc, const Tile::ID* id, const mat4* matrix) {
+ if (layer_desc.bucket->visibility == VisibilityType::None) return;
+ if (layer_desc.type == StyleLayerType::Background) {
// This layer defines a background color/image.
if (debug::renderTree) {
- std::cout << std::string(indent * 4, ' ') << "- " << layer_desc->id << " ("
- << layer_desc->type << ")" << std::endl;
+ std::cout << std::string(indent * 4, ' ') << "- " << layer_desc.id << " ("
+ << layer_desc.type << ")" << std::endl;
}
renderBackground(layer_desc);
} else {
// This is a singular layer.
- if (!layer_desc->bucket) {
- fprintf(stderr, "[WARNING] layer '%s' is missing bucket\n", layer_desc->id.c_str());
+ if (!layer_desc.bucket) {
+ fprintf(stderr, "[WARNING] layer '%s' is missing bucket\n", layer_desc.id.c_str());
return;
}
- if (!layer_desc->bucket->style_source) {
- fprintf(stderr, "[WARNING] can't find source for layer '%s'\n", layer_desc->id.c_str());
+ if (!layer_desc.bucket->style_source) {
+ fprintf(stderr, "[WARNING] can't find source for layer '%s'\n", layer_desc.id.c_str());
return;
}
- StyleSource const& style_source = *layer_desc->bucket->style_source;
+ StyleSource const& style_source = *layer_desc.bucket->style_source;
// Skip this layer if there is no data.
if (!style_source.source) {
@@ -324,36 +321,36 @@ void Painter::renderLayer(util::ptr<StyleLayer> layer_desc, const Tile::ID* id,
// This may occur when there /is/ a bucket created for this layer, but the min/max-zoom
// is set to a fractional value, or value that is larger than the source maxzoom.
const double zoom = state.getZoom();
- if (layer_desc->bucket->min_zoom > zoom ||
- layer_desc->bucket->max_zoom <= zoom) {
+ if (layer_desc.bucket->min_zoom > zoom ||
+ layer_desc.bucket->max_zoom <= zoom) {
return;
}
// Abort early if we can already deduce from the bucket type that
// we're not going to render anything anyway during this pass.
- switch (layer_desc->type) {
+ switch (layer_desc.type) {
case StyleLayerType::Fill:
- if (!layer_desc->getProperties<FillProperties>().isVisible()) return;
+ if (!layer_desc.getProperties<FillProperties>().isVisible()) return;
break;
case StyleLayerType::Line:
if (pass == RenderPass::Opaque) return;
- if (!layer_desc->getProperties<LineProperties>().isVisible()) return;
+ if (!layer_desc.getProperties<LineProperties>().isVisible()) return;
break;
case StyleLayerType::Symbol:
if (pass == RenderPass::Opaque) return;
- if (!layer_desc->getProperties<SymbolProperties>().isVisible()) return;
+ if (!layer_desc.getProperties<SymbolProperties>().isVisible()) return;
break;
case StyleLayerType::Raster:
if (pass == RenderPass::Opaque) return;
- if (!layer_desc->getProperties<RasterProperties>().isVisible()) return;
+ if (!layer_desc.getProperties<RasterProperties>().isVisible()) return;
break;
default:
break;
}
if (debug::renderTree) {
- std::cout << std::string(indent * 4, ' ') << "- " << layer_desc->id << " ("
- << layer_desc->type << ")" << std::endl;
+ std::cout << std::string(indent * 4, ' ') << "- " << layer_desc.id << " ("
+ << layer_desc.type << ")" << std::endl;
}
if (!id) {
style_source.source->render(*this, layer_desc);
@@ -363,17 +360,17 @@ void Painter::renderLayer(util::ptr<StyleLayer> layer_desc, const Tile::ID* id,
}
}
-void Painter::renderTileLayer(const Tile& tile, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) {
+void Painter::renderTileLayer(const Tile& tile, const StyleLayer &layer_desc, const mat4 &matrix) {
assert(tile.data);
- if (tile.data->hasData(*layer_desc) || layer_desc->type == StyleLayerType::Raster) {
+ if (tile.data->hasData(layer_desc) || layer_desc.type == StyleLayerType::Raster) {
gl::group group(std::string { "render " } + tile.data->name);
prepareTile(tile);
tile.data->render(*this, layer_desc, matrix);
}
}
-void Painter::renderBackground(util::ptr<StyleLayer> layer_desc) {
- const BackgroundProperties& properties = layer_desc->getProperties<BackgroundProperties>();
+void Painter::renderBackground(const StyleLayer &layer_desc) {
+ const BackgroundProperties& properties = layer_desc.getProperties<BackgroundProperties>();
if (properties.image.to.size()) {
if ((properties.opacity >= 1.0f) != (pass == RenderPass::Opaque))
diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp
index f38a9f0559..9c9c6a4642 100644
--- a/src/mbgl/renderer/painter.hpp
+++ b/src/mbgl/renderer/painter.hpp
@@ -81,11 +81,11 @@ public:
TransformState state,
std::chrono::steady_clock::time_point time);
- void renderLayers(util::ptr<StyleLayerGroup> group);
- void renderLayer(util::ptr<StyleLayer> layer_desc, const Tile::ID* id = nullptr, const mat4* matrix = nullptr);
+ void renderLayers(const StyleLayerGroup &group);
+ void renderLayer(const StyleLayer &layer_desc, const Tile::ID* id = nullptr, const mat4* matrix = nullptr);
// Renders a particular layer from a tile.
- void renderTileLayer(const Tile& tile, util::ptr<StyleLayer> layer_desc, const mat4 &matrix);
+ void renderTileLayer(const Tile& tile, const StyleLayer &layer_desc, const mat4 &matrix);
// Renders debug information for a tile.
void renderTileDebug(const Tile& tile);
@@ -95,11 +95,11 @@ public:
void renderDebugText(DebugBucket& bucket, const mat4 &matrix);
void renderDebugText(const std::vector<std::string> &strings);
- void renderFill(FillBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
- void renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
- void renderSymbol(SymbolBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
- void renderRaster(RasterBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
- void renderBackground(util::ptr<StyleLayer> layer_desc);
+ void renderFill(FillBucket& bucket, const StyleLayer &layer_desc, const Tile::ID& id, const mat4 &matrix);
+ void renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const Tile::ID& id, const mat4 &matrix);
+ void renderSymbol(SymbolBucket& bucket, const StyleLayer &layer_desc, const Tile::ID& id, const mat4 &matrix);
+ void renderRaster(RasterBucket& bucket, const StyleLayer &layer_desc, const Tile::ID& id, const mat4 &matrix);
+ void renderBackground(const StyleLayer &layer_desc);
float saturationFactor(float saturation);
float contrastFactor(float contrast);
@@ -109,7 +109,7 @@ public:
void renderPrerenderedTexture(RasterBucket &bucket, const mat4 &matrix, const RasterProperties& properties);
- void createPrerendered(RasterBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id);
+ void createPrerendered(RasterBucket& bucket, const StyleLayer &layer_desc, const Tile::ID& id);
void resize();
diff --git a/src/mbgl/renderer/painter_fill.cpp b/src/mbgl/renderer/painter_fill.cpp
index 36e8994fcb..53fa337bed 100644
--- a/src/mbgl/renderer/painter_fill.cpp
+++ b/src/mbgl/renderer/painter_fill.cpp
@@ -11,11 +11,11 @@
using namespace mbgl;
-void Painter::renderFill(FillBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) {
+void Painter::renderFill(FillBucket& bucket, const StyleLayer &layer_desc, const Tile::ID& id, const mat4 &matrix) {
// Abort early.
if (!bucket.hasData()) return;
- const FillProperties &properties = layer_desc->getProperties<FillProperties>();
+ const FillProperties &properties = layer_desc.getProperties<FillProperties>();
mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor);
Color fill_color = properties.fill_color;
diff --git a/src/mbgl/renderer/painter_line.cpp b/src/mbgl/renderer/painter_line.cpp
index fc4000276f..36b8c3b689 100644
--- a/src/mbgl/renderer/painter_line.cpp
+++ b/src/mbgl/renderer/painter_line.cpp
@@ -10,12 +10,12 @@
using namespace mbgl;
-void Painter::renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) {
+void Painter::renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const Tile::ID& id, const mat4 &matrix) {
// Abort early.
if (pass == RenderPass::Opaque) return;
if (!bucket.hasData()) return;
- const auto &properties = layer_desc->getProperties<LineProperties>();
+ const auto &properties = layer_desc.getProperties<LineProperties>();
const auto &layout = *bucket.styleLayout;
// the distance over which the line edge fades out.
diff --git a/src/mbgl/renderer/painter_raster.cpp b/src/mbgl/renderer/painter_raster.cpp
index 4ece54977b..9a6194309a 100644
--- a/src/mbgl/renderer/painter_raster.cpp
+++ b/src/mbgl/renderer/painter_raster.cpp
@@ -8,10 +8,10 @@
using namespace mbgl;
-void Painter::renderRaster(RasterBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID&, const mat4 &matrix) {
+void Painter::renderRaster(RasterBucket& bucket, const StyleLayer &layer_desc, const Tile::ID&, const mat4 &matrix) {
if (pass != RenderPass::Translucent) return;
- const RasterProperties &properties = layer_desc->getProperties<RasterProperties>();
+ const RasterProperties &properties = layer_desc.getProperties<RasterProperties>();
if (bucket.hasData()) {
depthMask(false);
diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp
index a4af17b4eb..9b533699e0 100644
--- a/src/mbgl/renderer/painter_symbol.cpp
+++ b/src/mbgl/renderer/painter_symbol.cpp
@@ -112,13 +112,13 @@ void Painter::renderSDF(SymbolBucket &bucket,
}
}
-void Painter::renderSymbol(SymbolBucket &bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) {
+void Painter::renderSymbol(SymbolBucket &bucket, const StyleLayer &layer_desc, const Tile::ID &id, const mat4 &matrix) {
// Abort early.
if (pass == RenderPass::Opaque) {
return;
}
- const auto &properties = layer_desc->getProperties<SymbolProperties>();
+ const auto &properties = layer_desc.getProperties<SymbolProperties>();
const auto &layout = *bucket.styleLayout;
MBGL_CHECK_ERROR(glDisable(GL_STENCIL_TEST));
diff --git a/src/mbgl/renderer/raster_bucket.cpp b/src/mbgl/renderer/raster_bucket.cpp
index 50af7e4cb4..b16303c84f 100644
--- a/src/mbgl/renderer/raster_bucket.cpp
+++ b/src/mbgl/renderer/raster_bucket.cpp
@@ -8,7 +8,8 @@ RasterBucket::RasterBucket(TexturePool& texturePool, const StyleLayoutRaster& la
raster(texturePool) {
}
-void RasterBucket::render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) {
+void RasterBucket::render(Painter &painter, const StyleLayer &layer_desc, const Tile::ID &id,
+ const mat4 &matrix) {
painter.renderRaster(*this, layer_desc, id, matrix);
}
diff --git a/src/mbgl/renderer/raster_bucket.hpp b/src/mbgl/renderer/raster_bucket.hpp
index 1f589e5b6c..168685b163 100644
--- a/src/mbgl/renderer/raster_bucket.hpp
+++ b/src/mbgl/renderer/raster_bucket.hpp
@@ -18,8 +18,9 @@ class RasterBucket : public Bucket {
public:
RasterBucket(TexturePool&, const StyleLayoutRaster&);
- virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
- virtual bool hasData() const;
+ void render(Painter &painter, const StyleLayer &layer_desc, const Tile::ID &id,
+ const mat4 &matrix) override;
+ bool hasData() const override;
bool setImage(const std::string &data);
diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp
index 25eecfc622..9996175998 100644
--- a/src/mbgl/renderer/symbol_bucket.cpp
+++ b/src/mbgl/renderer/symbol_bucket.cpp
@@ -30,8 +30,8 @@ SymbolBucket::~SymbolBucket() {
// Do not remove. header file only contains forward definitions to unique pointers.
}
-void SymbolBucket::render(Painter &painter, util::ptr<StyleLayer> layer_desc,
- const Tile::ID &id, const mat4 &matrix) {
+void SymbolBucket::render(Painter &painter, const StyleLayer &layer_desc, const Tile::ID &id,
+ const mat4 &matrix) {
painter.renderSymbol(*this, layer_desc, id, matrix);
}
diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp
index 8ad420cde0..0637c01cfe 100644
--- a/src/mbgl/renderer/symbol_bucket.hpp
+++ b/src/mbgl/renderer/symbol_bucket.hpp
@@ -56,12 +56,13 @@ class SymbolBucket : public Bucket {
public:
SymbolBucket(std::unique_ptr<const StyleLayoutSymbol> styleLayout, Collision &collision);
- ~SymbolBucket();
+ ~SymbolBucket() override;
- virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix);
- virtual bool hasData() const;
- virtual bool hasTextData() const;
- virtual bool hasIconData() const;
+ void render(Painter &painter, const StyleLayer &layer_desc, const Tile::ID &id,
+ const mat4 &matrix) override;
+ bool hasData() const override;
+ bool hasTextData() const;
+ bool hasIconData() const;
void addFeatures(const VectorTileLayer &layer, const FilterExpression &filter,
const Tile::ID &id, SpriteAtlas &spriteAtlas, Sprite &sprite,
diff --git a/src/mbgl/style/style_layer.hpp b/src/mbgl/style/style_layer.hpp
index 1dadfed94b..6e1fc7912b 100644
--- a/src/mbgl/style/style_layer.hpp
+++ b/src/mbgl/style/style_layer.hpp
@@ -24,7 +24,7 @@ class StyleLayer {
public:
StyleLayer(const std::string &id, std::map<ClassID, ClassProperties> &&styles);
- template <typename T> const T &getProperties() {
+ template <typename T> const T &getProperties() const {
if (properties.is<T>()) {
return properties.get<T>();
} else {