summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-07-01 21:44:15 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-07-04 16:56:43 +0300
commit63dd17e2bbdb2c956789865c1d517305f860a175 (patch)
tree6888c96f50df988e55b5722dd870db98fdd877b5 /src/mbgl
parentb1cbc2f2451d6eea9a8ad2adde1c8087ab581192 (diff)
downloadqtlocation-mapboxgl-63dd17e2bbdb2c956789865c1d517305f860a175.tar.gz
[core] Introduce TileRenderData
Remove rendering functionality from Tile implementations.
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/renderer/render_tile.cpp33
-rw-r--r--src/mbgl/renderer/render_tile.hpp7
-rw-r--r--src/mbgl/renderer/sources/render_tile_source.cpp1
-rw-r--r--src/mbgl/renderer/tile_render_data.cpp40
-rw-r--r--src/mbgl/renderer/tile_render_data.hpp61
-rw-r--r--src/mbgl/tile/geometry_tile.cpp165
-rw-r--r--src/mbgl/tile/geometry_tile.hpp14
-rw-r--r--src/mbgl/tile/raster_dem_tile.cpp16
-rw-r--r--src/mbgl/tile/raster_dem_tile.hpp8
-rw-r--r--src/mbgl/tile/raster_tile.cpp15
-rw-r--r--src/mbgl/tile/raster_tile.hpp8
-rw-r--r--src/mbgl/tile/tile.hpp13
12 files changed, 258 insertions, 123 deletions
diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp
index 74fc945ac1..a0230a6511 100644
--- a/src/mbgl/renderer/render_tile.cpp
+++ b/src/mbgl/renderer/render_tile.cpp
@@ -4,6 +4,7 @@
#include <mbgl/renderer/buckets/debug_bucket.hpp>
#include <mbgl/renderer/render_source.hpp>
#include <mbgl/renderer/render_static_data.hpp>
+#include <mbgl/renderer/tile_render_data.hpp>
#include <mbgl/programs/programs.hpp>
#include <mbgl/map/transform_state.hpp>
#include <mbgl/gfx/cull_face_mode.hpp>
@@ -15,7 +16,8 @@ namespace mbgl {
using namespace style;
-RenderTile::RenderTile(UnwrappedTileID id_, Tile& tile_) : id(std::move(id_)), tile(tile_) {
+RenderTile::RenderTile(UnwrappedTileID id_, Tile& tile_)
+ : id(std::move(id_)), tile(tile_) {
}
RenderTile::~RenderTile() = default;
@@ -65,32 +67,33 @@ const OverscaledTileID& RenderTile::getOverscaledTileID() const { return tile.id
bool RenderTile::holdForFade() const { return tile.holdForFade(); }
Bucket* RenderTile::getBucket(const style::Layer::Impl& impl) const {
- return tile.getBucket(impl);
+ assert(renderData);
+ return renderData->getBucket(impl);
}
const LayerRenderData* RenderTile::getLayerRenderData(const style::Layer::Impl& impl) const {
- return tile.getLayerRenderData(impl);
+ assert(renderData);
+ return renderData->getLayerRenderData(impl);
}
optional<ImagePosition> RenderTile::getPattern(const std::string& pattern) const {
- assert(tile.kind == Tile::Kind::Geometry);
- return static_cast<const GeometryTile&>(tile).getPattern(pattern);
+ assert(renderData);
+ return renderData->getPattern(pattern);
}
const gfx::Texture& RenderTile::getGlyphAtlasTexture() const {
- assert(tile.kind == Tile::Kind::Geometry);
- assert(static_cast<const GeometryTile&>(tile).glyphAtlasTexture);
- return *(static_cast<const GeometryTile&>(tile).glyphAtlasTexture);
+ assert(renderData);
+ return renderData->getGlyphAtlasTexture();
}
const gfx::Texture& RenderTile::getIconAtlasTexture() const {
- assert(tile.kind == Tile::Kind::Geometry);
- assert(static_cast<const GeometryTile&>(tile).iconAtlasTexture);
- return *(static_cast<const GeometryTile&>(tile).iconAtlasTexture);
+ assert(renderData);
+ return renderData->getIconAtlasTexture();
}
void RenderTile::upload(gfx::UploadPass& uploadPass) {
- tile.upload(uploadPass);
+ assert(renderData);
+ renderData->upload(uploadPass);
if (debugBucket) {
debugBucket->upload(uploadPass);
@@ -98,6 +101,10 @@ void RenderTile::upload(gfx::UploadPass& uploadPass) {
}
void RenderTile::prepare(const SourcePrepareParameters& parameters) {
+ renderData = tile.createRenderData();
+ assert(renderData);
+ needsRendering = tile.usedByRenderedLayers;
+
if (parameters.debugOptions != MapDebugOptions::NoDebug &&
(!debugBucket || debugBucket->renderable != tile.isRenderable() ||
debugBucket->complete != tile.isComplete() ||
@@ -121,7 +128,7 @@ void RenderTile::prepare(const SourcePrepareParameters& parameters) {
}
void RenderTile::finishRender(PaintParameters& parameters) {
- if (!tile.usedByRenderedLayers || parameters.debugOptions == MapDebugOptions::NoDebug)
+ if (!needsRendering || parameters.debugOptions == MapDebugOptions::NoDebug)
return;
static const style::Properties<>::PossiblyEvaluated properties {};
diff --git a/src/mbgl/renderer/render_tile.hpp b/src/mbgl/renderer/render_tile.hpp
index c863c5970e..a532bf8dd8 100644
--- a/src/mbgl/renderer/render_tile.hpp
+++ b/src/mbgl/renderer/render_tile.hpp
@@ -4,10 +4,9 @@
#include <mbgl/gfx/texture.hpp>
#include <mbgl/tile/tile_id.hpp>
#include <mbgl/util/mat4.hpp>
+#include <mbgl/renderer/image_atlas.hpp>
#include <mbgl/style/layer_impl.hpp>
#include <mbgl/style/types.hpp>
-#include <mbgl/renderer/image_atlas.hpp>
-#include <mbgl/renderer/tile_mask.hpp>
#include <array>
#include <memory>
@@ -26,6 +25,7 @@ class PaintParameters;
class DebugBucket;
class SourcePrepareParameters;
class FeatureIndex;
+class TileRenderData;
class RenderTile final {
public:
@@ -70,6 +70,9 @@ public:
const bool inViewportPixelUnits) const;
private:
Tile& tile;
+ // The following members are reset at placement stage.
+ std::unique_ptr<TileRenderData> renderData;
+ bool needsRendering = false;
};
} // namespace mbgl
diff --git a/src/mbgl/renderer/sources/render_tile_source.cpp b/src/mbgl/renderer/sources/render_tile_source.cpp
index 2d82603dd5..3af3b92e77 100644
--- a/src/mbgl/renderer/sources/render_tile_source.cpp
+++ b/src/mbgl/renderer/sources/render_tile_source.cpp
@@ -3,6 +3,7 @@
#include <mbgl/renderer/buckets/debug_bucket.hpp>
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/renderer/paint_parameters.hpp>
+#include <mbgl/renderer/tile_render_data.hpp>
#include <mbgl/tile/vector_tile.hpp>
namespace mbgl {
diff --git a/src/mbgl/renderer/tile_render_data.cpp b/src/mbgl/renderer/tile_render_data.cpp
new file mode 100644
index 0000000000..300e8d8488
--- /dev/null
+++ b/src/mbgl/renderer/tile_render_data.cpp
@@ -0,0 +1,40 @@
+#include <mbgl/renderer/tile_render_data.hpp>
+
+namespace mbgl {
+
+TileRenderData::TileRenderData() = default;
+
+TileRenderData::TileRenderData(std::shared_ptr<TileAtlasTextures> atlasTextures_)
+ : atlasTextures(std::move(atlasTextures_)) {
+}
+
+TileRenderData::~TileRenderData() = default;
+
+const gfx::Texture& TileRenderData::getGlyphAtlasTexture() const {
+ assert(atlasTextures);
+ assert(atlasTextures->glyph);
+ return *atlasTextures->glyph;
+}
+
+const gfx::Texture& TileRenderData::getIconAtlasTexture() const {
+ assert(atlasTextures);
+ assert(atlasTextures->icon);
+ return *atlasTextures->icon;
+}
+
+optional<ImagePosition> TileRenderData::getPattern(const std::string&) const {
+ assert(false);
+ return nullopt;
+}
+
+const LayerRenderData* TileRenderData::getLayerRenderData(const style::Layer::Impl&) const {
+ assert(false);
+ return nullptr;
+}
+
+Bucket* TileRenderData::getBucket(const style::Layer::Impl&) const {
+ assert(false);
+ return nullptr;
+}
+
+} // namespace mbgl
diff --git a/src/mbgl/renderer/tile_render_data.hpp b/src/mbgl/renderer/tile_render_data.hpp
new file mode 100644
index 0000000000..85bbc49565
--- /dev/null
+++ b/src/mbgl/renderer/tile_render_data.hpp
@@ -0,0 +1,61 @@
+#pragma once
+
+#include <mbgl/gfx/texture.hpp>
+#include <mbgl/renderer/image_atlas.hpp>
+#include <mbgl/style/layer_impl.hpp>
+
+#include <memory>
+
+namespace mbgl {
+
+namespace gfx {
+class UploadPass;
+} // namespace gfx
+
+class Bucket;
+class LayerRenderData;
+class SourcePrepareParameters;
+
+class TileAtlasTextures {
+public:
+ optional<gfx::Texture> glyph;
+ optional<gfx::Texture> icon;
+};
+
+class TileRenderData {
+public:
+ virtual ~TileRenderData();
+ const gfx::Texture& getGlyphAtlasTexture() const;
+ const gfx::Texture& getIconAtlasTexture() const;
+ // To be implemented for concrete tile types.
+ virtual optional<ImagePosition> getPattern(const std::string&) const;
+ virtual const LayerRenderData* getLayerRenderData(const style::Layer::Impl&) const;
+ virtual Bucket* getBucket(const style::Layer::Impl&) const;
+ virtual void upload(gfx::UploadPass&) {}
+ virtual void prepare(const SourcePrepareParameters&) {}
+
+protected:
+ TileRenderData();
+ TileRenderData(std::shared_ptr<TileAtlasTextures>);
+ std::shared_ptr<TileAtlasTextures> atlasTextures;
+};
+
+template <typename BucketType>
+class SharedBucketTileRenderData final : public TileRenderData {
+public:
+ SharedBucketTileRenderData(std::shared_ptr<BucketType> bucket_)
+ : bucket(std::move(bucket_)) {}
+
+private:
+ // TileRenderData overrides.
+ Bucket* getBucket(const style::Layer::Impl&) const override {
+ return bucket ? bucket.get() : nullptr;
+ }
+ void upload(gfx::UploadPass& uploadPass) override {
+ if (bucket) bucket->upload(uploadPass);
+ }
+
+ std::shared_ptr<BucketType> bucket;
+};
+
+} // namespace mbgl
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp
index 7fe6343889..0b9ba263f5 100644
--- a/src/mbgl/tile/geometry_tile.cpp
+++ b/src/mbgl/tile/geometry_tile.cpp
@@ -18,11 +18,98 @@
#include <mbgl/map/transform_state.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/actor/scheduler.hpp>
+#include <mbgl/renderer/tile_render_data.hpp>
namespace mbgl {
+LayerRenderData* GeometryTile::LayoutResult::getLayerRenderData(const style::Layer::Impl& layerImpl) {
+ auto it = layerRenderData.find(layerImpl.id);
+ if (it == layerRenderData.end()) {
+ return nullptr;
+ }
+ LayerRenderData& result = it->second;
+ if (result.layerProperties->baseImpl->getTypeInfo() != layerImpl.getTypeInfo()) {
+ // Layer data might be outdated, see issue #12432.
+ return nullptr;
+ }
+ return &result;
+}
+
+class GeometryTileRenderData final : public TileRenderData {
+public:
+ GeometryTileRenderData(
+ std::shared_ptr<GeometryTile::LayoutResult> layoutResult_,
+ std::shared_ptr<TileAtlasTextures> atlasTextures_,
+ ImageManager& imageManager_)
+ : TileRenderData(std::move(atlasTextures_))
+ , layoutResult(std::move(layoutResult_))
+ , imageManager(imageManager_) {
+ }
+
+private:
+ // TileRenderData overrides.
+ optional<ImagePosition> getPattern(const std::string&) const override;
+ const LayerRenderData* getLayerRenderData(const style::Layer::Impl&) const override;
+ Bucket* getBucket(const style::Layer::Impl&) const override;
+ void upload(gfx::UploadPass&) override;
+
+ std::shared_ptr<GeometryTile::LayoutResult> layoutResult;
+ ImageManager& imageManager;
+};
+
using namespace style;
+optional<ImagePosition> GeometryTileRenderData::getPattern(const std::string& pattern) const {
+ if (layoutResult) {
+ const auto& iconAtlas = layoutResult->iconAtlas;
+ auto it = iconAtlas.patternPositions.find(pattern);
+ if (it != iconAtlas.patternPositions.end()) {
+ return it->second;
+ }
+ }
+ return nullopt;
+}
+
+void GeometryTileRenderData::upload(gfx::UploadPass& uploadPass) {
+ if (!layoutResult) return;
+
+ auto uploadFn = [&] (Bucket& bucket) {
+ if (bucket.needsUpload()) {
+ bucket.upload(uploadPass);
+ }
+ };
+
+ for (auto& entry : layoutResult->layerRenderData) {
+ uploadFn(*entry.second.bucket);
+ }
+
+ assert(atlasTextures);
+
+ if (layoutResult->glyphAtlasImage) {
+ atlasTextures->glyph = uploadPass.createTexture(*layoutResult->glyphAtlasImage);
+ layoutResult->glyphAtlasImage = {};
+ }
+
+ if (layoutResult->iconAtlas.image.valid()) {
+ atlasTextures->icon = uploadPass.createTexture(layoutResult->iconAtlas.image);
+ layoutResult->iconAtlas.image = {};
+ }
+
+ if (atlasTextures->icon) {
+ layoutResult->iconAtlas.patchUpdatedImages(uploadPass, *atlasTextures->icon, imageManager);
+ }
+}
+
+Bucket* GeometryTileRenderData::getBucket(const Layer::Impl& layer) const {
+ const LayerRenderData* data = getLayerRenderData(layer);
+ return data ? data->bucket.get() : nullptr;
+}
+
+const LayerRenderData* GeometryTileRenderData::getLayerRenderData(const style::Layer::Impl& layerImpl) const {
+ return layoutResult ? layoutResult->getLayerRenderData(layerImpl) : nullptr;
+}
+
+
/*
Correlation between GeometryTile and GeometryTileWorker is safeguarded by two
correlation schemes:
@@ -88,6 +175,9 @@ void GeometryTile::setData(std::unique_ptr<const GeometryTileData> data_) {
worker.self().invoke(&GeometryTileWorker::setData, std::move(data_), correlationID);
}
+std::unique_ptr<TileRenderData> GeometryTile::createRenderData() {
+ return std::make_unique<GeometryTileRenderData>(layoutResult, atlasTextures, imageManager);
+}
void GeometryTile::setLayers(const std::vector<Immutable<LayerProperties>>& layers) {
// Mark the tile as pending again if it was complete before to prevent signaling a complete
@@ -131,6 +221,9 @@ void GeometryTile::onLayout(std::shared_ptr<LayoutResult> result, const uint64_t
}
layoutResult = std::move(result);
+ if (!atlasTextures) {
+ atlasTextures = std::make_shared<TileAtlasTextures>();
+ }
observer->onTileChanged(*this);
}
@@ -159,61 +252,12 @@ void GeometryTile::getImages(ImageRequestPair pair) {
imageManager.getImages(*this, std::move(pair));
}
-const optional<ImagePosition> GeometryTile::getPattern(const std::string& pattern) const {
- if (layoutResult) {
- const auto& iconAtlas = layoutResult->iconAtlas;
- auto it = iconAtlas.patternPositions.find(pattern);
- if (it != iconAtlas.patternPositions.end()) {
- return it->second;
- }
- }
- return nullopt;
-}
-
const std::shared_ptr<FeatureIndex> GeometryTile::getFeatureIndex() const {
return layoutResult ? layoutResult->featureIndex : nullptr;
}
-void GeometryTile::upload(gfx::UploadPass& uploadPass) {
- if (!layoutResult) return;
-
- auto uploadFn = [&] (Bucket& bucket) {
- if (bucket.needsUpload()) {
- bucket.upload(uploadPass);
- }
- };
-
- for (auto& entry : layoutResult->layerRenderData) {
- uploadFn(*entry.second.bucket);
- }
-
- if (layoutResult->glyphAtlasImage) {
- glyphAtlasTexture = uploadPass.createTexture(*layoutResult->glyphAtlasImage);
- layoutResult->glyphAtlasImage = {};
- }
-
- if (layoutResult->iconAtlas.image.valid()) {
- iconAtlasTexture = uploadPass.createTexture(layoutResult->iconAtlas.image);
- layoutResult->iconAtlas.image = {};
- }
-
- if (iconAtlasTexture) {
- layoutResult->iconAtlas.patchUpdatedImages(uploadPass, *iconAtlasTexture, imageManager);
- }
-}
-
-Bucket* GeometryTile::getBucket(const Layer::Impl& layer) const {
- const LayerRenderData* data = getLayerRenderData(layer);
- return data ? data->bucket.get() : nullptr;
-}
-
-const LayerRenderData* GeometryTile::getLayerRenderData(const style::Layer::Impl& layerImpl) const {
- auto* that = const_cast<GeometryTile*>(this);
- return that->getMutableLayerRenderData(layerImpl);
-}
-
bool GeometryTile::layerPropertiesUpdated(const Immutable<style::LayerProperties>& layerProperties) {
- LayerRenderData* renderData = getMutableLayerRenderData(*layerProperties->baseImpl);
+ LayerRenderData* renderData = getLayerRenderData(*layerProperties->baseImpl);
if (!renderData) {
return false;
}
@@ -233,27 +277,16 @@ const GeometryTileData* GeometryTile::getData() const {
return layoutResult->featureIndex->getData();
}
-LayerRenderData* GeometryTile::getMutableLayerRenderData(const style::Layer::Impl& layerImpl) {
- if (!layoutResult) return nullptr;
- auto& layerIdToLayerRenderData = layoutResult->layerRenderData;
- auto it = layerIdToLayerRenderData.find(layerImpl.id);
- if (it == layerIdToLayerRenderData.end()) {
- return nullptr;
- }
- LayerRenderData& result = it->second;
- if (result.layerProperties->baseImpl->getTypeInfo() != layerImpl.getTypeInfo()) {
- // Layer data might be outdated, see issue #12432.
- return nullptr;
- }
- return &result;
+LayerRenderData* GeometryTile::getLayerRenderData(const style::Layer::Impl& layerImpl) {
+ return layoutResult ? layoutResult->getLayerRenderData(layerImpl) : nullptr;
}
float GeometryTile::getQueryPadding(const std::vector<const RenderLayer*>& layers) {
float queryPadding = 0;
for (const RenderLayer* layer : layers) {
- auto bucket = getBucket(*layer->baseImpl);
- if (bucket && bucket->hasData()) {
- queryPadding = std::max(queryPadding, bucket->getQueryRadius(*layer));
+ const LayerRenderData* data = getLayerRenderData(*layer->baseImpl);
+ if (data && data->bucket && data->bucket->hasData()) {
+ queryPadding = std::max(queryPadding, data->bucket->getQueryRadius(*layer));
}
}
return queryPadding;
diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp
index 0373161d10..3d75dfc456 100644
--- a/src/mbgl/tile/geometry_tile.hpp
+++ b/src/mbgl/tile/geometry_tile.hpp
@@ -23,6 +23,7 @@ class SourceQueryOptions;
class TileParameters;
class GlyphAtlas;
class ImageAtlas;
+class TileAtlasTextures;
class GeometryTile : public Tile, public GlyphRequestor, public ImageRequestor {
public:
@@ -35,6 +36,7 @@ public:
void setError(std::exception_ptr);
void setData(std::unique_ptr<const GeometryTileData>);
+ std::unique_ptr<TileRenderData> createRenderData() override;
void setLayers(const std::vector<Immutable<style::LayerProperties>>&) override;
void setShowCollisionBoxes(const bool showCollisionBoxes) override;
@@ -44,9 +46,6 @@ public:
void getGlyphs(GlyphDependencies);
void getImages(ImageRequestPair);
- void upload(gfx::UploadPass&) override;
- Bucket* getBucket(const style::Layer::Impl&) const override;
- const LayerRenderData* getLayerRenderData(const style::Layer::Impl&) const override;
bool layerPropertiesUpdated(const Immutable<style::LayerProperties>&) override;
void queryRenderedFeatures(
@@ -72,6 +71,8 @@ public:
optional<AlphaImage> glyphAtlasImage;
ImageAtlas iconAtlas;
+ LayerRenderData* getLayerRenderData(const style::Layer::Impl&);
+
LayoutResult(std::unordered_map<std::string, LayerRenderData> renderData_,
std::unique_ptr<FeatureIndex> featureIndex_,
optional<AlphaImage> glyphAtlasImage_,
@@ -89,14 +90,13 @@ public:
void markRenderedIdeal() override;
void markRenderedPreviously() override;
void performedFadePlacement() override;
- const optional<ImagePosition> getPattern(const std::string& pattern) const;
const std::shared_ptr<FeatureIndex> getFeatureIndex() const;
const std::string sourceID;
protected:
const GeometryTileData* getData() const;
- LayerRenderData* getMutableLayerRenderData(const style::Layer::Impl&);
+ LayerRenderData* getLayerRenderData(const style::Layer::Impl&);
private:
void markObsolete();
@@ -114,6 +114,7 @@ private:
uint64_t correlationID = 0;
std::shared_ptr<LayoutResult> layoutResult;
+ std::shared_ptr<TileAtlasTextures> atlasTextures;
const MapMode mode;
@@ -127,9 +128,6 @@ private:
};
FadeState fadeState = FadeState::Loaded;
-public:
- optional<gfx::Texture> glyphAtlasTexture;
- optional<gfx::Texture> iconAtlasTexture;
};
} // namespace mbgl
diff --git a/src/mbgl/tile/raster_dem_tile.cpp b/src/mbgl/tile/raster_dem_tile.cpp
index cf70687ffe..c092809130 100644
--- a/src/mbgl/tile/raster_dem_tile.cpp
+++ b/src/mbgl/tile/raster_dem_tile.cpp
@@ -7,6 +7,7 @@
#include <mbgl/storage/resource.hpp>
#include <mbgl/storage/response.hpp>
#include <mbgl/renderer/tile_parameters.hpp>
+#include <mbgl/renderer/tile_render_data.hpp>
#include <mbgl/renderer/buckets/hillshade_bucket.hpp>
#include <mbgl/actor/scheduler.hpp>
@@ -35,6 +36,10 @@ RasterDEMTile::RasterDEMTile(const OverscaledTileID& id_,
RasterDEMTile::~RasterDEMTile() = default;
+std::unique_ptr<TileRenderData> RasterDEMTile::createRenderData() {
+ return std::make_unique<SharedBucketTileRenderData<HillshadeBucket>>(bucket);
+}
+
void RasterDEMTile::setError(std::exception_ptr err) {
loaded = true;
observer->onTileError(*this, err);
@@ -69,15 +74,8 @@ void RasterDEMTile::onError(std::exception_ptr err, const uint64_t resultCorrela
observer->onTileError(*this, err);
}
-void RasterDEMTile::upload(gfx::UploadPass& uploadPass) {
- if (bucket) {
- bucket->upload(uploadPass);
- }
-}
-
-
-Bucket* RasterDEMTile::getBucket(const style::Layer::Impl&) const {
- return bucket.get();
+bool RasterDEMTile::layerPropertiesUpdated(const Immutable<style::LayerProperties>&) {
+ return bool(bucket);
}
HillshadeBucket* RasterDEMTile::getBucket() const {
diff --git a/src/mbgl/tile/raster_dem_tile.hpp b/src/mbgl/tile/raster_dem_tile.hpp
index 165a5b9d2b..e6a6b6f9f5 100644
--- a/src/mbgl/tile/raster_dem_tile.hpp
+++ b/src/mbgl/tile/raster_dem_tile.hpp
@@ -59,21 +59,21 @@ namespace style {
class Layer;
} // namespace style
-class RasterDEMTile : public Tile {
+class RasterDEMTile final : public Tile {
public:
RasterDEMTile(const OverscaledTileID&,
const TileParameters&,
const Tileset&);
~RasterDEMTile() override;
+ std::unique_ptr<TileRenderData> createRenderData() override;
void setNecessity(TileNecessity) final;
void setError(std::exception_ptr);
void setMetadata(optional<Timestamp> modified, optional<Timestamp> expires);
void setData(std::shared_ptr<const std::string> data);
- void upload(gfx::UploadPass&) override;
- Bucket* getBucket(const style::Layer::Impl&) const override;
+ bool layerPropertiesUpdated(const Immutable<style::LayerProperties>& layerProperties) override;
HillshadeBucket* getBucket() const;
void backfillBorder(const RasterDEMTile& borderTile, const DEMTileNeighbors mask);
@@ -98,7 +98,7 @@ private:
// Contains the Bucket object for the tile. Buckets are render
// objects and they get added by tile parsing operations.
- std::unique_ptr<HillshadeBucket> bucket;
+ std::shared_ptr<HillshadeBucket> bucket;
};
diff --git a/src/mbgl/tile/raster_tile.cpp b/src/mbgl/tile/raster_tile.cpp
index 1d8e7f3b3c..50a0d700b8 100644
--- a/src/mbgl/tile/raster_tile.cpp
+++ b/src/mbgl/tile/raster_tile.cpp
@@ -7,6 +7,7 @@
#include <mbgl/storage/resource.hpp>
#include <mbgl/storage/response.hpp>
#include <mbgl/renderer/tile_parameters.hpp>
+#include <mbgl/renderer/tile_render_data.hpp>
#include <mbgl/renderer/buckets/raster_bucket.hpp>
#include <mbgl/actor/scheduler.hpp>
@@ -24,6 +25,10 @@ RasterTile::RasterTile(const OverscaledTileID& id_,
RasterTile::~RasterTile() = default;
+std::unique_ptr<TileRenderData> RasterTile::createRenderData() {
+ return std::make_unique<SharedBucketTileRenderData<RasterBucket>>(bucket);
+}
+
void RasterTile::setError(std::exception_ptr err) {
loaded = true;
observer->onTileError(*this, err);
@@ -58,14 +63,8 @@ void RasterTile::onError(std::exception_ptr err, const uint64_t resultCorrelatio
observer->onTileError(*this, err);
}
-void RasterTile::upload(gfx::UploadPass& uploadPass) {
- if (bucket) {
- bucket->upload(uploadPass);
- }
-}
-
-Bucket* RasterTile::getBucket(const style::Layer::Impl&) const {
- return bucket.get();
+bool RasterTile::layerPropertiesUpdated(const Immutable<style::LayerProperties>&) {
+ return bool(bucket);
}
void RasterTile::setMask(TileMask&& mask) {
diff --git a/src/mbgl/tile/raster_tile.hpp b/src/mbgl/tile/raster_tile.hpp
index f62ddebf57..49ca3239ef 100644
--- a/src/mbgl/tile/raster_tile.hpp
+++ b/src/mbgl/tile/raster_tile.hpp
@@ -15,21 +15,21 @@ namespace style {
class Layer;
} // namespace style
-class RasterTile : public Tile {
+class RasterTile final : public Tile {
public:
RasterTile(const OverscaledTileID&,
const TileParameters&,
const Tileset&);
~RasterTile() override;
+ std::unique_ptr<TileRenderData> createRenderData() override;
void setNecessity(TileNecessity) final;
void setError(std::exception_ptr);
void setMetadata(optional<Timestamp> modified, optional<Timestamp> expires);
void setData(std::shared_ptr<const std::string> data);
- void upload(gfx::UploadPass&) override;
- Bucket* getBucket(const style::Layer::Impl&) const override;
+ bool layerPropertiesUpdated(const Immutable<style::LayerProperties>& layerProperties) override;
void setMask(TileMask&&) override;
@@ -46,7 +46,7 @@ private:
// Contains the Bucket object for the tile. Buckets are render
// objects and they get added by tile parsing operations.
- std::unique_ptr<RasterBucket> bucket;
+ std::shared_ptr<RasterBucket> bucket;
};
} // namespace mbgl
diff --git a/src/mbgl/tile/tile.hpp b/src/mbgl/tile/tile.hpp
index 17a16b4666..4ba8bc1160 100644
--- a/src/mbgl/tile/tile.hpp
+++ b/src/mbgl/tile/tile.hpp
@@ -24,6 +24,7 @@ class LayerRenderData;
class TransformState;
class TileObserver;
class RenderLayer;
+class TileRenderData;
class RenderedQueryOptions;
class SourceQueryOptions;
class CollisionIndex;
@@ -45,6 +46,8 @@ public:
Tile(Kind, OverscaledTileID);
virtual ~Tile();
+ virtual std::unique_ptr<TileRenderData> createRenderData() = 0;
+
void setObserver(TileObserver* observer);
virtual void setNecessity(TileNecessity) {}
@@ -52,12 +55,6 @@ public:
// Mark this tile as no longer needed and cancel any pending work.
virtual void cancel();
- virtual void upload(gfx::UploadPass&) = 0;
- virtual Bucket* getBucket(const style::Layer::Impl&) const = 0;
- virtual const LayerRenderData* getLayerRenderData(const style::Layer::Impl&) const {
- assert(false);
- return nullptr;
- }
// Notifies this tile of the updated layer properties.
//
// Tile implementation should update the contained layer
@@ -65,9 +62,7 @@ public:
//
// Returns `true` if the corresponding render layer data is present in this tile (and i.e. it
// was succesfully updated); returns `false` otherwise.
- virtual bool layerPropertiesUpdated(const Immutable<style::LayerProperties>& layerProperties) {
- return bool(getBucket(*layerProperties->baseImpl));
- }
+ virtual bool layerPropertiesUpdated(const Immutable<style::LayerProperties>& layerProperties) = 0;
virtual void setShowCollisionBoxes(const bool) {}
virtual void setLayers(const std::vector<Immutable<style::LayerProperties>>&) {}
virtual void setMask(TileMask&&) {}