diff options
Diffstat (limited to 'meta/recipes-gnome/librsvg/librsvg/0001-GdkPixbufRGBA-ToGdkPixbufRGBA-start-naming-types-and.patch')
-rw-r--r-- | meta/recipes-gnome/librsvg/librsvg/0001-GdkPixbufRGBA-ToGdkPixbufRGBA-start-naming-types-and.patch | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/meta/recipes-gnome/librsvg/librsvg/0001-GdkPixbufRGBA-ToGdkPixbufRGBA-start-naming-types-and.patch b/meta/recipes-gnome/librsvg/librsvg/0001-GdkPixbufRGBA-ToGdkPixbufRGBA-start-naming-types-and.patch deleted file mode 100644 index 6935403138..0000000000 --- a/meta/recipes-gnome/librsvg/librsvg/0001-GdkPixbufRGBA-ToGdkPixbufRGBA-start-naming-types-and.patch +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | From c175ac8344aa465ffc2c2f3a9d02a7889f597f7f Mon Sep 17 00:00:00 2001 | ||
2 | From: Federico Mena Quintero <federico@gnome.org> | ||
3 | Date: Tue, 21 Sep 2021 12:05:27 -0500 | ||
4 | Subject: [PATCH] GdkPixbufRGBA, ToGdkPixbufRGBA - start naming types and | ||
5 | conversion traits for pixel formats | ||
6 | |||
7 | The code assumes that struct Pixel is always the layout that GdkPixbuf | ||
8 | uses. This is true right now, but is a hidden assumption. Let's | ||
9 | start giving better names to pixel formats. | ||
10 | |||
11 | Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/592> | ||
12 | Upstream-Status: Backport | ||
13 | Signed-off-by: Alexander Kanavin <alex@linutronix.de> | ||
14 | --- | ||
15 | src/surface_utils/mod.rs | 23 +++++++++++++++++++++++ | ||
16 | src/surface_utils/shared_surface.rs | 4 ++-- | ||
17 | 2 files changed, 25 insertions(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/src/surface_utils/mod.rs b/src/surface_utils/mod.rs | ||
20 | index 53bbd00bb..93d3b4f79 100644 | ||
21 | --- a/src/surface_utils/mod.rs | ||
22 | +++ b/src/surface_utils/mod.rs | ||
23 | @@ -22,6 +22,9 @@ use rgb::alt::ARGB8; | ||
24 | #[allow(clippy::upper_case_acronyms)] | ||
25 | pub type CairoARGB = ARGB8; | ||
26 | |||
27 | +/// GdkPixbuf's endian-independent RGBA8 pixel layout. | ||
28 | +pub type GdkPixbufRGBA = rgb::RGBA8; | ||
29 | + | ||
30 | /// Analogous to `rgb::FromSlice`, to convert from `[T]` to `[CairoARGB]` | ||
31 | #[allow(clippy::upper_case_acronyms)] | ||
32 | pub trait AsCairoARGB<T: Copy> { | ||
33 | @@ -57,6 +60,26 @@ pub enum EdgeMode { | ||
34 | None, | ||
35 | } | ||
36 | |||
37 | +/// Trait to convert pixels in various formats to RGBA, for GdkPixbuf. | ||
38 | +/// | ||
39 | +/// GdkPixbuf unconditionally uses RGBA ordering regardless of endianness, | ||
40 | +/// but we need to convert to it from Cairo's endian-dependent 0xaarrggbb. | ||
41 | +pub trait ToGdkPixbufRGBA { | ||
42 | + fn to_pixbuf_rgba(&self) -> GdkPixbufRGBA; | ||
43 | +} | ||
44 | + | ||
45 | +impl ToGdkPixbufRGBA for Pixel { | ||
46 | + #[inline] | ||
47 | + fn to_pixbuf_rgba(&self) -> GdkPixbufRGBA { | ||
48 | + GdkPixbufRGBA { | ||
49 | + r: self.r, | ||
50 | + g: self.g, | ||
51 | + b: self.b, | ||
52 | + a: self.a, | ||
53 | + } | ||
54 | + } | ||
55 | +} | ||
56 | + | ||
57 | /// Extension methods for `cairo::ImageSurfaceData`. | ||
58 | pub trait ImageSurfaceDataExt: DerefMut<Target = [u8]> { | ||
59 | /// Sets the pixel at the given coordinates. Assumes the `ARgb32` format. | ||
60 | diff --git a/src/surface_utils/shared_surface.rs b/src/surface_utils/shared_surface.rs | ||
61 | index 9d3289230..476a6f776 100644 | ||
62 | --- a/src/surface_utils/shared_surface.rs | ||
63 | +++ b/src/surface_utils/shared_surface.rs | ||
64 | @@ -15,7 +15,7 @@ use crate::util::clamp; | ||
65 | |||
66 | use super::{ | ||
67 | iterators::{PixelRectangle, Pixels}, | ||
68 | - AsCairoARGB, CairoARGB, EdgeMode, ImageSurfaceDataExt, Pixel, PixelOps, | ||
69 | + AsCairoARGB, CairoARGB, EdgeMode, ImageSurfaceDataExt, Pixel, PixelOps, ToGdkPixbufRGBA, | ||
70 | }; | ||
71 | |||
72 | /// Types of pixel data in a `ImageSurface`. | ||
73 | @@ -342,7 +342,7 @@ impl ImageSurface<Shared> { | ||
74 | .map(|row| row.as_rgba_mut()) | ||
75 | .zip(self.rows()) | ||
76 | .flat_map(|(dest_row, src_row)| src_row.iter().zip(dest_row.iter_mut())) | ||
77 | - .for_each(|(src, dest)| *dest = Pixel::from(*src).unpremultiply()); | ||
78 | + .for_each(|(src, dest)| *dest = Pixel::from(*src).unpremultiply().to_pixbuf_rgba()); | ||
79 | |||
80 | Some(pixbuf) | ||
81 | } | ||