Backport more color fixes to really fix RHBZ #1428559

This commit is contained in:
Adam Williamson 2017-03-07 11:58:10 -08:00
parent d12509b7f6
commit c24f6328ae
3 changed files with 217 additions and 2 deletions

View File

@ -0,0 +1,162 @@
From aa5738c777883f270ae9cb3b2988d194792fed75 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Fri, 3 Mar 2017 17:11:19 +0100
Subject: [PATCH 1/2] cogl: Add pixel_format_to_gl_with_target driver vfunc
This is used by the GL driver in order to determine whether swizzling
actually applies given the bitmap and target texture internal format.
If both agree that they store BGRA, then swizzling may apply.
https://bugzilla.gnome.org/show_bug.cgi?id=779234
---
cogl/cogl/cogl-driver.h | 7 +++++++
cogl/cogl/driver/gl/gl/cogl-driver-gl.c | 29 +++++++++++++++++++++++------
cogl/cogl/driver/gl/gles/cogl-driver-gles.c | 26 +++++++++++++++++++++-----
cogl/cogl/driver/nop/cogl-driver-nop.c | 1 +
4 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/cogl/cogl/cogl-driver.h b/cogl/cogl/cogl-driver.h
index 648228c6f..85aa0d870 100644
--- a/cogl/cogl/cogl-driver.h
+++ b/cogl/cogl/cogl-driver.h
@@ -55,6 +55,13 @@ struct _CoglDriverVtable
GLenum *out_glintformat,
GLenum *out_glformat,
GLenum *out_gltype);
+ CoglPixelFormat
+ (* pixel_format_to_gl_with_target) (CoglContext *context,
+ CoglPixelFormat format,
+ CoglPixelFormat target_format,
+ GLenum *out_glintformat,
+ GLenum *out_glformat,
+ GLenum *out_gltype);
CoglBool
(* update_features) (CoglContext *context,
diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
index 1cc63e82f..178262ac0 100644
--- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -96,11 +96,12 @@ _cogl_driver_pixel_format_from_gl_internal (CoglContext *context,
}
static CoglPixelFormat
-_cogl_driver_pixel_format_to_gl (CoglContext *context,
- CoglPixelFormat format,
- GLenum *out_glintformat,
- GLenum *out_glformat,
- GLenum *out_gltype)
+_cogl_driver_pixel_format_to_gl_with_target (CoglContext *context,
+ CoglPixelFormat format,
+ CoglPixelFormat target_format,
+ GLenum *out_glintformat,
+ GLenum *out_glformat,
+ GLenum *out_gltype)
{
CoglPixelFormat required_format;
GLenum glintformat = 0;
@@ -178,7 +179,8 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
* and buffer format are the same here, the pixels
* will be flipped through this extension.
*/
- if (_cogl_has_private_feature
+ if (target_format == format &&
+ _cogl_has_private_feature
(context, COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE))
glformat = GL_RGBA;
else
@@ -297,6 +299,20 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
return required_format;
}
+static CoglPixelFormat
+_cogl_driver_pixel_format_to_gl (CoglContext *context,
+ CoglPixelFormat format,
+ GLenum *out_glintformat,
+ GLenum *out_glformat,
+ GLenum *out_gltype)
+{
+ return _cogl_driver_pixel_format_to_gl_with_target (context,
+ format, format,
+ out_glintformat,
+ out_glformat,
+ out_gltype);
+}
+
static CoglBool
_cogl_get_gl_version (CoglContext *ctx,
int *major_out,
@@ -677,6 +693,7 @@ _cogl_driver_gl =
{
_cogl_driver_pixel_format_from_gl_internal,
_cogl_driver_pixel_format_to_gl,
+ _cogl_driver_pixel_format_to_gl_with_target,
_cogl_driver_update_features,
_cogl_offscreen_gl_allocate,
_cogl_offscreen_gl_free,
diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
index bf63fcc16..521f6ef3d 100644
--- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -67,11 +67,12 @@ _cogl_driver_pixel_format_from_gl_internal (CoglContext *context,
}
static CoglPixelFormat
-_cogl_driver_pixel_format_to_gl (CoglContext *context,
- CoglPixelFormat format,
- GLenum *out_glintformat,
- GLenum *out_glformat,
- GLenum *out_gltype)
+_cogl_driver_pixel_format_to_gl_with_target (CoglContext *context,
+ CoglPixelFormat format,
+ CoglPixelFormat target_format,
+ GLenum *out_glintformat,
+ GLenum *out_glformat,
+ GLenum *out_gltype)
{
CoglPixelFormat required_format;
GLenum glintformat;
@@ -219,6 +220,20 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
return required_format;
}
+static CoglPixelFormat
+_cogl_driver_pixel_format_to_gl (CoglContext *context,
+ CoglPixelFormat format,
+ GLenum *out_glintformat,
+ GLenum *out_glformat,
+ GLenum *out_gltype)
+{
+ return _cogl_driver_pixel_format_to_gl_with_target (context,
+ format, format,
+ out_glintformat,
+ out_glformat,
+ out_gltype);
+}
+
static CoglBool
_cogl_get_gl_version (CoglContext *ctx,
int *major_out,
@@ -457,6 +472,7 @@ _cogl_driver_gles =
{
_cogl_driver_pixel_format_from_gl_internal,
_cogl_driver_pixel_format_to_gl,
+ _cogl_driver_pixel_format_to_gl_with_target,
_cogl_driver_update_features,
_cogl_offscreen_gl_allocate,
_cogl_offscreen_gl_free,
diff --git a/cogl/cogl/driver/nop/cogl-driver-nop.c b/cogl/cogl/driver/nop/cogl-driver-nop.c
index d9b1d0f1f..6e04e7164 100644
--- a/cogl/cogl/driver/nop/cogl-driver-nop.c
+++ b/cogl/cogl/driver/nop/cogl-driver-nop.c
@@ -61,6 +61,7 @@ _cogl_driver_nop =
{
NULL, /* pixel_format_from_gl_internal */
NULL, /* pixel_format_to_gl */
+ NULL, /* pixel_format_to_gl_with_target */
_cogl_driver_update_features,
_cogl_offscreen_nop_allocate,
_cogl_offscreen_nop_free,
--
2.12.0

View File

@ -0,0 +1,44 @@
From 35388fb33cb39a311b4ccc504ac15a6c5d226dab Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Fri, 3 Mar 2017 17:13:10 +0100
Subject: [PATCH 2/2] cogl: Use pixel_format_to_gl_with_target on bitmap
uploading paths
We already do have a texture with an internal format in these paths,
so we should check the required format according to it.
This fixes CoglAtlasTexture (and CoglPangoRenderer indirectly), as
it forces a RGBA format on its texture, but pixel_format_to_gl()
anyway assumed swizzling is performed on the texture, while it is
not the case.
https://bugzilla.gnome.org/show_bug.cgi?id=779234
---
cogl/cogl/driver/gl/cogl-texture-2d-gl.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c
index 375edcb14..d1eff4507 100644
--- a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c
+++ b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c
@@ -772,11 +772,12 @@ _cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d,
upload_format = cogl_bitmap_get_format (upload_bmp);
- ctx->driver_vtable->pixel_format_to_gl (ctx,
- upload_format,
- NULL, /* internal format */
- &gl_format,
- &gl_type);
+ ctx->driver_vtable->pixel_format_to_gl_with_target (ctx,
+ upload_format,
+ _cogl_texture_get_format (tex),
+ NULL, /* internal gl format */
+ &gl_format,
+ &gl_type);
/* If this touches the first pixel then we'll update our copy */
if (dst_x == 0 && dst_y == 0 &&
--
2.12.0

View File

@ -5,7 +5,7 @@
Name: mutter
Version: 3.23.91
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Window and compositing manager based on Clutter
License: GPLv2+
@ -14,9 +14,13 @@ URL: http://www.gnome.org
Source0: http://download.gnome.org/sources/%{name}/3.23/%{name}-%{version}.tar.xz
Patch0: startup-notification.patch
# Backport of fix for color issue in 3.23.91:
# Backport of fixes for color issues in 3.23.91:
# https://git.gnome.org/browse/mutter/commit/?id=95e9fa10ef20a23912186c0cc701ab8f5a97f1a0
Patch1: 0001-cogl-Read-pixels-in-the-correct-32bit-format-as-per-.patch
# https://git.gnome.org/browse/mutter/commit/?id=aa5738c777883f270ae9cb3b2988d194792fed75
Patch2: 0001-cogl-Add-pixel_format_to_gl_with_target-driver-vfunc.patch
# https://git.gnome.org/browse/mutter/commit/?id=35388fb33cb39a311b4ccc504ac15a6c5d226dab
Patch3: 0002-cogl-Use-pixel_format_to_gl_with_target-on-bitmap-up.patch
BuildRequires: chrpath
BuildRequires: pango-devel
@ -112,6 +116,8 @@ the functionality of the installed %{name} package.
%setup -q
#patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
autoreconf -f -i
@ -184,6 +190,9 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
%{_datadir}/mutter/tests
%changelog
* Tue Mar 07 2017 Adam Williamson <awilliam@redhat.com> - 3.23.91-3
- Backport more color fixes, should really fix BGO #779234, RHBZ #1428559
* Thu Mar 02 2017 Adam Williamson <awilliam@redhat.com> - 3.23.91-2
- Backport fix for a color issue in 3.23.91 (BGO #779234, RHBZ #1428559)