From 3d9bc75c895e8f3db9c7191c70e441c14e066664 Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Tue, 3 Mar 2020 15:56:31 +0100 Subject: [PATCH] Backport fixes for 10-bit color (#1800865) --- 10.patch | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++ clutter.spec | 11 +++- 2 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 10.patch diff --git a/10.patch b/10.patch new file mode 100644 index 0000000..7a51552 --- /dev/null +++ b/10.patch @@ -0,0 +1,183 @@ +From 9b6d501726e4327db13f6516d229ec43e3cd44e0 Mon Sep 17 00:00:00 2001 +From: Floris Van den Abeele +Date: Sat, 7 Sep 2019 21:52:36 +0200 +Subject: [PATCH 1/2] Handle 8 and 10 bits colour depth in picking code (#11) + +--- + clutter/clutter-main.c | 52 ++++++++++++++++++++++++++---------------- + 1 file changed, 32 insertions(+), 20 deletions(-) + +diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c +index 3e4335ec4..bae74aaf4 100644 +--- a/clutter/clutter-main.c ++++ b/clutter/clutter-main.c +@@ -587,6 +587,9 @@ _clutter_id_to_color (guint id_, + { + ClutterMainContext *ctx; + gint red, green, blue; ++ /* keep track of the bit depth of the RGB channels of the framebuffers (i.e. ++ * either 8 or 10) */ ++ gint bpc; + + ctx = _clutter_context_get_default (); + +@@ -610,13 +613,16 @@ _clutter_id_to_color (guint id_, + } + } + ++ bpc = ctx->fb_r_mask; ++ g_assert (bpc == 8 || bpc == 10); ++ + /* compute the numbers we'll store in the components */ + red = (id_ >> (ctx->fb_g_mask_used+ctx->fb_b_mask_used)) +- & (0xff >> (8-ctx->fb_r_mask_used)); ++ & (0xff >> (bpc-ctx->fb_r_mask_used)); + green = (id_ >> ctx->fb_b_mask_used) +- & (0xff >> (8-ctx->fb_g_mask_used)); ++ & (0xff >> (bpc-ctx->fb_g_mask_used)); + blue = (id_) +- & (0xff >> (8-ctx->fb_b_mask_used)); ++ & (0xff >> (bpc-ctx->fb_b_mask_used)); + + /* shift left bits a bit and add one, this circumvents + * at least some potential rounding errors in GL/GLES +@@ -629,10 +635,10 @@ _clutter_id_to_color (guint id_, + if (ctx->fb_b_mask_used != ctx->fb_b_mask) + blue = blue * 2; + +- /* shift up to be full 8bit values */ +- red = (red << (8 - ctx->fb_r_mask)) | (0x7f >> (ctx->fb_r_mask_used)); +- green = (green << (8 - ctx->fb_g_mask)) | (0x7f >> (ctx->fb_g_mask_used)); +- blue = (blue << (8 - ctx->fb_b_mask)) | (0x7f >> (ctx->fb_b_mask_used)); ++ /* shift up to occupy the full bit depth of the channel */ ++ red = (red << (bpc - ctx->fb_r_mask)) | (0x7f >> (ctx->fb_r_mask_used)); ++ green = (green << (bpc - ctx->fb_g_mask)) | (0x7f >> (ctx->fb_g_mask_used)); ++ blue = (blue << (bpc - ctx->fb_b_mask)) | (0x7f >> (ctx->fb_b_mask_used)); + + col->red = red; + col->green = green; +@@ -646,9 +652,9 @@ _clutter_id_to_color (guint id_, + */ + if (G_UNLIKELY (clutter_pick_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS)) + { +- col->red = (col->red << 4) | (col->red >> 4); +- col->green = (col->green << 4) | (col->green >> 4); +- col->blue = (col->blue << 4) | (col->blue >> 4); ++ col->red = (col->red << bpc/2) | (col->red >> bpc/2); ++ col->green = (col->green << bpc/2) | (col->green >> bpc/2); ++ col->blue = (col->blue << bpc/2) | (col->blue >> bpc/2); + } + } + +@@ -658,11 +664,17 @@ _clutter_pixel_to_id (guchar pixel[4]) + ClutterMainContext *ctx; + gint red, green, blue; + guint retval; ++ /* keep track of the bit depth of the RGB channels of the framebuffers (i.e. ++ * either 8 or 10) */ ++ gint bpc; + + ctx = _clutter_context_get_default (); + ++ bpc = ctx->fb_r_mask; ++ g_assert (bpc == 8 || bpc == 10); ++ + /* reduce the pixel components to the number of bits actually used of the +- * 8bits. ++ * bit depth of the channel (i.e. 8 or 10 bits) + */ + if (G_UNLIKELY (clutter_pick_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS)) + { +@@ -673,18 +685,18 @@ _clutter_pixel_to_id (guchar pixel[4]) + * identifiers (otherwise pick buffers dumped to an image will pretty + * much just look black.) Here we reverse that rotation. + */ +- tmp = ((pixel[0] << 4) | (pixel[0] >> 4)); +- red = tmp >> (8 - ctx->fb_r_mask); +- tmp = ((pixel[1] << 4) | (pixel[1] >> 4)); +- green = tmp >> (8 - ctx->fb_g_mask); +- tmp = ((pixel[2] << 4) | (pixel[2] >> 4)); +- blue = tmp >> (8 - ctx->fb_b_mask); ++ tmp = ((pixel[0] << bpc/2) | (pixel[0] >> bpc/2)); ++ red = tmp >> (bpc - ctx->fb_r_mask); ++ tmp = ((pixel[1] << bpc/2) | (pixel[1] >> bpc/2)); ++ green = tmp >> (bpc - ctx->fb_g_mask); ++ tmp = ((pixel[2] << bpc/2) | (pixel[2] >> bpc/2)); ++ blue = tmp >> (bpc - ctx->fb_b_mask); + } + else + { +- red = pixel[0] >> (8 - ctx->fb_r_mask); +- green = pixel[1] >> (8 - ctx->fb_g_mask); +- blue = pixel[2] >> (8 - ctx->fb_b_mask); ++ red = pixel[0] >> (bpc - ctx->fb_r_mask); ++ green = pixel[1] >> (bpc - ctx->fb_g_mask); ++ blue = pixel[2] >> (bpc - ctx->fb_b_mask); + } + + /* divide potentially by two if 'fuzzy' */ +-- +2.24.1 + + +From 6134c915fd66fdb4c6b89b0547e68ac8edc62a08 Mon Sep 17 00:00:00 2001 +From: Floris Van den Abeele +Date: Mon, 7 Oct 2019 22:55:48 +0200 +Subject: [PATCH 2/2] Fix coding style issues in MR !10 + +--- + clutter/clutter-main.c | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c +index bae74aaf4..89b2f9e6b 100644 +--- a/clutter/clutter-main.c ++++ b/clutter/clutter-main.c +@@ -617,12 +617,12 @@ _clutter_id_to_color (guint id_, + g_assert (bpc == 8 || bpc == 10); + + /* compute the numbers we'll store in the components */ +- red = (id_ >> (ctx->fb_g_mask_used+ctx->fb_b_mask_used)) +- & (0xff >> (bpc-ctx->fb_r_mask_used)); ++ red = (id_ >> (ctx->fb_g_mask_used + ctx->fb_b_mask_used)) ++ & (0xff >> (bpc - ctx->fb_r_mask_used)); + green = (id_ >> ctx->fb_b_mask_used) +- & (0xff >> (bpc-ctx->fb_g_mask_used)); ++ & (0xff >> (bpc - ctx->fb_g_mask_used)); + blue = (id_) +- & (0xff >> (bpc-ctx->fb_b_mask_used)); ++ & (0xff >> (bpc - ctx->fb_b_mask_used)); + + /* shift left bits a bit and add one, this circumvents + * at least some potential rounding errors in GL/GLES +@@ -652,9 +652,9 @@ _clutter_id_to_color (guint id_, + */ + if (G_UNLIKELY (clutter_pick_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS)) + { +- col->red = (col->red << bpc/2) | (col->red >> bpc/2); +- col->green = (col->green << bpc/2) | (col->green >> bpc/2); +- col->blue = (col->blue << bpc/2) | (col->blue >> bpc/2); ++ col->red = (col->red << bpc / 2) | (col->red >> bpc / 2); ++ col->green = (col->green << bpc / 2) | (col->green >> bpc / 2); ++ col->blue = (col->blue << bpc / 2) | (col->blue >> bpc / 2); + } + } + +@@ -685,11 +685,11 @@ _clutter_pixel_to_id (guchar pixel[4]) + * identifiers (otherwise pick buffers dumped to an image will pretty + * much just look black.) Here we reverse that rotation. + */ +- tmp = ((pixel[0] << bpc/2) | (pixel[0] >> bpc/2)); ++ tmp = ((pixel[0] << bpc / 2) | (pixel[0] >> bpc / 2)); + red = tmp >> (bpc - ctx->fb_r_mask); +- tmp = ((pixel[1] << bpc/2) | (pixel[1] >> bpc/2)); ++ tmp = ((pixel[1] << bpc / 2) | (pixel[1] >> bpc / 2)); + green = tmp >> (bpc - ctx->fb_g_mask); +- tmp = ((pixel[2] << bpc/2) | (pixel[2] >> bpc/2)); ++ tmp = ((pixel[2] << bpc / 2) | (pixel[2] >> bpc / 2)); + blue = tmp >> (bpc - ctx->fb_b_mask); + } + else +-- +2.24.1 + diff --git a/clutter.spec b/clutter.spec index 0e29727..6d5bd61 100644 --- a/clutter.spec +++ b/clutter.spec @@ -10,13 +10,17 @@ Name: clutter Version: 1.26.2 -Release: 10%{?dist} +Release: 11%{?dist} Summary: Open Source software library for creating rich graphical user interfaces License: LGPLv2+ URL: http://www.clutter-project.org/ Source0: https://download.gnome.org/sources/%{name}/1.26/%{name}-%{version}.tar.xz +# Backport fixes for 10-bit color +# https://bugzilla.redhat.com/show_bug.cgi?id=1800865 +Patch0: 10.patch + BuildRequires: gettext BuildRequires: pkgconfig(atk) BuildRequires: pkgconfig(cairo-gobject) >= %{cairo_version} @@ -84,7 +88,7 @@ the functionality of the installed clutter package. %endif %prep -%setup -q +%autosetup -p1 %build %configure \ @@ -131,6 +135,9 @@ find %{buildroot} -name '*.la' -delete %endif %changelog +* Tue Mar 03 2020 Kalev Lember - 1.26.2-11 +- Backport fixes for 10-bit color (#1800865) + * Tue Jan 28 2020 Fedora Release Engineering - 1.26.2-10 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild