Drawable Renderer (#1570), Reworking fill drawables into layer group

This commit is contained in:
Tim Sylvester
2023-05-11 14:55:53 -07:00
committed by Bart Louwers
parent 86a374476f
commit 6a1b48bb45
14 changed files with 269 additions and 230 deletions

View File

@@ -117,6 +117,7 @@ protected:
};
using DrawablePtr = std::shared_ptr<Drawable>;
using UniqueDrawable = std::unique_ptr<Drawable>;
/// Comparator for sorting drawable pointers primarily by layer index
struct DrawablePtrLessByLayer {

View File

@@ -31,18 +31,17 @@ public:
virtual ~DrawableBuilder();
/// Get the drawable we're currently working on, if any
DrawablePtr getCurrentDrawable(bool createIfNone);
const UniqueDrawable& getCurrentDrawable(bool createIfNone);
/// Close the current drawable, using a new one for any further work
void flush();
/// Get all the completed drawables
const std::vector<DrawablePtr>& getDrawables() const { return drawables; }
const std::vector<UniqueDrawable>& getDrawables() const { return drawables; }
/// Get all the completed drawables and release ownership
std::vector<DrawablePtr> clearDrawables() {
std::vector<DrawablePtr> v = std::move(drawables);
drawables = {};
std::vector<UniqueDrawable> clearDrawables() {
std::vector<UniqueDrawable> v = std::move(drawables);
return v;
}
@@ -114,7 +113,7 @@ public:
protected:
/// Create an instance of the appropriate drawable type
virtual DrawablePtr createDrawable() const = 0;
virtual UniqueDrawable createDrawable() const = 0;
/// Setup the SDK-specific aspects after all the values are present
virtual void init() = 0;
@@ -128,8 +127,8 @@ protected:
DepthMaskType depthType = DepthMaskType::ReadOnly;
gfx::ShaderProgramBasePtr shader;
mat4 matrix;
DrawablePtr currentDrawable;
std::vector<DrawablePtr> drawables;
UniqueDrawable currentDrawable;
std::vector<UniqueDrawable> drawables;
std::vector<DrawableTweakerPtr> tweakers;
ColorMode colorMode = ColorMode::PerVertex;

View File

@@ -20,7 +20,7 @@ public:
void setVertexAttributes(VertexAttributeArrayGL&& value) { vertexAttributes = std::move(value); }
protected:
gfx::DrawablePtr createDrawable() const override;
gfx::UniqueDrawable createDrawable() const override;
/// Setup the SDK-specific aspects after all the values are present
void init() override;

View File

@@ -14,7 +14,7 @@ class RenderOrchestrator;
using ChangeRequestPtr = std::shared_ptr<ChangeRequest>;
using UniqueChangeRequest = std::unique_ptr<ChangeRequest>;
using UniqueChangeRequestVec = std::vector<UniqueChangeRequest>;
using UniqueLayerGroup = std::unique_ptr<LayerGroup>;
using LayerGroupPtr = std::shared_ptr<LayerGroup>;
namespace gfx {
class Drawable;
@@ -97,13 +97,13 @@ protected:
*/
class AddLayerGroupRequest : public ChangeRequest {
public:
AddLayerGroupRequest(UniqueLayerGroup &&layerGroup_, bool canReplace);
AddLayerGroupRequest(LayerGroupPtr layerGroup_, bool canReplace);
AddLayerGroupRequest(AddLayerGroupRequest &&other);
void execute(RenderOrchestrator &) override;
protected:
UniqueLayerGroup layerGroup;
LayerGroupPtr layerGroup;
bool replace;
};

View File

@@ -60,6 +60,10 @@ public:
void render(RenderOrchestrator&, PaintParameters&) override;
const gfx::UniqueDrawable& getDrawable(mbgl::RenderPass, const OverscaledTileID&) const;
gfx::UniqueDrawable removeDrawable(mbgl::RenderPass, const OverscaledTileID&);
bool addDrawable(mbgl::RenderPass, const OverscaledTileID&, gfx::UniqueDrawable&&);
protected:
struct Impl;
std::unique_ptr<Impl> impl;

View File

@@ -19,7 +19,7 @@ void DrawableBuilder::setColor(const Color& value) {
impl->currentColor = value;
}
DrawablePtr DrawableBuilder::getCurrentDrawable(bool createIfNone) {
const UniqueDrawable& DrawableBuilder::getCurrentDrawable(bool createIfNone) {
if (!currentDrawable && createIfNone) {
currentDrawable = createDrawable();
}
@@ -28,20 +28,19 @@ DrawablePtr DrawableBuilder::getCurrentDrawable(bool createIfNone) {
void DrawableBuilder::flush() {
if (!impl->vertices.empty()) {
auto draw = getCurrentDrawable(/*createIfNone=*/true);
currentDrawable->setRenderPass(renderPass);
currentDrawable->setDrawPriority(drawPriority);
currentDrawable->setLayerIndex(layerIndex);
currentDrawable->setDepthType(depthType);
currentDrawable->setShader(shader);
currentDrawable->setMatrix(matrix);
currentDrawable->setVertexAttributes(getVertexAttributes());
currentDrawable->addTweakers(tweakers.begin(), tweakers.end());
const auto& draw = getCurrentDrawable(/*createIfNone=*/true);
draw->setRenderPass(renderPass);
draw->setDrawPriority(drawPriority);
draw->setLayerIndex(layerIndex);
draw->setDepthType(depthType);
draw->setShader(shader);
draw->setMatrix(matrix);
draw->setVertexAttributes(getVertexAttributes());
draw->addTweakers(tweakers.begin(), tweakers.end());
init();
}
if (currentDrawable) {
drawables.push_back(currentDrawable);
currentDrawable.reset();
drawables.emplace_back(std::move(currentDrawable));
}
}

View File

@@ -7,8 +7,8 @@
namespace mbgl {
namespace gl {
gfx::DrawablePtr DrawableGLBuilder::createDrawable() const {
return std::make_shared<DrawableGL>(drawableName.empty() ? name : drawableName);
gfx::UniqueDrawable DrawableGLBuilder::createDrawable() const {
return std::make_unique<DrawableGL>(drawableName.empty() ? name : drawableName);
};
void DrawableGLBuilder::init() {

View File

@@ -17,7 +17,7 @@ void ResetColorRequest::execute(RenderOrchestrator &orchestrator) {
}
}
AddLayerGroupRequest::AddLayerGroupRequest(UniqueLayerGroup &&layerGroup_, bool canReplace)
AddLayerGroupRequest::AddLayerGroupRequest(LayerGroupPtr layerGroup_, bool canReplace)
: layerGroup(std::move(layerGroup_)),
replace(canReplace) {}

View File

@@ -38,12 +38,35 @@ TileLayerGroup::TileLayerGroup(int32_t layerIndex_, std::size_t initialCapacity)
TileLayerGroup::~TileLayerGroup() {}
static const gfx::UniqueDrawable no_tile;
const gfx::UniqueDrawable& TileLayerGroup::getDrawable(mbgl::RenderPass pass, const OverscaledTileID& id) const {
const auto hit = impl->tileDrawables.find({pass, id});
return (hit == impl->tileDrawables.end()) ? no_tile : hit->second;
}
gfx::UniqueDrawable TileLayerGroup::removeDrawable(mbgl::RenderPass pass, const OverscaledTileID& id) {
const auto hit = impl->tileDrawables.find({pass, id});
if (hit == impl->tileDrawables.end()) {
return {};
}
auto drawable = std::move(hit->second);
impl->tileDrawables.erase(hit);
return drawable;
}
bool TileLayerGroup::addDrawable(mbgl::RenderPass pass, const OverscaledTileID& id, gfx::UniqueDrawable&& drawable) {
const auto result = impl->tileDrawables.insert(std::make_pair(TileLayerGroupTileKey{pass, id}, gfx::UniqueDrawable()));
if (result.second) {
return false;
} else {
result.first->second = std::move(drawable);
return true;
}
}
void TileLayerGroup::render([[maybe_unused]] RenderOrchestrator& orchestrator,
[[maybe_unused]] PaintParameters& parameters) {
auto pass = mbgl::RenderPass::Opaque;
auto id = OverscaledTileID{0, 0, 0, 0, 0};
auto key = TileLayerGroupTileKey{pass, id};
impl->tileDrawables.insert(std::make_pair(key, gfx::UniqueDrawable()));
}
} // namespace mbgl

View File

@@ -330,7 +330,7 @@ void RenderBackgroundLayer::update(const int32_t layerIndex,
auto& drawable = newDrawables[0];
drawable->setTileID(tileID);
drawable->mutableUniformBuffers().addOrReplace("BackgroundLayerUBO", uniformBuffer);
result.first->second = drawable;
result.first->second = std::move(drawable);
changes.emplace_back(std::make_unique<AddDrawableRequest>(std::move(drawable)));
++stats.tileDrawablesAdded;
// Log::Warning(Event::General, "Adding drawable for " + util::toString(tileID) + " total " +

View File

@@ -8,6 +8,7 @@
#include <mbgl/programs/programs.hpp>
#include <mbgl/renderer/buckets/fill_bucket.hpp>
#include <mbgl/renderer/image_manager.hpp>
#include <mbgl/renderer/layer_group.hpp>
#include <mbgl/renderer/layers/render_fill_layer.hpp>
#include <mbgl/renderer/paint_parameters.hpp>
#include <mbgl/renderer/render_source.hpp>
@@ -343,6 +344,11 @@ void RenderFillLayer::update(const int32_t layerIndex,
// }
// }
if (!tileLayerGroup) {
tileLayerGroup = std::make_shared<TileLayerGroup>(layerIndex, /*initialCapacity=*/64);
changes.emplace_back(std::make_unique<AddLayerGroupRequest>(tileLayerGroup, /*canReplace=*/true));
}
if (!renderTiles || renderTiles->empty()) {
if (!tileDrawables.empty()) {
removeDrawables<decltype(tileDrawables)::const_iterator>(
@@ -380,211 +386,212 @@ void RenderFillLayer::update(const int32_t layerIndex,
}
std::unique_ptr<gfx::DrawableBuilder> builder;
std::vector<gfx::DrawablePtr> newTiles;
if (unevaluated.get<FillPattern>().isUndefined()) {
// parameters.renderTileClippingMasks(renderTiles);
for (const RenderTile& tile : *renderTiles) {
const auto& tileID = tile.getOverscaledTileID();
for (const auto renderPass : {RenderPass::Opaque, RenderPass::Translucent}) {
if (unevaluated.get<FillPattern>().isUndefined()) {
// parameters.renderTileClippingMasks(renderTiles);
for (const RenderTile& tile : *renderTiles) {
const auto& tileID = tile.getOverscaledTileID();
const auto hit = tileDrawables.find(tileID);
auto& tileDrawable = tileLayerGroup->getDrawable(renderPass, tileID);
const auto renderPass = RenderPass::Translucent;
const LayerRenderData* renderData = getRenderDataForPass(tile, renderPass);
if (!renderData) {
// Remove the tile if it was previously present
if (hit != tileDrawables.end()) {
if (hit->second) {
changes.emplace_back(std::make_unique<RemoveDrawableRequest>(hit->second->getId()));
const auto removeTile = [&](){
if (tileDrawable) {
changes.emplace_back(std::make_unique<RemoveDrawableRequest>(tileDrawable->getId()));
tileLayerGroup->removeDrawable(renderPass, tileID);
++stats.tileDrawablesRemoved;
}
tileDrawables.erase(hit);
++stats.tileDrawablesRemoved;
};
const LayerRenderData* renderData = getRenderDataForPass(tile, renderPass);
if (!renderData) {
removeTile();
continue;
}
auto& bucket = static_cast<FillBucket&>(*renderData->bucket);
const auto& evaluated = getEvaluated<FillLayerProperties>(renderData->layerProperties);
const auto evalColor = evaluated.get<FillColor>().constantOr(Color());
const auto fillOpacity = evaluated.get<FillOpacity>().constantOr(0);
const auto fillColor = evalColor * (fillOpacity > 0.0f ? fillOpacity : 1.0f);
const auto fillRenderPass = (evalColor.a >= 1.0f && fillOpacity >= 1.0f
/* && parameters.currentLayer >= parameters.opaquePassCutoff*/)
? RenderPass::Opaque
: RenderPass::Translucent;
if (fillRenderPass != renderPass) {
removeTile();
continue;
}
if (tileDrawable) {
// needed and already present, update?
continue;
}
if (!builder) {
builder = context.createDrawableBuilder("fill");
builder->setShader(shader);
builder->addTweaker(context.createDrawableTweaker());
builder->setColorMode(gfx::DrawableBuilder::ColorMode::PerVertex);
builder->setDepthType(gfx::DepthMaskType::ReadWrite);
builder->setLayerIndex(layerIndex);
}
// tile.translatedMatrix(evaluated.get<FillTranslate>(), evaluated.get<FillTranslateAnchor>(),
// parameters.state)
builder->setColor(fillColor);
builder->setRenderPass(renderPass);
const std::vector<gfx::VertexVector<gfx::detail::VertexType<gfx::AttributeType<int16_t, 2>>>::Vertex>&
verts = bucket.vertices.vector();
std::vector<std::array<int16_t, 2>> rawVerts(verts.size());
std::transform(verts.begin(), verts.end(), rawVerts.begin(), [](const auto& x) { return x.a1; });
for (const auto& seg : bucket.triangleSegments) {
builder->addTriangles(rawVerts,
seg.vertexOffset,
seg.vertexLength,
bucket.triangles.vector(),
seg.indexOffset,
seg.indexLength);
}
// evaluated.get<FillTranslate>(),
// evaluated.get<FillTranslateAnchor>(),
// parameters.stencilModeForClipping(tile.id),
// parameters.colorModeForRenderPass(),
// gfx::CullFaceMode::disabled(),
//
// const auto isOpaque = (evaluated.get<FillColor>().constantOr(Color()).a >= 1.0f &&
// evaluated.get<FillOpacity>().constantOr(0) >= 1.0f
// );// && layerIndex >= parameters.opaquePassCutoff);
// const auto fillRenderPass = isOpaque ? RenderPass::Opaque : RenderPass::Translucent;
//
// if (renderPass == fillRenderPass) {
// }
// const auto depthMask = (renderPass == RenderPass::Opaque) ? gfx::DepthMaskType::ReadWrite
// : gfx::DepthMaskType::ReadOnly;
// const auto depthMode = parameters.depthModeForSublayer(1, depthMask);
// if (evaluated.get<FillAntialias>() && parameters.pass == RenderPass::Translucent) {
// draw(*fillOutlineProgram,
// gfx::Lines{2.0f},
// parameters.depthModeForSublayer(unevaluated.get<FillOutlineColor>().isUndefined() ? 2
// : 0,
// gfx::DepthMaskType::ReadOnly),
// *bucket.lineIndexBuffer,
// bucket.lineSegments,
// FillOutlineProgram::TextureBindings{});
// }
builder->flush();
auto newDrawables = builder->clearDrawables();
if (!newDrawables.empty()) {
auto& drawable = newDrawables[0];
drawable->setTileID(tileID);
// Track it.
tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable));
++stats.tileDrawablesAdded;
// Log::Warning(Event::General, "Adding drawable for " + util::toString(tileID) + " total " +
// std::to_string(stats.tileDrawablesAdded+1));
}
continue;
}
if (hit != tileDrawables.end()) {
// already present
continue;
}
auto& bucket = static_cast<FillBucket&>(*renderData->bucket);
const auto& evaluated = getEvaluated<FillLayerProperties>(renderData->layerProperties);
if (!builder) {
builder = context.createDrawableBuilder("fill");
builder->setShader(shader);
builder->addTweaker(context.createDrawableTweaker());
builder->setColorMode(gfx::DrawableBuilder::ColorMode::PerVertex);
builder->setDepthType(gfx::DepthMaskType::ReadWrite);
builder->setLayerIndex(layerIndex);
}
// tile.translatedMatrix(evaluated.get<FillTranslate>(), evaluated.get<FillTranslateAnchor>(),
// parameters.state)
const auto evalColor = evaluated.get<FillColor>().constantOr(Color());
const auto fillOpacity = evaluated.get<FillOpacity>().constantOr(0);
const auto fillColor = evalColor * (fillOpacity > 0.0f ? fillOpacity : 1.0f);
builder->setColor(fillColor);
const auto fillRenderPass = (evalColor.a >= 1.0f && fillOpacity >= 1.0f
/* && parameters.currentLayer >= parameters.opaquePassCutoff*/)
? RenderPass::Opaque
: RenderPass::Translucent;
builder->setRenderPass(fillRenderPass);
const std::vector<gfx::VertexVector<gfx::detail::VertexType<gfx::AttributeType<int16_t, 2>>>::Vertex>&
verts = bucket.vertices.vector();
std::vector<std::array<int16_t, 2>> rawVerts(verts.size());
std::transform(verts.begin(), verts.end(), rawVerts.begin(), [](const auto& x) { return x.a1; });
for (const auto& seg : bucket.triangleSegments) {
builder->addTriangles(rawVerts,
seg.vertexOffset,
seg.vertexLength,
bucket.triangles.vector(),
seg.indexOffset,
seg.indexLength);
}
// evaluated.get<FillTranslate>(),
// evaluated.get<FillTranslateAnchor>(),
// parameters.stencilModeForClipping(tile.id),
// parameters.colorModeForRenderPass(),
// gfx::CullFaceMode::disabled(),
} else {
// if (parameters.pass != RenderPass::Translucent) {
// return;
// }
//
// const auto isOpaque = (evaluated.get<FillColor>().constantOr(Color()).a >= 1.0f &&
// evaluated.get<FillOpacity>().constantOr(0) >= 1.0f
// );// && layerIndex >= parameters.opaquePassCutoff);
// const auto fillRenderPass = isOpaque ? RenderPass::Opaque : RenderPass::Translucent;
// parameters.renderTileClippingMasks(renderTiles);
//
// if (renderPass == fillRenderPass) {
// for (const RenderTile& tile : *renderTiles) {
// const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
// if (!renderData) {
// continue;
// }
// const auto depthMask = (renderPass == RenderPass::Opaque) ? gfx::DepthMaskType::ReadWrite
// : gfx::DepthMaskType::ReadOnly;
// const auto depthMode = parameters.depthModeForSublayer(1, depthMask);
// if (evaluated.get<FillAntialias>() && parameters.pass == RenderPass::Translucent) {
// draw(*fillOutlineProgram,
// auto& bucket = static_cast<FillBucket&>(*renderData->bucket);
// const auto& evaluated = getEvaluated<FillLayerProperties>(renderData->layerProperties);
// const auto& crossfade = getCrossfade<FillLayerProperties>(renderData->layerProperties);
//
// const auto& fillPatternValue =
// evaluated.get<FillPattern>().constantOr(Faded<expression::Image>{"", ""});
// std::optional<ImagePosition> patternPosA = tile.getPattern(fillPatternValue.from.id());
// std::optional<ImagePosition> patternPosB = tile.getPattern(fillPatternValue.to.id());
//
// auto draw = [&](auto& programInstance,
// const auto& drawMode,
// const auto& depthMode,
// const auto& indexBuffer,
// const auto& segments,
// auto&& textureBindings) {
// const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID());
// paintPropertyBinders.setPatternParameters(patternPosA, patternPosB, crossfade);
//
// const auto allUniformValues = programInstance.computeAllUniformValues(
// FillPatternProgram::layoutUniformValues(
// tile.translatedMatrix(
// evaluated.get<FillTranslate>(), evaluated.get<FillTranslateAnchor>(),
// parameters.state),
// parameters.backend.getDefaultRenderable().getSize(),
// tile.getIconAtlasTexture().size,
// crossfade,
// tile.id,
// parameters.state,
// parameters.pixelRatio),
// paintPropertyBinders,
// evaluated,
// static_cast<float>(parameters.state.getZoom()));
// const auto allAttributeBindings = programInstance.computeAllAttributeBindings(
// *bucket.vertexBuffer, paintPropertyBinders, evaluated);
//
// checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings));
//
// programInstance.draw(parameters.context,
// *parameters.renderPass,
// drawMode,
// depthMode,
// parameters.stencilModeForClipping(tile.id),
// parameters.colorModeForRenderPass(),
// gfx::CullFaceMode::disabled(),
// indexBuffer,
// segments,
// allUniformValues,
// allAttributeBindings,
// std::forward<decltype(textureBindings)>(textureBindings),
// getID());
// };
//
// if (bucket.triangleIndexBuffer) {
// draw(*fillPatternProgram,
// gfx::Triangles(),
// parameters.depthModeForSublayer(1, gfx::DepthMaskType::ReadWrite),
// *bucket.triangleIndexBuffer,
// bucket.triangleSegments,
// FillPatternProgram::TextureBindings{
// textures::image::Value{tile.getIconAtlasTexture().getResource(),
// gfx::TextureFilterType::Linear},
// });
// }
// if (evaluated.get<FillAntialias>() && unevaluated.get<FillOutlineColor>().isUndefined()) {
// draw(*fillOutlinePatternProgram,
// gfx::Lines{2.0f},
// parameters.depthModeForSublayer(unevaluated.get<FillOutlineColor>().isUndefined() ? 2
// : 0,
// gfx::DepthMaskType::ReadOnly),
// parameters.depthModeForSublayer(2, gfx::DepthMaskType::ReadOnly),
// *bucket.lineIndexBuffer,
// bucket.lineSegments,
// FillOutlineProgram::TextureBindings{});
// FillOutlinePatternProgram::TextureBindings{
// textures::image::Value{tile.getIconAtlasTexture().getResource(),
// gfx::TextureFilterType::Linear},
// });
// }
builder->flush();
auto newDrawables = builder->clearDrawables();
if (!newDrawables.empty()) {
auto& drawable = newDrawables[0];
drawable->setTileID(tileID);
// Track it.
#if !defined(NDEBUG)
const auto result =
#endif
tileDrawables.insert(std::make_pair(tileID, drawable));
// This should always insert because we checked previously.
assert(result.second);
changes.emplace_back(std::make_unique<AddDrawableRequest>(std::move(drawable)));
++stats.tileDrawablesAdded;
// Log::Warning(Event::General, "Adding drawable for " + util::toString(tileID) + " total " +
// std::to_string(stats.tileDrawablesAdded+1));
}
// }
}
} else {
// if (parameters.pass != RenderPass::Translucent) {
// return;
// }
//
// parameters.renderTileClippingMasks(renderTiles);
//
// for (const RenderTile& tile : *renderTiles) {
// const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
// if (!renderData) {
// continue;
// }
// auto& bucket = static_cast<FillBucket&>(*renderData->bucket);
// const auto& evaluated = getEvaluated<FillLayerProperties>(renderData->layerProperties);
// const auto& crossfade = getCrossfade<FillLayerProperties>(renderData->layerProperties);
//
// const auto& fillPatternValue =
// evaluated.get<FillPattern>().constantOr(Faded<expression::Image>{"", ""});
// std::optional<ImagePosition> patternPosA = tile.getPattern(fillPatternValue.from.id());
// std::optional<ImagePosition> patternPosB = tile.getPattern(fillPatternValue.to.id());
//
// auto draw = [&](auto& programInstance,
// const auto& drawMode,
// const auto& depthMode,
// const auto& indexBuffer,
// const auto& segments,
// auto&& textureBindings) {
// const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID());
// paintPropertyBinders.setPatternParameters(patternPosA, patternPosB, crossfade);
//
// const auto allUniformValues = programInstance.computeAllUniformValues(
// FillPatternProgram::layoutUniformValues(
// tile.translatedMatrix(
// evaluated.get<FillTranslate>(), evaluated.get<FillTranslateAnchor>(),
// parameters.state),
// parameters.backend.getDefaultRenderable().getSize(),
// tile.getIconAtlasTexture().size,
// crossfade,
// tile.id,
// parameters.state,
// parameters.pixelRatio),
// paintPropertyBinders,
// evaluated,
// static_cast<float>(parameters.state.getZoom()));
// const auto allAttributeBindings = programInstance.computeAllAttributeBindings(
// *bucket.vertexBuffer, paintPropertyBinders, evaluated);
//
// checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings));
//
// programInstance.draw(parameters.context,
// *parameters.renderPass,
// drawMode,
// depthMode,
// parameters.stencilModeForClipping(tile.id),
// parameters.colorModeForRenderPass(),
// gfx::CullFaceMode::disabled(),
// indexBuffer,
// segments,
// allUniformValues,
// allAttributeBindings,
// std::forward<decltype(textureBindings)>(textureBindings),
// getID());
// };
//
// if (bucket.triangleIndexBuffer) {
// draw(*fillPatternProgram,
// gfx::Triangles(),
// parameters.depthModeForSublayer(1, gfx::DepthMaskType::ReadWrite),
// *bucket.triangleIndexBuffer,
// bucket.triangleSegments,
// FillPatternProgram::TextureBindings{
// textures::image::Value{tile.getIconAtlasTexture().getResource(),
// gfx::TextureFilterType::Linear},
// });
// }
// if (evaluated.get<FillAntialias>() && unevaluated.get<FillOutlineColor>().isUndefined()) {
// draw(*fillOutlinePatternProgram,
// gfx::Lines{2.0f},
// parameters.depthModeForSublayer(2, gfx::DepthMaskType::ReadOnly),
// *bucket.lineIndexBuffer,
// bucket.lineSegments,
// FillOutlinePatternProgram::TextureBindings{
// textures::image::Value{tile.getIconAtlasTexture().getResource(),
// gfx::TextureFilterType::Linear},
// });
// }
// }
}
}

View File

@@ -5,6 +5,8 @@
#include <mbgl/style/layers/fill_layer_properties.hpp>
#include <mbgl/layout/pattern_layout.hpp>
#include <memory>
namespace mbgl {
class FillBucket;
@@ -12,6 +14,8 @@ class FillProgram;
class FillPatternProgram;
class FillOutlineProgram;
class FillOutlinePatternProgram;
class TileLayerGroup;
using TileLayerGroupPtr = std::shared_ptr<TileLayerGroup>;
class RenderFillLayer final : public RenderLayer {
public:
@@ -50,6 +54,8 @@ private:
std::shared_ptr<FillPatternProgram> fillPatternProgram;
std::shared_ptr<FillOutlineProgram> fillOutlineProgram;
std::shared_ptr<FillOutlinePatternProgram> fillOutlinePatternProgram;
TileLayerGroupPtr tileLayerGroup;
};
} // namespace mbgl

View File

@@ -778,9 +778,9 @@ const gfx::DrawablePtr& RenderOrchestrator::getDrawable(const util::SimpleIdenti
void RenderOrchestrator::onRemoveLayerGroup(LayerGroup&) {}
bool RenderOrchestrator::addLayerGroup(UniqueLayerGroup&& layerGroup, const bool replace) {
bool RenderOrchestrator::addLayerGroup(LayerGroupPtr layerGroup, const bool replace) {
const auto index = layerGroup->getLayerIndex();
const auto result = layerGroupsByLayerIndex.insert(std::make_pair(index, UniqueLayerGroup{}));
const auto result = layerGroupsByLayerIndex.insert(std::make_pair(index, LayerGroupPtr{}));
if (result.second) {
// added
result.first->second = std::move(layerGroup);
@@ -808,9 +808,9 @@ bool RenderOrchestrator::removeLayerGroup(const int32_t layerIndex) {
}
}
static const UniqueLayerGroup no_group;
static const LayerGroupPtr no_group;
const UniqueLayerGroup& RenderOrchestrator::getLayerGroup(const int32_t layerIndex) const {
const LayerGroupPtr& RenderOrchestrator::getLayerGroup(const int32_t layerIndex) const {
const auto hit = layerGroupsByLayerIndex.find(layerIndex);
return (hit == layerGroupsByLayerIndex.end()) ? no_group : hit->second;
}

View File

@@ -103,9 +103,9 @@ public:
const gfx::DrawablePtr& getDrawable(const util::SimpleIdentity&);
bool addLayerGroup(UniqueLayerGroup&&, bool replace);
bool addLayerGroup(LayerGroupPtr, bool replace);
bool removeLayerGroup(const int32_t layerIndex);
const UniqueLayerGroup& getLayerGroup(const int32_t layerIndex) const;
const LayerGroupPtr& getLayerGroup(const int32_t layerIndex) const;
void observeLayerGroups(std::function<void(LayerGroup&)>);
void observeLayerGroups(std::function<void(const LayerGroup&)>) const;
@@ -186,7 +186,7 @@ private:
DrawableMap drawables;
std::vector<std::unique_ptr<ChangeRequest>> pendingChanges;
using LayerGroupMap = std::map<int32_t, UniqueLayerGroup>;
using LayerGroupMap = std::map<int32_t, LayerGroupPtr>;
LayerGroupMap layerGroupsByLayerIndex;
};