[librsvg: 2/9] Use the rgb crate and define a CairoARGB pixel type
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 2/9] Use the rgb crate and define a CairoARGB pixel type
- Date: Fri, 29 May 2020 21:15:57 +0000 (UTC)
commit 9e7da97ef1b57ef64f2958d5245a8349aa6b16e0
Author: Federico Mena Quintero <federico gnome org>
Date: Thu May 28 17:12:50 2020 -0500
Use the rgb crate and define a CairoARGB pixel type
This is endian-dependent, so we pick from rgb's types at compile-time.
Cargo.lock | 7 +++++++
rsvg_internals/Cargo.toml | 1 +
rsvg_internals/src/surface_utils/mod.rs | 12 ++++++++++++
3 files changed, 20 insertions(+)
---
diff --git a/Cargo.lock b/Cargo.lock
index 3cbba348..9eee9350 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1306,6 +1306,11 @@ dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "rgb"
+version = "0.8.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
[[package]]
name = "rsvg_internals"
version = "0.0.1"
@@ -1339,6 +1344,7 @@ dependencies = [
"rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rctree 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rgb 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tinyvec 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1885,6 +1891,7 @@ dependencies = [
"checksum regex-automata 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" =
"ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4"
"checksum regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)" =
"26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
+"checksum rgb 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)" =
"a85b83fd629b0ce765f45316774fa6aaa95947fd74c8e4bbf3c6d1e349701d95"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum ryu 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" =
"ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1"
"checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" =
"93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
diff --git a/rsvg_internals/Cargo.toml b/rsvg_internals/Cargo.toml
index a7f0daeb..ef2c4eea 100644
--- a/rsvg_internals/Cargo.toml
+++ b/rsvg_internals/Cargo.toml
@@ -36,6 +36,7 @@ pango-sys = "0.9.0"
pangocairo = "0.9.0"
rayon = "1"
rctree = "0.3.3"
+rgb = "0.8.17"
regex = "1"
selectors = "0.22.0"
tinyvec = {version = "0.3.2", features = ["alloc"]}
diff --git a/rsvg_internals/src/surface_utils/mod.rs b/rsvg_internals/src/surface_utils/mod.rs
index 59eb363f..206f82b0 100644
--- a/rsvg_internals/src/surface_utils/mod.rs
+++ b/rsvg_internals/src/surface_utils/mod.rs
@@ -6,6 +6,18 @@ pub mod iterators;
pub mod shared_surface;
pub mod srgb;
+// These two are for Cairo's platform-endian 0xaarrggbb pixels
+
+#[cfg(target_endian = "little")]
+use rgb::alt::BGRA8;
+#[cfg(target_endian = "little")]
+pub type CairoARGB = BGRA8;
+
+#[cfg(target_endian = "big")]
+use rgb::alt::ARGB8;
+#[cfg(target_endian = "big")]
+pub type CairoARGB = ARGB8;
+
/// A pixel consisting of R, G, B and A values.
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
pub struct Pixel {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]