summaryrefslogtreecommitdiff
path: root/src/mbgl/gl
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-11-04 17:12:47 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-11-04 21:24:05 +0100
commiteed16cb1bb14c5de68e71ba7960cbe264cc08760 (patch)
tree6e43e3d84c170b8bf55742bd0dfdc8022922dbd8 /src/mbgl/gl
parent008a83b91584b8cf406264c5378bdd7ef87683ec (diff)
downloadqtlocation-mapboxgl-eed16cb1bb14c5de68e71ba7960cbe264cc08760.tar.gz
[core] add state tracking to pixel transfer
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r--src/mbgl/gl/context.cpp2
-rw-r--r--src/mbgl/gl/context.hpp2
-rw-r--r--src/mbgl/gl/value.cpp28
-rw-r--r--src/mbgl/gl/value.hpp28
4 files changed, 60 insertions, 0 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index ceb9796ba6..1cd546f407 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -285,6 +285,8 @@ void Context::setDirtyState() {
rasterPos.setDirty();
pixelStorePack.setDirty();
pixelStoreUnpack.setDirty();
+ pixelTransferDepth.setDirty();
+ pixelTransferStencil.setDirty();
#endif // MBGL_USE_GLES2
for (auto& tex : texture) {
tex.setDirty();
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp
index b3edd55636..9bfa54fa55 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -132,6 +132,8 @@ public:
State<value::RasterPos> rasterPos;
State<value::PixelStorePack> pixelStorePack;
State<value::PixelStoreUnpack> pixelStoreUnpack;
+ State<value::PixelTransferDepth> pixelTransferDepth;
+ State<value::PixelTransferStencil> pixelTransferStencil;
#endif // MBGL_USE_GLES2
private:
diff --git a/src/mbgl/gl/value.cpp b/src/mbgl/gl/value.cpp
index af4f03a132..86218f3d9a 100644
--- a/src/mbgl/gl/value.cpp
+++ b/src/mbgl/gl/value.cpp
@@ -417,6 +417,34 @@ PixelStoreUnpack::Type PixelStoreUnpack::Get() {
return value;
}
+const constexpr PixelTransferDepth::Type PixelTransferDepth::Default;
+
+void PixelTransferDepth::Set(const Type& value) {
+ MBGL_CHECK_ERROR(glPixelTransferf(GL_DEPTH_SCALE, value.scale));
+ MBGL_CHECK_ERROR(glPixelTransferf(GL_DEPTH_BIAS, value.bias));
+}
+
+PixelTransferDepth::Type PixelTransferDepth::Get() {
+ Type value;
+ MBGL_CHECK_ERROR(glGetFloatv(GL_DEPTH_SCALE, &value.scale));
+ MBGL_CHECK_ERROR(glGetFloatv(GL_DEPTH_BIAS, &value.bias));
+ return value;
+}
+
+const constexpr PixelTransferStencil::Type PixelTransferStencil::Default;
+
+void PixelTransferStencil::Set(const Type& value) {
+ MBGL_CHECK_ERROR(glPixelTransferf(GL_INDEX_SHIFT, value.shift));
+ MBGL_CHECK_ERROR(glPixelTransferf(GL_INDEX_OFFSET, value.offset));
+}
+
+PixelTransferStencil::Type PixelTransferStencil::Get() {
+ Type value;
+ MBGL_CHECK_ERROR(glGetIntegerv(GL_INDEX_SHIFT, &value.shift));
+ MBGL_CHECK_ERROR(glGetIntegerv(GL_INDEX_OFFSET, &value.offset));
+ return value;
+}
+
#endif // MBGL_USE_GLES2
} // namespace value
diff --git a/src/mbgl/gl/value.hpp b/src/mbgl/gl/value.hpp
index 613bbfcab2..3586c26bda 100644
--- a/src/mbgl/gl/value.hpp
+++ b/src/mbgl/gl/value.hpp
@@ -282,6 +282,34 @@ struct PixelStoreUnpack {
static Type Get();
};
+struct PixelTransferDepth {
+ struct Type {
+ float scale;
+ float bias;
+ };
+ static const constexpr Type Default = { 1, 0 };
+ static void Set(const Type&);
+ static Type Get();
+};
+
+constexpr bool operator!=(const PixelTransferDepth::Type& a, const PixelTransferDepth::Type& b) {
+ return a.scale != b.scale || a.bias != b.bias;
+}
+
+struct PixelTransferStencil {
+ struct Type {
+ int32_t shift;
+ int32_t offset;
+ };
+ static const constexpr Type Default = { 0, 0 };
+ static void Set(const Type&);
+ static Type Get();
+};
+
+constexpr bool operator!=(const PixelTransferStencil::Type& a, const PixelTransferStencil::Type& b) {
+ return a.shift != b.shift || a.offset != b.offset;
+}
+
#endif // MBGL_USE_GLES2
} // namespace value