diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-06-07 15:46:16 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-06-13 10:18:43 -0700 |
commit | b201a7900f989af432aaea500a0e6c5ea5bbba53 (patch) | |
tree | 4786889bb4dcec59f2e0e0ee4171facbea372756 | |
parent | f5d3b850bff06e3cd4d4bcff288dceeb53cfa82d (diff) | |
download | qtlocation-mapboxgl-b201a7900f989af432aaea500a0e6c5ea5bbba53.tar.gz |
[core] glPixelStorei is in OpenGL ES 2
-rw-r--r-- | src/mbgl/gl/context.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/gl/context.hpp | 5 | ||||
-rw-r--r-- | src/mbgl/gl/types.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/gl/value.cpp | 56 | ||||
-rw-r--r-- | src/mbgl/gl/value.hpp | 28 |
5 files changed, 47 insertions, 52 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 2a36100dfd..348e0a0e77 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -258,11 +258,9 @@ std::unique_ptr<uint8_t[]> Context::readFramebuffer(const Size size, const Textu const size_t stride = size.width * (format == TextureFormat::RGBA ? 4 : 1); auto data = std::make_unique<uint8_t[]>(stride * size.height); -#if not MBGL_USE_GLES2 // When reading data from the framebuffer, make sure that we are storing the values // tightly packed into the buffer to avoid buffer overruns. pixelStorePack = { 1 }; -#endif // MBGL_USE_GLES2 MBGL_CHECK_ERROR(glReadPixels(0, 0, size.width, size.height, static_cast<GLenum>(format), GL_UNSIGNED_BYTE, data.get())); @@ -489,12 +487,12 @@ void Context::setDirtyState() { program.setDirty(); lineWidth.setDirty(); activeTexture.setDirty(); + pixelStorePack.setDirty(); + pixelStoreUnpack.setDirty(); #if not MBGL_USE_GLES2 pointSize.setDirty(); pixelZoom.setDirty(); rasterPos.setDirty(); - pixelStorePack.setDirty(); - pixelStoreUnpack.setDirty(); pixelTransferDepth.setDirty(); pixelTransferStencil.setDirty(); #endif // MBGL_USE_GLES2 diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index 9086b8c955..4f5b4c797c 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -206,11 +206,12 @@ public: State<value::BindVertexBuffer> vertexBuffer; State<value::BindElementBuffer> elementBuffer; + State<value::PixelStorePack> pixelStorePack; + State<value::PixelStoreUnpack> pixelStoreUnpack; + #if not MBGL_USE_GLES2 State<value::PixelZoom> pixelZoom; State<value::RasterPos> rasterPos; - State<value::PixelStorePack> pixelStorePack; - State<value::PixelStoreUnpack> pixelStoreUnpack; State<value::PixelTransferDepth> pixelTransferDepth; State<value::PixelTransferStencil> pixelTransferStencil; #endif // MBGL_USE_GLES2 diff --git a/src/mbgl/gl/types.hpp b/src/mbgl/gl/types.hpp index 0595419674..31e3076f67 100644 --- a/src/mbgl/gl/types.hpp +++ b/src/mbgl/gl/types.hpp @@ -66,8 +66,6 @@ enum class PrimitiveType { TriangleFan = 0x0006 }; -#if not MBGL_USE_GLES2 - struct PixelStorageType { int32_t alignment; }; @@ -76,8 +74,6 @@ constexpr bool operator!=(const PixelStorageType& a, const PixelStorageType& b) return a.alignment != b.alignment; } -#endif // MBGL_USE_GLES2 - using BinaryProgramFormat = uint32_t; } // namespace gl diff --git a/src/mbgl/gl/value.cpp b/src/mbgl/gl/value.cpp index 32c632d101..2b825fb2bd 100644 --- a/src/mbgl/gl/value.cpp +++ b/src/mbgl/gl/value.cpp @@ -365,6 +365,34 @@ BindVertexArray::Type BindVertexArray::Get(const Context& context) { return binding; } +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; +} + #if not MBGL_USE_GLES2 const constexpr PointSize::Type PointSize::Default; @@ -404,34 +432,6 @@ RasterPos::Type RasterPos::Get() { return { pos[0], pos[1], pos[2], pos[3] }; } -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; -} - const constexpr PixelTransferDepth::Type PixelTransferDepth::Default; void PixelTransferDepth::Set(const Type& value) { diff --git a/src/mbgl/gl/value.hpp b/src/mbgl/gl/value.hpp index b8656db5b0..d4c7b5cdc3 100644 --- a/src/mbgl/gl/value.hpp +++ b/src/mbgl/gl/value.hpp @@ -239,6 +239,20 @@ struct BindVertexArray { static Type Get(const Context&); }; +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(); +}; + #if not MBGL_USE_GLES2 struct PointSize { @@ -278,20 +292,6 @@ 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(); -}; - struct PixelTransferDepth { struct Type { float scale; |