summaryrefslogtreecommitdiff
path: root/src/mbgl/gl
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-11-04 17:01:22 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-11-04 21:24:05 +0100
commit008a83b91584b8cf406264c5378bdd7ef87683ec (patch)
tree661e94fe3eb7bcb39a0e93acefce6e30e3d6b3f5 /src/mbgl/gl
parent176730bff64fc8f935e3337f870b2ff2a930ed15 (diff)
downloadqtlocation-mapboxgl-008a83b91584b8cf406264c5378bdd7ef87683ec.tar.gz
[core] add state tracking to pixel store packing alignment
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/types.hpp12
-rw-r--r--src/mbgl/gl/value.cpp29
-rw-r--r--src/mbgl/gl/value.hpp16
5 files changed, 59 insertions, 2 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index fc35028473..ceb9796ba6 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -283,6 +283,8 @@ void Context::setDirtyState() {
pointSize.setDirty();
pixelZoom.setDirty();
rasterPos.setDirty();
+ pixelStorePack.setDirty();
+ pixelStoreUnpack.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 e0f9b871cc..b3edd55636 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -130,6 +130,8 @@ public:
#if not MBGL_USE_GLES2
State<value::PixelZoom> pixelZoom;
State<value::RasterPos> rasterPos;
+ State<value::PixelStorePack> pixelStorePack;
+ State<value::PixelStoreUnpack> pixelStoreUnpack;
#endif // MBGL_USE_GLES2
private:
diff --git a/src/mbgl/gl/types.hpp b/src/mbgl/gl/types.hpp
index 16a37d58c1..6e1bc5f8e1 100644
--- a/src/mbgl/gl/types.hpp
+++ b/src/mbgl/gl/types.hpp
@@ -62,5 +62,17 @@ enum class PrimitiveType {
TriangleFan = 0x0006
};
+#if not MBGL_USE_GLES2
+
+struct PixelStorageType {
+ int32_t alignment;
+};
+
+constexpr bool operator!=(const PixelStorageType& a, const PixelStorageType& b) {
+ return a.alignment != b.alignment;
+}
+
+#endif // MBGL_USE_GLES2
+
} // namespace gl
} // namespace mbgl
diff --git a/src/mbgl/gl/value.cpp b/src/mbgl/gl/value.cpp
index f25008854d..af4f03a132 100644
--- a/src/mbgl/gl/value.cpp
+++ b/src/mbgl/gl/value.cpp
@@ -389,8 +389,35 @@ RasterPos::Type RasterPos::Get() {
return { pos[0], pos[1], pos[2], pos[3] };
}
-#endif // MBGL_USE_GLES2
+const constexpr PixelStorePack::Type PixelStorePack::Default;
+
+void PixelStorePack::Set(const Type& value) {
+ assert(value.alignment == 1 || value.alignment == 2 || value.alignment == 4 ||
+ value.alignment == 8);
+ MBGL_CHECK_ERROR(glPixelStorei(GL_PACK_ALIGNMENT, value.alignment));
+}
+
+PixelStorePack::Type PixelStorePack::Get() {
+ Type value;
+ MBGL_CHECK_ERROR(glGetIntegerv(GL_PACK_ALIGNMENT, &value.alignment));
+ return value;
+}
+
+const constexpr PixelStoreUnpack::Type PixelStoreUnpack::Default;
+void PixelStoreUnpack::Set(const Type& value) {
+ assert(value.alignment == 1 || value.alignment == 2 || value.alignment == 4 ||
+ value.alignment == 8);
+ MBGL_CHECK_ERROR(glPixelStorei(GL_UNPACK_ALIGNMENT, value.alignment));
+}
+
+PixelStoreUnpack::Type PixelStoreUnpack::Get() {
+ Type value;
+ MBGL_CHECK_ERROR(glGetIntegerv(GL_UNPACK_ALIGNMENT, &value.alignment));
+ return value;
+}
+
+#endif // MBGL_USE_GLES2
} // namespace value
} // namespace gl
diff --git a/src/mbgl/gl/value.hpp b/src/mbgl/gl/value.hpp
index 1f01d4e71a..613bbfcab2 100644
--- a/src/mbgl/gl/value.hpp
+++ b/src/mbgl/gl/value.hpp
@@ -259,7 +259,7 @@ struct RasterPos {
double z;
double w;
};
- static const constexpr Type Default = { 0, 0, 0, 0 };
+ static const constexpr Type Default = { 0, 0, 0, 1 };
static void Set(const Type&);
static Type Get();
};
@@ -268,6 +268,20 @@ constexpr bool operator!=(const RasterPos::Type& a, const RasterPos::Type& b) {
return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
}
+struct PixelStorePack {
+ using Type = PixelStorageType;
+ static const constexpr Type Default = { 4 };
+ static void Set(const Type&);
+ static Type Get();
+};
+
+struct PixelStoreUnpack {
+ using Type = PixelStorageType;
+ static const constexpr Type Default = { 4 };
+ static void Set(const Type&);
+ static Type Get();
+};
+
#endif // MBGL_USE_GLES2
} // namespace value