Skip to content
Permalink
Browse files
Add APNG support
https://bugs.webkit.org/show_bug.cgi?id=17022

Patch by Max Stepin <maxstepin@gmail.com> on 2015-03-16
Reviewed by Carlos Garcia Campos.

Source/WebCore:

Test: fast/images/animated-png.html

* platform/image-decoders/ImageDecoder.h:
(WebCore::ImageFrame::divide255):
(WebCore::ImageFrame::overRGBA):
* platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::frameHeader):
(WebCore::readChunks):
(WebCore::PNGImageReader::PNGImageReader):
(WebCore::PNGImageDecoder::PNGImageDecoder):
(WebCore::PNGImageDecoder::frameBufferAtIndex):
(WebCore::PNGImageDecoder::headerAvailable):
(WebCore::PNGImageDecoder::rowAvailable):
(WebCore::PNGImageDecoder::pngComplete):
(WebCore::PNGImageDecoder::readChunks):
(WebCore::PNGImageDecoder::frameHeader):
(WebCore::PNGImageDecoder::init):
(WebCore::PNGImageDecoder::clearFrameBufferCache):
(WebCore::PNGImageDecoder::initFrameBuffer):
(WebCore::PNGImageDecoder::frameComplete):
(WebCore::PNGImageDecoder::processingStart):
(WebCore::PNGImageDecoder::processingFinish):
(WebCore::PNGImageDecoder::fallbackNotAnimated):
* platform/image-decoders/png/PNGImageDecoder.h:
(WebCore::PNGImageDecoder::frameCount):
(WebCore::PNGImageDecoder::repetitionCount):
(WebCore::PNGImageDecoder::isComplete):

Source/WTF:

* wtf/FeatureDefines.h:

LayoutTests:

* fast/images/animated-png-expected.html: Added.
* fast/images/animated-png.html: Added.
* fast/images/resources/apng00-ref.png: Added.
* fast/images/resources/apng00.png: Added.
* fast/images/resources/apng01-ref.png: Added.
* fast/images/resources/apng01.png: Added.
* fast/images/resources/apng02-ref.png: Added.
* fast/images/resources/apng02.png: Added.
* fast/images/resources/apng04-ref.png: Added.
* fast/images/resources/apng04.png: Added.
* fast/images/resources/apng08-ref.png: Added.
* fast/images/resources/apng08.png: Added.
* fast/images/resources/apng10-ref.png: Added.
* fast/images/resources/apng10.png: Added.
* fast/images/resources/apng11-ref.png: Added.
* fast/images/resources/apng11.png: Added.
* fast/images/resources/apng12-ref.png: Added.
* fast/images/resources/apng12.png: Added.
* fast/images/resources/apng14-ref.png: Added.
* fast/images/resources/apng14.png: Added.
* fast/images/resources/apng18-ref.png: Added.
* fast/images/resources/apng18.png: Added.
* fast/images/resources/apng24-ref.png: Added.
* fast/images/resources/apng24.png: Added.
* fast/images/resources/apng26-ref.png: Added.
* fast/images/resources/apng26.png: Added.
* platform/mac/TestExpectations:

Canonical link: https://commits.webkit.org/160733@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181553 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Max Stepin authored and webkit-commit-queue committed Mar 16, 2015
1 parent 7801ddf commit 0e86ffeb68747d3b58571d83c9b0997cd1a15d83
Showing with 733 additions and 11 deletions.
  1. +35 −0 LayoutTests/ChangeLog
  2. +13 −0 LayoutTests/fast/images/animated-png-expected.html
  3. +27 −0 LayoutTests/fast/images/animated-png.html
  4. BIN LayoutTests/fast/images/resources/apng00-ref.png
  5. BIN LayoutTests/fast/images/resources/apng00.png
  6. BIN LayoutTests/fast/images/resources/apng01-ref.png
  7. BIN LayoutTests/fast/images/resources/apng01.png
  8. BIN LayoutTests/fast/images/resources/apng02-ref.png
  9. BIN LayoutTests/fast/images/resources/apng02.png
  10. BIN LayoutTests/fast/images/resources/apng04-ref.png
  11. BIN LayoutTests/fast/images/resources/apng04.png
  12. BIN LayoutTests/fast/images/resources/apng08-ref.png
  13. BIN LayoutTests/fast/images/resources/apng08.png
  14. BIN LayoutTests/fast/images/resources/apng10-ref.png
  15. BIN LayoutTests/fast/images/resources/apng10.png
  16. BIN LayoutTests/fast/images/resources/apng11-ref.png
  17. BIN LayoutTests/fast/images/resources/apng11.png
  18. BIN LayoutTests/fast/images/resources/apng12-ref.png
  19. BIN LayoutTests/fast/images/resources/apng12.png
  20. BIN LayoutTests/fast/images/resources/apng14-ref.png
  21. BIN LayoutTests/fast/images/resources/apng14.png
  22. BIN LayoutTests/fast/images/resources/apng18-ref.png
  23. BIN LayoutTests/fast/images/resources/apng18.png
  24. BIN LayoutTests/fast/images/resources/apng24-ref.png
  25. BIN LayoutTests/fast/images/resources/apng24.png
  26. BIN LayoutTests/fast/images/resources/apng26-ref.png
  27. BIN LayoutTests/fast/images/resources/apng26.png
  28. +3 −0 LayoutTests/platform/mac/TestExpectations
  29. +9 −0 Source/WTF/ChangeLog
  30. +4 −0 Source/WTF/wtf/FeatureDefines.h
  31. +35 −0 Source/WebCore/ChangeLog
  32. +42 −0 Source/WebCore/platform/image-decoders/ImageDecoder.h
  33. +508 −10 Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
  34. +57 −1 Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h
