summaryrefslogtreecommitdiff
path: root/src/mbgl/style
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-08-20 13:55:58 -0400
committerKonstantin Käfer <mail@kkaefer.com>2015-08-20 16:13:45 -0400
commit038b65ededebb8b0de04f2dc1faeaaa06cce9eb2 (patch)
tree3f84d20be5f7076da245b79ccb7832fff02cfa79 /src/mbgl/style
parent19d42acc8479efc0b05eda3721817ffa3314e2da (diff)
downloadqtlocation-mapboxgl-038b65ededebb8b0de04f2dc1faeaaa06cce9eb2.tar.gz
move RenderPass check to the StyleLayer object
Diffstat (limited to 'src/mbgl/style')
-rw-r--r--src/mbgl/style/style_layer.cpp24
-rw-r--r--src/mbgl/style/style_layer.hpp14
2 files changed, 36 insertions, 2 deletions
diff --git a/src/mbgl/style/style_layer.cpp b/src/mbgl/style/style_layer.cpp
index 5fc6af793c..dfd693dffa 100644
--- a/src/mbgl/style/style_layer.cpp
+++ b/src/mbgl/style/style_layer.cpp
@@ -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 {
diff --git a/src/mbgl/style/style_layer.hpp b/src/mbgl/style/style_layer.hpp
index 56b8cb8f19..6d14e57e18 100644
--- a/src/mbgl/style/style_layer.hpp
+++ b/src/mbgl/style/style_layer.hpp
@@ -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.