summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/annotation/render_annotation_source.cpp7
-rw-r--r--src/mbgl/annotation/render_annotation_source.hpp5
-rw-r--r--src/mbgl/renderer/painter.cpp9
-rw-r--r--src/mbgl/renderer/painter.hpp6
-rw-r--r--src/mbgl/renderer/render_source.hpp9
-rw-r--r--src/mbgl/renderer/render_tile.cpp13
-rw-r--r--src/mbgl/renderer/render_tile.hpp6
-rw-r--r--src/mbgl/renderer/sources/render_geojson_source.cpp7
-rw-r--r--src/mbgl/renderer/sources/render_geojson_source.hpp5
-rw-r--r--src/mbgl/renderer/sources/render_image_source.cpp9
-rw-r--r--src/mbgl/renderer/sources/render_image_source.hpp7
-rw-r--r--src/mbgl/renderer/sources/render_raster_source.cpp4
-rw-r--r--src/mbgl/renderer/sources/render_raster_source.hpp5
-rw-r--r--src/mbgl/renderer/sources/render_vector_source.cpp7
-rw-r--r--src/mbgl/renderer/sources/render_vector_source.hpp5
-rw-r--r--src/mbgl/renderer/tile_pyramid.cpp7
-rw-r--r--src/mbgl/renderer/tile_pyramid.hpp4
17 files changed, 42 insertions, 73 deletions
diff --git a/src/mbgl/annotation/render_annotation_source.cpp b/src/mbgl/annotation/render_annotation_source.cpp
index 4618761273..b8601d4ed2 100644
--- a/src/mbgl/annotation/render_annotation_source.cpp
+++ b/src/mbgl/annotation/render_annotation_source.cpp
@@ -1,6 +1,7 @@
#include <mbgl/annotation/render_annotation_source.hpp>
#include <mbgl/annotation/annotation_tile.hpp>
#include <mbgl/renderer/render_tile.hpp>
+#include <mbgl/renderer/painter.hpp>
#include <mbgl/algorithm/generate_clip_ids.hpp>
#include <mbgl/algorithm/generate_clip_ids_impl.hpp>
@@ -43,9 +44,9 @@ void RenderAnnotationSource::update(Immutable<style::Source::Impl> baseImpl_,
});
}
-void RenderAnnotationSource::startRender(algorithm::ClipIDGenerator& generator, const mat4& projMatrix, const mat4& clipMatrix, const TransformState& transform) {
- generator.update(tilePyramid.getRenderTiles());
- tilePyramid.startRender(projMatrix, clipMatrix, transform);
+void RenderAnnotationSource::startRender(Painter& painter) {
+ painter.clipIDGenerator.update(tilePyramid.getRenderTiles());
+ tilePyramid.startRender(painter);
}
void RenderAnnotationSource::finishRender(Painter& painter) {
diff --git a/src/mbgl/annotation/render_annotation_source.hpp b/src/mbgl/annotation/render_annotation_source.hpp
index e0c9018e17..fe384c64ca 100644
--- a/src/mbgl/annotation/render_annotation_source.hpp
+++ b/src/mbgl/annotation/render_annotation_source.hpp
@@ -18,10 +18,7 @@ public:
bool needsRelayout,
const TileParameters&) final;
- void startRender(algorithm::ClipIDGenerator&,
- const mat4& projMatrix,
- const mat4& clipMatrix,
- const TransformState&) final;
+ void startRender(Painter&) final;
void finishRender(Painter&) final;
std::map<UnwrappedTileID, RenderTile>& getRenderTiles() final;
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index 6fb325db40..15aaa9c002 100644
--- a/src/mbgl/renderer/painter.cpp
+++ b/src/mbgl/renderer/painter.cpp
@@ -28,9 +28,6 @@
#include <mbgl/programs/program_parameters.hpp>
#include <mbgl/programs/programs.hpp>
-#include <mbgl/algorithm/generate_clip_ids.hpp>
-#include <mbgl/algorithm/generate_clip_ids_impl.hpp>
-
#include <mbgl/util/constants.hpp>
#include <mbgl/util/mat3.hpp>
#include <mbgl/util/string.hpp>
@@ -202,14 +199,14 @@ void Painter::render(RenderStyle& style, const FrameData& frame_, View& view) {
MBGL_DEBUG_GROUP(context, "clip");
// Update all clipping IDs.
- algorithm::ClipIDGenerator generator;
+ clipIDGenerator = algorithm::ClipIDGenerator();
for (const auto& source : sources) {
- source->startRender(generator, projMatrix, nearClippedProjMatrix, state);
+ source->startRender(*this);
}
MBGL_DEBUG_GROUP(context, "clipping masks");
- for (const auto& stencil : generator.getStencils()) {
+ for (const auto& stencil : clipIDGenerator.getStencils()) {
MBGL_DEBUG_GROUP(context, std::string{ "mask: " } + util::toString(stencil.first));
renderClippingMask(stencil.first, stencil.second);
}
diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp
index fddaff6318..75a3ad5f89 100644
--- a/src/mbgl/renderer/painter.hpp
+++ b/src/mbgl/renderer/painter.hpp
@@ -21,6 +21,8 @@
#include <mbgl/util/constants.hpp>
#include <mbgl/util/offscreen_texture.hpp>
+#include <mbgl/algorithm/generate_clip_ids.hpp>
+
#include <array>
#include <vector>
#include <set>
@@ -100,7 +102,6 @@ public:
bool needsAnimation() const;
-private:
template <class Iterator>
void renderPass(PaintParameters&,
RenderPass,
@@ -123,9 +124,10 @@ private:
}
#endif
-private:
gl::Context& context;
+ algorithm::ClipIDGenerator clipIDGenerator;
+
mat4 projMatrix;
mat4 nearClippedProjMatrix;
diff --git a/src/mbgl/renderer/render_source.hpp b/src/mbgl/renderer/render_source.hpp
index b396a0fdb6..a00a6c797d 100644
--- a/src/mbgl/renderer/render_source.hpp
+++ b/src/mbgl/renderer/render_source.hpp
@@ -26,10 +26,6 @@ class Tile;
class RenderSourceObserver;
class TileParameters;
-namespace algorithm {
-class ClipIDGenerator;
-} // namespace algorithm
-
class RenderSource : protected TileObserver {
public:
static std::unique_ptr<RenderSource> create(Immutable<style::Source::Impl>);
@@ -58,10 +54,7 @@ public:
bool needsRelayout,
const TileParameters&) = 0;
- virtual void startRender(algorithm::ClipIDGenerator&,
- const mat4& projMatrix,
- const mat4& clipMatrix,
- const TransformState&) = 0;
+ virtual void startRender(Painter&) = 0;
virtual void finishRender(Painter&) = 0;
virtual std::map<UnwrappedTileID, RenderTile>& getRenderTiles() = 0;
diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp
index ce59186e61..3f6b270a95 100644
--- a/src/mbgl/renderer/render_tile.cpp
+++ b/src/mbgl/renderer/render_tile.cpp
@@ -1,4 +1,5 @@
#include <mbgl/renderer/render_tile.hpp>
+#include <mbgl/renderer/painter.hpp>
#include <mbgl/map/transform_state.hpp>
namespace mbgl {
@@ -44,15 +45,13 @@ mat4 RenderTile::translatedClipMatrix(const std::array<float, 2>& translation,
return translateVtxMatrix(nearClippedMatrix, translation, anchor, state);
}
-void RenderTile::calculateMatrices(const mat4& projMatrix,
- const mat4& projClipMatrix,
- const TransformState& transform) {
+void RenderTile::startRender(Painter& painter) {
// Calculate two matrices for this tile: matrix is the standard tile matrix; nearClippedMatrix
// clips the near plane to 100 to save depth buffer precision
- transform.matrixFor(matrix, id);
- transform.matrixFor(nearClippedMatrix, id);
- matrix::multiply(matrix, projMatrix, matrix);
- matrix::multiply(nearClippedMatrix, projClipMatrix, nearClippedMatrix);
+ painter.state.matrixFor(matrix, id);
+ painter.state.matrixFor(nearClippedMatrix, id);
+ matrix::multiply(matrix, painter.projMatrix, matrix);
+ matrix::multiply(nearClippedMatrix, painter.nearClippedProjMatrix, nearClippedMatrix);
}
} // namespace mbgl
diff --git a/src/mbgl/renderer/render_tile.hpp b/src/mbgl/renderer/render_tile.hpp
index 02e8667eec..6677278873 100644
--- a/src/mbgl/renderer/render_tile.hpp
+++ b/src/mbgl/renderer/render_tile.hpp
@@ -11,6 +11,7 @@ namespace mbgl {
class Tile;
class TransformState;
+class Painter;
class RenderTile {
public:
@@ -35,9 +36,8 @@ public:
style::TranslateAnchorType anchor,
const TransformState&) const;
- void calculateMatrices(const mat4& projMatrix,
- const mat4& projClipMatrix,
- const TransformState&);
+ void startRender(Painter&);
+
private:
mat4 translateVtxMatrix(const mat4& tileMatrix,
const std::array<float, 2>& translation,
diff --git a/src/mbgl/renderer/sources/render_geojson_source.cpp b/src/mbgl/renderer/sources/render_geojson_source.cpp
index 96500d8fae..337b7b8b7a 100644
--- a/src/mbgl/renderer/sources/render_geojson_source.cpp
+++ b/src/mbgl/renderer/sources/render_geojson_source.cpp
@@ -1,5 +1,6 @@
#include <mbgl/renderer/sources/render_geojson_source.hpp>
#include <mbgl/renderer/render_tile.hpp>
+#include <mbgl/renderer/painter.hpp>
#include <mbgl/tile/geojson_tile.hpp>
#include <mbgl/algorithm/generate_clip_ids.hpp>
@@ -58,9 +59,9 @@ void RenderGeoJSONSource::update(Immutable<style::Source::Impl> baseImpl_,
});
}
-void RenderGeoJSONSource::startRender(algorithm::ClipIDGenerator& generator, const mat4& projMatrix, const mat4& clipMatrix, const TransformState& transform) {
- generator.update(tilePyramid.getRenderTiles());
- tilePyramid.startRender(projMatrix, clipMatrix, transform);
+void RenderGeoJSONSource::startRender(Painter& painter) {
+ painter.clipIDGenerator.update(tilePyramid.getRenderTiles());
+ tilePyramid.startRender(painter);
}
void RenderGeoJSONSource::finishRender(Painter& painter) {
diff --git a/src/mbgl/renderer/sources/render_geojson_source.hpp b/src/mbgl/renderer/sources/render_geojson_source.hpp
index 2683ef9d21..9b5477e1d0 100644
--- a/src/mbgl/renderer/sources/render_geojson_source.hpp
+++ b/src/mbgl/renderer/sources/render_geojson_source.hpp
@@ -22,10 +22,7 @@ public:
bool needsRelayout,
const TileParameters&) final;
- void startRender(algorithm::ClipIDGenerator&,
- const mat4& projMatrix,
- const mat4& clipMatrix,
- const TransformState&) final;
+ void startRender(Painter&) final;
void finishRender(Painter&) final;
std::map<UnwrappedTileID, RenderTile>& getRenderTiles() final;
diff --git a/src/mbgl/renderer/sources/render_image_source.cpp b/src/mbgl/renderer/sources/render_image_source.cpp
index ffa8e6bb5e..82ddd318bd 100644
--- a/src/mbgl/renderer/sources/render_image_source.cpp
+++ b/src/mbgl/renderer/sources/render_image_source.cpp
@@ -26,10 +26,7 @@ bool RenderImageSource::isLoaded() const {
return !!bucket;
}
-void RenderImageSource::startRender(algorithm::ClipIDGenerator&,
- const mat4& projMatrix,
- const mat4&,
- const TransformState& transformState) {
+void RenderImageSource::startRender(Painter& painter) {
if (!isLoaded()) {
return;
@@ -39,8 +36,8 @@ void RenderImageSource::startRender(algorithm::ClipIDGenerator&,
for (size_t i = 0; i < tileIds.size(); i++) {
mat4 matrix;
matrix::identity(matrix);
- transformState.matrixFor(matrix, tileIds[i]);
- matrix::multiply(matrix, projMatrix, matrix);
+ painter.state.matrixFor(matrix, tileIds[i]);
+ matrix::multiply(matrix, painter.projMatrix, matrix);
matrices.push_back(matrix);
}
}
diff --git a/src/mbgl/renderer/sources/render_image_source.hpp b/src/mbgl/renderer/sources/render_image_source.hpp
index c4685cf891..175330b35f 100644
--- a/src/mbgl/renderer/sources/render_image_source.hpp
+++ b/src/mbgl/renderer/sources/render_image_source.hpp
@@ -21,13 +21,8 @@ public:
bool isLoaded() const final;
void upload(gl::Context&);
- void startRender(algorithm::ClipIDGenerator&,
- const mat4& projMatrix,
- const mat4& clipMatrix,
- const TransformState&) final;
-
+ void startRender(Painter&) final;
void render(Painter&, PaintParameters&, const RenderLayer&);
-
void finishRender(Painter&) final;
void update(Immutable<style::Source::Impl>,
diff --git a/src/mbgl/renderer/sources/render_raster_source.cpp b/src/mbgl/renderer/sources/render_raster_source.cpp
index 81a9771676..385437af1d 100644
--- a/src/mbgl/renderer/sources/render_raster_source.cpp
+++ b/src/mbgl/renderer/sources/render_raster_source.cpp
@@ -56,8 +56,8 @@ void RenderRasterSource::update(Immutable<style::Source::Impl> baseImpl_,
});
}
-void RenderRasterSource::startRender(algorithm::ClipIDGenerator&, const mat4& projMatrix, const mat4& clipMatrix, const TransformState& transform) {
- tilePyramid.startRender(projMatrix, clipMatrix, transform);
+void RenderRasterSource::startRender(Painter& painter) {
+ tilePyramid.startRender(painter);
}
void RenderRasterSource::finishRender(Painter& painter) {
diff --git a/src/mbgl/renderer/sources/render_raster_source.hpp b/src/mbgl/renderer/sources/render_raster_source.hpp
index 9209a5ca65..d1e37a3099 100644
--- a/src/mbgl/renderer/sources/render_raster_source.hpp
+++ b/src/mbgl/renderer/sources/render_raster_source.hpp
@@ -18,10 +18,7 @@ public:
bool needsRelayout,
const TileParameters&) final;
- void startRender(algorithm::ClipIDGenerator&,
- const mat4& projMatrix,
- const mat4& clipMatrix,
- const TransformState&) final;
+ void startRender(Painter&) final;
void finishRender(Painter&) final;
std::map<UnwrappedTileID, RenderTile>& getRenderTiles() final;
diff --git a/src/mbgl/renderer/sources/render_vector_source.cpp b/src/mbgl/renderer/sources/render_vector_source.cpp
index 30014a89dc..5b266b10a5 100644
--- a/src/mbgl/renderer/sources/render_vector_source.cpp
+++ b/src/mbgl/renderer/sources/render_vector_source.cpp
@@ -1,5 +1,6 @@
#include <mbgl/renderer/sources/render_vector_source.hpp>
#include <mbgl/renderer/render_tile.hpp>
+#include <mbgl/renderer/painter.hpp>
#include <mbgl/tile/vector_tile.hpp>
#include <mbgl/algorithm/generate_clip_ids.hpp>
@@ -59,9 +60,9 @@ void RenderVectorSource::update(Immutable<style::Source::Impl> baseImpl_,
});
}
-void RenderVectorSource::startRender(algorithm::ClipIDGenerator& generator, const mat4& projMatrix, const mat4& clipMatrix, const TransformState& transform) {
- generator.update(tilePyramid.getRenderTiles());
- tilePyramid.startRender(projMatrix, clipMatrix, transform);
+void RenderVectorSource::startRender(Painter& painter) {
+ painter.clipIDGenerator.update(tilePyramid.getRenderTiles());
+ tilePyramid.startRender(painter);
}
void RenderVectorSource::finishRender(Painter& painter) {
diff --git a/src/mbgl/renderer/sources/render_vector_source.hpp b/src/mbgl/renderer/sources/render_vector_source.hpp
index 1f1acdd551..d5d9598a75 100644
--- a/src/mbgl/renderer/sources/render_vector_source.hpp
+++ b/src/mbgl/renderer/sources/render_vector_source.hpp
@@ -18,10 +18,7 @@ public:
bool needsRelayout,
const TileParameters&) final;
- void startRender(algorithm::ClipIDGenerator&,
- const mat4& projMatrix,
- const mat4& clipMatrix,
- const TransformState&) final;
+ void startRender(Painter&) final;
void finishRender(Painter&) final;
std::map<UnwrappedTileID, RenderTile>& getRenderTiles() final;
diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp
index 184bafc204..c2806299e3 100644
--- a/src/mbgl/renderer/tile_pyramid.cpp
+++ b/src/mbgl/renderer/tile_pyramid.cpp
@@ -39,12 +39,9 @@ bool TilePyramid::isLoaded() const {
return true;
}
-void TilePyramid::startRender(const mat4& projMatrix,
- const mat4& clipMatrix,
- const TransformState& transform) {
+void TilePyramid::startRender(Painter& painter) {
for (auto& pair : renderTiles) {
- auto& tile = pair.second;
- tile.calculateMatrices(projMatrix, clipMatrix, transform);
+ pair.second.startRender(painter);
}
}
diff --git a/src/mbgl/renderer/tile_pyramid.hpp b/src/mbgl/renderer/tile_pyramid.hpp
index d989306414..5846560808 100644
--- a/src/mbgl/renderer/tile_pyramid.hpp
+++ b/src/mbgl/renderer/tile_pyramid.hpp
@@ -42,9 +42,7 @@ public:
Range<uint8_t> zoomRange,
std::function<std::unique_ptr<Tile> (const OverscaledTileID&)> createTile);
- void startRender(const mat4& projMatrix,
- const mat4& clipMatrix,
- const TransformState&);
+ void startRender(Painter&);
void finishRender(Painter&);
std::map<UnwrappedTileID, RenderTile>& getRenderTiles();