From 498264959a0ce0f036ce70b6cdc0db7d255ae32d Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Wed, 18 Dec 2019 13:50:51 -0500 Subject: [PATCH] cogl: Add support for GL_ANGLE_pack_reverse_row_order This is the GLES equivalent of GL_MESA_pack_invert. https://gitlab.gnome.org/GNOME/mutter/merge_requests/980 --- cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 13 +++++++++++-- cogl/cogl/driver/gl/gles/cogl-driver-gles.c | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c index b956a8314..3c91c9ff8 100644 --- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c +++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c @@ -106,6 +106,9 @@ #ifndef GL_PACK_INVERT_MESA #define GL_PACK_INVERT_MESA 0x8758 #endif +#ifndef GL_PACK_REVERSE_ROW_ORDER_ANGLE +#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 +#endif #ifndef GL_BACK_LEFT #define GL_BACK_LEFT 0x0402 #endif @@ -1190,6 +1193,7 @@ _cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer, GLenum gl_intformat; GLenum gl_format; GLenum gl_type; + GLenum gl_pack_enum = GL_FALSE; gboolean pack_invert_set; int status = FALSE; @@ -1220,7 +1224,12 @@ _cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer, (source & COGL_READ_PIXELS_NO_FLIP) == 0 && !cogl_is_offscreen (framebuffer)) { - GE (ctx, glPixelStorei (GL_PACK_INVERT_MESA, TRUE)); + if (ctx->driver == COGL_DRIVER_GLES2) + gl_pack_enum = GL_PACK_REVERSE_ROW_ORDER_ANGLE; + else + gl_pack_enum = GL_PACK_INVERT_MESA; + + GE (ctx, glPixelStorei (gl_pack_enum, TRUE)); pack_invert_set = TRUE; } else @@ -1414,7 +1423,7 @@ EXIT: * to interfere with other Cogl components so all other code can assume that * we leave the pack_invert state off. */ if (pack_invert_set) - GE (ctx, glPixelStorei (GL_PACK_INVERT_MESA, FALSE)); + GE (ctx, glPixelStorei (gl_pack_enum, FALSE)); return status; } diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c index a29ac49aa..fc04c8c91 100644 --- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c @@ -300,6 +300,10 @@ _cogl_driver_update_features (CoglContext *context, gl_minor, gl_extensions); + if (_cogl_check_extension ("GL_ANGLE_pack_reverse_row_order", gl_extensions)) + COGL_FLAGS_SET (private_features, + COGL_PRIVATE_FEATURE_MESA_PACK_INVERT, TRUE); + /* Note GLES 2 core doesn't support mipmaps for npot textures or * repeat modes other than CLAMP_TO_EDGE. */