mirrored from https://skia.googlesource.com/skia
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rust png] Integrate
cICP
support into SkPngRustCodec
.
This CL propagates the data from the `cICP` chunk into `SkEncodedInfo::ICCProfile`. Dependencies: * This CL unblocks enabling the `PNGTests.cicp` test in the Chromium CL at https://crrev.com/c/6013356. * This CL depends on the new `SkColorSpace::MakeCICP` API that was recently added in https://crrev.com/c/5999738. This CL patches the `png` crate in a way that corresponds to the following upstream PRs (rolling this CL into Chromium depends on https://crrev.com/c/5999738 which included the same patches): * image-rs/image-png#526 - baseline to make subsequent patches easier to apply * image-rs/image-png#528 - `mDCv` and `cLLI` * image-rs/image-png#529 - `cICP` Bug: chromium:376758571 Change-Id: I1e550b1eba4d629ff4337d85daa5656ac03f3a5a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/917216 Commit-Queue: Łukasz Anforowicz <[email protected]> Reviewed-by: Daniel Dilan <[email protected]>
- Loading branch information
1 parent
b33556c
commit 608f252
Showing
9 changed files
with
573 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
experimental/rust_png/patches/0201-Add-EXIF-and-ICC-encoding-and-fix-chunk-order.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
From 6bbdb506da254033aaa60975851e5fae2a7b4c42 Mon Sep 17 00:00:00 2001 | ||
From: Jonathan Behrens <[email protected]> | ||
Date: Sun, 20 Oct 2024 12:03:53 -0700 | ||
Subject: [PATCH] Add EXIF and ICC encoding and fix chunk order | ||
|
||
--- | ||
src/chunk.rs | 2 ++ | ||
src/common.rs | 30 ++++++++++++++++++++++-------- | ||
2 files changed, 24 insertions(+), 8 deletions(-) | ||
|
||
diff --git a/third_party/rust/chromium_crates_io/vendor/png-0.17.14/src/chunk.rs b/third_party/rust/chromium_crates_io/vendor/png-0.17.14/src/chunk.rs | ||
index 39578a4..3908313 100644 | ||
--- a/third_party/rust/chromium_crates_io/vendor/png-0.17.14/src/chunk.rs | ||
+++ b/third_party/rust/chromium_crates_io/vendor/png-0.17.14/src/chunk.rs | ||
@@ -35,6 +35,8 @@ pub const gAMA: ChunkType = ChunkType(*b"gAMA"); | ||
pub const sRGB: ChunkType = ChunkType(*b"sRGB"); | ||
/// ICC profile chunk | ||
pub const iCCP: ChunkType = ChunkType(*b"iCCP"); | ||
+/// EXIF metadata chunk | ||
+pub const eXIf: ChunkType = ChunkType(*b"eXIf"); | ||
/// Latin-1 uncompressed textual data | ||
pub const tEXt: ChunkType = ChunkType(*b"tEXt"); | ||
/// Latin-1 compressed textual data | ||
diff --git a/third_party/rust/chromium_crates_io/vendor/png-0.17.14/src/common.rs b/third_party/rust/chromium_crates_io/vendor/png-0.17.14/src/common.rs | ||
index a3b6c27..259a2b1 100644 | ||
--- a/third_party/rust/chromium_crates_io/vendor/png-0.17.14/src/common.rs | ||
+++ b/third_party/rust/chromium_crates_io/vendor/png-0.17.14/src/common.rs | ||
@@ -507,6 +507,8 @@ pub struct Info<'a> { | ||
pub srgb: Option<SrgbRenderingIntent>, | ||
/// The ICC profile for the image. | ||
pub icc_profile: Option<Cow<'a, [u8]>>, | ||
+ /// The EXIF metadata for the image. | ||
+ pub exif_metadata: Option<Cow<'a, [u8]>>, | ||
/// tEXt field | ||
pub uncompressed_latin1_text: Vec<TEXtChunk>, | ||
/// zTXt field | ||
@@ -537,6 +539,7 @@ impl Default for Info<'_> { | ||
source_chromaticities: None, | ||
srgb: None, | ||
icc_profile: None, | ||
+ exif_metadata: None, | ||
uncompressed_latin1_text: Vec::new(), | ||
compressed_latin1_text: Vec::new(), | ||
utf8_text: Vec::new(), | ||
@@ -631,6 +634,7 @@ impl Info<'_> { | ||
data[9] = self.color_type as u8; | ||
data[12] = self.interlaced as u8; | ||
encoder::write_chunk(&mut w, chunk::IHDR, &data)?; | ||
+ | ||
// Encode the pHYs chunk | ||
if let Some(pd) = self.pixel_dims { | ||
let mut phys_data = [0; 9]; | ||
@@ -643,14 +647,6 @@ impl Info<'_> { | ||
encoder::write_chunk(&mut w, chunk::pHYs, &phys_data)?; | ||
} | ||
|
||
- if let Some(p) = &self.palette { | ||
- encoder::write_chunk(&mut w, chunk::PLTE, p)?; | ||
- }; | ||
- | ||
- if let Some(t) = &self.trns { | ||
- encoder::write_chunk(&mut w, chunk::tRNS, t)?; | ||
- } | ||
- | ||
// If specified, the sRGB information overrides the source gamma and chromaticities. | ||
if let Some(srgb) = &self.srgb { | ||
let gamma = crate::srgb::substitute_gamma(); | ||
@@ -665,11 +661,29 @@ impl Info<'_> { | ||
if let Some(chrms) = self.source_chromaticities { | ||
chrms.encode(&mut w)?; | ||
} | ||
+ if let Some(iccp) = &self.icc_profile { | ||
+ encoder::write_chunk(&mut w, chunk::iCCP, iccp)?; | ||
+ } | ||
} | ||
+ | ||
+ if let Some(exif) = &self.exif_metadata { | ||
+ encoder::write_chunk(&mut w, chunk::eXIf, exif)?; | ||
+ } | ||
+ | ||
if let Some(actl) = self.animation_control { | ||
actl.encode(&mut w)?; | ||
} | ||
|
||
+ // The position of the PLTE chunk is important, it must come before the tRNS chunk and after | ||
+ // many of the other metadata chunks. | ||
+ if let Some(p) = &self.palette { | ||
+ encoder::write_chunk(&mut w, chunk::PLTE, p)?; | ||
+ }; | ||
+ | ||
+ if let Some(t) = &self.trns { | ||
+ encoder::write_chunk(&mut w, chunk::tRNS, t)?; | ||
+ } | ||
+ | ||
for text_chunk in &self.uncompressed_latin1_text { | ||
text_chunk.encode(&mut w)?; | ||
} | ||
-- | ||
2.47.0.199.ga7371fff76-goog | ||
|
Oops, something went wrong.