[mutter] cogl: Read pixels in the correct 32bit format as per the given bitmap



commit 95e9fa10ef20a23912186c0cc701ab8f5a97f1a0
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Mar 1 18:53:57 2017 +0100

    cogl: Read pixels in the correct 32bit format as per the given bitmap
    
    Fixes the gnome-shell screenshot tool from getting colors with the
    wrong byte order.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779234

 cogl/cogl/driver/gl/cogl-framebuffer-gl.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
index 18ba08a..2af36f0 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -1418,6 +1418,15 @@ _cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
                                                             &gl_format,
                                                             &gl_type);
 
+  /* As we are reading pixels, we want to consider the bitmap according to
+   * its real pixel format, not the swizzled channels we pretend face to the
+   * pipeline.
+   */
+  if ((format == COGL_PIXEL_FORMAT_BGRA_8888 ||
+       format == COGL_PIXEL_FORMAT_BGRA_8888_PRE) &&
+      _cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE))
+    gl_format = GL_BGRA;
+
   /* NB: All offscreen rendering is done upside down so there is no need
    * to flip in this case... */
   if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_MESA_PACK_INVERT) &&


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]