From 28eb2e635417c7fb8d746a9ed1d76774066098b3 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Thu, 1 Jun 2017 21:31:19 +0300 Subject: [PATCH] [core] Added Backend::{assume,set}Viewport --- include/mbgl/map/backend.hpp | 4 ++-- platform/android/src/native_map_view.cpp | 6 +++--- platform/glfw/glfw_view.cpp | 4 ++-- platform/ios/src/MGLMapView.mm | 4 ++-- platform/macos/src/MGLMapView.mm | 4 ++-- platform/qt/src/qmapboxgl.cpp | 4 ++-- src/mbgl/map/backend.cpp | 9 +++++---- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/include/mbgl/map/backend.hpp b/include/mbgl/map/backend.hpp index 884c4b525..23a75b82a 100644 --- a/include/mbgl/map/backend.hpp +++ b/include/mbgl/map/backend.hpp @@ -61,7 +61,7 @@ protected: // Tells the renderer that OpenGL state has already been set by the windowing toolkit. // It sets the internal assumed state to the supplied values. void assumeFramebufferBinding(gl::FramebufferID fbo); - void assumeViewportSize(const Size&); + void assumeViewport(int32_t x, int32_t y, const Size&); // Returns true when assumed framebuffer binding hasn't changed from the implicit binding. bool implicitFramebufferBound(); @@ -69,7 +69,7 @@ protected: // Triggers an OpenGL state update if the internal assumed state doesn't match the // supplied values. void setFramebufferBinding(gl::FramebufferID fbo); - void setViewportSize(const Size&); + void setViewport(int32_t x, int32_t y, const Size&); protected: std::unique_ptr context; diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index 73a4f9654..7696be5b1 100755 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -109,7 +109,7 @@ NativeMapView::~NativeMapView() { */ void NativeMapView::bind() { setFramebufferBinding(0); - setViewportSize(getFramebufferSize()); + setViewport(0, 0, getFramebufferSize()); } /** @@ -292,7 +292,7 @@ void NativeMapView::render(jni::JNIEnv& env) { BackendScope guard(*this); if (framebufferSizeChanged) { - setViewportSize(getFramebufferSize()); + setViewport(0, 0, getFramebufferSize()); framebufferSizeChanged = false; } @@ -1430,7 +1430,7 @@ mbgl::Size NativeMapView::getFramebufferSize() const { void NativeMapView::updateAssumedState() { assumeFramebufferBinding(0); - assumeViewportSize(getFramebufferSize()); + assumeViewport(0, 0, getFramebufferSize()); } void NativeMapView::updateFps() { diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index c5d36a555..4f878550b 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -136,12 +136,12 @@ void GLFWView::setMap(mbgl::Map *map_) { void GLFWView::updateAssumedState() { assumeFramebufferBinding(0); - assumeViewportSize(getFramebufferSize()); + assumeViewport(0, 0, getFramebufferSize()); } void GLFWView::bind() { setFramebufferBinding(0); - setViewportSize(getFramebufferSize()); + setViewport(0, 0, getFramebufferSize()); } void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, int mods) { diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 9a9f71d5c..8ae3049e3 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -5439,7 +5439,7 @@ public: /// context state with the anticipated values. void updateAssumedState() override { assumeFramebufferBinding(ImplicitFramebufferBinding); - assumeViewportSize(nativeView.framebufferSize); + assumeViewport(0, 0, nativeView.framebufferSize); } void bind() override { @@ -5452,7 +5452,7 @@ public: updateAssumedState(); } else { // Our framebuffer is still bound, but the viewport might have changed. - setViewportSize(nativeView.framebufferSize); + setViewport(0, 0, nativeView.framebufferSize); } } diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index c7f6e59c8..a8a84522a 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -2888,12 +2888,12 @@ public: void updateAssumedState() override { glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo); assumeFramebufferBinding(fbo); - assumeViewportSize(nativeView.framebufferSize); + assumeViewport(0, 0, nativeView.framebufferSize); } void bind() override { setFramebufferBinding(fbo); - setViewportSize(nativeView.framebufferSize); + setViewport(0, 0, nativeView.framebufferSize); } mbgl::PremultipliedImage readStillImage() { diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 01471bf73..7bc02c9d1 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -1506,12 +1506,12 @@ mbgl::Size QMapboxGLPrivate::framebufferSize() const { void QMapboxGLPrivate::updateAssumedState() { assumeFramebufferBinding(fbObject); - assumeViewportSize(framebufferSize()); + assumeViewport(0, 0, framebufferSize()); } void QMapboxGLPrivate::bind() { setFramebufferBinding(fbObject); - setViewportSize(framebufferSize()); + setViewport(0, 0, framebufferSize()); } void QMapboxGLPrivate::invalidate() diff --git a/src/mbgl/map/backend.cpp b/src/mbgl/map/backend.cpp index 0b4fd0105..4c84453c1 100644 --- a/src/mbgl/map/backend.cpp +++ b/src/mbgl/map/backend.cpp @@ -32,8 +32,9 @@ void Backend::assumeFramebufferBinding(const gl::FramebufferID fbo) { assert(gl::value::BindFramebuffer::Get() == getContext().bindFramebuffer.getCurrentValue()); } } -void Backend::assumeViewportSize(const Size& size) { - getContext().viewport.setCurrentValue({ 0, 0, size }); + +void Backend::assumeViewport(int32_t x, int32_t y, const Size& size) { + getContext().viewport.setCurrentValue({ x, y, size }); assert(gl::value::Viewport::Get() == getContext().viewport.getCurrentValue()); } @@ -48,8 +49,8 @@ void Backend::setFramebufferBinding(const gl::FramebufferID fbo) { } } -void Backend::setViewportSize(const Size& size) { - getContext().viewport = { 0, 0, size }; +void Backend::setViewport(int32_t x, int32_t y, const Size& size) { + getContext().viewport = { x, y, size }; assert(gl::value::Viewport::Get() == getContext().viewport.getCurrentValue()); }