[core] Remove casts for Custom and Background render layers
This commit is contained in:
@@ -123,4 +123,12 @@ void RenderBackgroundLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
}
|
||||
}
|
||||
|
||||
optional<Color> RenderBackgroundLayer::getSolidBackground() const {
|
||||
if (!evaluated.get<BackgroundPattern>().from.empty()) {
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
return { evaluated.get<BackgroundColor>() * evaluated.get<BackgroundOpacity>() };
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -15,6 +15,7 @@ public:
|
||||
void evaluate(const PropertyEvaluationParameters&) override;
|
||||
bool hasTransition() const override;
|
||||
bool hasCrossfade() const override;
|
||||
optional<Color> getSolidBackground() const final;
|
||||
void render(PaintParameters&, RenderSource*) override;
|
||||
|
||||
std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const RenderLayer*>&) const override;
|
||||
|
||||
@@ -90,6 +90,10 @@ void RenderLayer::update() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
optional<Color> RenderLayer::getSolidBackground() const {
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
RenderLayer::RenderTiles RenderLayer::filterRenderTiles(RenderTiles tiles, FilterFunctionPtr filterFn) const {
|
||||
assert(filterFn != nullptr);
|
||||
RenderTiles filtered;
|
||||
|
||||
@@ -101,6 +101,9 @@ public:
|
||||
// similar to color ramp. Temporarily moved to the base.
|
||||
virtual void update();
|
||||
|
||||
// TODO: Only for background layers.
|
||||
virtual optional<Color> getSolidBackground() const;
|
||||
|
||||
friend std::string layoutKey(const RenderLayer&);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -218,9 +218,9 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
|
||||
bool needsRelayout = false;
|
||||
|
||||
for (const auto& layer : *layerImpls) {
|
||||
if (layer->type == LayerType::Background ||
|
||||
layer->type == LayerType::Custom ||
|
||||
layer->source != source->id) {
|
||||
|
||||
if (layer->getTypeInfo()->source == LayerTypeInfo::Source::NotRequired
|
||||
|| layer->source != source->id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -298,21 +298,16 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (const RenderBackgroundLayer* background = layer->as<RenderBackgroundLayer>()) {
|
||||
const BackgroundPaintProperties::PossiblyEvaluated& paint = background->evaluated;
|
||||
if (parameters.contextMode == GLContextMode::Unique
|
||||
&& layerImpl.get() == layerImpls->at(0).get()
|
||||
&& paint.get<BackgroundPattern>().from.empty()) {
|
||||
// This is a solid background. We can use glClear().
|
||||
backgroundColor = paint.get<BackgroundColor>() * paint.get<BackgroundOpacity>();
|
||||
} else {
|
||||
// This is a textured background, or not the bottommost layer. We need to render it with a quad.
|
||||
order.emplace_back(RenderItem { *layer, nullptr });
|
||||
if (parameters.contextMode == GLContextMode::Unique
|
||||
&& layerImpl.get() == layerImpls->at(0).get()) {
|
||||
const auto& solidBackground = layer->getSolidBackground();
|
||||
if (solidBackground) {
|
||||
backgroundColor = *solidBackground;
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (layer->is<RenderCustomLayer>()) {
|
||||
if (layerImpl->getTypeInfo()->source == LayerTypeInfo::Source::NotRequired) {
|
||||
order.emplace_back(RenderItem { *layer, nullptr });
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user