Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Reapply style layer copy technique
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Jul 1, 2015
1 parent fc64e97 commit c0af683
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/mbgl/map/tile_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ using namespace mbgl;

TileWorker::TileWorker(const TileID& id_,
Style& style_,
std::vector<util::ptr<StyleLayer>> layers_,
const uint16_t maxZoom_,
const std::atomic<TileData::State>& state_,
std::unique_ptr<CollisionTile> collision_)
: style(style_),
: layers(std::move(layers_)),
style(style_),
id(id_),
maxZoom(maxZoom_),
state(state_),
Expand Down Expand Up @@ -48,7 +50,7 @@ size_t TileWorker::countBuckets() const {
TileParseResult TileWorker::parse(const GeometryTile& geometryTile) {
partialParse = false;

for (const auto& layer : style.layers) {
for (const auto& layer : layers) {
parseLayer(*layer, geometryTile);
}

Expand All @@ -58,7 +60,7 @@ TileParseResult TileWorker::parse(const GeometryTile& geometryTile) {
void TileWorker::redoPlacement(float angle, bool collisionDebug) {
collision->reset(angle, 0);
collision->setDebug(collisionDebug);
for (const auto& layer_desc : style.layers) {
for (const auto& layer_desc : layers) {
auto bucket = getBucket(*layer_desc);
if (bucket) {
bucket->placeFeatures();
Expand Down
7 changes: 6 additions & 1 deletion src/mbgl/map/tile_worker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <mbgl/geometry/fill_buffer.hpp>
#include <mbgl/geometry/line_buffer.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/ptr.hpp>
#include <mbgl/style/filter_expression.hpp>

#include <string>
Expand All @@ -20,6 +21,7 @@ class CollisionTile;
class GeometryTile;
class Style;
class Bucket;
class StyleLayer;
class StyleBucket;
class GeometryTileLayer;

Expand All @@ -31,6 +33,7 @@ class TileWorker : public util::noncopyable {
public:
TileWorker(const TileID&,
Style&,
std::vector<util::ptr<StyleLayer>>,
const uint16_t maxZoom,
const std::atomic<TileData::State>&,
std::unique_ptr<CollisionTile>);
Expand All @@ -42,7 +45,7 @@ class TileWorker : public util::noncopyable {
TileParseResult parse(const GeometryTile&);
void redoPlacement(float angle, bool collisionDebug);

Style& style;
std::vector<util::ptr<StyleLayer>> layers;

private:
void parseLayer(const StyleLayer&, const GeometryTile&);
Expand All @@ -54,6 +57,8 @@ class TileWorker : public util::noncopyable {
template <class Bucket>
void addBucketGeometries(Bucket&, const GeometryTileLayer&, const FilterExpression&);

Style& style;

const TileID id;
const uint16_t maxZoom;
const std::atomic<TileData::State>& state;
Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/map/vector_tile_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ VectorTileData::VectorTileData(const TileID& id_,
worker(style_.workers),
tileWorker(id_,
style_,
style_.layers,
source_.max_zoom,
state,
std::make_unique<CollisionTile>(id_.z, 4096,
Expand Down Expand Up @@ -115,7 +116,7 @@ void VectorTileData::redoPlacement(float angle, bool collisionDebug) {
currentCollisionDebug = collisionDebug;

workRequest = worker.redoPlacement(tileWorker, angle, collisionDebug, [this] {
for (const auto& layer : tileWorker.style.layers) {
for (const auto& layer : tileWorker.layers) {
auto bucket = getBucket(*layer);
if (bucket) {
bucket->swapRenderData();
Expand Down

0 comments on commit c0af683

Please sign in to comment.