summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-06-01 21:32:26 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2017-06-13 13:37:41 +0300
commita05f060153497e1be6515120b65f580f4551f9e0 (patch)
treeb736fe12eebe4bfdac0154c4e45d4dbf26207b57 /src
parent28eb2e635417c7fb8d746a9ed1d76774066098b3 (diff)
downloadqtlocation-mapboxgl-a05f060153497e1be6515120b65f580f4551f9e0.tar.gz
[core] Added Backend::{assume,set}ScissorTest
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/gl/context.cpp4
-rw-r--r--src/mbgl/gl/context.hpp1
-rw-r--r--src/mbgl/gl/value.cpp12
-rw-r--r--src/mbgl/gl/value.hpp7
-rw-r--r--src/mbgl/map/backend.cpp10
-rw-r--r--src/mbgl/util/offscreen_texture.cpp1
6 files changed, 33 insertions, 2 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index 6a68c3ff69..2a36100dfd 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -468,8 +468,8 @@ void Context::reset() {
}
void Context::setDirtyState() {
- // Note: does not set viewport/bindFramebuffer to dirty since they are handled separately in
- // the view object.
+ // Note: does not set viewport/scissorTest/bindFramebuffer to dirty
+ // since they are handled separately in the view object.
stencilFunc.setDirty();
stencilMask.setDirty();
stencilTest.setDirty();
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp
index 56c0618989..9086b8c955 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -199,6 +199,7 @@ public:
State<value::ActiveTexture> activeTexture;
State<value::BindFramebuffer> bindFramebuffer;
State<value::Viewport> viewport;
+ State<value::ScissorTest> scissorTest;
std::array<State<value::BindTexture>, 2> texture;
State<value::BindVertexArray, const Context&> vertexArrayObject { *this };
State<value::Program> program;
diff --git a/src/mbgl/gl/value.cpp b/src/mbgl/gl/value.cpp
index c081c941f5..32c632d101 100644
--- a/src/mbgl/gl/value.cpp
+++ b/src/mbgl/gl/value.cpp
@@ -267,6 +267,18 @@ Viewport::Type Viewport::Get() {
{ static_cast<uint32_t>(viewport[2]), static_cast<uint32_t>(viewport[3]) } };
}
+const constexpr ScissorTest::Type ScissorTest::Default;
+
+void ScissorTest::Set(const Type& value) {
+ MBGL_CHECK_ERROR(value ? glEnable(GL_SCISSOR_TEST) : glDisable(GL_SCISSOR_TEST));
+}
+
+ScissorTest::Type ScissorTest::Get() {
+ Type scissorTest;
+ MBGL_CHECK_ERROR(scissorTest = glIsEnabled(GL_SCISSOR_TEST));
+ return scissorTest;
+}
+
const constexpr BindFramebuffer::Type BindFramebuffer::Default;
void BindFramebuffer::Set(const Type& value) {
diff --git a/src/mbgl/gl/value.hpp b/src/mbgl/gl/value.hpp
index aa5cca6fec..b8656db5b0 100644
--- a/src/mbgl/gl/value.hpp
+++ b/src/mbgl/gl/value.hpp
@@ -182,6 +182,13 @@ struct Viewport {
static Type Get();
};
+struct ScissorTest {
+ using Type = bool;
+ static const constexpr Type Default = false;
+ static void Set(const Type&);
+ static Type Get();
+};
+
constexpr bool operator!=(const Viewport::Type& a, const Viewport::Type& b) {
return a.x != b.x || a.y != b.y || a.size != b.size;
}
diff --git a/src/mbgl/map/backend.cpp b/src/mbgl/map/backend.cpp
index 4c84453c1f..83c2fed00b 100644
--- a/src/mbgl/map/backend.cpp
+++ b/src/mbgl/map/backend.cpp
@@ -38,6 +38,11 @@ void Backend::assumeViewport(int32_t x, int32_t y, const Size& size) {
assert(gl::value::Viewport::Get() == getContext().viewport.getCurrentValue());
}
+void Backend::assumeScissorTest(bool enabled) {
+ getContext().scissorTest.setCurrentValue(enabled);
+ assert(gl::value::ScissorTest::Get() == getContext().scissorTest.getCurrentValue());
+}
+
bool Backend::implicitFramebufferBound() {
return getContext().bindFramebuffer.getCurrentValue() == ImplicitFramebufferBinding;
}
@@ -54,6 +59,11 @@ void Backend::setViewport(int32_t x, int32_t y, const Size& size) {
assert(gl::value::Viewport::Get() == getContext().viewport.getCurrentValue());
}
+void Backend::setScissorTest(bool enabled) {
+ getContext().scissorTest = enabled;
+ assert(gl::value::ScissorTest::Get() == getContext().scissorTest.getCurrentValue());
+}
+
Backend::~Backend() = default;
} // namespace mbgl
diff --git a/src/mbgl/util/offscreen_texture.cpp b/src/mbgl/util/offscreen_texture.cpp
index fe24774b7c..77a1416e48 100644
--- a/src/mbgl/util/offscreen_texture.cpp
+++ b/src/mbgl/util/offscreen_texture.cpp
@@ -33,6 +33,7 @@ public:
}
context.activeTexture = 0;
+ context.scissorTest = false;
context.viewport = { 0, 0, size };
}