diff options
Diffstat (limited to 'src/images/SkWebpEncoder.cpp')
-rw-r--r-- | src/images/SkWebpEncoder.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/images/SkWebpEncoder.cpp b/src/images/SkWebpEncoder.cpp index 5c26111040..b6c6212314 100644 --- a/src/images/SkWebpEncoder.cpp +++ b/src/images/SkWebpEncoder.cpp @@ -124,8 +124,7 @@ static int stream_writer(const uint8_t* data, size_t data_size, return stream->write(data, data_size) ? 1 : 0; } -static bool do_encode(SkWStream* stream, const SkPixmap& pixmap, const SkWebpEncoder::Options& opts) -{ +bool SkWebpEncoder::Encode(SkWStream* stream, const SkPixmap& pixmap, const Options& opts) { if (!SkPixmapIsValid(pixmap, opts.fUnpremulBehavior)) { return false; } @@ -168,6 +167,16 @@ static bool do_encode(SkWStream* stream, const SkPixmap& pixmap, const SkWebpEnc return false; } + // The choice of |webp_config.method| currently just match Chrome's defaults. We + // could potentially expose this to the client. + if (Compression::kLossy == opts.fCompression) { + webp_config.lossless = 0; + webp_config.method = 3; + } else { + webp_config.lossless = 1; + webp_config.method = 0; + } + WebPPicture pic; WebPPictureInit(&pic); SkAutoTCallVProc<WebPPicture, WebPPictureFree> autoPic(&pic); @@ -236,8 +245,4 @@ static bool do_encode(SkWStream* stream, const SkPixmap& pixmap, const SkWebpEnc return true; } -bool SkWebpEncoder::Encode(SkWStream* dst, const SkPixmap& src, const Options& opts) { - return do_encode(dst, src, opts); -} - #endif |