summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-01-04 16:11:53 +0100
committerLuboš Luňák <l.lunak@collabora.com>2021-01-07 16:27:34 +0100
commit121f5962fa03055f91d7e81b9ab41476d58278fe (patch)
tree2cd2fc3c60711674070fa21ec0639b7ee708cdae
parent41cabebf9c95459c2c1912528446c45e70c3f203 (diff)
faster debug dumping for Skia
Write out the png images as quickly as possible, with still at least minimal compression. Without compression the debug images are way too big, but otherwise it's preferred that this is fast (especially when possibly dumping thousands of images). Skia's PNG code ignores the quality and hardcodes the libpng defaults, so patch Skia to explicitly handle the quality we want. It'd be also possible to use SkPngEncoder directly, but SkImage makes it non-trivial to get at the pixel data if it's on the GPU, and the internal getROPixels() invoked by encodeToData() also caches the content, so be lazy and patch Skia. Change-Id: I09cc61115246de4fc9d076953eb7fec8140c32cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108668 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--external/skia/UnpackedTarball_skia.mk3
-rw-r--r--external/skia/fast-png-write.patch.115
-rw-r--r--vcl/skia/SkiaHelper.cxx2
3 files changed, 18 insertions, 2 deletions
diff --git a/external/skia/UnpackedTarball_skia.mk b/external/skia/UnpackedTarball_skia.mk
index 319b33716a96..946750730edb 100644
--- a/external/skia/UnpackedTarball_skia.mk
+++ b/external/skia/UnpackedTarball_skia.mk
@@ -36,7 +36,8 @@ skia_patches := \
c++20.patch.0 \
constexpr-debug-std-max.patch.1 \
swap-buffers-rect.patch.1 \
- ubsan.patch.0
+ ubsan.patch.0 \
+ fast-png-write.patch.1 \
$(eval $(call gb_UnpackedTarball_set_patchlevel,skia,1))
diff --git a/external/skia/fast-png-write.patch.1 b/external/skia/fast-png-write.patch.1
new file mode 100644
index 000000000000..f47a2af70460
--- /dev/null
+++ b/external/skia/fast-png-write.patch.1
@@ -0,0 +1,15 @@
+diff --git a/src/images/SkImageEncoder.cpp b/src/images/SkImageEncoder.cpp
+index a96a93e0fc..1c110afa58 100644
+--- a/src/images/SkImageEncoder.cpp
++++ b/src/images/SkImageEncoder.cpp
+@@ -46,6 +46,10 @@ bool SkEncodeImage(SkWStream* dst, const SkPixmap& src,
+ }
+ case SkEncodedImageFormat::kPNG: {
+ SkPngEncoder::Options opts;
++ if (quality == 1) {
++ opts.fFilterFlags = SkPngEncoder::FilterFlag::kNone;
++ opts.fZLibLevel = 1;
++ }
+ return SkPngEncoder::Encode(dst, src, opts);
+ }
+ case SkEncodedImageFormat::kWEBP: {
diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index 6d76d1dfce65..b2da1e4b1ef8 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -620,7 +620,7 @@ void dump(const sk_sp<SkSurface>& surface, const char* file)
void dump(const sk_sp<SkImage>& image, const char* file)
{
- sk_sp<SkData> data = image->encodeToData();
+ sk_sp<SkData> data = image->encodeToData(SkEncodedImageFormat::kPNG, 1);
std::ofstream ostream(file, std::ios::binary);
ostream.write(static_cast<const char*>(data->data()), data->size());
}