summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/frame_history.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/renderer/frame_history.cpp')
-rw-r--r--src/mbgl/renderer/frame_history.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mbgl/renderer/frame_history.cpp b/src/mbgl/renderer/frame_history.cpp
index 35e246f488..de153b6963 100644
--- a/src/mbgl/renderer/frame_history.cpp
+++ b/src/mbgl/renderer/frame_history.cpp
@@ -37,9 +37,9 @@ void FrameHistory::record(const TimePoint& now, float zoom, const Duration& dura
}
for (int16_t z = 0; z <= 255; z++) {
- std::chrono::duration<float> timeDiff = now - changeTimes[z];
- int32_t opacityChange = (duration == Milliseconds(0) ? 1 : (timeDiff / duration)) * 255;
- uint8_t opacity = z <= zoomIndex
+ const std::chrono::duration<float> timeDiff = now - changeTimes[z];
+ const int32_t opacityChange = (duration == Milliseconds(0) ? 1 : (timeDiff / duration)) * 255;
+ const uint8_t opacity = z <= zoomIndex
? util::min(255, changeOpacities[z] + opacityChange)
: util::max(0, changeOpacities[z] - opacityChange);
if (opacities.data[z] != opacity) {
@@ -74,4 +74,8 @@ void FrameHistory::bind(gl::Context& context, uint32_t unit) {
context.bindTexture(*texture, unit);
}
+bool FrameHistory::isVisible(const float zoom) const {
+ return opacities.data[std::floor(zoom * 10)] != 0;
+}
+
} // namespace mbgl