aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/images
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2017-04-05 21:56:10 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-05 21:56:14 +0000
commite87d7781db75a7ec22a103eda0886c2ca8dc4d9d (patch)
treeca27f77744950d94ecf077fd1c81903e9951a336 /src/images
parent4f783f8ada809a5a4146545fedb23bf0a362208b (diff)
Revert "Add support for writing ICC profiles to webp encoder"
This reverts commit 0c9d0b4e03b6c10778329e995b5dfdcb97954b28. Reason for revert: Looks like it's breaking a number of bots. Original change's description: > Add support for writing ICC profiles to webp encoder > > Bug: skia: > Change-Id: If0a8f84ed88da96924370b841f2283c0ff8e32ab > Reviewed-on: https://skia-review.googlesource.com/10212 > Commit-Queue: Matt Sarett <msarett@google.com> > Reviewed-by: Leon Scroggins <scroggo@google.com> > TBR=msarett@google.com,scroggo@google.com,reviews@skia.org,jzern@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: Ic06ad9f19a4d743b34f8d3bd33f171b9d74badcb Reviewed-on: https://skia-review.googlesource.com/11408 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src/images')
-rw-r--r--src/images/SkWEBPImageEncoder.cpp56
1 files changed, 11 insertions, 45 deletions
diff --git a/src/images/SkWEBPImageEncoder.cpp b/src/images/SkWEBPImageEncoder.cpp
index 728dbc712a..28dff0569c 100644
--- a/src/images/SkWEBPImageEncoder.cpp
+++ b/src/images/SkWEBPImageEncoder.cpp
@@ -26,7 +26,7 @@
#include "SkUnPreMultiply.h"
#include "SkUtils.h"
-// A WebP encoder only, on top of (subset of) libwebp
+// A WebP decoder only, on top of (subset of) libwebp
// For more information on WebP image format, and libwebp library, see:
// http://code.google.com/speed/webp/
// http://www.webmproject.org/code/#libwebp_webp_image_decoder_library
@@ -37,7 +37,6 @@ extern "C" {
// If moving libwebp out of skia source tree, path for webp headers must be
// updated accordingly. Here, we enforce using local copy in webp sub-directory.
#include "webp/encode.h"
-#include "webp/mux.h"
}
static transform_scanline_proc choose_proc(const SkImageInfo& info) {
@@ -175,17 +174,10 @@ static bool do_encode(SkWStream* stream, const SkPixmap& srcPixmap, const SkEnco
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.
- sk_sp<SkData> icc = pixmap.colorSpace() ? icc_from_color_space(*pixmap.colorSpace()) : nullptr;
- SkDynamicMemoryWStream tmp;
- pic.custom_ptr = icc ? (void*)&tmp : (void*)stream;
+ pic.custom_ptr = (void*)stream;
const uint8_t* src = (uint8_t*)pixmap.addr();
const int rgbStride = pic.width * bpp;
@@ -198,47 +190,21 @@ static bool do_encode(SkWStream* stream, const SkPixmap& srcPixmap, const SkEnco
proc((char*) &rgb[y * rgbStride], (const char*) &src[y * rowBytes], pic.width, bpp, colors);
}
- auto importProc = WebPPictureImportRGB;
- if (3 != bpp) {
+ bool ok;
+ if (bpp == 3) {
+ ok = SkToBool(WebPPictureImportRGB(&pic, &rgb[0], rgbStride));
+ } else {
if (pixmap.isOpaque()) {
- importProc = WebPPictureImportRGBX;
+ ok = SkToBool(WebPPictureImportRGBX(&pic, &rgb[0], rgbStride));
} else {
- importProc = WebPPictureImportRGBA;
+ ok = SkToBool(WebPPictureImportRGBA(&pic, &rgb[0], rgbStride));
}
}
- if (!importProc(&pic, &rgb[0], rgbStride)) {
- return false;
- }
-
- if (!WebPEncode(&webp_config, &pic)) {
- return false;
- }
-
- if (icc) {
- sk_sp<SkData> encodedData = tmp.detachAsData();
- WebPData encoded = { encodedData->bytes(), encodedData->size() };
- WebPData iccChunk = { icc->bytes(), icc->size() };
-
- SkAutoTCallVProc<WebPMux, WebPMuxDelete> mux(WebPMuxNew());
- if (WEBP_MUX_OK != WebPMuxSetImage(mux, &encoded, 0)) {
- return false;
- }
-
- if (WEBP_MUX_OK != WebPMuxSetChunk(mux, "ICCP", &iccChunk, 0)) {
- return false;
- }
-
- WebPData assembled;
- if (WEBP_MUX_OK != WebPMuxAssemble(mux, &assembled)) {
- return false;
- }
-
- stream->write(assembled.bytes, assembled.size);
- WebPDataClear(&assembled);
- }
+ ok = ok && WebPEncode(&webp_config, &pic);
+ WebPPictureFree(&pic);
- return true;
+ return ok;
}
bool SkEncodeImageAsWEBP(SkWStream* stream, const SkPixmap& src, int quality) {