- Revision
- 125869
- Author
- [email protected]
- Date
- 2012-08-17 01:52:52 -0700 (Fri, 17 Aug 2012)
Log Message
Source/WebCore: libwebp-0.2.0: handle alpha channel if present
https://bugs.webkit.org/show_bug.cgi?id=93430
Patch by Pascal Massimino <[email protected]> on 2012-08-17
Reviewed by Adam Barth.
updated the Layout test webp-image-decoding.html
* platform/image-decoders/webp/WEBPImageDecoder.cpp:
(outputMode):
switch to premultiplied-RGB if needed
(WebCore::WEBPImageDecoder::WEBPImageDecoder):
(WebCore::WEBPImageDecoder::decode):
use WebPGetFeatures() instead of WebPGetInfo(),
to detect presence of alpha channel
* platform/image-decoders/webp/WEBPImageDecoder.h:
(WEBPImageDecoder):
add a m_hasAlpha field
LayoutTests: update layout test for new libwebp-0.2.0
https://bugs.webkit.org/show_bug.cgi?id=93430
Patch by Pascal Massimino <[email protected]> on 2012-08-17
Reviewed by Adam Barth.
* fast/images/resources/test2.webp: Added.
lossy+alpha example
* fast/images/resources/test3.webp: Added.
lossless with alpha example
* fast/images/webp-image-decoding-expected.txt:
* fast/images/webp-image-decoding.html:
Updated test. Will now decode test2.webp and test3.webp too.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (125868 => 125869)
--- trunk/LayoutTests/ChangeLog 2012-08-17 08:35:14 UTC (rev 125868)
+++ trunk/LayoutTests/ChangeLog 2012-08-17 08:52:52 UTC (rev 125869)
@@ -1,3 +1,18 @@
+2012-08-17 Pascal Massimino <[email protected]>
+
+ update layout test for new libwebp-0.2.0
+ https://bugs.webkit.org/show_bug.cgi?id=93430
+
+ Reviewed by Adam Barth.
+
+ * fast/images/resources/test2.webp: Added.
+ lossy+alpha example
+ * fast/images/resources/test3.webp: Added.
+ lossless with alpha example
+ * fast/images/webp-image-decoding-expected.txt:
+ * fast/images/webp-image-decoding.html:
+ Updated test. Will now decode test2.webp and test3.webp too.
+
2012-08-17 Yoshifumi Inoue <[email protected]>
[Tests] Adding tests for multiple fields time input UI
Added: trunk/LayoutTests/fast/images/resources/test2.webp (0 => 125869)
--- trunk/LayoutTests/fast/images/resources/test2.webp (rev 0)
+++ trunk/LayoutTests/fast/images/resources/test2.webp 2012-08-17 08:52:52 UTC (rev 125869)
@@ -0,0 +1,7 @@
+RIFF WEBPVP8X
+ ? ? ALPH\xFC w@&\x82a\xF4#\xFD\xC3:)"\xE6?+8\xA0l۶\xAC\xC1\xA9$\xB2[\xE3 q\x90H\xAE\x95\xA6\xD5\xDDy\xEEn\xC9\xD3*\xABk\xC4\xF9\xD6\xFD?|\xF6\xBC\xCF\xF3\xCD[D\xFF\xB8m\xA3\xA4nj{\x84\xE2\xAF!o\xB1\xD3 Z\xF1\xDET<\xBC\xFF\xF8\xAFUX\xBFħ\x8D38g\xBD\x89=\xA7\x89O\x89!'\xF5\x9CN\x98\xB2K\xC8s"\x8A\xEAo0'1\xC6D9F\xCCGF,\xCF\xC9\xCF\xCA߰\x99bd\xD3\xCC<\x9F\xD5\xC2̳='7\xCC9\x86\xCC\x86\xDC\xF2\xC36\xD8\xD0\xF3\x82\xE1L
+x\xC5p\xA1\x81Ⱦcx\xD2AT1\x9E\x93\xFE;AoB\x88~/\xF4{\xA5\xBF\xDE\xFD]\xD2\xDF5\xFD_\xD0\xFF\x95\xFF\x92\xFE\xAF\xE9vA\xBBB\xB7K2\xD85\xBA]T\xD0\xED*/\xAA]\xFE\x97 VP8 \xF4 \xD2 \x9D*@ @ >u0\x92G\xA2?c\xAA\x88\xD1,\xE0佇\x93\xFDW\xF2\xF0ϥWN\xFB\x9F\xBAW\xF3\x80\xF1 \xE9\xE6\xEC\x84\xFB\x87P\xB7\xA0\x96/\xB2\xEC\xA7뇳\xB3\x97\xFBp\xEE\xDFw\xDBO\xB2
+\xF9X\xA7\xFE\xB2tI\x83*\xEFFTyT 1\x8E\x86\xC7_\xF7@\x9B'Ƥῐ$\xC7s\xC7wX;B1\x94` \xFE\xFF9\xB0\xB2h\xE6\xA0\xCC
+\xD2\xDCQF\x94\x9DA,\xFBK\x81E\xC0DӨ\xEF\xA2\xC2z\xF7\xFAg\xF5sd|\xB5\xE0#\xE7\x9E?\xC1XHHl\xB0\x9C\xBA}\x8D\xEB\xFC\xB1d\xD4 g\xB3\x86W |\xA4ӛ)\xF7\xB53\xEF`C\x85\xAC-\x8F \xC3J0s+N:\xBA\xB89\x800\xAFz\x94G \xEA\xF50/\xC7\xFC\x98\xBF\xE7䳡*\x9A>\x82\xEA\xA0F\xC8\xF9\xFA\x87j 90bv\x88+\x8E\xFF\x95ېͼ\x88\xD2k\xC9!t\xEB\x{36F439B}\x97G\x9BR\xCF\xFA\xC0ҺY\xC5x\xDB/\x98$oZ\xECM \xE1X\x97S\x8A\xFF%u\x9F9w\x88\xE4<\xCC|5L\xE3h{TY\x8ASn\xBA)\x8F\xBF\xFB\xFF\xEF\xC7W8Ǘ\xF4D\x97Y\xB1_}@\xD2c9\x80\xCA*\xF4\xD6iLy9
+\xE9\xBA\xF3\x8F\x93b\x87\xE9\xFFR+}\xA2?\xA6
+4%;\xD95\xA6\xE9\xBC\\xE7\xEF\xBB\xFC\xFD\x8B\xA1\x87hw\x9C\xB4\x86uY\xA1\x87N\xFF\x8E\xDF\xE0Ҡ\xBC\xF8\xD9y{\xD7\xFD\xE0\x9ApyĜ\xF2\xD53x\xFA\xA5\xE2BE4\xFC.\x86j/HtRnQ\x8A\xFB\xDA-D~e\xC3he\xAC\xE5\x82\xE4.\xB4M\xFE@
\ No newline at end of file
Added: trunk/LayoutTests/fast/images/resources/test3.webp (0 => 125869)
--- trunk/LayoutTests/fast/images/resources/test3.webp (rev 0)
+++ trunk/LayoutTests/fast/images/resources/test3.webp 2012-08-17 08:52:52 UTC (rev 125869)
@@ -0,0 +1,3 @@
+RIFF
+ WEBPVP8L\xFD /?\xC0w Lv\xE7O\xC5؏\xD10dJ\xB4H"
+p@a\x94mۖ58\x95Dvk$ɵҴ\xBA\xCC۲\xBBk\xF2\xB4\xCA\xEA\xDA\xE7[Ǟ_\xB1=\xCF\xF3\xBE\xF3\xD1n\xDB(\xD91c\xA1\xFAk\x98\xBF<>\xB6\xF3\xBD\xA5|\xFA\xD0\xDDk\xB8~\xED\xDEY7\xC7s\xA6\xD9!|0%\xA0\xE6P|\xC4.]\x9C\xB2[@mFC\xD3\xE2(nn,\x86\x8A\x99\xE2HR\xF9\x9A9"\x9B\xD2(z\x9Ce`\x98\xE7\x9AC\xE7\x8ECo\xD9㰯\xC1\xF0\xF59\i1B7:\x8C\xFC\x88Û\xA3,3~\x9AHH\xE0^dݫ\xC0\xBB\x90\xF6\xAEޥ\xB4w-\xF0/d\xFD+\x81)\xFB_3tA\xBA\xAE0t\xE9t\x8D\xD0\xC5O\xD0UB\x97\xFF\x93
\ No newline at end of file
Modified: trunk/LayoutTests/fast/images/webp-image-decoding-expected.txt (125868 => 125869)
--- trunk/LayoutTests/fast/images/webp-image-decoding-expected.txt 2012-08-17 08:35:14 UTC (rev 125868)
+++ trunk/LayoutTests/fast/images/webp-image-decoding-expected.txt 2012-08-17 08:52:52 UTC (rev 125869)
@@ -1,2 +1,2 @@
-
-128x128
+
+128x128 64x64 64x64
Modified: trunk/LayoutTests/fast/images/webp-image-decoding.html (125868 => 125869)
--- trunk/LayoutTests/fast/images/webp-image-decoding.html 2012-08-17 08:35:14 UTC (rev 125868)
+++ trunk/LayoutTests/fast/images/webp-image-decoding.html 2012-08-17 08:52:52 UTC (rev 125869)
@@ -7,10 +7,16 @@
window._onload_ = function() {
document.getElementById('results').innerHTML =
document.getElementsByTagName('img')[0].width + 'x' +
- document.getElementsByTagName('img')[0].height;
+ document.getElementsByTagName('img')[0].height + ' ' +
+ document.getElementsByTagName('img')[1].width + 'x' +
+ document.getElementsByTagName('img')[1].height + ' ' +
+ document.getElementsByTagName('img')[2].width + 'x' +
+ document.getElementsByTagName('img')[2].height;
}
</script>
<img src=""
+<img src=""
+<img src=""
<div id="results"></div>
</body>
</html>
Modified: trunk/Source/WebCore/ChangeLog (125868 => 125869)
--- trunk/Source/WebCore/ChangeLog 2012-08-17 08:35:14 UTC (rev 125868)
+++ trunk/Source/WebCore/ChangeLog 2012-08-17 08:52:52 UTC (rev 125869)
@@ -1,3 +1,24 @@
+2012-08-17 Pascal Massimino <[email protected]>
+
+ libwebp-0.2.0: handle alpha channel if present
+
+ https://bugs.webkit.org/show_bug.cgi?id=93430
+
+ Reviewed by Adam Barth.
+
+ updated the Layout test webp-image-decoding.html
+
+ * platform/image-decoders/webp/WEBPImageDecoder.cpp:
+ (outputMode):
+ switch to premultiplied-RGB if needed
+ (WebCore::WEBPImageDecoder::WEBPImageDecoder):
+ (WebCore::WEBPImageDecoder::decode):
+ use WebPGetFeatures() instead of WebPGetInfo(),
+ to detect presence of alpha channel
+ * platform/image-decoders/webp/WEBPImageDecoder.h:
+ (WEBPImageDecoder):
+ add a m_hasAlpha field
+
2012-08-17 Yoshifumi Inoue <[email protected]>
[Forms] Enable multiple fields time input UI for Chromium except Android
Modified: trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp (125868 => 125869)
--- trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp 2012-08-17 08:35:14 UTC (rev 125868)
+++ trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp 2012-08-17 08:52:52 UTC (rev 125869)
@@ -34,12 +34,18 @@
#include "PlatformInstrumentation.h"
#include "webp/decode.h"
+// backward emulation for earlier versions than 0.1.99
+#if (WEBP_DECODER_ABI_VERSION < 0x0163)
+#define MODE_rgbA MODE_RGBA
+#define MODE_bgrA MODE_BGRA
+#endif
+
#if CPU(BIG_ENDIAN) || CPU(MIDDLE_ENDIAN)
-inline WEBP_CSP_MODE outputMode() { return MODE_RGBA; }
+inline WEBP_CSP_MODE outputMode(bool hasAlpha) { return hasAlpha ? MODE_rgbA : MODE_RGBA; }
#elif USE(SKIA) && SK_B32_SHIFT
-inline WEBP_CSP_MODE outputMode() { return MODE_RGBA; }
+inline WEBP_CSP_MODE outputMode(bool hasAlpha) { return hasAlpha ? MODE_rgbA : MODE_RGBA; }
#else // LITTLE_ENDIAN, output BGRA pixels.
-inline WEBP_CSP_MODE outputMode() { return MODE_BGRA; }
+inline WEBP_CSP_MODE outputMode(bool hasAlpha) { return hasAlpha ? MODE_bgrA : MODE_BGRA; }
#endif
namespace WebCore {
@@ -48,6 +54,7 @@
ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption)
: ImageDecoder(alphaOption, gammaAndColorProfileOption)
, m_decoder(0)
+ , m_hasAlpha(false)
{
}
@@ -98,8 +105,19 @@
if (dataSize < imageHeaderSize)
return false;
int width, height;
+#if (WEBP_DECODER_ABI_VERSION >= 0x0163)
+ WebPBitstreamFeatures features;
+ if (WebPGetFeatures(dataBytes, dataSize, &features) != VP8_STATUS_OK)
+ return setFailed();
+ width = features.width;
+ height = features.height;
+ m_hasAlpha = features.has_alpha;
+#else
+ // Earlier version won't be able to display WebP files with alpha.
if (!WebPGetInfo(dataBytes, dataSize, &width, &height))
return setFailed();
+ m_hasAlpha = false;
+#endif
if (!setSize(width, height))
return setFailed();
}
@@ -116,7 +134,7 @@
if (!buffer.setSize(size().width(), size().height()))
return setFailed();
buffer.setStatus(ImageFrame::FramePartial);
- buffer.setHasAlpha(false); // FIXME: webp does not support alpha yet.
+ buffer.setHasAlpha(m_hasAlpha);
buffer.setOriginalFrameRect(IntRect(IntPoint(), size()));
}
@@ -124,7 +142,7 @@
int rowStride = size().width() * sizeof(ImageFrame::PixelData);
uint8_t* output = reinterpret_cast<uint8_t*>(buffer.getAddr(0, 0));
int outputSize = size().height() * rowStride;
- m_decoder = WebPINewRGB(outputMode(), output, outputSize, rowStride);
+ m_decoder = WebPINewRGB(outputMode(m_hasAlpha), output, outputSize, rowStride);
if (!m_decoder)
return setFailed();
}
Modified: trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h (125868 => 125869)
--- trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h 2012-08-17 08:35:14 UTC (rev 125868)
+++ trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h 2012-08-17 08:52:52 UTC (rev 125869)
@@ -50,6 +50,7 @@
bool decode(bool onlySize);
WebPIDecoder* m_decoder;
+ bool m_hasAlpha;
};
} // namespace WebCore