[core] Add Source::startRender for parallelism with finishRender

This commit is contained in:
John Firebaugh
2016-06-14 10:51:25 -07:00
parent 5bbcca8326
commit 98357ab68e
3 changed files with 21 additions and 14 deletions

View File

@@ -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());

View File

@@ -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);

View File

@@ -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;