@@ -1,3 +1,38 @@
2015-03-16 Max Stepin <maxstepin@gmail.com>

Add APNG support
https://bugs.webkit.org/show_bug.cgi?id=17022

Reviewed by Carlos Garcia Campos.

* fast/images/animated-png-expected.html: Added.
* fast/images/animated-png.html: Added.
* fast/images/resources/apng00-ref.png: Added.
* fast/images/resources/apng00.png: Added.
* fast/images/resources/apng01-ref.png: Added.
* fast/images/resources/apng01.png: Added.
* fast/images/resources/apng02-ref.png: Added.
* fast/images/resources/apng02.png: Added.
* fast/images/resources/apng04-ref.png: Added.
* fast/images/resources/apng04.png: Added.
* fast/images/resources/apng08-ref.png: Added.
* fast/images/resources/apng08.png: Added.
* fast/images/resources/apng10-ref.png: Added.
* fast/images/resources/apng10.png: Added.
* fast/images/resources/apng11-ref.png: Added.
* fast/images/resources/apng11.png: Added.
* fast/images/resources/apng12-ref.png: Added.
* fast/images/resources/apng12.png: Added.
* fast/images/resources/apng14-ref.png: Added.
* fast/images/resources/apng14.png: Added.
* fast/images/resources/apng18-ref.png: Added.
* fast/images/resources/apng18.png: Added.
* fast/images/resources/apng24-ref.png: Added.
* fast/images/resources/apng24.png: Added.
* fast/images/resources/apng26-ref.png: Added.
* fast/images/resources/apng26.png: Added.
* platform/mac/TestExpectations:

2015-03-16 Gyuyoung Kim <gyuyoung.kim@samsung.com>

[EFL] Unreviewed EFL gardening on 16th Mar.
@@ -0,0 +1,13 @@
<html>
<head>
<title>APNG reftest: when animation ends, compare its last frame against the reference static PNG.</title>
<style>
img { margin: 1px; }
</style>
</head>
<body style="margin: 1px">
<img src=resources/apng00-ref.png><img src=resources/apng01-ref.png><img src=resources/apng02-ref.png><img src=resources/apng04-ref.png><img src=resources/apng08-ref.png><br>
<img src=resources/apng10-ref.png><img src=resources/apng11-ref.png><img src=resources/apng12-ref.png><img src=resources/apng14-ref.png><img src=resources/apng18-ref.png><br>
<img src=resources/apng24-ref.png><img src=resources/apng26-ref.png>
</body>
</html>
@@ -0,0 +1,27 @@
<html>
<head>
<title>APNG reftest: when animation ends, compare its last frame against the reference static PNG.</title>
<script>
if (window.testRunner)
testRunner.dumpAsText(true);

window.onload = function() {
if (window.testRunner)
testRunner.waitUntilDone();

window.setTimeout(function() {
if (window.testRunner)
testRunner.notifyDone();
}, 300);
}
</script>
<style>
img { margin: 1px; }
</style>
</head>
<body style="margin: 1px">
<img src=resources/apng00.png><img src=resources/apng01.png><img src=resources/apng02.png><img src=resources/apng04.png><img src=resources/apng08.png><br>
<img src=resources/apng10.png><img src=resources/apng11.png><img src=resources/apng12.png><img src=resources/apng14.png><img src=resources/apng18.png><br>
<img src=resources/apng24.png><img src=resources/apng26.png>
</body>
</html>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -1273,3 +1273,6 @@ webkit.org/b/142142 media/video-initially-hidden-volume-slider-up.html [ Skip ]

