diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-11-04 17:50:42 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-11-04 21:24:05 +0100 |
commit | 7b772611d576ed99b148208c21824bb089663599 (patch) | |
tree | c693f89323fd309ac63a982e2510464603b11e35 /src/mbgl/gl | |
parent | 29c5c13aa2860a0e8c1ac9a826b08330708d3f29 (diff) | |
download | qtlocation-mapboxgl-7b772611d576ed99b148208c21824bb089663599.tar.gz |
[core] move pixel blitting to gl::Context
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r-- | src/mbgl/gl/context.cpp | 11 | ||||
-rw-r--r-- | src/mbgl/gl/context.hpp | 11 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 811a038caf..c63819bc03 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -118,6 +118,17 @@ std::unique_ptr<uint8_t[]> Context::readFramebuffer(const Size size, const Textu return data; } +#if not MBGL_USE_GLES2 +void Context::drawPixels(const Size size, const void* data, TextureFormat format) { + pixelStoreUnpack = { 1 }; + if (format != TextureFormat::RGBA) { + format = static_cast<TextureFormat>(GL_LUMINANCE); + } + MBGL_CHECK_ERROR(glDrawPixels(size.width, size.height, static_cast<GLenum>(GL_LUMINANCE), + GL_UNSIGNED_BYTE, data)); +} +#endif // MBGL_USE_GLES2 + namespace { void checkFramebuffer() { diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index 169aa5566e..438450fe14 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -71,6 +71,14 @@ public: return { size, readFramebuffer(size, format, flip) }; } +#if not MBGL_USE_GLES2 + template <typename Image> + void drawPixels(const Image& image) { + auto format = image.channels == 4 ? TextureFormat::RGBA : TextureFormat::Alpha; + drawPixels(image.size, image.data.get(), format); + } +#endif // MBGL_USE_GLES2 + // Create a texture from an image with data. template <typename Image> Texture createTexture(const Image& image, TextureUnit unit = 0) { @@ -177,6 +185,9 @@ private: UniqueFramebuffer createFramebuffer(); UniqueRenderbuffer createRenderbuffer(RenderbufferType, Size size); std::unique_ptr<uint8_t[]> readFramebuffer(Size, TextureFormat, bool flip); +#if not MBGL_USE_GLES2 + void drawPixels(Size size, const void* data, TextureFormat); +#endif // MBGL_USE_GLES2 PrimitiveType operator()(const Points&); PrimitiveType operator()(const Lines&); |