move RenderPass check to the StyleLayer object
This commit is contained in:
@@ -285,7 +285,7 @@ void Painter::renderPass(RenderPass pass_,
|
||||
for (; it != end; ++it, i += increment) {
|
||||
const auto& item = *it;
|
||||
if (item.bucket && item.tile) {
|
||||
if (item.hasRenderPass(pass)) {
|
||||
if (item.layer.hasRenderPass(pass)) {
|
||||
MBGL_DEBUG_GROUP(item.layer.id + " - " + std::string(item.tile->id));
|
||||
setStrata(i * strataThickness);
|
||||
prepareTile(*item.tile);
|
||||
@@ -350,14 +350,6 @@ std::vector<RenderItem> Painter::determineRenderOrder(const Style& style) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't include invisible layers.
|
||||
if (!layer.isVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Determine what render passes we need for this layer.
|
||||
const RenderPass passes = determineRenderPasses(layer);
|
||||
|
||||
const auto& tiles = source->getTiles();
|
||||
for (auto tile : tiles) {
|
||||
assert(tile);
|
||||
@@ -367,7 +359,7 @@ std::vector<RenderItem> Painter::determineRenderOrder(const Style& style) {
|
||||
|
||||
auto bucket = tile->data->getBucket(layer);
|
||||
if (bucket) {
|
||||
order.emplace_back(layer, tile, bucket, passes);
|
||||
order.emplace_back(layer, tile, bucket);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -375,28 +367,6 @@ std::vector<RenderItem> Painter::determineRenderOrder(const Style& style) {
|
||||
return order;
|
||||
}
|
||||
|
||||
RenderPass Painter::determineRenderPasses(const StyleLayer& layer) {
|
||||
RenderPass passes = RenderPass::None;
|
||||
|
||||
if (layer.properties.is<FillProperties>()) {
|
||||
const FillProperties &properties = layer.properties.get<FillProperties>();
|
||||
const float alpha = properties.fill_color[3] * properties.opacity;
|
||||
|
||||
if (properties.antialias) {
|
||||
passes |= RenderPass::Translucent;
|
||||
}
|
||||
if (!properties.image.from.empty() || alpha < 1.0f) {
|
||||
passes |= RenderPass::Translucent;
|
||||
} else {
|
||||
passes |= RenderPass::Opaque;
|
||||
}
|
||||
} else {
|
||||
passes |= RenderPass::Translucent;
|
||||
}
|
||||
|
||||
return passes;
|
||||
}
|
||||
|
||||
void Painter::renderBackground(const StyleLayer &layer_desc) {
|
||||
// Note: This function is only called for textured background. Otherwise, the background color
|
||||
// is created with glClear.
|
||||
|
||||
@@ -63,19 +63,13 @@ struct ClipID;
|
||||
struct RenderItem {
|
||||
inline RenderItem(const StyleLayer& layer_,
|
||||
const Tile* tile_ = nullptr,
|
||||
Bucket* bucket_ = nullptr,
|
||||
RenderPass passes_ = RenderPass::Opaque)
|
||||
: tile(tile_), bucket(bucket_), layer(layer_), passes(passes_) {
|
||||
Bucket* bucket_ = nullptr)
|
||||
: tile(tile_), bucket(bucket_), layer(layer_) {
|
||||
}
|
||||
|
||||
const Tile* const tile;
|
||||
Bucket* const bucket;
|
||||
const StyleLayer& layer;
|
||||
const RenderPass passes;
|
||||
|
||||
inline bool hasRenderPass(RenderPass pass) const {
|
||||
return bool(passes & pass);
|
||||
}
|
||||
};
|
||||
|
||||
class Painter : private util::noncopyable {
|
||||
@@ -145,7 +139,6 @@ private:
|
||||
mat4 translatedMatrix(const mat4& matrix, const std::array<float, 2> &translation, const TileID &id, TranslateAnchorType anchor);
|
||||
|
||||
std::vector<RenderItem> determineRenderOrder(const Style& style);
|
||||
static RenderPass determineRenderPasses(const StyleLayer&);
|
||||
|
||||
template <class Iterator>
|
||||
void renderPass(RenderPass,
|
||||
|
||||
@@ -28,6 +28,10 @@ bool StyleLayer::isVisible() const {
|
||||
}
|
||||
}
|
||||
|
||||
bool StyleLayer::hasRenderPass(RenderPass pass) const {
|
||||
return bool(passes & pass);
|
||||
}
|
||||
|
||||
void StyleLayer::setClasses(const std::vector<std::string> &class_names, const TimePoint& now,
|
||||
const PropertyTransition &defaultTransition) {
|
||||
// Stores all keys that we have already added transitions for.
|
||||
@@ -260,6 +264,26 @@ void StyleLayer::updateProperties(float z, const TimePoint& now, ZoomHistory &zo
|
||||
case StyleLayerType::Background: applyStyleProperties<BackgroundProperties>(z, now, zoomHistory); break;
|
||||
default: properties.set<std::false_type>(); break;
|
||||
}
|
||||
|
||||
// Update the render passes when this layer is visible.
|
||||
passes = RenderPass::None;
|
||||
if (isVisible()) {
|
||||
if (properties.is<FillProperties>()) {
|
||||
const FillProperties &fillProperties = properties.get<FillProperties>();
|
||||
const float alpha = fillProperties.fill_color[3] * fillProperties.opacity;
|
||||
|
||||
if (fillProperties.antialias) {
|
||||
passes |= RenderPass::Translucent;
|
||||
}
|
||||
if (!fillProperties.image.from.empty() || alpha < 1.0f) {
|
||||
passes |= RenderPass::Translucent;
|
||||
} else {
|
||||
passes |= RenderPass::Opaque;
|
||||
}
|
||||
} else {
|
||||
passes |= RenderPass::Translucent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool StyleLayer::hasTransitions() const {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <mbgl/style/applied_class_properties.hpp>
|
||||
#include <mbgl/style/zoom_history.hpp>
|
||||
|
||||
#include <mbgl/renderer/render_pass.hpp>
|
||||
|
||||
#include <mbgl/util/ptr.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/chrono.hpp>
|
||||
@@ -35,8 +37,9 @@ public:
|
||||
// Determines whether this layer is the background layer.
|
||||
bool isBackground() const;
|
||||
|
||||
// Checks whether the layer is currently visible at all.
|
||||
bool isVisible() const;
|
||||
public:
|
||||
// Checks whether this layer needs to be rendered in the given render pass.
|
||||
bool hasRenderPass(RenderPass) const;
|
||||
|
||||
// Updates the StyleProperties information in this layer by evaluating all
|
||||
// pending transitions and applied classes in order.
|
||||
@@ -62,6 +65,9 @@ private:
|
||||
// Removes all expired style transitions.
|
||||
void cleanupAppliedStyleProperties(const TimePoint& now);
|
||||
|
||||
// Checks whether the layer is currently visible at all.
|
||||
bool isVisible() const;
|
||||
|
||||
public:
|
||||
// The name of this layer.
|
||||
const std::string id;
|
||||
@@ -80,6 +86,10 @@ private:
|
||||
// optional transition times.
|
||||
std::map<PropertyKey, AppliedClassPropertyValues> appliedStyle;
|
||||
|
||||
// Stores what render passes this layer is currently enabled for. This depends on the
|
||||
// evaluated StyleProperties object and is updated accordingly.
|
||||
RenderPass passes = RenderPass::None;
|
||||
|
||||
public:
|
||||
// Stores the evaluated, and cascaded styling information, specific to this
|
||||
// layer's type.
|
||||
|
||||
Reference in New Issue
Block a user