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
This commit is contained in:
Adam Jackson 2019-12-18 13:50:51 -05:00
parent e89cea8e5a
commit 498264959a
2 changed files with 15 additions and 2 deletions

View File

@ -106,6 +106,9 @@
#ifndef GL_PACK_INVERT_MESA #ifndef GL_PACK_INVERT_MESA
#define GL_PACK_INVERT_MESA 0x8758 #define GL_PACK_INVERT_MESA 0x8758
#endif #endif
#ifndef GL_PACK_REVERSE_ROW_ORDER_ANGLE
#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4
#endif
#ifndef GL_BACK_LEFT #ifndef GL_BACK_LEFT
#define GL_BACK_LEFT 0x0402 #define GL_BACK_LEFT 0x0402
#endif #endif
@ -1190,6 +1193,7 @@ _cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
GLenum gl_intformat; GLenum gl_intformat;
GLenum gl_format; GLenum gl_format;
GLenum gl_type; GLenum gl_type;
GLenum gl_pack_enum = GL_FALSE;
gboolean pack_invert_set; gboolean pack_invert_set;
int status = FALSE; int status = FALSE;
@ -1220,7 +1224,12 @@ _cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
(source & COGL_READ_PIXELS_NO_FLIP) == 0 && (source & COGL_READ_PIXELS_NO_FLIP) == 0 &&
!cogl_is_offscreen (framebuffer)) !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; pack_invert_set = TRUE;
} }
else else
@ -1414,7 +1423,7 @@ EXIT:
* to interfere with other Cogl components so all other code can assume that * to interfere with other Cogl components so all other code can assume that
* we leave the pack_invert state off. */ * we leave the pack_invert state off. */
if (pack_invert_set) if (pack_invert_set)
GE (ctx, glPixelStorei (GL_PACK_INVERT_MESA, FALSE)); GE (ctx, glPixelStorei (gl_pack_enum, FALSE));
return status; return status;
} }

View File

@ -300,6 +300,10 @@ _cogl_driver_update_features (CoglContext *context,
gl_minor, gl_minor,
gl_extensions); 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 /* Note GLES 2 core doesn't support mipmaps for npot textures or
* repeat modes other than CLAMP_TO_EDGE. */ * repeat modes other than CLAMP_TO_EDGE. */