aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/images
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-05-19 19:12:54 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-19 23:35:46 +0000
commit2f687877835b60497a48537b940cd634088eedf4 (patch)
tree6dea16905f2bdfbf79a2b34bdcb75215759201fd /src/images
parent45d71a5c75cefec2f44b2013b30ff53eab923160 (diff)
SkWebpEncoder: use bgra for lossless and yuv for lossy
Previosuly, we would (accidentally) always use just yuv. Bug: 713862 Change-Id: I00acc6ca2841ba0636494119b7b4f46a9deee401 Reviewed-on: https://skia-review.googlesource.com/17406 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'src/images')
-rw-r--r--src/images/SkWebpEncoder.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/images/SkWebpEncoder.cpp b/src/images/SkWebpEncoder.cpp
index 276837cb12..38e6773d92 100644
--- a/src/images/SkWebpEncoder.cpp
+++ b/src/images/SkWebpEncoder.cpp
@@ -167,25 +167,29 @@ bool SkWebpEncoder::Encode(SkWStream* stream, const SkPixmap& pixmap, const Opti
return false;
}
- // The choice of |webp_config.method| currently just match Chrome's defaults. We
- // could potentially expose this to the client.
+ WebPPicture pic;
+ WebPPictureInit(&pic);
+ SkAutoTCallVProc<WebPPicture, WebPPictureFree> autoPic(&pic);
+ pic.width = pixmap.width();
+ pic.height = pixmap.height();
+ pic.writer = stream_writer;
+
+ // Set compression, method, and pixel format.
+ // libwebp recommends using BGRA for lossless and YUV for lossy.
+ // The choices of |webp_config.method| currently just match Chrome's defaults. We
+ // could potentially expose this decision to the client.
if (Compression::kLossy == opts.fCompression) {
webp_config.lossless = 0;
#ifndef SK_WEBP_ENCODER_USE_DEFAULT_METHOD
webp_config.method = 3;
#endif
+ pic.use_argb = 0;
} else {
webp_config.lossless = 1;
webp_config.method = 0;
+ pic.use_argb = 1;
}
- WebPPicture pic;
- WebPPictureInit(&pic);
- SkAutoTCallVProc<WebPPicture, WebPPictureFree> autoPic(&pic);
- pic.width = pixmap.width();
- pic.height = pixmap.height();
- pic.writer = stream_writer;
-
// If there is no need to embed an ICC profile, we write directly to the input stream.
// Otherwise, we will first encode to |tmp| and use a mux to add the ICC chunk. libwebp
// forces us to have an encoded image before we can add a profile.