Skip to content

Commit

Permalink
Merge r181553 - Add APNG support
Browse files Browse the repository at this point in the history
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:
  • Loading branch information
Max Stepin authored and carlosgcampos committed Mar 17, 2015
1 parent 1e42fca commit 7aaa2f2
Show file tree
Hide file tree
Showing 33 changed files with 730 additions and 11 deletions.
35 changes: 35 additions & 0 deletions LayoutTests/ChangeLog
@@ -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-11 Myles C. Maxfield <mmaxfield@apple.com>

Inline block children do not have correct baselines if their children are also block elements
Expand Down
13 changes: 13 additions & 0 deletions LayoutTests/fast/images/animated-png-expected.html
@@ -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>
27 changes: 27 additions & 0 deletions LayoutTests/fast/images/animated-png.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>
Binary file added LayoutTests/fast/images/resources/apng00-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng00.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng01-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng01.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng02-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng02.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng04-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng04.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng08-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng08.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng10-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng10.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng11-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng11.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng12-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng12.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng14-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng14.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng18-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng18.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng24-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng24.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng26-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LayoutTests/fast/images/resources/apng26.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions Source/WTF/ChangeLog
@@ -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-13 Mark Lam <mark.lam@apple.com>

Introduce WTF::Atomic to wrap std::atomic for a friendlier CAS.
Expand Down
4 changes: 4 additions & 0 deletions Source/WTF/wtf/FeatureDefines.h
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions Source/WebCore/ChangeLog
@@ -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 Simon Fraser <simon.fraser@apple.com>

Remove a redundant repaint when a layer becomes composited
Expand Down
42 changes: 42 additions & 0 deletions Source/WebCore/platform/image-decoders/ImageDecoder.h
Expand Up @@ -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
{
Expand Down

0 comments on commit 7aaa2f2

Please sign in to comment.