diff options
author | noel@chromium.org <noel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-04 08:09:20 +0000 |
---|---|---|
committer | noel@chromium.org <noel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-04 08:09:20 +0000 |
commit | 24258f8c58c172fe7ce59822752f9757ebb7e53c (patch) | |
tree | 82143864d471750dd092017dbf0b029906e08cac /third_party | |
parent | 5750c520339e4bd5ff202a1ce17be8e2c659be2b (diff) | |
download | chromium_src-24258f8c58c172fe7ce59822752f9757ebb7e53c.zip chromium_src-24258f8c58c172fe7ce59822752f9757ebb7e53c.tar.gz chromium_src-24258f8c58c172fe7ce59822752f9757ebb7e53c.tar.bz2 |
When importing BGRA or RGBA data for encoding, provide variants of
the WEBPImportPicture API for RGBX and BRGX data meaning the alpha
channel should be ignored.
Note: the existing WEBPImportPictureRGBA|BGRA routines also ignore
the alpha channel, but won't in a future version of libwebp. Thus,
if WebKit continues using the existing routines, the alpha channel
will be imported and encoded in libwebp.next, and hence will break
canvas.toDataURL("image/webp") and its layout tests.
BUG=130144
TEST=Webkit test pass when using the new functions.
Review URL: https://chromiumcodereview.appspot.com/10496016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140264 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/libwebp/README.chromium | 2 | ||||
-rw-r--r-- | third_party/libwebp/enc/picture.c | 14 | ||||
-rw-r--r-- | third_party/libwebp/webp/encode.h | 11 |
3 files changed, 25 insertions, 2 deletions
diff --git a/third_party/libwebp/README.chromium b/third_party/libwebp/README.chromium index 758051a..525267b 100644 --- a/third_party/libwebp/README.chromium +++ b/third_party/libwebp/README.chromium @@ -21,6 +21,8 @@ Local changes: * Removed examples/, documentation and build related files, keeping only the contents of src/. * Merged COPYING/PATENTS to LICENSE + * Add BGRX and RGBX variants to the WEBPImportPicture API (needs to be + upstreamed to libwebp master). Upstream cherry-picks: 7bb6a9c idec: fix internal state corruption 89cd1bb idec: fix WebPIUpdate failure diff --git a/third_party/libwebp/enc/picture.c b/third_party/libwebp/enc/picture.c index 2f3c96e..56ff85f3 100644 --- a/third_party/libwebp/enc/picture.c +++ b/third_party/libwebp/enc/picture.c @@ -593,6 +593,20 @@ int WebPPictureImportBGRA(WebPPicture* const picture, return Import(picture, rgba, rgba_stride, 4, 1, 1); } +int WebPPictureImportRGBX(WebPPicture* const picture, + const uint8_t* const rgba, int rgba_stride) { + picture->colorspace &= ~WEBP_CSP_ALPHA_BIT; + if (!WebPPictureAlloc(picture)) return 0; + return Import(picture, rgba, rgba_stride, 4, 0, 0); +} + +int WebPPictureImportBGRX(WebPPicture* const picture, + const uint8_t* const rgba, int rgba_stride) { + picture->colorspace &= ~WEBP_CSP_ALPHA_BIT; + if (!WebPPictureAlloc(picture)) return 0; + return Import(picture, rgba, rgba_stride, 4, 1, 0); +} + //------------------------------------------------------------------------------ // Simplest call: diff --git a/third_party/libwebp/webp/encode.h b/third_party/libwebp/webp/encode.h index 31f0539..ae98419 100644 --- a/third_party/libwebp/webp/encode.h +++ b/third_party/libwebp/webp/encode.h @@ -249,15 +249,22 @@ WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* const pic, // Returns 0 in case of memory error. WEBP_EXTERN(int) WebPPictureImportRGB( WebPPicture* const picture, const uint8_t* const rgb, int rgb_stride); -// Same, but for RGBA buffer +// Same, but for RGBA buffer. WEBP_EXTERN(int) WebPPictureImportRGBA( WebPPicture* const picture, const uint8_t* const rgba, int rgba_stride); +// Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format +// input buffer ignoring the alpha channel. Avoids needing to copy the data +// to a temporary 24-bit RGB buffer to import the RGB only. +WEBP_EXTERN(int) WebPPictureImportRGBX( + WebPPicture* const picture, const uint8_t* const rgbx, int rgbx_stride); -// Variant of the above, but taking BGR(A) input: +// Variants of the above, but taking BGR(A|X) input. WEBP_EXTERN(int) WebPPictureImportBGR( WebPPicture* const picture, const uint8_t* const bgr, int bgr_stride); WEBP_EXTERN(int) WebPPictureImportBGRA( WebPPicture* const picture, const uint8_t* const bgra, int bgra_stride); +WEBP_EXTERN(int) WebPPictureImportBGRX( + WebPPicture* const picture, const uint8_t* const bgrx, int bgrx_stride); //------------------------------------------------------------------------------ // Main call |