# Test uses Yosemite blurs
[ Mavericks ] compositing/media-controls-bar-appearance.html [ Skip ]

# Mavericks and prior do not support APNG.
webkit.org/b/17022 [ MountainLion Mavericks ] fast/images/animated-png.html [ Skip ]
@@ -1,3 +1,12 @@
2015-03-16 Max Stepin <maxstepin@gmail.com>

Add APNG support
https://bugs.webkit.org/show_bug.cgi?id=17022

Reviewed by Carlos Garcia Campos.

* wtf/FeatureDefines.h:

2015-03-15 Benjamin Poulain <benjamin@webkit.org>

CSS: fix the case-insensitive matching of the attribute selectors Begin, End and Hyphen
@@ -307,6 +307,10 @@ the public iOS SDK. We will also need to update the FeatureDefines.xcconfig file
#define ENABLE_ACCELERATED_OVERFLOW_SCROLLING 0
#endif

#if !defined(ENABLE_APNG)
#define ENABLE_APNG 1
#endif

#if !defined(ENABLE_BATTERY_STATUS)
#define ENABLE_BATTERY_STATUS 0
#endif
@@ -1,3 +1,38 @@
2015-03-16 Max Stepin <maxstepin@gmail.com>

Add APNG support
https://bugs.webkit.org/show_bug.cgi?id=17022

Reviewed by Carlos Garcia Campos.

Test: fast/images/animated-png.html

* platform/image-decoders/ImageDecoder.h:
(WebCore::ImageFrame::divide255):
(WebCore::ImageFrame::overRGBA):
* platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::frameHeader):
(WebCore::readChunks):
(WebCore::PNGImageReader::PNGImageReader):
(WebCore::PNGImageDecoder::PNGImageDecoder):
(WebCore::PNGImageDecoder::frameBufferAtIndex):
(WebCore::PNGImageDecoder::headerAvailable):
(WebCore::PNGImageDecoder::rowAvailable):
(WebCore::PNGImageDecoder::pngComplete):
(WebCore::PNGImageDecoder::readChunks):
(WebCore::PNGImageDecoder::frameHeader):
(WebCore::PNGImageDecoder::init):
(WebCore::PNGImageDecoder::clearFrameBufferCache):
(WebCore::PNGImageDecoder::initFrameBuffer):
(WebCore::PNGImageDecoder::frameComplete):
(WebCore::PNGImageDecoder::processingStart):
(WebCore::PNGImageDecoder::processingFinish):
(WebCore::PNGImageDecoder::fallbackNotAnimated):
* platform/image-decoders/png/PNGImageDecoder.h:
(WebCore::PNGImageDecoder::frameCount):
(WebCore::PNGImageDecoder::repetitionCount):
(WebCore::PNGImageDecoder::isComplete):

2015-03-15 Benjamin Poulain <benjamin@webkit.org>

CSS: fix the case-insensitive matching of the attribute selectors Begin, End and Hyphen
@@ -165,6 +165,48 @@ namespace WebCore {
*dest = (a << 24 | r << 16 | g << 8 | b);
}

#if ENABLE(APNG)
static inline unsigned divide255(unsigned a)
{
return (a + (a >> 8) + 1) >> 8;
}

inline void overRGBA(PixelData* dest, unsigned r, unsigned g, unsigned b, unsigned a)
{
if (!a)
return;

if (a < 255) {
unsigned aDest = ((*dest) >> 24) & 255;
if (aDest) {
unsigned rDest = ((*dest) >> 16) & 255;
unsigned gDest = ((*dest) >> 8) & 255;
unsigned bDest = (*dest) & 255;
unsigned aAux = 255 - a;
if (!m_premultiplyAlpha) {
rDest = divide255(rDest * aDest);
gDest = divide255(gDest * aDest);
bDest = divide255(bDest * aDest);
}
r = divide255(r * a + rDest * aAux);
g = divide255(g * a + gDest * aAux);
b = divide255(b * a + bDest * aAux);
a += divide255(aDest * aAux);
if (!m_premultiplyAlpha) {
r = (r * 255 + a - 1) / a;
g = (g * 255 + a - 1) / a;
b = (b * 255 + a - 1) / a;
}
} else if (m_premultiplyAlpha) {
r = divide255(r * a);
g = divide255(g * a);
b = divide255(b * a);
}
}
*dest = (a << 24 | r << 16 | g << 8 | b);
}
#endif

private:
int width() const
{

0 comments on commit 0e86ffe

Please sign in to comment.