summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-06-14 10:51:25 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-06-14 11:25:45 -0700
commit98357ab68e3f8513065dfeb86aff94225288166f (patch)
treef18680864008406ebbc4dca9b8b271d6ec1d4fc9
parent5bbcca832660f80c42e8bfdb5d1836ea8113bb19 (diff)
downloadqtlocation-mapboxgl-98357ab68e3f8513065dfeb86aff94225288166f.tar.gz
[core] Add Source::startRender for parallelism with finishRender
-rw-r--r--src/mbgl/renderer/painter.cpp6
-rw-r--r--src/mbgl/style/source.cpp14
-rw-r--r--src/mbgl/style/source.hpp15
3 files changed, 21 insertions, 14 deletions
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index 5dfced7fe6..e4d30ec107 100644
--- a/src/mbgl/renderer/painter.cpp
+++ b/src/mbgl/renderer/painter.cpp
@@ -161,11 +161,7 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a
// Update all clipping IDs.
algorithm::ClipIDGenerator generator;
for (const auto& source : sources) {
- if (source->type == SourceType::Vector || source->type == SourceType::GeoJSON ||
- source->type == SourceType::Annotations) {
- source->updateClipIDs(generator);
- }
- source->updateMatrices(projMatrix, state);
+ source->startRender(generator, projMatrix, state);
}
drawClippingMasks(generator.getStencils());
diff --git a/src/mbgl/style/source.cpp b/src/mbgl/style/source.cpp
index ca0943918b..212d6d5803 100644
--- a/src/mbgl/style/source.cpp
+++ b/src/mbgl/style/source.cpp
@@ -22,6 +22,8 @@
#include <mbgl/gl/debugging.hpp>
#include <mbgl/algorithm/update_renderables.hpp>
+#include <mbgl/algorithm/generate_clip_ids.hpp>
+#include <mbgl/algorithm/generate_clip_ids_impl.hpp>
#include <mapbox/geometry/envelope.hpp>
@@ -58,7 +60,15 @@ void Source::invalidateTiles() {
cache.clear();
}
-void Source::updateMatrices(const mat4 &projMatrix, const TransformState &transform) {
+void Source::startRender(algorithm::ClipIDGenerator& generator,
+ const mat4& projMatrix,
+ const TransformState& transform) {
+ if (type == SourceType::Vector ||
+ type == SourceType::GeoJSON ||
+ type == SourceType::Annotations) {
+ generator.update(renderTiles);
+ }
+
for (auto& pair : renderTiles) {
auto& tile = pair.second;
transform.matrixFor(tile.matrix, tile.id);
@@ -66,7 +76,7 @@ void Source::updateMatrices(const mat4 &projMatrix, const TransformState &transf
}
}
-void Source::finishRender(Painter &painter) {
+void Source::finishRender(Painter& painter) {
for (auto& pair : renderTiles) {
auto& tile = pair.second;
painter.renderTileDebug(tile);
diff --git a/src/mbgl/style/source.hpp b/src/mbgl/style/source.hpp
index 575297e326..350534e634 100644
--- a/src/mbgl/style/source.hpp
+++ b/src/mbgl/style/source.hpp
@@ -23,6 +23,10 @@ class TransformState;
class RenderTile;
struct ClipID;
+namespace algorithm {
+class ClipIDGenerator;
+} // namespace algorithm
+
namespace style {
class Style;
@@ -45,13 +49,10 @@ public:
// new data available that a tile in the "partial" state might be interested at.
bool update(const UpdateParameters&);
- template <typename ClipIDGenerator>
- void updateClipIDs(ClipIDGenerator& generator) {
- generator.update(renderTiles);
- }
-
- void updateMatrices(const mat4 &projMatrix, const TransformState &transform);
- void finishRender(Painter &painter);
+ void startRender(algorithm::ClipIDGenerator&,
+ const mat4& projMatrix,
+ const TransformState&);
+ void finishRender(Painter&);
const std::map<UnwrappedTileID, RenderTile>& getRenderTiles() const;