diff options
author | Alexander Kanavin <alex.kanavin@gmail.com> | 2021-10-10 21:10:00 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-14 11:48:45 +0100 |
commit | c7af21fd8b490a0099ce530188ac99b23612a7c5 (patch) | |
tree | e314d1239ca996950a853d16ffdf44ba78a0e0c3 /meta/recipes-gnome | |
parent | a83dc97c7b669b5e37c4973b67a5906569894b7a (diff) | |
download | poky-c7af21fd8b490a0099ce530188ac99b23612a7c5.tar.gz |
librsvg: add backports to fix big endian targets (e.g. mips)
(From OE-Core rev: 2fd0ad104b29473c8a1b0b5c173ab54c48994271)
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-gnome')
5 files changed, 318 insertions, 3 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 new file mode 100644 index 0000000000..6935403138 --- /dev/null +++ b/meta/recipes-gnome/librsvg/librsvg/0001-GdkPixbufRGBA-ToGdkPixbufRGBA-start-naming-types-and.patch | |||
@@ -0,0 +1,81 @@ | |||
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 | } | ||
diff --git a/meta/recipes-gnome/librsvg/librsvg/0002-New-ToPixel-trait.patch b/meta/recipes-gnome/librsvg/librsvg/0002-New-ToPixel-trait.patch new file mode 100644 index 0000000000..c71c93e1a1 --- /dev/null +++ b/meta/recipes-gnome/librsvg/librsvg/0002-New-ToPixel-trait.patch | |||
@@ -0,0 +1,100 @@ | |||
1 | From 47478d5a8a4b7a05b44f024404137c4c68b62b7e Mon Sep 17 00:00:00 2001 | ||
2 | From: Federico Mena Quintero <federico@gnome.org> | ||
3 | Date: Tue, 21 Sep 2021 12:22:15 -0500 | ||
4 | Subject: [PATCH] New ToPixel trait | ||
5 | |||
6 | Use it where we convert GdkPixbuf pixels to our own Pixel for premultiplication. | ||
7 | |||
8 | Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/592> | ||
9 | Upstream-Status: Backport | ||
10 | Signed-off-by: Alexander Kanavin <alex@linutronix.de> | ||
11 | --- | ||
12 | src/surface_utils/mod.rs | 32 +++++++++++++++++++++++++++++ | ||
13 | src/surface_utils/shared_surface.rs | 5 +++-- | ||
14 | 2 files changed, 35 insertions(+), 2 deletions(-) | ||
15 | |||
16 | diff --git a/src/surface_utils/mod.rs b/src/surface_utils/mod.rs | ||
17 | index 93d3b4f79..58953e6a0 100644 | ||
18 | --- a/src/surface_utils/mod.rs | ||
19 | +++ b/src/surface_utils/mod.rs | ||
20 | @@ -25,6 +25,9 @@ pub type CairoARGB = ARGB8; | ||
21 | /// GdkPixbuf's endian-independent RGBA8 pixel layout. | ||
22 | pub type GdkPixbufRGBA = rgb::RGBA8; | ||
23 | |||
24 | +/// GdkPixbuf's packed RGB pixel layout. | ||
25 | +pub type GdkPixbufRGB = rgb::RGB8; | ||
26 | + | ||
27 | /// Analogous to `rgb::FromSlice`, to convert from `[T]` to `[CairoARGB]` | ||
28 | #[allow(clippy::upper_case_acronyms)] | ||
29 | pub trait AsCairoARGB<T: Copy> { | ||
30 | @@ -68,6 +71,11 @@ pub trait ToGdkPixbufRGBA { | ||
31 | fn to_pixbuf_rgba(&self) -> GdkPixbufRGBA; | ||
32 | } | ||
33 | |||
34 | +/// Trait to convert pixels in various formats to our own Pixel layout. | ||
35 | +pub trait ToPixel { | ||
36 | + fn to_pixel(&self) -> Pixel; | ||
37 | +} | ||
38 | + | ||
39 | impl ToGdkPixbufRGBA for Pixel { | ||
40 | #[inline] | ||
41 | fn to_pixbuf_rgba(&self) -> GdkPixbufRGBA { | ||
42 | @@ -80,6 +88,30 @@ impl ToGdkPixbufRGBA for Pixel { | ||
43 | } | ||
44 | } | ||
45 | |||
46 | +impl ToPixel for GdkPixbufRGBA { | ||
47 | + #[inline] | ||
48 | + fn to_pixel(&self) -> Pixel { | ||
49 | + Pixel { | ||
50 | + r: self.r, | ||
51 | + g: self.g, | ||
52 | + b: self.b, | ||
53 | + a: self.a, | ||
54 | + } | ||
55 | + } | ||
56 | +} | ||
57 | + | ||
58 | +impl ToPixel for GdkPixbufRGB { | ||
59 | + #[inline] | ||
60 | + fn to_pixel(&self) -> Pixel { | ||
61 | + Pixel { | ||
62 | + r: self.r, | ||
63 | + g: self.g, | ||
64 | + b: self.b, | ||
65 | + a: 255, | ||
66 | + } | ||
67 | + } | ||
68 | +} | ||
69 | + | ||
70 | /// Extension methods for `cairo::ImageSurfaceData`. | ||
71 | pub trait ImageSurfaceDataExt: DerefMut<Target = [u8]> { | ||
72 | /// Sets the pixel at the given coordinates. Assumes the `ARgb32` format. | ||
73 | diff --git a/src/surface_utils/shared_surface.rs b/src/surface_utils/shared_surface.rs | ||
74 | index 476a6f776..9fa9a2e15 100644 | ||
75 | --- a/src/surface_utils/shared_surface.rs | ||
76 | +++ b/src/surface_utils/shared_surface.rs | ||
77 | @@ -16,6 +16,7 @@ use crate::util::clamp; | ||
78 | use super::{ | ||
79 | iterators::{PixelRectangle, Pixels}, | ||
80 | AsCairoARGB, CairoARGB, EdgeMode, ImageSurfaceDataExt, Pixel, PixelOps, ToGdkPixbufRGBA, | ||
81 | + ToPixel, | ||
82 | }; | ||
83 | |||
84 | /// Types of pixel data in a `ImageSurface`. | ||
85 | @@ -304,13 +305,13 @@ impl ImageSurface<Shared> { | ||
86 | .map(|row| row.as_rgba()) | ||
87 | .zip(surf.rows_mut()) | ||
88 | .flat_map(|(src_row, dest_row)| src_row.iter().zip(dest_row.iter_mut())) | ||
89 | - .for_each(|(src, dest)| *dest = src.premultiply().into()); | ||
90 | + .for_each(|(src, dest)| *dest = src.to_pixel().premultiply().into()); | ||
91 | } else { | ||
92 | pixbuf_rows | ||
93 | .map(|row| row.as_rgb()) | ||
94 | .zip(surf.rows_mut()) | ||
95 | .flat_map(|(src_row, dest_row)| src_row.iter().zip(dest_row.iter_mut())) | ||
96 | - .for_each(|(src, dest)| *dest = src.alpha(0xff).into()); | ||
97 | + .for_each(|(src, dest)| *dest = src.to_pixel().into()); | ||
98 | } | ||
99 | |||
100 | if let (Some(content_type), Some(bytes)) = (content_type, mime_data) { | ||
diff --git a/meta/recipes-gnome/librsvg/librsvg/0003-New-ToCairoARGB-trait.patch b/meta/recipes-gnome/librsvg/librsvg/0003-New-ToCairoARGB-trait.patch new file mode 100644 index 0000000000..8dd45ef0a2 --- /dev/null +++ b/meta/recipes-gnome/librsvg/librsvg/0003-New-ToCairoARGB-trait.patch | |||
@@ -0,0 +1,81 @@ | |||
1 | From f5768df65cf6277e8ab687a84fdc5d9addaa373d Mon Sep 17 00:00:00 2001 | ||
2 | From: Federico Mena Quintero <federico@gnome.org> | ||
3 | Date: Tue, 21 Sep 2021 12:49:53 -0500 | ||
4 | Subject: [PATCH] New ToCairoARGB trait | ||
5 | |||
6 | Use it in the pixbuf-to-cairo-surface function. | ||
7 | |||
8 | Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/592> | ||
9 | Upstream-Status: Backport | ||
10 | Signed-off-by: Alexander Kanavin <alex@linutronix.de> | ||
11 | --- | ||
12 | src/surface_utils/mod.rs | 17 +++++++++++++++++ | ||
13 | src/surface_utils/shared_surface.rs | 8 ++++---- | ||
14 | 2 files changed, 21 insertions(+), 4 deletions(-) | ||
15 | |||
16 | diff --git a/src/surface_utils/mod.rs b/src/surface_utils/mod.rs | ||
17 | index 58953e6a0..3f915cd01 100644 | ||
18 | --- a/src/surface_utils/mod.rs | ||
19 | +++ b/src/surface_utils/mod.rs | ||
20 | @@ -76,6 +76,11 @@ pub trait ToPixel { | ||
21 | fn to_pixel(&self) -> Pixel; | ||
22 | } | ||
23 | |||
24 | +/// Trait to convert pixels in various formats to Cairo's endian-dependent 0xaarrggbb. | ||
25 | +pub trait ToCairoARGB { | ||
26 | + fn to_cairo_argb(&self) -> CairoARGB; | ||
27 | +} | ||
28 | + | ||
29 | impl ToGdkPixbufRGBA for Pixel { | ||
30 | #[inline] | ||
31 | fn to_pixbuf_rgba(&self) -> GdkPixbufRGBA { | ||
32 | @@ -112,6 +117,18 @@ impl ToPixel for GdkPixbufRGB { | ||
33 | } | ||
34 | } | ||
35 | |||
36 | +impl ToCairoARGB for Pixel { | ||
37 | + #[inline] | ||
38 | + fn to_cairo_argb(&self) -> CairoARGB { | ||
39 | + CairoARGB { | ||
40 | + r: self.r, | ||
41 | + g: self.g, | ||
42 | + b: self.b, | ||
43 | + a: self.a, | ||
44 | + } | ||
45 | + } | ||
46 | +} | ||
47 | + | ||
48 | /// Extension methods for `cairo::ImageSurfaceData`. | ||
49 | pub trait ImageSurfaceDataExt: DerefMut<Target = [u8]> { | ||
50 | /// Sets the pixel at the given coordinates. Assumes the `ARgb32` format. | ||
51 | diff --git a/src/surface_utils/shared_surface.rs b/src/surface_utils/shared_surface.rs | ||
52 | index 9fa9a2e15..34dfc992e 100644 | ||
53 | --- a/src/surface_utils/shared_surface.rs | ||
54 | +++ b/src/surface_utils/shared_surface.rs | ||
55 | @@ -15,8 +15,8 @@ use crate::util::clamp; | ||
56 | |||
57 | use super::{ | ||
58 | iterators::{PixelRectangle, Pixels}, | ||
59 | - AsCairoARGB, CairoARGB, EdgeMode, ImageSurfaceDataExt, Pixel, PixelOps, ToGdkPixbufRGBA, | ||
60 | - ToPixel, | ||
61 | + AsCairoARGB, CairoARGB, EdgeMode, ImageSurfaceDataExt, Pixel, PixelOps, ToCairoARGB, | ||
62 | + ToGdkPixbufRGBA, ToPixel, | ||
63 | }; | ||
64 | |||
65 | /// Types of pixel data in a `ImageSurface`. | ||
66 | @@ -305,13 +305,13 @@ impl ImageSurface<Shared> { | ||
67 | .map(|row| row.as_rgba()) | ||
68 | .zip(surf.rows_mut()) | ||
69 | .flat_map(|(src_row, dest_row)| src_row.iter().zip(dest_row.iter_mut())) | ||
70 | - .for_each(|(src, dest)| *dest = src.to_pixel().premultiply().into()); | ||
71 | + .for_each(|(src, dest)| *dest = src.to_pixel().premultiply().to_cairo_argb()); | ||
72 | } else { | ||
73 | pixbuf_rows | ||
74 | .map(|row| row.as_rgb()) | ||
75 | .zip(surf.rows_mut()) | ||
76 | .flat_map(|(src_row, dest_row)| src_row.iter().zip(dest_row.iter_mut())) | ||
77 | - .for_each(|(src, dest)| *dest = src.to_pixel().into()); | ||
78 | + .for_each(|(src, dest)| *dest = src.to_pixel().to_cairo_argb()); | ||
79 | } | ||
80 | |||
81 | if let (Some(content_type), Some(bytes)) = (content_type, mime_data) { | ||
diff --git a/meta/recipes-gnome/librsvg/librsvg/0004-impl-ToPixel-for-CairoARGB.patch b/meta/recipes-gnome/librsvg/librsvg/0004-impl-ToPixel-for-CairoARGB.patch new file mode 100644 index 0000000000..caf81af5d0 --- /dev/null +++ b/meta/recipes-gnome/librsvg/librsvg/0004-impl-ToPixel-for-CairoARGB.patch | |||
@@ -0,0 +1,49 @@ | |||
1 | From c66987d6fa9f9e442eb7dac947f469bcf8c35d48 Mon Sep 17 00:00:00 2001 | ||
2 | From: Federico Mena Quintero <federico@gnome.org> | ||
3 | Date: Tue, 21 Sep 2021 12:54:12 -0500 | ||
4 | Subject: [PATCH] impl ToPixel for CairoARGB | ||
5 | |||
6 | Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/592> | ||
7 | Upstream-Status: Backport | ||
8 | Signed-off-by: Alexander Kanavin <alex@linutronix.de> | ||
9 | --- | ||
10 | src/surface_utils/mod.rs | 12 ++++++++++++ | ||
11 | src/surface_utils/shared_surface.rs | 2 +- | ||
12 | 2 files changed, 13 insertions(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/src/surface_utils/mod.rs b/src/surface_utils/mod.rs | ||
15 | index 3f915cd01..4f751ece4 100644 | ||
16 | --- a/src/surface_utils/mod.rs | ||
17 | +++ b/src/surface_utils/mod.rs | ||
18 | @@ -93,6 +93,18 @@ impl ToGdkPixbufRGBA for Pixel { | ||
19 | } | ||
20 | } | ||
21 | |||
22 | +impl ToPixel for CairoARGB { | ||
23 | + #[inline] | ||
24 | + fn to_pixel(&self) -> Pixel { | ||
25 | + Pixel { | ||
26 | + r: self.r, | ||
27 | + g: self.g, | ||
28 | + b: self.b, | ||
29 | + a: self.a, | ||
30 | + } | ||
31 | + } | ||
32 | +} | ||
33 | + | ||
34 | impl ToPixel for GdkPixbufRGBA { | ||
35 | #[inline] | ||
36 | fn to_pixel(&self) -> Pixel { | ||
37 | diff --git a/src/surface_utils/shared_surface.rs b/src/surface_utils/shared_surface.rs | ||
38 | index 34dfc992e..20cd0f40b 100644 | ||
39 | --- a/src/surface_utils/shared_surface.rs | ||
40 | +++ b/src/surface_utils/shared_surface.rs | ||
41 | @@ -343,7 +343,7 @@ impl ImageSurface<Shared> { | ||
42 | .map(|row| row.as_rgba_mut()) | ||
43 | .zip(self.rows()) | ||
44 | .flat_map(|(dest_row, src_row)| src_row.iter().zip(dest_row.iter_mut())) | ||
45 | - .for_each(|(src, dest)| *dest = Pixel::from(*src).unpremultiply().to_pixbuf_rgba()); | ||
46 | + .for_each(|(src, dest)| *dest = src.to_pixel().unpremultiply().to_pixbuf_rgba()); | ||
47 | |||
48 | Some(pixbuf) | ||
49 | } | ||
diff --git a/meta/recipes-gnome/librsvg/librsvg_2.52.0.bb b/meta/recipes-gnome/librsvg/librsvg_2.52.0.bb index acd0310139..28b8bf2dcf 100644 --- a/meta/recipes-gnome/librsvg/librsvg_2.52.0.bb +++ b/meta/recipes-gnome/librsvg/librsvg_2.52.0.bb | |||
@@ -16,9 +16,13 @@ BBCLASSEXTEND = "native" | |||
16 | 16 | ||
17 | inherit gnomebase gtk-doc pixbufcache upstream-version-is-even gobject-introspection rust | 17 | inherit gnomebase gtk-doc pixbufcache upstream-version-is-even gobject-introspection rust |
18 | 18 | ||
19 | SRC_URI += " file://0001-Makefile.am-pass-rust-target-to-cargo-also-when-not-.patch \ | 19 | SRC_URI += "file://0001-Makefile.am-pass-rust-target-to-cargo-also-when-not-.patch \ |
20 | file://0001-system-deps-src-lib.rs-do-not-probe-into-harcoded-li.patch \ | 20 | file://0001-system-deps-src-lib.rs-do-not-probe-into-harcoded-li.patch \ |
21 | " | 21 | file://0001-GdkPixbufRGBA-ToGdkPixbufRGBA-start-naming-types-and.patch \ |
22 | file://0002-New-ToPixel-trait.patch \ | ||
23 | file://0003-New-ToCairoARGB-trait.patch \ | ||
24 | file://0004-impl-ToPixel-for-CairoARGB.patch \ | ||
25 | " | ||
22 | 26 | ||
23 | SRC_URI[archive.sha256sum] = "bd821fb3e16494b61f5185addd23b726b064f203122b3ab4b3d5d7a44e6bf393" | 27 | SRC_URI[archive.sha256sum] = "bd821fb3e16494b61f5185addd23b726b064f203122b3ab4b3d5d7a44e6bf393" |
24 | 28 | ||