<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[205877] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/205877">205877</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-09-13 13:56:22 -0700 (Tue, 13 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Get rid of the m_premultiplyAlpha flag of the ImageFrame class
https://bugs.webkit.org/show_bug.cgi?id=159721

Patch by Said Abou-Hallawa &lt;sabouhallawa@apple.com&gt; on 2016-09-13
Reviewed by Simon Fraser.

This flag was only needed when calling ImageBackingStore::create() in
ImageFrame::setSize(). Instead we can pass ImageDecoder::m_premultiplyAlpha
to ImageFrame::setSize(), which is renamed ImageFrame::initializeBackingStore().
The passed premultiplyAlpha can then be passed to ImageBackingStore::create().

* platform/image-decoders/ImageDecoder.cpp:
(WebCore::ImageFrame::ImageFrame):
(WebCore::ImageFrame::operator=):
(WebCore::ImageFrame::initializeBackingStore):
(WebCore::ImageFrame::copyBitmapData): Deleted.
(WebCore::ImageFrame::setSize): Deleted.
* platform/image-decoders/ImageDecoder.h:
(WebCore::ImageFrame::disposalMethod):
(WebCore::ImageFrame::setDisposalMethod):
(WebCore::ImageDecoder::premultiplyAlpha):
(WebCore::ImageFrame::premultiplyAlpha): Deleted.
(WebCore::ImageFrame::setPremultiplyAlpha): Deleted.
* platform/image-decoders/bmp/BMPImageDecoder.cpp:
(WebCore::BMPImageDecoder::frameBufferAtIndex):
* platform/image-decoders/bmp/BMPImageReader.cpp:
(WebCore::BMPImageReader::decodeBMP):
* platform/image-decoders/gif/GIFImageDecoder.cpp:
(WebCore::GIFImageDecoder::decode):
(WebCore::GIFImageDecoder::initFrameBuffer):
* platform/image-decoders/ico/ICOImageDecoder.cpp:
(WebCore::ICOImageDecoder::frameCount):
* platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
(WebCore::JPEGImageDecoder::frameBufferAtIndex):
(WebCore::JPEGImageDecoder::outputScanlines):
* platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::PNGImageDecoder::frameBufferAtIndex):
(WebCore::PNGImageDecoder::rowAvailable):
(WebCore::PNGImageDecoder::readChunks):
(WebCore::PNGImageDecoder::initFrameBuffer):
(WebCore::setPixelRGB): Deleted.
(WebCore::setPixelRGBA): Deleted.
(WebCore::setPixelPremultipliedRGBA): Deleted.
* platform/image-decoders/webp/WEBPImageDecoder.cpp:
(WebCore::WEBPImageDecoder::frameBufferAtIndex):
(WebCore::WEBPImageDecoder::decode):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersImageDecodercpp">trunk/Source/WebCore/platform/image-decoders/ImageDecoder.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersImageDecoderh">trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersbmpBMPImageDecodercpp">trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersbmpBMPImageReadercpp">trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageReader.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersgifGIFImageDecodercpp">trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersicoICOImageDecodercpp">trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersjpegJPEGImageDecodercpp">trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecoderspngPNGImageDecodercpp">trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecoderswebpWEBPImageDecodercpp">trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205876 => 205877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-13 20:47:15 UTC (rev 205876)
+++ trunk/Source/WebCore/ChangeLog        2016-09-13 20:56:22 UTC (rev 205877)
</span><span class="lines">@@ -1,3 +1,51 @@
</span><ins>+2016-09-13  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        Get rid of the m_premultiplyAlpha flag of the ImageFrame class
+        https://bugs.webkit.org/show_bug.cgi?id=159721
+
+        Reviewed by Simon Fraser.
+
+        This flag was only needed when calling ImageBackingStore::create() in 
+        ImageFrame::setSize(). Instead we can pass ImageDecoder::m_premultiplyAlpha 
+        to ImageFrame::setSize(), which is renamed ImageFrame::initializeBackingStore().
+        The passed premultiplyAlpha can then be passed to ImageBackingStore::create().
+
+        * platform/image-decoders/ImageDecoder.cpp:
+        (WebCore::ImageFrame::ImageFrame):
+        (WebCore::ImageFrame::operator=):
+        (WebCore::ImageFrame::initializeBackingStore):
+        (WebCore::ImageFrame::copyBitmapData): Deleted.
+        (WebCore::ImageFrame::setSize): Deleted.
+        * platform/image-decoders/ImageDecoder.h:
+        (WebCore::ImageFrame::disposalMethod):
+        (WebCore::ImageFrame::setDisposalMethod):
+        (WebCore::ImageDecoder::premultiplyAlpha):
+        (WebCore::ImageFrame::premultiplyAlpha): Deleted.
+        (WebCore::ImageFrame::setPremultiplyAlpha): Deleted.
+        * platform/image-decoders/bmp/BMPImageDecoder.cpp:
+        (WebCore::BMPImageDecoder::frameBufferAtIndex):
+        * platform/image-decoders/bmp/BMPImageReader.cpp:
+        (WebCore::BMPImageReader::decodeBMP):
+        * platform/image-decoders/gif/GIFImageDecoder.cpp:
+        (WebCore::GIFImageDecoder::decode):
+        (WebCore::GIFImageDecoder::initFrameBuffer):
+        * platform/image-decoders/ico/ICOImageDecoder.cpp:
+        (WebCore::ICOImageDecoder::frameCount):
+        * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
+        (WebCore::JPEGImageDecoder::frameBufferAtIndex):
+        (WebCore::JPEGImageDecoder::outputScanlines):
+        * platform/image-decoders/png/PNGImageDecoder.cpp:
+        (WebCore::PNGImageDecoder::frameBufferAtIndex):
+        (WebCore::PNGImageDecoder::rowAvailable):
+        (WebCore::PNGImageDecoder::readChunks):
+        (WebCore::PNGImageDecoder::initFrameBuffer):
+        (WebCore::setPixelRGB): Deleted.
+        (WebCore::setPixelRGBA): Deleted.
+        (WebCore::setPixelPremultipliedRGBA): Deleted.
+        * platform/image-decoders/webp/WEBPImageDecoder.cpp:
+        (WebCore::WEBPImageDecoder::frameBufferAtIndex):
+        (WebCore::WEBPImageDecoder::decode):
+
</ins><span class="cx"> 2016-09-12  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win][Direct2D] Provide Direct2D-based geometry and transform cast operations
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersImageDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/ImageDecoder.cpp (205876 => 205877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/ImageDecoder.cpp        2016-09-13 20:47:15 UTC (rev 205876)
+++ trunk/Source/WebCore/platform/image-decoders/ImageDecoder.cpp        2016-09-13 20:56:22 UTC (rev 205877)
</span><span class="lines">@@ -132,7 +132,6 @@
</span><span class="cx">     , m_status(FrameEmpty)
</span><span class="cx">     , m_duration(0)
</span><span class="cx">     , m_disposalMethod(DisposeNotSpecified)
</span><del>-    , m_premultiplyAlpha(true)
</del><span class="cx"> {
</span><span class="cx"> } 
</span><span class="cx"> 
</span><span class="lines">@@ -141,12 +140,13 @@
</span><span class="cx">     if (this == &amp;other)
</span><span class="cx">         return *this;
</span><span class="cx"> 
</span><del>-    copyBitmapData(other);
</del><ins>+    if (other.backingStore())
+        initializeBackingStore(*other.backingStore());
+
</ins><span class="cx">     setHasAlpha(other.m_hasAlpha);
</span><span class="cx">     setStatus(other.status());
</span><span class="cx">     setDuration(other.duration());
</span><span class="cx">     setDisposalMethod(other.disposalMethod());
</span><del>-    setPremultiplyAlpha(other.premultiplyAlpha());
</del><span class="cx">     return *this;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -175,23 +175,21 @@
</span><span class="cx">     setHasAlpha(true);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageFrame::copyBitmapData(const ImageFrame&amp; other)
</del><ins>+bool ImageFrame::initializeBackingStore(const ImageBackingStore&amp; backingStore)
</ins><span class="cx"> {
</span><del>-    if (this == &amp;other)
</del><ins>+    if (&amp;backingStore == this-&gt;backingStore())
</ins><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    if (other.m_backingStore)
-        m_backingStore = ImageBackingStore::create(*other.m_backingStore.get());
-    else
-        m_backingStore = nullptr;
-    
-    return true;
</del><ins>+    m_backingStore = ImageBackingStore::create(backingStore);
+    return m_backingStore != nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageFrame::setSize(const IntSize&amp; size)
</del><ins>+bool ImageFrame::initializeBackingStore(const IntSize&amp; size, bool premultiplyAlpha)
</ins><span class="cx"> {
</span><del>-    ASSERT(!m_backingStore);
-    m_backingStore = ImageBackingStore::create(size, m_premultiplyAlpha);
</del><ins>+    if (size.isEmpty())
+        return false;
+
+    m_backingStore = ImageBackingStore::create(size, premultiplyAlpha);
</ins><span class="cx">     return m_backingStore != nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersImageDecoderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h (205876 => 205877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h        2016-09-13 20:47:15 UTC (rev 205876)
+++ trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h        2016-09-13 20:56:22 UTC (rev 205877)
</span><span class="lines">@@ -72,12 +72,7 @@
</span><span class="cx">         void clearPixelData();
</span><span class="cx">         void zeroFillPixelData();
</span><span class="cx">         void zeroFillFrameRect(const IntRect&amp;);
</span><del>-
-        // Makes this frame have an independent copy of the provided image's
-        // pixel data, so that modifications in one frame are not reflected in
-        // the other.  Returns whether the copy succeeded.
-        bool copyBitmapData(const ImageFrame&amp;);
-
</del><ins>+        
</ins><span class="cx">         // Copies the pixel data at [(startX, startY), (endX, startY)) to the
</span><span class="cx">         // same X-coordinates on each subsequent row up to but not including
</span><span class="cx">         // endY.
</span><span class="lines">@@ -86,10 +81,14 @@
</span><span class="cx">             m_backingStore-&gt;repeatFirstRow(IntRect(startX, startY, endX -startX , endY - startY));
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        // Allocates space for the pixel data.  Must be called before any pixels
-        // are written.  Must only be called once.  Returns whether allocation
-        // succeeded.
-        bool setSize(const IntSize&amp;);
</del><ins>+        // Makes this frame have an independent copy of the provided image's
+        // pixel data, so that modifications in one frame are not reflected in
+        // the other. Returns whether the copy succeeded.
+        bool initializeBackingStore(const ImageBackingStore&amp;);
+
+        // Allocates space for the pixel data. Returns whether allocation succeeded.
+        bool initializeBackingStore(const IntSize&amp;, bool premultiplyAlpha);
+
</ins><span class="cx">         IntSize size() const { return m_backingStore ? m_backingStore-&gt;size() : IntSize(); }
</span><span class="cx"> 
</span><span class="cx">         // Returns a caller-owned pointer to the underlying native image data.
</span><span class="lines">@@ -105,7 +104,6 @@
</span><span class="cx">         FrameStatus status() const { return m_status; }
</span><span class="cx">         unsigned duration() const { return m_duration; }
</span><span class="cx">         FrameDisposalMethod disposalMethod() const { return m_disposalMethod; }
</span><del>-        bool premultiplyAlpha() const { return m_premultiplyAlpha; }
</del><span class="cx"> 
</span><span class="cx">         void setHasAlpha(bool alpha);
</span><span class="cx">         void setOriginalFrameRect(const IntRect&amp;);
</span><span class="lines">@@ -112,7 +110,6 @@
</span><span class="cx">         void setStatus(FrameStatus status);
</span><span class="cx">         void setDuration(unsigned duration) { m_duration = duration; }
</span><span class="cx">         void setDisposalMethod(FrameDisposalMethod method) { m_disposalMethod = method; }
</span><del>-        void setPremultiplyAlpha(bool premultiplyAlpha) { m_premultiplyAlpha = premultiplyAlpha; }
</del><span class="cx"> 
</span><span class="cx">         inline RGBA32* pixelAt(int x, int y)
</span><span class="cx">         {
</span><span class="lines">@@ -146,7 +143,6 @@
</span><span class="cx">         FrameStatus m_status;
</span><span class="cx">         unsigned m_duration;
</span><span class="cx">         FrameDisposalMethod m_disposalMethod;
</span><del>-        bool m_premultiplyAlpha;
</del><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     // ImageDecoder is a base for all format-specific decoders
</span><span class="lines">@@ -174,6 +170,8 @@
</span><span class="cx">         static std::unique_ptr&lt;ImageDecoder&gt; create(const SharedBuffer&amp; data, ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption);
</span><span class="cx"> 
</span><span class="cx">         virtual String filenameExtension() const = 0;
</span><ins>+        
+        bool premultiplyAlpha() const { return m_premultiplyAlpha; }
</ins><span class="cx"> 
</span><span class="cx">         bool isAllDataReceived() const { return m_isAllDataReceived; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersbmpBMPImageDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp (205876 => 205877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp        2016-09-13 20:47:15 UTC (rev 205876)
+++ trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp        2016-09-13 20:56:22 UTC (rev 205877)
</span><span class="lines">@@ -70,10 +70,8 @@
</span><span class="cx">     if (index)
</span><span class="cx">         return 0;
</span><span class="cx"> 
</span><del>-    if (m_frameBufferCache.isEmpty()) {
</del><ins>+    if (m_frameBufferCache.isEmpty())
</ins><span class="cx">         m_frameBufferCache.resize(1);
</span><del>-        m_frameBufferCache.first().setPremultiplyAlpha(m_premultiplyAlpha);
-    }
</del><span class="cx"> 
</span><span class="cx">     ImageFrame* buffer = &amp;m_frameBufferCache.first();
</span><span class="cx">     if (buffer-&gt;status() != ImageFrame::FrameComplete)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersbmpBMPImageReadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageReader.cpp (205876 => 205877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageReader.cpp        2016-09-13 20:47:15 UTC (rev 205876)
+++ trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageReader.cpp        2016-09-13 20:56:22 UTC (rev 205877)
</span><span class="lines">@@ -78,12 +78,10 @@
</span><span class="cx">     // Initialize the framebuffer if needed.
</span><span class="cx">     ASSERT(m_buffer);  // Parent should set this before asking us to decode!
</span><span class="cx">     if (m_buffer-&gt;status() == ImageFrame::FrameEmpty) {
</span><del>-        if (!m_buffer-&gt;setSize(m_parent-&gt;size()))
</del><ins>+        if (!m_buffer-&gt;initializeBackingStore(m_parent-&gt;size(), m_parent-&gt;premultiplyAlpha()))
</ins><span class="cx">             return m_parent-&gt;setFailed(); // Unable to allocate.
</span><ins>+
</ins><span class="cx">         m_buffer-&gt;setStatus(ImageFrame::FramePartial);
</span><del>-        // setSize() calls eraseARGB(), which resets the alpha flag, so we force
-        // it back to false here.  We'll set it true below in all cases where
-        // these 0s could actually show through.
</del><span class="cx">         m_buffer-&gt;setHasAlpha(false);
</span><span class="cx"> 
</span><span class="cx">         if (!m_isTopDown)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersgifGIFImageDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp (205876 => 205877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp        2016-09-13 20:47:15 UTC (rev 205876)
+++ trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp        2016-09-13 20:56:22 UTC (rev 205877)
</span><span class="lines">@@ -321,10 +321,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    const size_t oldSize = m_frameBufferCache.size();
</del><span class="cx">     m_frameBufferCache.resize(m_reader-&gt;imagesCount());
</span><del>-    for (size_t i = oldSize; i &lt; m_reader-&gt;imagesCount(); ++i)
-        m_frameBufferCache[i].setPremultiplyAlpha(m_premultiplyAlpha);
</del><span class="cx"> 
</span><span class="cx">     if (query == GIFFrameCountQuery)
</span><span class="cx">         return;
</span><span class="lines">@@ -361,7 +358,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (!frameIndex) {
</span><span class="cx">         // This is the first frame, so we're not relying on any previous data.
</span><del>-        if (!buffer-&gt;setSize(scaledSize()))
</del><ins>+        if (!buffer-&gt;initializeBackingStore(scaledSize(), m_premultiplyAlpha))
</ins><span class="cx">             return setFailed();
</span><span class="cx">     } else {
</span><span class="cx">         // The starting state for this frame depends on the previous frame's
</span><span class="lines">@@ -382,7 +379,7 @@
</span><span class="cx"> 
</span><span class="cx">         if ((prevMethod == ImageFrame::DisposeNotSpecified) || (prevMethod == ImageFrame::DisposeKeep)) {
</span><span class="cx">             // Preserve the last frame as the starting state for this frame.
</span><del>-            if (!buffer-&gt;copyBitmapData(*prevBuffer))
</del><ins>+            if (!prevBuffer-&gt;backingStore() || !buffer-&gt;initializeBackingStore(*prevBuffer-&gt;backingStore()))
</ins><span class="cx">                 return setFailed();
</span><span class="cx">         } else {
</span><span class="cx">             // We want to clear the previous frame to transparent, without
</span><span class="lines">@@ -392,11 +389,11 @@
</span><span class="cx">             if (!frameIndex || prevRect.contains(IntRect(IntPoint(), scaledSize()))) {
</span><span class="cx">                 // Clearing the first frame, or a frame the size of the whole
</span><span class="cx">                 // image, results in a completely empty image.
</span><del>-                if (!buffer-&gt;setSize(bufferSize))
</del><ins>+                if (!buffer-&gt;initializeBackingStore(bufferSize, m_premultiplyAlpha))
</ins><span class="cx">                     return setFailed();
</span><span class="cx">             } else {
</span><span class="cx">                 // Copy the whole previous buffer, then clear just its frame.
</span><del>-                if (!buffer-&gt;copyBitmapData(*prevBuffer))
</del><ins>+                if (!prevBuffer-&gt;backingStore() || !buffer-&gt;initializeBackingStore(*prevBuffer-&gt;backingStore()))
</ins><span class="cx">                     return setFailed();
</span><span class="cx">                 buffer-&gt;zeroFillFrameRect(prevRect);
</span><span class="cx">             }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersicoICOImageDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp (205876 => 205877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp        2016-09-13 20:47:15 UTC (rev 205876)
+++ trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp        2016-09-13 20:56:22 UTC (rev 205877)
</span><span class="lines">@@ -98,11 +98,8 @@
</span><span class="cx"> size_t ICOImageDecoder::frameCount()
</span><span class="cx"> {
</span><span class="cx">     decode(0, true);
</span><del>-    if (m_frameBufferCache.isEmpty()) {
</del><ins>+    if (m_frameBufferCache.isEmpty())
</ins><span class="cx">         m_frameBufferCache.resize(m_dirEntries.size());
</span><del>-        for (size_t i = 0; i &lt; m_dirEntries.size(); ++i)
-            m_frameBufferCache[i].setPremultiplyAlpha(m_premultiplyAlpha);
-    }
</del><span class="cx">     // CAUTION: We must not resize m_frameBufferCache again after this, as
</span><span class="cx">     // decodeAtIndex() may give a BMPImageReader a pointer to one of the
</span><span class="cx">     // entries.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersjpegJPEGImageDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp (205876 => 205877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp        2016-09-13 20:47:15 UTC (rev 205876)
+++ trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp        2016-09-13 20:56:22 UTC (rev 205877)
</span><span class="lines">@@ -533,10 +533,8 @@
</span><span class="cx">     if (index)
</span><span class="cx">         return 0;
</span><span class="cx"> 
</span><del>-    if (m_frameBufferCache.isEmpty()) {
</del><ins>+    if (m_frameBufferCache.isEmpty())
</ins><span class="cx">         m_frameBufferCache.resize(1);
</span><del>-        m_frameBufferCache[0].setPremultiplyAlpha(m_premultiplyAlpha);
-    }
</del><span class="cx"> 
</span><span class="cx">     ImageFrame&amp; frame = m_frameBufferCache[0];
</span><span class="cx">     if (frame.status() != ImageFrame::FrameComplete)
</span><span class="lines">@@ -617,7 +615,7 @@
</span><span class="cx">     // Initialize the framebuffer if needed.
</span><span class="cx">     ImageFrame&amp; buffer = m_frameBufferCache[0];
</span><span class="cx">     if (buffer.status() == ImageFrame::FrameEmpty) {
</span><del>-        if (!buffer.setSize(scaledSize()))
</del><ins>+        if (!buffer.initializeBackingStore(scaledSize(), m_premultiplyAlpha))
</ins><span class="cx">             return setFailed();
</span><span class="cx">         buffer.setStatus(ImageFrame::FramePartial);
</span><span class="cx">         // The buffer is transparent outside the decoded area while the image is
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecoderspngPNGImageDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp (205876 => 205877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp        2016-09-13 20:47:15 UTC (rev 205876)
+++ trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp        2016-09-13 20:56:22 UTC (rev 205877)
</span><span class="lines">@@ -257,10 +257,8 @@
</span><span class="cx">         return nullptr;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (m_frameBufferCache.isEmpty()) {
</del><ins>+    if (m_frameBufferCache.isEmpty())
</ins><span class="cx">         m_frameBufferCache.resize(1);
</span><del>-        m_frameBufferCache[0].setPremultiplyAlpha(m_premultiplyAlpha);
-    }
</del><span class="cx"> 
</span><span class="cx">     ImageFrame&amp; frame = m_frameBufferCache[index];
</span><span class="cx">     if (frame.status() != ImageFrame::FrameComplete)
</span><span class="lines">@@ -411,29 +409,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline void setPixelRGB(RGBA32* dest, png_bytep pixel)
-{
-    *dest = 0xFF000000U | pixel[0] &lt;&lt; 16 | pixel[1] &lt;&lt; 8 | pixel[2];
-}
-
-static inline void setPixelRGBA(RGBA32* dest, png_bytep pixel, unsigned char&amp; nonTrivialAlphaMask)
-{
-    unsigned char a = pixel[3];
-    *dest = a &lt;&lt; 24 | pixel[0] &lt;&lt; 16 | pixel[1] &lt;&lt; 8 | pixel[2];
-    nonTrivialAlphaMask |= (255 - a);
-}
-
-static inline void setPixelPremultipliedRGBA(RGBA32* dest, png_bytep pixel, unsigned char&amp; nonTrivialAlphaMask)
-{
-    unsigned char a = pixel[3];
-    unsigned char r = fastDivideBy255(pixel[0] * a);
-    unsigned char g = fastDivideBy255(pixel[1] * a);
-    unsigned char b = fastDivideBy255(pixel[2] * a);
-
-    *dest = a &lt;&lt; 24 | r &lt;&lt; 16 | g &lt;&lt; 8 | b;
-    nonTrivialAlphaMask |= (255 - a);
-}
-
</del><span class="cx"> void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex, int)
</span><span class="cx"> {
</span><span class="cx">     if (m_frameBufferCache.isEmpty())
</span><span class="lines">@@ -447,7 +422,7 @@
</span><span class="cx">     ImageFrame&amp; buffer = m_frameBufferCache[m_currentFrame];
</span><span class="cx">     if (buffer.status() == ImageFrame::FrameEmpty) {
</span><span class="cx">         png_structp png = m_reader-&gt;pngPtr();
</span><del>-        if (!buffer.setSize(scaledSize())) {
</del><ins>+        if (!buffer.initializeBackingStore(scaledSize(), m_premultiplyAlpha)) {
</ins><span class="cx">             longjmp(JMPBUF(png), 1);
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="lines">@@ -534,10 +509,10 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
</span><span class="cx">     if (m_scaled) {
</span><del>-        for (int x = 0; x &lt; width; ++x) {
</del><ins>+        for (int x = 0; x &lt; width; ++x, ++address) {
</ins><span class="cx">             png_bytep pixel = row + m_scaledColumns[x] * colorChannels;
</span><span class="cx">             unsigned alpha = hasAlpha ? pixel[3] : 255;
</span><del>-            buffer.setPixel(address++, pixel[0], pixel[1], pixel[2], alpha);
</del><ins>+            buffer.setPixel(address, pixel[0], pixel[1], pixel[2], alpha);
</ins><span class="cx">             nonTrivialAlphaMask |= (255 - alpha);
</span><span class="cx">         }
</span><span class="cx">     } else
</span><span class="lines">@@ -545,20 +520,17 @@
</span><span class="cx">     {
</span><span class="cx">         png_bytep pixel = row;
</span><span class="cx">         if (hasAlpha) {
</span><del>-            if (buffer.premultiplyAlpha()) {
-                for (int x = 0; x &lt; width; ++x, pixel += 4)
-                    setPixelPremultipliedRGBA(address++, pixel, nonTrivialAlphaMask);
-            } else {
-                for (int x = 0; x &lt; width; ++x, pixel += 4)
-                    setPixelRGBA(address++, pixel, nonTrivialAlphaMask);
</del><ins>+            for (int x = 0; x &lt; width; ++x, pixel += 4, ++address) {
+                unsigned alpha = pixel[3];
+                buffer.setPixel(address, pixel[0], pixel[1], pixel[2], alpha);
+                nonTrivialAlphaMask |= (255 - alpha);
</ins><span class="cx">             }
</span><span class="cx">         } else {
</span><del>-            for (int x = 0; x &lt; width; ++x, pixel += 3)
-                setPixelRGB(address++, pixel);
</del><ins>+            for (int x = 0; x &lt; width; ++x, pixel += 3, ++address)
+                *address = makeRGB(pixel[0], pixel[1], pixel[2]);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-
</del><span class="cx">     if (nonTrivialAlphaMask &amp;&amp; !buffer.hasAlpha())
</span><span class="cx">         buffer.setHasAlpha(true);
</span><span class="cx"> }
</span><span class="lines">@@ -618,8 +590,6 @@
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         m_frameBufferCache.resize(m_frameCount);
</span><del>-        for (auto&amp; imageFrame : m_frameBufferCache)
-            imageFrame.setPremultiplyAlpha(m_premultiplyAlpha);
</del><span class="cx">     } else if (!memcmp(chunk-&gt;name, &quot;fcTL&quot;, 4) &amp;&amp; chunk-&gt;size == 26) {
</span><span class="cx">         if (m_hasInfo &amp;&amp; !m_isAnimated)
</span><span class="cx">             return;
</span><span class="lines">@@ -661,10 +631,8 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (m_frameBufferCache.isEmpty()) {
</del><ins>+        if (m_frameBufferCache.isEmpty())
</ins><span class="cx">             m_frameBufferCache.resize(1);
</span><del>-            m_frameBufferCache[0].setPremultiplyAlpha(m_premultiplyAlpha);
-        }
</del><span class="cx"> 
</span><span class="cx">         if (m_currentFrame &lt; m_frameBufferCache.size()) {
</span><span class="cx">             ImageFrame&amp; buffer = m_frameBufferCache[m_currentFrame];
</span><span class="lines">@@ -809,11 +777,14 @@
</span><span class="cx">         prevBuffer = &amp;m_frameBufferCache[--frameIndex];
</span><span class="cx">         prevMethod = prevBuffer-&gt;disposalMethod();
</span><span class="cx">     }
</span><ins>+
+    png_structp png = m_reader-&gt;pngPtr();
</ins><span class="cx">     ASSERT(prevBuffer-&gt;status() == ImageFrame::FrameComplete);
</span><span class="cx"> 
</span><span class="cx">     if (prevMethod == ImageFrame::DisposeKeep) {
</span><span class="cx">         // Preserve the last frame as the starting state for this frame.
</span><del>-        buffer.copyBitmapData(*prevBuffer);
</del><ins>+        if (!prevBuffer-&gt;backingStore() || !buffer.initializeBackingStore(*prevBuffer-&gt;backingStore()))
+            longjmp(JMPBUF(png), 1);
</ins><span class="cx">     } else {
</span><span class="cx">         // We want to clear the previous frame to transparent, without
</span><span class="cx">         // affecting pixels in the image outside of the frame.
</span><span class="lines">@@ -824,7 +795,10 @@
</span><span class="cx">             buffer.zeroFillPixelData();
</span><span class="cx">         } else {
</span><span class="cx">             // Copy the whole previous buffer, then clear just its frame.
</span><del>-            buffer.copyBitmapData(*prevBuffer);
</del><ins>+            if (!prevBuffer-&gt;backingStore() || !buffer.initializeBackingStore(*prevBuffer-&gt;backingStore())) {
+                longjmp(JMPBUF(png), 1);
+                return;
+            }
</ins><span class="cx">             buffer.zeroFillFrameRect(prevRect);
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecoderswebpWEBPImageDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp (205876 => 205877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp        2016-09-13 20:47:15 UTC (rev 205876)
+++ trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp        2016-09-13 20:56:22 UTC (rev 205877)
</span><span class="lines">@@ -78,10 +78,8 @@
</span><span class="cx">     if (index)
</span><span class="cx">         return 0;
</span><span class="cx"> 
</span><del>-    if (m_frameBufferCache.isEmpty()) {
</del><ins>+    if (m_frameBufferCache.isEmpty())
</ins><span class="cx">         m_frameBufferCache.resize(1);
</span><del>-        m_frameBufferCache[0].setPremultiplyAlpha(m_premultiplyAlpha);
-    }
</del><span class="cx"> 
</span><span class="cx">     ImageFrame&amp; frame = m_frameBufferCache[0];
</span><span class="cx">     if (frame.status() != ImageFrame::FrameComplete)
</span><span class="lines">@@ -128,7 +126,7 @@
</span><span class="cx">     ASSERT(buffer.status() != ImageFrame::FrameComplete);
</span><span class="cx"> 
</span><span class="cx">     if (buffer.status() == ImageFrame::FrameEmpty) {
</span><del>-        if (!buffer.setSize(size()))
</del><ins>+        if (!buffer.initializeBackingStore(size(), m_premultiplyAlpha))
</ins><span class="cx">             return setFailed();
</span><span class="cx">         buffer.setStatus(ImageFrame::FramePartial);
</span><span class="cx">         buffer.setHasAlpha(m_hasAlpha);
</span></span></pre>
</div>
</div>

</body>
</html>