https://bugs.webkit.org/show_bug.cgi?id=118350
Patch by Balazs Kelemen <b.kelemen@samsung.com> on 2013-07-03
Reviewed by Allan Sandfeld Jensen.
No new tests. Actually it is not covered by existing tests. Surprisingly we haven't got pixel
tests for animated images. Given that this patch is pretty trivial I don't think it's worth the
cost to start introducing such tests.
I added a manual test: animated-gif-dispose-background.html.
GIFImageDecoder::initializeFrameBuffer use a loop to fill a subrect with tranparent pixels.
This is extremely ineffecient. The use case for this code path is not frequent on the web
but it's still better to fix it.
* platform/image-decoders/ImageDecoder.cpp:
(WebCore::ImageFrame::zeroFillFrameRect):
* platform/image-decoders/ImageDecoder.h:
* platform/image-decoders/gif/GIFImageDecoder.cpp:
(WebCore::GIFImageDecoder::initFrameBuffer):
Fixed indentation in addition.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@152352
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
--- /dev/null
+<html>
+<body>
+ <p>Animated gif with background dispose method. Animation frames live behind their rects filled with transparent pixels.</p>
+ <img src="./resources/dispose-background.gif" />
+</body>
+</html>
+2013-07-03 Balazs Kelemen <b.kelemen@samsung.com>
+
+ Gif: zero filling should use memset instead of setRGBA for every pixel
+ https://bugs.webkit.org/show_bug.cgi?id=118350
+
+ Reviewed by Allan Sandfeld Jensen.
+
+ No new tests. Actually it is not covered by existing tests. Surprisingly we haven't got pixel
+ tests for animated images. Given that this patch is pretty trivial I don't think it's worth the
+ cost to start introducing such tests.
+ I added a manual test: animated-gif-dispose-background.html.
+
+ GIFImageDecoder::initializeFrameBuffer use a loop to fill a subrect with tranparent pixels.
+ This is extremely ineffecient. The use case for this code path is not frequent on the web
+ but it's still better to fix it.
+
+ * platform/image-decoders/ImageDecoder.cpp:
+ (WebCore::ImageFrame::zeroFillFrameRect):
+ * platform/image-decoders/ImageDecoder.h:
+ * platform/image-decoders/gif/GIFImageDecoder.cpp:
+ (WebCore::GIFImageDecoder::initFrameBuffer):
+ Fixed indentation in addition.
+
2013-07-03 Przemyslaw Szymanski <p.szymanski3@samsung.com>
TextureUnit code optimization
m_hasAlpha = true;
}
+void ImageFrame::zeroFillFrameRect(const IntRect& rect)
+{
+ ASSERT(IntRect(IntPoint(), m_size).contains(rect));
+
+ if (rect.isEmpty())
+ return;
+
+ size_t rectWidthInBytes = rect.width() * sizeof(PixelData);
+ PixelData* start = m_bytes + (rect.y() * width()) + rect.x();
+ for (int i = 0; i < rect.height(); ++i) {
+ memset(start, 0, rectWidthInBytes);
+ start += width();
+ }
+
+ setHasAlpha(true);
+}
+
bool ImageFrame::copyBitmapData(const ImageFrame& other)
{
if (this == &other)
// These do not touch other metadata, only the raw pixel data.
void clearPixelData();
void zeroFillPixelData();
+ void zeroFillFrameRect(const IntRect&);
// Makes this frame have an independent copy of the provided image's
// pixel data, so that modifications in one frame are not reflected in
int top = upperBoundScaledY(frameRect.y());
int bottom = lowerBoundScaledY(frameRect.maxY(), top);
buffer->setOriginalFrameRect(IntRect(left, top, right - left, bottom - top));
-
+
if (!frameIndex) {
// This is the first frame, so we're not relying on any previous data.
if (!buffer->setSize(scaledSize().width(), scaledSize().height()))
if (!buffer->setSize(bufferSize.width(), bufferSize.height()))
return setFailed();
} else {
- // Copy the whole previous buffer, then clear just its frame.
- if (!buffer->copyBitmapData(*prevBuffer))
- return setFailed();
- for (int y = prevRect.y(); y < prevRect.maxY(); ++y) {
- for (int x = prevRect.x(); x < prevRect.maxX(); ++x)
- buffer->setRGBA(x, y, 0, 0, 0, 0);
- }
- if ((prevRect.width() > 0) && (prevRect.height() > 0))
- buffer->setHasAlpha(true);
+ // Copy the whole previous buffer, then clear just its frame.
+ if (!buffer->copyBitmapData(*prevBuffer))
+ return setFailed();
+ buffer->zeroFillFrameRect(prevRect);
}
}
}