@fmalita, can you PTAL?
/cc @danieldilan as FYI
SK_API sk_sp<SkData> EncodePngAsSkData(GrDirectContext* context,
const SkImage& src,
int zlibCompressionLevel);
The overload that accepts `zlibCompressionLevel` has only 1 caller, so I though that it is useful to have it as a separate overload (e.g. to easily see in code search Xrefs that there is indeed only 1 caller).
nullptr, *params->image, kZLibCompressionLevel);
This is the only caller of (`skia/ext/codec_utils.h`) that requires support for custom `SkPngEncoder::Options`. (FWIW `//ui/gfx/codec/png_codec.cc` doesn't go through `skia/ext/codec_utils.h` but also supports options for custom compression levels or for adding comments.)
I note that `SkPngRustEncoder::CompressionLevel::kLow` is not quite the same as `fZlibLevel = 0` in `SkPngEncoder::Options`. But I think this should be fine (at least IMHO it shouldn't block this CL nor the Rust PNG trials). I'll loop the code owner just in case.
I remember that I promised to compression level of Rust `png` vs `libpng` on a randomly chose image - it's still on my TODO list. https://crates.io/crates/png advertises that it "includes a fast encoding mode powered by fdeflate that is dramatically faster than the fastest mode of libpng while simultaneously providing better compression ratio".
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
/cc @lizeb - see below
nullptr, *params->image, kZLibCompressionLevel);
This is the only caller of (`skia/ext/codec_utils.h`) that requires support for custom `SkPngEncoder::Options`. (FWIW `//ui/gfx/codec/png_codec.cc` doesn't go through `skia/ext/codec_utils.h` but also supports options for custom compression levels or for adding comments.)
I note that `SkPngRustEncoder::CompressionLevel::kLow` is not quite the same as `fZlibLevel = 0` in `SkPngEncoder::Options`. But I think this should be fine (at least IMHO it shouldn't block this CL nor the Rust PNG trials). I'll loop the code owner just in case.
I remember that I promised to compression level of Rust `png` vs `libpng` on a randomly chose image - it's still on my TODO list. https://crates.io/crates/png advertises that it "includes a fast encoding mode powered by fdeflate that is dramatically faster than the fastest mode of libpng while simultaneously providing better compression ratio".
/cc @lizeb who authored this `case` in https://crrev.com/c/5645862 in July 2024.
I think the only next steps would be to watch the histograms from the CanvasHibernationSnapshotZstd.gcl study - I'll add the to the design doc at go/rusty-png-in-chromium-and-skia (done) and to the `RustyPng.gcl` study (see cl/705961197):
(I see that the histograms won't expire until May 2025.)
Please let me know if you have any feedback.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
SK_API sk_sp<SkData> EncodePngAsSkData(GrDirectContext* context,
const SkImage& src,
int zlibCompressionLevel);
The overload that accepts `zlibCompressionLevel` has only 1 caller, so I though that it is useful to have it as a separate overload (e.g. to easily see in code search Xrefs that there is indeed only 1 caller).
Acknowledged
const SkImage& src,
Would it make more sense to take a `const SkImage*` instead, and add a null check here? I think that would eliminate some of the defensive checks in client code, and is also more aligned with `SkPngCoder::Encode`.
SkPngEncoder::Options options = {};
options.fZLibLevel = zlibCompressionLevel;
nit: can we use c++20 designated initializers yet? I'm dying to write something like this :")
`const SkPngEncoder::Options options = { .fZlibLevel = zlibCompressionLevel };`
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Would it make more sense to take a `const SkImage*` instead, and add a null check here? I think that would eliminate some of the defensive checks in client code, and is also more aligned with `SkPngCoder::Encode`.
Done
SkPngEncoder::Options options = {};
options.fZLibLevel = zlibCompressionLevel;
nit: can we use c++20 designated initializers yet? I'm dying to write something like this :")
`const SkPngEncoder::Options options = { .fZlibLevel = zlibCompressionLevel };`
Done.
FWIW https://en.cppreference.com/w/cpp/language/aggregate_initialization#Implicitly_initialized_elements says that
1. If the element has a default member initializer, the element is initialized from that initializer.
(since C++11)
2. Otherwise, if the element is not a reference, the element is copy-initialized from an empty initializer list.
Item 1 applies to `fFilterFlags` and `fICCProfile` and `fICCProfileDescription`. I _think_ that item 2 applies to `fComments` (i.e. that it will invoke the default constructor of `sk_sp<...>` and the copy that into `fComments`).
nullptr, *params->image, kZLibCompressionLevel);
Łukasz AnforowiczThis is the only caller of (`skia/ext/codec_utils.h`) that requires support for custom `SkPngEncoder::Options`. (FWIW `//ui/gfx/codec/png_codec.cc` doesn't go through `skia/ext/codec_utils.h` but also supports options for custom compression levels or for adding comments.)
I note that `SkPngRustEncoder::CompressionLevel::kLow` is not quite the same as `fZlibLevel = 0` in `SkPngEncoder::Options`. But I think this should be fine (at least IMHO it shouldn't block this CL nor the Rust PNG trials). I'll loop the code owner just in case.
I remember that I promised to compression level of Rust `png` vs `libpng` on a randomly chose image - it's still on my TODO list. https://crates.io/crates/png advertises that it "includes a fast encoding mode powered by fdeflate that is dramatically faster than the fastest mode of libpng while simultaneously providing better compression ratio".
/cc @lizeb who authored this `case` in https://crrev.com/c/5645862 in July 2024.
I think the only next steps would be to watch the histograms from the CanvasHibernationSnapshotZstd.gcl study - I'll add the to the design doc at go/rusty-png-in-chromium-and-skia (done) and to the `RustyPng.gcl` study (see cl/705961197):
- 'Blink.Canvas.2DLayerBridge.Compression.DecompressionTime',
- 'Blink.Canvas.2DLayerBridge.Compression.Ratio',
- 'Blink.Canvas.2DLayerBridge.Compression.ThreadTime',
(I see that the histograms won't expire until May 2025.)
Please let me know if you have any feedback.
@lizeb, maybe one other thing to consider would be to keep [the `kCanvasHibernationSnapshotZstd` feature](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/graphics/canvas_hibernation_handler.cc;l=47-52;drc=2d2d0f30da5d041405838dbad97f02c146724b2c) and then (once Rusty PNG reaches Stable) we could do a 2x2 comparison:
```
| regular encode | zstd
----------+----------------+------
libpng | |
Rusty PNG | |
```
WDYT?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
+@xiyuan from chrome/browser/ash/app_list/OWNERS - can you PTAL at the changes in this directory?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
+@fredmello from components/paint_preview/OWNERS - can you PTAL at the changes in this directory?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
+@rbpotter from //printing/OWNERS - can you PTAL at the changes in this directory?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
+@dcheng from content/renderer/OWNERS - can you PTAL at the changes in this directory? (I asked a random number generator for a number from 1 to 3, and it said that I should send the CL to the 1st person from the OWNERS file :-)
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
lgtm
int zlibCompressionLevel);
nit: `zlibCompressionLevel` -> `zlib_compression_level` ?
nit: `zlibCompressionLevel` -> `zlib_compression_level` ?
Ooops. Done. My brain has significant inertia when switching between Skia and Chromium style guides :-P.
Redirecting to thestig@ for printing backend changes.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Redirecting to thestig@ for printing backend changes.
Redirecting to thestig@ for printing backend changes.
IIUC thestig@ won't be able to take a look until Dec 19th... Let me try @awscreen in the meantime. FWIW this is a more-or-less mechanical change, so it should be fairly straightforward to review.
@awscreen, can you PTAL at the //printing/common/metafile_utils.cc changes?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Commit-Queue | +2 |
Thanks for the reviews everyone! @lizeb - I'll resolve the comment thread below and push the CL to CQ. I'll follow-up separately over email.
nullptr, *params->image, kZLibCompressionLevel);
Łukasz AnforowiczThis is the only caller of (`skia/ext/codec_utils.h`) that requires support for custom `SkPngEncoder::Options`. (FWIW `//ui/gfx/codec/png_codec.cc` doesn't go through `skia/ext/codec_utils.h` but also supports options for custom compression levels or for adding comments.)
I note that `SkPngRustEncoder::CompressionLevel::kLow` is not quite the same as `fZlibLevel = 0` in `SkPngEncoder::Options`. But I think this should be fine (at least IMHO it shouldn't block this CL nor the Rust PNG trials). I'll loop the code owner just in case.
I remember that I promised to compression level of Rust `png` vs `libpng` on a randomly chose image - it's still on my TODO list. https://crates.io/crates/png advertises that it "includes a fast encoding mode powered by fdeflate that is dramatically faster than the fastest mode of libpng while simultaneously providing better compression ratio".
Łukasz Anforowicz/cc @lizeb who authored this `case` in https://crrev.com/c/5645862 in July 2024.
I think the only next steps would be to watch the histograms from the CanvasHibernationSnapshotZstd.gcl study - I'll add the to the design doc at go/rusty-png-in-chromium-and-skia (done) and to the `RustyPng.gcl` study (see cl/705961197):
- 'Blink.Canvas.2DLayerBridge.Compression.DecompressionTime',
- 'Blink.Canvas.2DLayerBridge.Compression.Ratio',
- 'Blink.Canvas.2DLayerBridge.Compression.ThreadTime',
(I see that the histograms won't expire until May 2025.)
Please let me know if you have any feedback.
@lizeb, maybe one other thing to consider would be to keep [the `kCanvasHibernationSnapshotZstd` feature](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/graphics/canvas_hibernation_handler.cc;l=47-52;drc=2d2d0f30da5d041405838dbad97f02c146724b2c) and then (once Rusty PNG reaches Stable) we could do a 2x2 comparison:
```
| regular encode | zstd
----------+----------------+------
libpng | |
Rusty PNG | |
```WDYT?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[rust png] Use `SkPngRustEncoder` (if enabled) when encoding `SkImage`s.
This CL reroutes direct calls to `SkPngEncoder::Encode(...image...)` to
instead go through helper functions that offer the same functionality,
but select `SkPngEncoder` vs `SkPngRustEncoder` at runtime, based on the
`skia::kRustyPngFeature`.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |