<!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>[199290] trunk</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/199290">199290</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-04-11 00:29:33 -0700 (Mon, 11 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge CG ImageSource and non CG ImageSource implementation in one file
https://bugs.webkit.org/show_bug.cgi?id=155456

Patch by Said Abou-Hallawa &lt;sabouhallawa@apple,com&gt; on 2016-04-11
Reviewed by Darin Adler.
Source/WebCore:

ImageSource for CG and CG code paths look very similar. All the platform
specific code can be moved to ImageDecoder classes for CG and non CG. And
we can have the ImageSource be platform independent and we get rid of
ImageSourceCG.cpp.

Test: fast/images/image-subsampling.html

* CMakeLists.txt:
* PlatformAppleWin.cmake:
* PlatformMac.cmake:
* WebCore.xcodeproj/project.pbxproj:
Delete ImageSourceCG.cpp form all make files and add ImageSource.cpp to
CMakeLists.txt.

* platform/Cursor.cpp:
(WebCore::determineHotSpot):
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::hotSpot):
(WebCore::BitmapImage::getHotSpot): Deleted.
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
(WebCore::Image::hotSpot):
(WebCore::Image::getHotSpot): Deleted.
Rename getHotSpot() to hotSpot() and change it to return Optional&lt;IntPoint&gt;.

* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::~ImageSource): Remove clear(true) call. It does nothing.
(WebCore::ImageSource::clearFrameBufferCache): A wrapper which calls ImageDecoder::clearFrameBufferCache().
(WebCore::ImageSource::clear): Calls clearFrameBufferCache() which will do nothing for CG.

(WebCore::ImageSource::ensureDecoderIsCreated): Change SharedBuffer* to
const SharedBuffer&amp; and remove the call to ImageDecoder::setMaxNumPixels().
The value of const static int CG ImageDecoder::m_maxNumPixels will be set
based on IMAGE_DECODER_DOWN_SAMPLING.

(WebCore::ImageSource::setData): Pass SharedBuffer&amp; to the underlying functions.

(WebCore::ImageSource::calculateMaximumSubsamplingLevel): Returns the maximum
subsampling level allowed for an image.

(WebCore::ImageSource::subsamplingLevelForScale): Converts from a scale to
SubsamplingLevel taking into consideration the maximumSubsamplingLevel for
a particular image.

(WebCore::ImageSource::bytesDecodedToDetermineProperties): Returns the number
of encoded bytes which can determine the image properties. For non CG it's
zero. For CG it is a maximum value which can be corrected later.

(WebCore::ImageSource::isSizeAvailable):
(WebCore::ImageSource::sizeRespectingOrientation):
(WebCore::ImageSource::frameCount):
(WebCore::ImageSource::repetitionCount):
(WebCore::ImageSource::filenameExtension):
(WebCore::ImageSource::getHotSpot):
(WebCore::ImageSource::frameIsCompleteAtIndex):
(WebCore::ImageSource::frameHasAlphaAtIndex):
(WebCore::ImageSource::allowSubsamplingOfFrameAtIndex):
(WebCore::ImageSource::frameSizeAtIndex):
(WebCore::ImageSource::frameBytesAtIndex):
(WebCore::ImageSource::frameDurationAtIndex):
(WebCore::ImageSource::orientationAtIndex):
(WebCore::ImageSource::createFrameImageAtIndex):
These are wrappers for the ImageDecoder APIs. The purpose of these functions
is to ensure the ImageDecoder is created.

(WebCore::ImageSource::dump): Called from BitmapImage::dump().

(WebCore::ImageSource::getHotSpot): Deleted.

* platform/graphics/ImageSource.h:
(WebCore::ImageSource::setAllowSubsampling): Called from BitmapImage::setAllowSubsampling().

(WebCore::ImageSource::maxPixelsPerDecodedImage): Deleted.
(WebCore::ImageSource::setMaxPixelsPerDecodedImage): Deleted.
Setting maxPixelsPerDecodedImage was moved to the non CG ImageDecoder.

* platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::ImageDecoder::setData): Change SharedBuffer* to SharedBuffer&amp;.

(WebCore::ImageDecoder::subsamplingLevelForScale): Deleted.
The code was moved to ImageSource::subsamplingLevelForScale().

* platform/graphics/cg/ImageDecoderCG.h:
(WebCore::ImageDecoder::create): Make the prototype of this function
suitable for CG and non CG cases.
(WebCore::ImageDecoder::clearFrameBufferCache): Empty functions for CG.

* platform/graphics/cg/ImageSourceCG.cpp: Removed.

* platform/image-decoders/ImageDecoder.cpp:
(WebCore::ImageDecoder::frameIsCompleteAtIndex): A mew function to return
whether the frame decoding is complete or not.

(WebCore::ImageDecoder::frameHasAlphaAtIndex): Simplify the logic.

(WebCore::ImageDecoder::frameDurationAtIndex): The code was moved from
ImageSource::frameDurationAtIndex() in ImageSource.cpp.

(WebCore::ImageDecoder::createFrameImageAtIndex): The code was moved from
ImageSource::createFrameImageAtIndex() in ImageSource.cpp.

* platform/image-decoders/ImageDecoder.h:
(WebCore::ImageDecoder::ImageDecoder): Initialize the members in class.
(WebCore::ImageDecoder::~ImageDecoder): Fix the braces style.
(WebCore::ImageDecoder::setData): Change the type of the argument from
SharedBuffer* to SharedBuffer&amp;.
(WebCore::ImageDecoder::frameSizeAtIndex): Add the argument SubsamplingLevel
so it can have the same prototype as CG.
(WebCore::ImageDecoder::orientationAtIndex): Rename it to the same of CG.

(WebCore::ImageDecoder::allowSubsamplingOfFrameAtIndex):
(WebCore::ImageDecoder::bytesDecodedToDetermineProperties):
(WebCore::ImageDecoder::subsamplingLevelForScale): Add these functions
and return the default values so we do not have to add directive compiled
non CG blocks in ImageSource.cpp.

(WebCore::ImageDecoder::hotSpot): Return Optional&lt;IntPoint&gt;.

(WebCore::ImageDecoder::orientation): Deleted.
(WebCore::ImageDecoder::setMaxNumPixels): Deleted.

* platform/image-decoders/bmp/BMPImageDecoder.cpp:
(WebCore::BMPImageDecoder::setData):
* platform/image-decoders/bmp/BMPImageDecoder.h:
* platform/image-decoders/gif/GIFImageDecoder.cpp:
(WebCore::GIFImageDecoder::setData):
(WebCore::GIFImageDecoder::decode):
* platform/image-decoders/gif/GIFImageDecoder.h:
* platform/image-decoders/gif/GIFImageReader.h:
(GIFImageReader::setData):
* platform/image-decoders/ico/ICOImageDecoder.cpp:
(WebCore::ICOImageDecoder::setData):
Use reference SharedBuffer instead of pointer SharedBuffer.

(WebCore::ICOImageDecoder::hotSpot):
(WebCore::ICOImageDecoder::hotSpotAtIndex):
Change hotSpot() to return Optional&lt;IntPoint&gt;.
* platform/image-decoders/ico/ICOImageDecoder.h:

(WebCore::ICOImageDecoder::setDataForPNGDecoderAtIndex):
Pass reference SharedBuffer instead of pointer SharedBuffer.

Source/WebKit2:

* UIProcess/API/efl/EwkView.cpp:
(EwkView::setCursor):
Replace the call to Image::getHotSpot() by Image::hotSpot().

LayoutTests:

Add a test for image sub-sampling. The image subsampling is enabled by
default for iOS platform only. But it can be explicitly enabled through
the setting ImageSubsamplingEnabled.

* fast/images/image-subsampling-expected.html: Added.
* fast/images/image-subsampling.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformAppleWincmake">trunk/Source/WebCore/PlatformAppleWin.cmake</a></li>
<li><a href="#trunkSourceWebCorePlatformMaccmake">trunk/Source/WebCore/PlatformMac.cmake</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformCursorcpp">trunk/Source/WebCore/platform/Cursor.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsBitmapImagecpp">trunk/Source/WebCore/platform/graphics/BitmapImage.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsBitmapImageh">trunk/Source/WebCore/platform/graphics/BitmapImage.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageh">trunk/Source/WebCore/platform/graphics/Image.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageSourcecpp">trunk/Source/WebCore/platform/graphics/ImageSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageSourceh">trunk/Source/WebCore/platform/graphics/ImageSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgImageDecoderCGcpp">trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgImageDecoderCGh">trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h</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="#trunkSourceWebCoreplatformimagedecodersbmpBMPImageDecoderh">trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersgifGIFImageDecodercpp">trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersgifGIFImageDecoderh">trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersgifGIFImageReaderh">trunk/Source/WebCore/platform/image-decoders/gif/GIFImageReader.h</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersicoICOImageDecodercpp">trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformimagedecodersicoICOImageDecoderh">trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIeflEwkViewcpp">trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastimagesimagesubsamplingexpectedhtml">trunk/LayoutTests/fast/images/image-subsampling-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastimagesimagesubsamplinghtml">trunk/LayoutTests/fast/images/image-subsampling.html</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicscgImageSourceCGcpp">trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/LayoutTests/ChangeLog        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-04-11  Said Abou-Hallawa  &lt;sabouhallawa@apple,com&gt;
+
+        Merge CG ImageSource and non CG ImageSource implementation in one file
+        https://bugs.webkit.org/show_bug.cgi?id=155456
+
+        Reviewed by Darin Adler.
+        
+        Add a test for image sub-sampling. The image subsampling is enabled by
+        default for iOS platform only. But it can be explicitly enabled through
+        the setting ImageSubsamplingEnabled.
+
+        * fast/images/image-subsampling-expected.html: Added.
+        * fast/images/image-subsampling.html: Added.
+
</ins><span class="cx"> 2016-04-09  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r199268.
</span></span></pre></div>
<a id="trunkLayoutTestsfastimagesimagesubsamplingexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/images/image-subsampling-expected.html (0 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/image-subsampling-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/images/image-subsampling-expected.html        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        div {
+            width: 100px;
+            height: 100px;
+            margin: 10px;
+            display: inline-block;
+        }
+    &lt;/style&gt;
+&lt;head&gt;
+&lt;body&gt;
+&lt;script&gt;
+    function createDiv(color) {
+        var divElement = document.createElement(&quot;div&quot;);
+        divElement.style.backgroundColor = color;
+        document.body.appendChild(divElement);
+    }
+
+    createDiv(&quot;red&quot;);
+    createDiv(&quot;green&quot;);
+    createDiv(&quot;blue&quot;);
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastimagesimagesubsamplinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/images/image-subsampling.html (0 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/image-subsampling.html                                (rev 0)
+++ trunk/LayoutTests/fast/images/image-subsampling.html        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        div {
+            width: 100px;
+            height: 100px;
+            margin: 10px;
+            display: inline-block;
+        }
+        img {
+            width: 100px;
+            height: 100px;
+        }
+    &lt;/style&gt;
+&lt;head&gt;
+&lt;body&gt;
+&lt;script&gt;
+    if (window.internals)
+        window.internals.settings.setImageSubsamplingEnabled(true);
+
+    function createImage(color) {
+        var canvas = document.createElement(&quot;canvas&quot;);
+        canvas.width = 1024 * 3;
+        canvas.height = 1024 * 3;
+        var ctx = canvas.getContext(&quot;2d&quot;);
+        ctx.fillStyle = color;
+        ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+        var imgElement = document.createElement(&quot;img&quot;);
+        imgElement.src = canvas.toDataURL(&quot;image/png&quot;);
+
+        var divElement = document.createElement(&quot;div&quot;);
+        divElement.appendChild(imgElement);
+        document.body.appendChild(divElement);
+    }
+    
+    createImage(&quot;red&quot;);
+    createImage(&quot;green&quot;);
+    createImage(&quot;blue&quot;);
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -2214,6 +2214,7 @@
</span><span class="cx">     platform/graphics/Image.cpp
</span><span class="cx">     platform/graphics/ImageBuffer.cpp
</span><span class="cx">     platform/graphics/ImageOrientation.cpp
</span><ins>+    platform/graphics/ImageSource.cpp
</ins><span class="cx">     platform/graphics/IntPoint.cpp
</span><span class="cx">     platform/graphics/IntRect.cpp
</span><span class="cx">     platform/graphics/IntSize.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/ChangeLog        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -1,3 +1,152 @@
</span><ins>+2016-04-11  Said Abou-Hallawa  &lt;sabouhallawa@apple,com&gt;
+
+        Merge CG ImageSource and non CG ImageSource implementation in one file
+        https://bugs.webkit.org/show_bug.cgi?id=155456
+
+        Reviewed by Darin Adler.
+
+        ImageSource for CG and CG code paths look very similar. All the platform
+        specific code can be moved to ImageDecoder classes for CG and non CG. And
+        we can have the ImageSource be platform independent and we get rid of
+        ImageSourceCG.cpp.
+
+        Test: fast/images/image-subsampling.html
+
+        * CMakeLists.txt:
+        * PlatformAppleWin.cmake:
+        * PlatformMac.cmake:
+        * WebCore.xcodeproj/project.pbxproj:
+        Delete ImageSourceCG.cpp form all make files and add ImageSource.cpp to
+        CMakeLists.txt.
+        
+        * platform/Cursor.cpp:
+        (WebCore::determineHotSpot):
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::hotSpot):
+        (WebCore::BitmapImage::getHotSpot): Deleted.
+        * platform/graphics/BitmapImage.h:
+        * platform/graphics/Image.h:
+        (WebCore::Image::hotSpot):
+        (WebCore::Image::getHotSpot): Deleted.
+        Rename getHotSpot() to hotSpot() and change it to return Optional&lt;IntPoint&gt;.
+        
+        * platform/graphics/ImageSource.cpp:
+        (WebCore::ImageSource::~ImageSource): Remove clear(true) call. It does nothing.
+        (WebCore::ImageSource::clearFrameBufferCache): A wrapper which calls ImageDecoder::clearFrameBufferCache().
+        (WebCore::ImageSource::clear): Calls clearFrameBufferCache() which will do nothing for CG.
+        
+        (WebCore::ImageSource::ensureDecoderIsCreated): Change SharedBuffer* to
+        const SharedBuffer&amp; and remove the call to ImageDecoder::setMaxNumPixels().
+        The value of const static int CG ImageDecoder::m_maxNumPixels will be set
+        based on IMAGE_DECODER_DOWN_SAMPLING.
+        
+        (WebCore::ImageSource::setData): Pass SharedBuffer&amp; to the underlying functions.
+        
+        (WebCore::ImageSource::calculateMaximumSubsamplingLevel): Returns the maximum
+        subsampling level allowed for an image.
+        
+        (WebCore::ImageSource::subsamplingLevelForScale): Converts from a scale to
+        SubsamplingLevel taking into consideration the maximumSubsamplingLevel for
+        a particular image.
+        
+        (WebCore::ImageSource::bytesDecodedToDetermineProperties): Returns the number
+        of encoded bytes which can determine the image properties. For non CG it's
+        zero. For CG it is a maximum value which can be corrected later.
+        
+        (WebCore::ImageSource::isSizeAvailable):
+        (WebCore::ImageSource::sizeRespectingOrientation):
+        (WebCore::ImageSource::frameCount):
+        (WebCore::ImageSource::repetitionCount):
+        (WebCore::ImageSource::filenameExtension):
+        (WebCore::ImageSource::getHotSpot):
+        (WebCore::ImageSource::frameIsCompleteAtIndex):
+        (WebCore::ImageSource::frameHasAlphaAtIndex):
+        (WebCore::ImageSource::allowSubsamplingOfFrameAtIndex):
+        (WebCore::ImageSource::frameSizeAtIndex):
+        (WebCore::ImageSource::frameBytesAtIndex):
+        (WebCore::ImageSource::frameDurationAtIndex):
+        (WebCore::ImageSource::orientationAtIndex):
+        (WebCore::ImageSource::createFrameImageAtIndex):
+        These are wrappers for the ImageDecoder APIs. The purpose of these functions
+        is to ensure the ImageDecoder is created.
+        
+        (WebCore::ImageSource::dump): Called from BitmapImage::dump().
+        
+        (WebCore::ImageSource::getHotSpot): Deleted.
+        
+        * platform/graphics/ImageSource.h:
+        (WebCore::ImageSource::setAllowSubsampling): Called from BitmapImage::setAllowSubsampling().
+        
+        (WebCore::ImageSource::maxPixelsPerDecodedImage): Deleted.
+        (WebCore::ImageSource::setMaxPixelsPerDecodedImage): Deleted.
+        Setting maxPixelsPerDecodedImage was moved to the non CG ImageDecoder.
+        
+        * platform/graphics/cg/ImageDecoderCG.cpp:
+        (WebCore::ImageDecoder::setData): Change SharedBuffer* to SharedBuffer&amp;.
+
+        (WebCore::ImageDecoder::subsamplingLevelForScale): Deleted.
+        The code was moved to ImageSource::subsamplingLevelForScale().
+        
+        * platform/graphics/cg/ImageDecoderCG.h:
+        (WebCore::ImageDecoder::create): Make the prototype of this function
+        suitable for CG and non CG cases.
+        (WebCore::ImageDecoder::clearFrameBufferCache): Empty functions for CG.
+        
+        * platform/graphics/cg/ImageSourceCG.cpp: Removed.
+        
+        * platform/image-decoders/ImageDecoder.cpp:
+        (WebCore::ImageDecoder::frameIsCompleteAtIndex): A mew function to return
+        whether the frame decoding is complete or not.
+        
+        (WebCore::ImageDecoder::frameHasAlphaAtIndex): Simplify the logic.
+        
+        (WebCore::ImageDecoder::frameDurationAtIndex): The code was moved from
+        ImageSource::frameDurationAtIndex() in ImageSource.cpp.
+        
+        (WebCore::ImageDecoder::createFrameImageAtIndex): The code was moved from
+        ImageSource::createFrameImageAtIndex() in ImageSource.cpp.
+        
+        * platform/image-decoders/ImageDecoder.h:
+        (WebCore::ImageDecoder::ImageDecoder): Initialize the members in class.
+        (WebCore::ImageDecoder::~ImageDecoder): Fix the braces style.
+        (WebCore::ImageDecoder::setData): Change the type of the argument from
+        SharedBuffer* to SharedBuffer&amp;.
+        (WebCore::ImageDecoder::frameSizeAtIndex): Add the argument SubsamplingLevel
+        so it can have the same prototype as CG.
+        (WebCore::ImageDecoder::orientationAtIndex): Rename it to the same of CG.
+        
+        (WebCore::ImageDecoder::allowSubsamplingOfFrameAtIndex):
+        (WebCore::ImageDecoder::bytesDecodedToDetermineProperties):
+        (WebCore::ImageDecoder::subsamplingLevelForScale): Add these functions
+        and return the default values so we do not have to add directive compiled
+        non CG blocks in ImageSource.cpp.
+
+        (WebCore::ImageDecoder::hotSpot): Return Optional&lt;IntPoint&gt;.
+        
+        (WebCore::ImageDecoder::orientation): Deleted.
+        (WebCore::ImageDecoder::setMaxNumPixels): Deleted.
+        
+        * platform/image-decoders/bmp/BMPImageDecoder.cpp:
+        (WebCore::BMPImageDecoder::setData):
+        * platform/image-decoders/bmp/BMPImageDecoder.h:
+        * platform/image-decoders/gif/GIFImageDecoder.cpp:
+        (WebCore::GIFImageDecoder::setData):
+        (WebCore::GIFImageDecoder::decode):
+        * platform/image-decoders/gif/GIFImageDecoder.h:
+        * platform/image-decoders/gif/GIFImageReader.h:
+        (GIFImageReader::setData):
+        * platform/image-decoders/ico/ICOImageDecoder.cpp:
+        (WebCore::ICOImageDecoder::setData):
+        Use reference SharedBuffer instead of pointer SharedBuffer.
+        
+        (WebCore::ICOImageDecoder::hotSpot):
+        (WebCore::ICOImageDecoder::hotSpotAtIndex):
+        Change hotSpot() to return Optional&lt;IntPoint&gt;.
+        * platform/image-decoders/ico/ICOImageDecoder.h:
+                
+        (WebCore::ICOImageDecoder::setDataForPNGDecoderAtIndex):
+        Pass reference SharedBuffer instead of pointer SharedBuffer.
+
</ins><span class="cx"> 2016-04-11  Fujii Hironori  &lt;Hironori.Fujii@jp.sony.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CMake] Make FOLDER property INHERITED
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformAppleWincmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformAppleWin.cmake (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformAppleWin.cmake        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/PlatformAppleWin.cmake        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -72,7 +72,6 @@
</span><span class="cx">     platform/graphics/cg/ImageBufferDataCG.cpp
</span><span class="cx">     platform/graphics/cg/ImageCG.cpp
</span><span class="cx">     platform/graphics/cg/ImageDecoderCG.cpp
</span><del>-    platform/graphics/cg/ImageSourceCG.cpp
</del><span class="cx">     platform/graphics/cg/ImageSourceCGWin.cpp
</span><span class="cx">     platform/graphics/cg/IntPointCG.cpp
</span><span class="cx">     platform/graphics/cg/IntRectCG.cpp
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformMaccmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformMac.cmake (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformMac.cmake        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/PlatformMac.cmake        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -406,7 +406,6 @@
</span><span class="cx">     platform/graphics/cg/ImageBufferDataCG.cpp
</span><span class="cx">     platform/graphics/cg/ImageCG.cpp
</span><span class="cx">     platform/graphics/cg/ImageDecoderCG.cpp
</span><del>-    platform/graphics/cg/ImageSourceCG.cpp
</del><span class="cx">     platform/graphics/cg/ImageSourceCGMac.mm
</span><span class="cx">     platform/graphics/cg/IntPointCG.cpp
</span><span class="cx">     platform/graphics/cg/IntRectCG.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -4986,7 +4986,6 @@
</span><span class="cx">                 B275355A0B053814002CE64F /* FloatRectCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B275352C0B053814002CE64F /* FloatRectCG.cpp */; };
</span><span class="cx">                 B275355B0B053814002CE64F /* FloatSizeCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B275352D0B053814002CE64F /* FloatSizeCG.cpp */; };
</span><span class="cx">                 B275355E0B053814002CE64F /* ImageCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B27535300B053814002CE64F /* ImageCG.cpp */; };
</span><del>-                B275355F0B053814002CE64F /* ImageSourceCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B27535310B053814002CE64F /* ImageSourceCG.cpp */; };
</del><span class="cx">                 B27535600B053814002CE64F /* IntPointCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B27535320B053814002CE64F /* IntPointCG.cpp */; };
</span><span class="cx">                 B27535610B053814002CE64F /* IntRectCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B27535330B053814002CE64F /* IntRectCG.cpp */; };
</span><span class="cx">                 B27535620B053814002CE64F /* IntSizeCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B27535340B053814002CE64F /* IntSizeCG.cpp */; };
</span><span class="lines">@@ -12877,7 +12876,6 @@
</span><span class="cx">                 B275352C0B053814002CE64F /* FloatRectCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FloatRectCG.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 B275352D0B053814002CE64F /* FloatSizeCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FloatSizeCG.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 B27535300B053814002CE64F /* ImageCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ImageCG.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                B27535310B053814002CE64F /* ImageSourceCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ImageSourceCG.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 B27535320B053814002CE64F /* IntPointCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IntPointCG.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 B27535330B053814002CE64F /* IntRectCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IntRectCG.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 B27535340B053814002CE64F /* IntSizeCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IntSizeCG.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -21785,7 +21783,6 @@
</span><span class="cx">                                 B27535300B053814002CE64F /* ImageCG.cpp */,
</span><span class="cx">                                 555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */,
</span><span class="cx">                                 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */,
</span><del>-                                B27535310B053814002CE64F /* ImageSourceCG.cpp */,
</del><span class="cx">                                 4B3480920EEF50D400AC1B41 /* ImageSourceCG.h */,
</span><span class="cx">                                 4B3480910EEF50D400AC1B41 /* ImageSourceCGMac.mm */,
</span><span class="cx">                                 B27535320B053814002CE64F /* IntPointCG.cpp */,
</span><span class="lines">@@ -30004,7 +30001,6 @@
</span><span class="cx">                                 2D5A592F152525230036EE51 /* ImageOrientation.cpp in Sources */,
</span><span class="cx">                                 B51A2F4117D7D5DE0072517A /* ImageQualityController.cpp in Sources */,
</span><span class="cx">                                 0F3C725E1974874B00AEDD0C /* ImageSource.cpp in Sources */,
</span><del>-                                B275355F0B053814002CE64F /* ImageSourceCG.cpp in Sources */,
</del><span class="cx">                                 4B3480930EEF50D400AC1B41 /* ImageSourceCGMac.mm in Sources */,
</span><span class="cx">                                 316FE1170E6E1DA700BF6088 /* ImplicitAnimation.cpp in Sources */,
</span><span class="cx">                                 BE961C5418AD338500D07DC5 /* InbandDataTextTrack.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformCursorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Cursor.cpp (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Cursor.cpp        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/Cursor.cpp        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -44,10 +44,10 @@
</span><span class="cx">         return specifiedHotSpot;
</span><span class="cx"> 
</span><span class="cx">     // If hot spot is not specified externally, it can be extracted from some image formats (e.g. .cur).
</span><del>-    IntPoint intrinsicHotSpot;
-    bool imageHasIntrinsicHotSpot = image-&gt;getHotSpot(intrinsicHotSpot);
-    if (imageHasIntrinsicHotSpot &amp;&amp; imageRect.contains(intrinsicHotSpot))
-        return intrinsicHotSpot;
</del><ins>+    if (auto intrinsicHotSpot = image-&gt;hotSpot()) {
+        if (imageRect.contains(intrinsicHotSpot.value()))
+            return intrinsicHotSpot.value();
+    }
</ins><span class="cx"> 
</span><span class="cx">     return IntPoint();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsBitmapImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -254,9 +254,9 @@
</span><span class="cx">     return m_sizeRespectingOrientation;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool BitmapImage::getHotSpot(IntPoint&amp; hotSpot) const
</del><ins>+Optional&lt;IntPoint&gt; BitmapImage::hotSpot() const
</ins><span class="cx"> {
</span><del>-    bool result = m_source.getHotSpot(hotSpot);
</del><ins>+    auto result = m_source.hotSpot();
</ins><span class="cx">     didDecodeProperties();
</span><span class="cx">     return result;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsBitmapImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/BitmapImage.h        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -125,7 +125,7 @@
</span><span class="cx">     FloatSize size() const override;
</span><span class="cx">     IntSize sizeRespectingOrientation() const;
</span><span class="cx"> 
</span><del>-    bool getHotSpot(IntPoint&amp;) const override;
</del><ins>+    Optional&lt;IntPoint&gt; hotSpot() const override;
</ins><span class="cx"> 
</span><span class="cx">     unsigned decodedSize() const { return m_decodedSize; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Image.h (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Image.h        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/graphics/Image.h        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;GraphicsTypes.h&quot;
</span><span class="cx"> #include &quot;ImageOrientation.h&quot;
</span><span class="cx"> #include &quot;NativeImagePtr.h&quot;
</span><ins>+#include &lt;wtf/Optional.h&gt;
</ins><span class="cx"> #include &lt;wtf/PassRefPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="lines">@@ -107,7 +108,7 @@
</span><span class="cx">     FloatRect rect() const { return FloatRect(FloatPoint(), size()); }
</span><span class="cx">     float width() const { return size().width(); }
</span><span class="cx">     float height() const { return size().height(); }
</span><del>-    virtual bool getHotSpot(IntPoint&amp;) const { return false; }
</del><ins>+    virtual Optional&lt;IntPoint&gt; hotSpot() const { return Nullopt; }
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     virtual FloatSize originalSize() const { return size(); }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageSource.cpp (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageSource.cpp        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.cpp        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006 Apple Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2006, 2010, 2011, 2012, 2014, 2016 Apple Inc.  All rights reserved.
</ins><span class="cx">  * Copyright (C) 2007 Alp Toker &lt;alp.toker@collabora.co.uk&gt;
</span><span class="cx">  * Copyright (C) 2008, Google Inc. All rights reserved.
</span><span class="cx">  * Copyright (C) 2007-2009 Torch Mobile, Inc
</span><span class="lines">@@ -29,19 +29,16 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;ImageSource.h&quot;
</span><span class="cx"> 
</span><del>-#if !USE(CG)
-
</del><ins>+#if USE(CG)
+#include &quot;ImageDecoderCG.h&quot;
+#else
</ins><span class="cx"> #include &quot;ImageDecoder.h&quot;
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;ImageOrientation.h&quot;
</span><del>-#include &quot;NotImplemented.h&quot;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
-unsigned ImageSource::s_maxPixelsPerDecodedImage = 1024 * 1024;
-#endif
-
</del><span class="cx"> ImageSource::ImageSource(ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption)
</span><span class="cx">     : m_alphaOption(alphaOption)
</span><span class="cx">     , m_gammaAndColorProfileOption(gammaAndColorProfileOption)
</span><span class="lines">@@ -50,15 +47,22 @@
</span><span class="cx"> 
</span><span class="cx"> ImageSource::~ImageSource()
</span><span class="cx"> {
</span><del>-    clear(true);
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ImageSource::clear(bool destroyAll, size_t clearBeforeFrame, SharedBuffer* data, bool allDataReceived)
</del><ins>+void ImageSource::clearFrameBufferCache(size_t clearBeforeFrame)
</ins><span class="cx"> {
</span><del>-    if (!destroyAll) {
-        if (m_decoder)
-            m_decoder-&gt;clearFrameBufferCache(clearBeforeFrame);
</del><ins>+    if (!initialized())
</ins><span class="cx">         return;
</span><ins>+    m_decoder-&gt;clearFrameBufferCache(clearBeforeFrame);
+}
+
+void ImageSource::clear(bool destroyAllFrames, size_t clearBeforeFrame, SharedBuffer* data, bool allDataReceived)
+{
+    // There's no need to throw away the decoder unless we're explicitly asked
+    // to destroy all of the frames.
+    if (!destroyAllFrames) {
+        clearFrameBufferCache(clearBeforeFrame);
+        return;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_decoder = nullptr;
</span><span class="lines">@@ -67,20 +71,12 @@
</span><span class="cx">         setData(data, allDataReceived);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ImageSource::ensureDecoderIsCreated(SharedBuffer* data)
</del><ins>+void ImageSource::ensureDecoderIsCreated(const SharedBuffer&amp; data)
</ins><span class="cx"> {
</span><span class="cx">     if (initialized())
</span><span class="cx">         return;
</span><span class="cx">     
</span><del>-    // Make the decoder by sniffing the bytes.
-    // This method will examine the data and instantiate an instance of the appropriate decoder plugin.
-    // If insufficient bytes are available to determine the image type, no decoder plugin will be
-    // made.
-    m_decoder = ImageDecoder::create(*data, m_alphaOption, m_gammaAndColorProfileOption);
-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
-    if (m_decoder &amp;&amp; s_maxPixelsPerDecodedImage)
-        m_decoder-&gt;setMaxNumPixels(s_maxPixelsPerDecodedImage);
-#endif
</del><ins>+    m_decoder = ImageDecoder::create(data, m_alphaOption, m_gammaAndColorProfileOption);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
</span><span class="lines">@@ -88,7 +84,7 @@
</span><span class="cx">     if (!data)
</span><span class="cx">         return;
</span><span class="cx">     
</span><del>-    ensureDecoderIsCreated(data);
</del><ins>+    ensureDecoderIsCreated(*data);
</ins><span class="cx">     
</span><span class="cx">     if (!initialized()) {
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="lines">@@ -96,25 +92,48 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (m_decoder)
</span><del>-        m_decoder-&gt;setData(data, allDataReceived);
</del><ins>+        m_decoder-&gt;setData(*data, allDataReceived);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-String ImageSource::filenameExtension() const
</del><ins>+SubsamplingLevel ImageSource::calculateMaximumSubsamplingLevel() const
</ins><span class="cx"> {
</span><del>-    return m_decoder ? m_decoder-&gt;filenameExtension() : String();
</del><ins>+    if (!m_allowSubsampling || !allowSubsamplingOfFrameAtIndex(0))
+        return 0;
+    
+    // FIXME: this value was chosen to be appropriate for iOS since the image
+    // subsampling is only enabled by default on iOS. Choose a different value
+    // if image subsampling is enabled on other platform.
+    const int maximumImageAreaBeforeSubsampling = 5 * 1024 * 1024;
+    const SubsamplingLevel maxSubsamplingLevel = 3;
+    
+    for (SubsamplingLevel level = 0; level &lt; maxSubsamplingLevel; ++level) {
+        if (frameSizeAtIndex(0, level).area() &lt; maximumImageAreaBeforeSubsampling)
+            return level;
+    }
+    
+    return maxSubsamplingLevel;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-SubsamplingLevel ImageSource::subsamplingLevelForScale(float) const
</del><ins>+SubsamplingLevel ImageSource::subsamplingLevelForScale(float scale) const
</ins><span class="cx"> {
</span><del>-    return 0;
</del><ins>+    if (!(scale &gt; 0 &amp;&amp; scale &lt;= 1))
+        return 0;
+    
+    SubsamplingLevel maximumSubsamplingLevel = calculateMaximumSubsamplingLevel();
+    if (!maximumSubsamplingLevel)
+        return 0;
+
+    // There are four subsampling levels: 0 = 1x, 1 = 0.5x, 2 = 0.25x, 3 = 0.125x.
+    SubsamplingLevel result = std::ceil(std::log2(1 / scale));
+    return std::min(result, maximumSubsamplingLevel);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageSource::allowSubsamplingOfFrameAtIndex(size_t) const
</del><ins>+size_t ImageSource::bytesDecodedToDetermineProperties()
</ins><span class="cx"> {
</span><del>-    return false;
</del><ins>+    return ImageDecoder::bytesDecodedToDetermineProperties();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageSource::isSizeAvailable()
</del><ins>+bool ImageSource::isSizeAvailable() const
</ins><span class="cx"> {
</span><span class="cx">     return initialized() &amp;&amp; m_decoder-&gt;isSizeAvailable();
</span><span class="cx"> }
</span><span class="lines">@@ -129,97 +148,71 @@
</span><span class="cx">     return frameSizeAtIndex(0, 0, RespectImageOrientation);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-IntSize ImageSource::frameSizeAtIndex(size_t index, SubsamplingLevel, RespectImageOrientationEnum shouldRespectImageOrientation) const
</del><ins>+size_t ImageSource::frameCount() const
</ins><span class="cx"> {
</span><del>-    if (!initialized())
-        return { };
-
-    IntSize size = m_decoder-&gt;frameSizeAtIndex(index);
-    ImageOrientation orientation = m_decoder-&gt;orientation();
-    
-    return shouldRespectImageOrientation == RespectImageOrientation &amp;&amp; orientation.usesWidthAsHeight() ? size.transposedSize() : size;
</del><ins>+    return initialized() ? m_decoder-&gt;frameCount() : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageSource::getHotSpot(IntPoint&amp; hotSpot) const
</del><ins>+int ImageSource::repetitionCount()
</ins><span class="cx"> {
</span><del>-    return initialized() &amp;&amp; m_decoder-&gt;hotSpot(hotSpot);
</del><ins>+    return initialized() ? m_decoder-&gt;repetitionCount() : cAnimationNone;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-size_t ImageSource::bytesDecodedToDetermineProperties() const
</del><ins>+String ImageSource::filenameExtension() const
</ins><span class="cx"> {
</span><del>-    return 0;
</del><ins>+    return initialized() ? m_decoder-&gt;filenameExtension() : String();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-int ImageSource::repetitionCount()
</del><ins>+Optional&lt;IntPoint&gt; ImageSource::hotSpot() const
</ins><span class="cx"> {
</span><del>-    return initialized() ? m_decoder-&gt;repetitionCount() : cAnimationNone;
</del><ins>+    return initialized() ? m_decoder-&gt;hotSpot() : Nullopt;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-size_t ImageSource::frameCount() const
</del><ins>+bool ImageSource::frameIsCompleteAtIndex(size_t index)
</ins><span class="cx"> {
</span><del>-    return initialized() ? m_decoder-&gt;frameCount() : 0;
</del><ins>+    return initialized() &amp;&amp; m_decoder-&gt;frameIsCompleteAtIndex(index);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-NativeImagePtr ImageSource::createFrameImageAtIndex(size_t index, SubsamplingLevel)
</del><ins>+bool ImageSource::frameHasAlphaAtIndex(size_t index)
</ins><span class="cx"> {
</span><del>-    if (!initialized())
-        return nullptr;
</del><ins>+    return !initialized() || m_decoder-&gt;frameHasAlphaAtIndex(index);
+}
</ins><span class="cx"> 
</span><del>-    // Zero-height images can cause problems for some ports.  If we have an
-    // empty image dimension, just bail.
-    if (size().isEmpty())
-        return nullptr;
-
-    ImageFrame* buffer = m_decoder-&gt;frameBufferAtIndex(index);
-    if (!buffer || buffer-&gt;status() == ImageFrame::FrameEmpty)
-        return nullptr;
-
-    // Return the buffer contents as a native image.  For some ports, the data
-    // is already in a native container, and this just increments its refcount.
-    return buffer-&gt;asNewNativeImage();
</del><ins>+bool ImageSource::allowSubsamplingOfFrameAtIndex(size_t index) const
+{
+    return initialized() &amp;&amp; m_decoder-&gt;allowSubsamplingOfFrameAtIndex(index);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-float ImageSource::frameDurationAtIndex(size_t index)
</del><ins>+IntSize ImageSource::frameSizeAtIndex(size_t index, SubsamplingLevel subsamplingLevel, RespectImageOrientationEnum shouldRespectImageOrientation) const
</ins><span class="cx"> {
</span><span class="cx">     if (!initialized())
</span><del>-        return 0;
</del><ins>+        return { };
</ins><span class="cx"> 
</span><del>-    ImageFrame* buffer = m_decoder-&gt;frameBufferAtIndex(index);
-    if (!buffer || buffer-&gt;status() == ImageFrame::FrameEmpty)
-        return 0;
</del><ins>+    IntSize size = m_decoder-&gt;frameSizeAtIndex(index, subsamplingLevel);
+    if (shouldRespectImageOrientation != RespectImageOrientation)
+        return size;
</ins><span class="cx"> 
</span><del>-    // Many annoying ads specify a 0 duration to make an image flash as quickly as possible.
-    // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify
-    // a duration of &lt;= 10 ms. See &lt;rdar://problem/7689300&gt; and &lt;http://webkit.org/b/36082&gt;
-    // for more information.
-    const float duration = buffer-&gt;duration() / 1000.0f;
-    if (duration &lt; 0.011f)
-        return 0.100f;
-    return duration;
</del><ins>+    return orientationAtIndex(index).usesWidthAsHeight() ? size.transposedSize() : size;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-ImageOrientation ImageSource::orientationAtIndex(size_t) const
</del><ins>+unsigned ImageSource::frameBytesAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const
</ins><span class="cx"> {
</span><del>-    return initialized() ? m_decoder-&gt;orientation() : ImageOrientation();
</del><ins>+    return frameSizeAtIndex(index, subsamplingLevel).area() * 4;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageSource::frameHasAlphaAtIndex(size_t index)
</del><ins>+float ImageSource::frameDurationAtIndex(size_t index)
</ins><span class="cx"> {
</span><del>-    return !initialized() || m_decoder-&gt;frameHasAlphaAtIndex(index);
</del><ins>+    return initialized() ? m_decoder-&gt;frameDurationAtIndex(index) : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageSource::frameIsCompleteAtIndex(size_t index)
</del><ins>+ImageOrientation ImageSource::orientationAtIndex(size_t index) const
</ins><span class="cx"> {
</span><del>-    if (!initialized())
-        return false;
-
-    ImageFrame* buffer = m_decoder-&gt;frameBufferAtIndex(index);
-    return buffer &amp;&amp; buffer-&gt;status() == ImageFrame::FrameComplete;
</del><ins>+    return initialized() ? m_decoder-&gt;orientationAtIndex(index) : ImageOrientation();
</ins><span class="cx"> }
</span><del>-
-unsigned ImageSource::frameBytesAtIndex(size_t index, SubsamplingLevel) const
</del><ins>+    
+NativeImagePtr ImageSource::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel)
</ins><span class="cx"> {
</span><del>-    return initialized() ? m_decoder-&gt;frameBytesAtIndex(index) : 0;
</del><ins>+    return initialized() ? m_decoder-&gt;createFrameImageAtIndex(index, subsamplingLevel) : nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ImageSource::dump(TextStream&amp; ts) const
</span><span class="lines">@@ -233,5 +226,3 @@
</span><span class="cx"> }
</span><span class="cx">     
</span><span class="cx"> }
</span><del>-
-#endif // USE(CG)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageSource.h (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageSource.h        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.h        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2004, 2005, 2006 Apple Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012, 2014, 2016 Apple Inc.  All rights reserved.
</ins><span class="cx">  * Copyright (C) 2007-2008 Torch Mobile, Inc.
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -28,18 +28,15 @@
</span><span class="cx"> #define ImageSource_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ImageOrientation.h&quot;
</span><ins>+#include &quot;IntPoint.h&quot;
</ins><span class="cx"> #include &quot;NativeImagePtr.h&quot;
</span><span class="cx"> #include &quot;TextStream.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/Noncopyable.h&gt;
</span><ins>+#include &lt;wtf/Optional.h&gt;
</ins><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><del>-#if USE(CG)
-typedef struct CGImageSource* CGImageSourceRef;
-typedef const struct __CFData* CFDataRef;
-#endif
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class ImageOrientation;
</span><span class="lines">@@ -83,7 +80,7 @@
</span><span class="cx">         GammaAndColorProfileIgnored
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    ImageSource(AlphaOption alphaOption = AlphaPremultiplied, GammaAndColorProfileOption gammaAndColorProfileOption = GammaAndColorProfileApplied);
</del><ins>+    ImageSource(AlphaOption = AlphaPremultiplied, GammaAndColorProfileOption = GammaAndColorProfileApplied);
</ins><span class="cx">     ~ImageSource();
</span><span class="cx"> 
</span><span class="cx">     // Tells the ImageSource that the Image no longer cares about decoded frame
</span><span class="lines">@@ -107,76 +104,61 @@
</span><span class="cx">     // who set |destroyAll| to true if they wish to be able to continue using
</span><span class="cx">     // the ImageSource.  This way implementations which choose to destroy their
</span><span class="cx">     // decoders in some cases can reconstruct them correctly.
</span><del>-    void clear(bool destroyAll,
-               size_t clearBeforeFrame = 0,
-               SharedBuffer* data = NULL,
-               bool allDataReceived = false);
</del><ins>+    void clear(bool destroyAll, size_t clearBeforeFrame = 0, SharedBuffer* data = nullptr, bool allDataReceived = false);
</ins><span class="cx"> 
</span><span class="cx">     bool initialized() const { return m_decoder.get(); }
</span><span class="cx"> 
</span><span class="cx">     void setData(SharedBuffer* data, bool allDataReceived);
</span><del>-    String filenameExtension() const;
</del><span class="cx"> 
</span><span class="cx">     SubsamplingLevel subsamplingLevelForScale(float) const;
</span><del>-    bool allowSubsamplingOfFrameAtIndex(size_t) const;
</del><span class="cx">     void setAllowSubsampling(bool allowSubsampling) { m_allowSubsampling = allowSubsampling; }
</span><del>-    SubsamplingLevel maximumSubsamplingLevel() const;
-
-    bool isSizeAvailable();
</del><ins>+    static size_t bytesDecodedToDetermineProperties();
</ins><span class="cx">     
</span><ins>+    bool isSizeAvailable() const;
</ins><span class="cx">     // Always original size, without subsampling.
</span><span class="cx">     IntSize size() const;
</span><span class="cx">     IntSize sizeRespectingOrientation() const;
</span><del>-    
-    // Size of optionally subsampled frame.
-    IntSize frameSizeAtIndex(size_t, SubsamplingLevel = 0, RespectImageOrientationEnum = DoNotRespectImageOrientation) const;
</del><span class="cx"> 
</span><del>-    bool getHotSpot(IntPoint&amp;) const;
-
-    size_t bytesDecodedToDetermineProperties() const;
-
</del><ins>+    size_t frameCount() const;
</ins><span class="cx">     int repetitionCount();
</span><ins>+    String filenameExtension() const;
+    Optional&lt;IntPoint&gt; hotSpot() const;
</ins><span class="cx"> 
</span><del>-    size_t frameCount() const;
-
-    // Callers should not call this after calling clear() with a higher index;
-    // see comments on clear() above.
-    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = 0);
-
-    float frameDurationAtIndex(size_t);
-    bool frameHasAlphaAtIndex(size_t); // Whether or not the frame actually used any alpha.
</del><span class="cx">     bool frameIsCompleteAtIndex(size_t); // Whether or not the frame is completely decoded.
</span><del>-    ImageOrientation orientationAtIndex(size_t) const; // EXIF image orientation
-
</del><ins>+    bool frameHasAlphaAtIndex(size_t); // Whether or not the frame actually used any alpha.
+    bool allowSubsamplingOfFrameAtIndex(size_t) const;
+    
+    // Size of optionally subsampled frame.
+    IntSize frameSizeAtIndex(size_t, SubsamplingLevel = 0, RespectImageOrientationEnum = DoNotRespectImageOrientation) const;
+    
</ins><span class="cx">     // Return the number of bytes in the decoded frame. If the frame is not yet
</span><span class="cx">     // decoded then return 0.
</span><span class="cx">     unsigned frameBytesAtIndex(size_t, SubsamplingLevel = 0) const;
</span><del>-
-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
-    static unsigned maxPixelsPerDecodedImage() { return s_maxPixelsPerDecodedImage; }
-    static void setMaxPixelsPerDecodedImage(unsigned maxPixels) { s_maxPixelsPerDecodedImage = maxPixels; }
-#endif
-
</del><ins>+    
+    float frameDurationAtIndex(size_t);
+    ImageOrientation orientationAtIndex(size_t) const; // EXIF image orientation
+    
+    // Callers should not call this after calling clear() with a higher index;
+    // see comments on clear() above.
+    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = 0);
+    
</ins><span class="cx"> private:
</span><del>-    void ensureDecoderIsCreated(SharedBuffer*);
</del><ins>+    void clearFrameBufferCache(size_t);
+    void ensureDecoderIsCreated(const SharedBuffer&amp;);
</ins><span class="cx">     SubsamplingLevel calculateMaximumSubsamplingLevel() const;
</span><span class="cx">     void dump(TextStream&amp;) const;
</span><span class="cx">     
</span><span class="cx">     std::unique_ptr&lt;ImageDecoder&gt; m_decoder;
</span><del>-    
</del><ins>+
+    // The default value of m_allowSubsampling should be the same as defaultImageSubsamplingEnabled in Settings.cpp
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     bool m_allowSubsampling { true };
</span><span class="cx"> #else
</span><span class="cx">     bool m_allowSubsampling { false };
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if !USE(CG)
</del><span class="cx">     AlphaOption m_alphaOption;
</span><span class="cx">     GammaAndColorProfileOption m_gammaAndColorProfileOption;
</span><del>-#endif
-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
-    static unsigned s_maxPixelsPerDecodedImage;
-#endif
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgImageDecoderCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -122,15 +122,6 @@
</span><span class="cx">     m_nativeDecoder = adoptCF(CGImageSourceCreateIncremental(nullptr));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SubsamplingLevel ImageDecoder::subsamplingLevelForScale(float scale, SubsamplingLevel maximumSubsamplingLevel)
-{
-    // There are four subsampling levels: 0 = 1x, 1 = 0.5x, 2 = 0.25x, 3 = 0.125x.
-    float clampedScale = std::max&lt;float&gt;(0.125, std::min&lt;float&gt;(1, scale));
-    SubsamplingLevel result = ceilf(log2f(1 / clampedScale));
-    ASSERT(result &gt;=0 &amp;&amp; result &lt;= 3);
-    return std::min(result, maximumSubsamplingLevel);
-}
-
</del><span class="cx"> size_t ImageDecoder::bytesDecodedToDetermineProperties()
</span><span class="cx"> {
</span><span class="cx">     // Measured by tracing malloc/calloc calls on Mac OS 10.6.6, x86_64.
</span><span class="lines">@@ -210,26 +201,25 @@
</span><span class="cx">     return cAnimationNone;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageDecoder::hotSpot(IntPoint&amp; hotSpot) const
</del><ins>+Optional&lt;IntPoint&gt; ImageDecoder::hotSpot() const
</ins><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;CFDictionaryRef&gt; properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get()));
</span><span class="cx">     if (!properties)
</span><del>-        return false;
</del><ins>+        return Nullopt;
</ins><span class="cx">     
</span><span class="cx">     int x = -1, y = -1;
</span><span class="cx">     CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(properties.get(), CFSTR(&quot;hotspotX&quot;));
</span><span class="cx">     if (!num || !CFNumberGetValue(num, kCFNumberIntType, &amp;x))
</span><del>-        return false;
</del><ins>+        return Nullopt;
</ins><span class="cx">     
</span><span class="cx">     num = (CFNumberRef)CFDictionaryGetValue(properties.get(), CFSTR(&quot;hotspotY&quot;));
</span><span class="cx">     if (!num || !CFNumberGetValue(num, kCFNumberIntType, &amp;y))
</span><del>-        return false;
</del><ins>+        return Nullopt;
</ins><span class="cx">     
</span><span class="cx">     if (x &lt; 0 || y &lt; 0)
</span><del>-        return false;
</del><ins>+        return Nullopt;
</ins><span class="cx">     
</span><del>-    hotSpot = IntPoint(x, y);
-    return true;
</del><ins>+    return IntPoint(x, y);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IntSize ImageDecoder::frameSizeAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const
</span><span class="lines">@@ -386,21 +376,21 @@
</span><span class="cx">     CGImageSourceUpdateData(m_nativeDecoder.get(), data, allDataReceived);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
</del><ins>+void ImageDecoder::setData(SharedBuffer&amp; data, bool allDataReceived)
</ins><span class="cx"> {
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     // On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge.
</span><span class="cx">     // We use SharedBuffer's ability to wrap itself inside CFData to get around this, ensuring that ImageIO is
</span><span class="cx">     // really looking at the SharedBuffer.
</span><del>-    setData(data-&gt;createCFData().get(), allDataReceived);
</del><ins>+    setData(data.createCFData().get(), allDataReceived);
</ins><span class="cx"> #else
</span><span class="cx">     // Create a CGDataProvider to wrap the SharedBuffer.
</span><del>-    data-&gt;ref();
</del><ins>+    data.ref();
</ins><span class="cx">     // We use the GetBytesAtPosition callback rather than the GetBytePointer one because SharedBuffer
</span><span class="cx">     // does not provide a way to lock down the byte pointer and guarantee that it won't move, which
</span><span class="cx">     // is a requirement for using the GetBytePointer callback.
</span><span class="cx">     CGDataProviderDirectCallbacks providerCallbacks = { 0, 0, 0, sharedBufferGetBytesAtPosition, sharedBufferRelease };
</span><del>-    RetainPtr&lt;CGDataProviderRef&gt; dataProvider = adoptCF(CGDataProviderCreateDirect(data, data-&gt;size(), &amp;providerCallbacks));
</del><ins>+    RetainPtr&lt;CGDataProviderRef&gt; dataProvider = adoptCF(CGDataProviderCreateDirect(&amp;data, data.size(), &amp;providerCallbacks));
</ins><span class="cx">     CGImageSourceUpdateDataProvider(m_nativeDecoder.get(), dataProvider.get(), allDataReceived);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgImageDecoderCGh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -29,19 +29,23 @@
</span><span class="cx"> #include &quot;ImageSourceCG.h&quot;
</span><span class="cx"> #include &quot;IntSize.h&quot;
</span><span class="cx"> 
</span><ins>+#include &lt;wtf/Optional.h&gt;
+
+typedef struct CGImageSource* CGImageSourceRef;
+typedef const struct __CFData* CFDataRef;
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class ImageDecoder {
</span><span class="cx"> public:
</span><span class="cx">     ImageDecoder();
</span><span class="cx">     
</span><del>-    static std::unique_ptr&lt;ImageDecoder&gt; create()
</del><ins>+    static std::unique_ptr&lt;ImageDecoder&gt; create(const SharedBuffer&amp;, ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption)
</ins><span class="cx">     {
</span><span class="cx">         return std::make_unique&lt;ImageDecoder&gt;();
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     static size_t bytesDecodedToDetermineProperties();
</span><del>-    static SubsamplingLevel subsamplingLevelForScale(float scale, SubsamplingLevel maximumSubsamplingLevel);
</del><span class="cx">     
</span><span class="cx">     String filenameExtension() const;
</span><span class="cx">     bool isSizeAvailable() const;
</span><span class="lines">@@ -50,7 +54,7 @@
</span><span class="cx">     IntSize size() const;
</span><span class="cx">     size_t frameCount() const;
</span><span class="cx">     int repetitionCount() const;
</span><del>-    bool hotSpot(IntPoint&amp; hotSpot) const;
</del><ins>+    Optional&lt;IntPoint&gt; hotSpot() const;
</ins><span class="cx">     
</span><span class="cx">     IntSize frameSizeAtIndex(size_t, SubsamplingLevel) const;
</span><span class="cx">     bool frameIsCompleteAtIndex(size_t) const;
</span><span class="lines">@@ -64,8 +68,10 @@
</span><span class="cx">     NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel) const;
</span><span class="cx">     
</span><span class="cx">     void setData(CFDataRef, bool allDataReceived);
</span><del>-    void setData(SharedBuffer*, bool allDataReceived);
</del><ins>+    void setData(SharedBuffer&amp;, bool allDataReceived);
</ins><span class="cx">     
</span><ins>+    void clearFrameBufferCache(size_t) { }
+    
</ins><span class="cx"> protected:
</span><span class="cx">     mutable IntSize m_size;
</span><span class="cx">     RetainPtr&lt;CGImageSourceRef&gt; m_nativeDecoder;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgImageSourceCGcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -1,215 +0,0 @@
</span><del>-/*
- * Copyright (C) 2004, 2005, 2006, 2008, 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#include &quot;config.h&quot;
-#include &quot;ImageSource.h&quot;
-
-#if USE(CG)
-#include &quot;ImageSourceCG.h&quot;
-
-#include &quot;ImageDecoderCG.h&quot;
-#include &quot;ImageOrientation.h&quot;
-#include &quot;SharedBuffer.h&quot;
-
-namespace WebCore {
-
-ImageSource::ImageSource(ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption)
-{
-    // FIXME: AlphaOption and GammaAndColorProfileOption are ignored.
-}
-
-ImageSource::~ImageSource()
-{
-    clear(true);
-}
-
-void ImageSource::clear(bool destroyAllFrames, size_t, SharedBuffer* data, bool allDataReceived)
-{
-    // Recent versions of ImageIO discard previously decoded image frames if the client
-    // application no longer holds references to them, so there's no need to throw away
-    // the decoder unless we're explicitly asked to destroy all of the frames.
-    if (!destroyAllFrames)
-        return;
-
-    m_decoder = nullptr;
-    
-    if (data)
-        setData(data, allDataReceived);
-}
-    
-void ImageSource::ensureDecoderIsCreated(SharedBuffer*)
-{
-    if (initialized())
-        return;
-    m_decoder = ImageDecoder::create();
-}
-
-void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
-{
-    if (!data)
-        return;
-    
-    ensureDecoderIsCreated(data);
-    
-    if (!initialized()) {
-        ASSERT_NOT_REACHED();
-        return;
-    }
-    
-    m_decoder-&gt;setData(data, allDataReceived);
-}
-
-String ImageSource::filenameExtension() const
-{
-    return initialized() ? m_decoder-&gt;filenameExtension() : String();
-}
-    
-SubsamplingLevel ImageSource::calculateMaximumSubsamplingLevel() const
-{
-    if (!m_allowSubsampling || !allowSubsamplingOfFrameAtIndex(0))
-        return 0;
-
-    // Values chosen to be appropriate for iOS.
-    const int cMaximumImageAreaBeforeSubsampling = 5 * 1024 * 1024;
-    const SubsamplingLevel maxSubsamplingLevel = 3;
-
-    SubsamplingLevel currentLevel = 0;
-    for ( ; currentLevel &lt;= maxSubsamplingLevel; ++currentLevel) {
-        IntSize frameSize = frameSizeAtIndex(0, currentLevel);
-        if (frameSize.area() &lt; cMaximumImageAreaBeforeSubsampling)
-            break;
-    }
-
-    return currentLevel;
-}
-    
-SubsamplingLevel ImageSource::maximumSubsamplingLevel() const
-{
-#if PLATFORM(IOS)
-    return calculateMaximumSubsamplingLevel();
-#endif
-    return 0;
-}
-
-SubsamplingLevel ImageSource::subsamplingLevelForScale(float scale) const
-{
-    return ImageDecoder::subsamplingLevelForScale(scale, maximumSubsamplingLevel());
-}
-
-bool ImageSource::isSizeAvailable()
-{
-    return initialized() &amp;&amp; m_decoder-&gt;isSizeAvailable();
-}
-
-bool ImageSource::allowSubsamplingOfFrameAtIndex(size_t index) const
-{
-    return initialized() &amp;&amp; m_decoder-&gt;allowSubsamplingOfFrameAtIndex(index);
-}
-
-IntSize ImageSource::frameSizeAtIndex(size_t index, SubsamplingLevel subsamplingLevel, RespectImageOrientationEnum shouldRespectImageOrientation) const
-{
-    if (!initialized())
-        return { };
-    
-    IntSize size = m_decoder-&gt;frameSizeAtIndex(index, subsamplingLevel);
-    ImageOrientation orientation = m_decoder-&gt;orientationAtIndex(index);
-    
-    return shouldRespectImageOrientation == RespectImageOrientation &amp;&amp; orientation.usesWidthAsHeight() ? size.transposedSize() : size;
-}
-
-ImageOrientation ImageSource::orientationAtIndex(size_t index) const
-{
-    return initialized() ? m_decoder-&gt;orientationAtIndex(index) : ImageOrientation();
-}
-
-IntSize ImageSource::size() const
-{
-    return frameSizeAtIndex(0, 0);
-}
-    
-IntSize ImageSource::sizeRespectingOrientation() const
-{
-    return frameSizeAtIndex(0, 0, RespectImageOrientation);
-}
-
-bool ImageSource::getHotSpot(IntPoint&amp; hotSpot) const
-{
-    return initialized() &amp;&amp; m_decoder-&gt;hotSpot(hotSpot);
-}
-
-size_t ImageSource::bytesDecodedToDetermineProperties() const
-{
-    return ImageDecoder::bytesDecodedToDetermineProperties();
-}
-    
-int ImageSource::repetitionCount()
-{
-    return initialized() ? m_decoder-&gt;repetitionCount() : cAnimationLoopOnce;
-}
-
-size_t ImageSource::frameCount() const
-{
-    return initialized() ? m_decoder-&gt;frameCount() : 0;
-}
-
-RetainPtr&lt;CGImageRef&gt; ImageSource::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel)
-{
-    return initialized() ? m_decoder-&gt;createFrameImageAtIndex(index, subsamplingLevel) : nullptr;
-}
-
-bool ImageSource::frameIsCompleteAtIndex(size_t index)
-{
-    return initialized() &amp;&amp; m_decoder-&gt;frameIsCompleteAtIndex(index);
-}
-
-float ImageSource::frameDurationAtIndex(size_t index)
-{
-    return initialized() ? m_decoder-&gt;frameDurationAtIndex(index) : 0;
-}
-
-bool ImageSource::frameHasAlphaAtIndex(size_t index)
-{
-    return !initialized() || m_decoder-&gt;frameHasAlphaAtIndex(index);
-}
-
-unsigned ImageSource::frameBytesAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const
-{
-    IntSize frameSize = frameSizeAtIndex(index, subsamplingLevel);
-    return frameSize.area() * 4;
-}
-    
-void ImageSource::dump(TextStream&amp; ts) const
-{
-    if (m_allowSubsampling)
-        ts.dumpProperty(&quot;allow-subsampling&quot;, m_allowSubsampling);
-    
-    ImageOrientation orientation = orientationAtIndex(0);
-    if (orientation != OriginTopLeft)
-        ts.dumpProperty(&quot;orientation&quot;, orientation);
-}
-
-}
-
-#endif // USE(CG)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersImageDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/ImageDecoder.cpp (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/ImageDecoder.cpp        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/image-decoders/ImageDecoder.cpp        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -1,4 +1,5 @@
</span><span class="cx"> /*
</span><ins>+ * Copyright (C) 2016 Apple Inc.  All rights reserved.
</ins><span class="cx">  * Copyright (C) 2008-2009 Torch Mobile, Inc.
</span><span class="cx">  * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
</span><span class="cx">  *
</span><span class="lines">@@ -270,15 +271,18 @@
</span><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ImageDecoder::frameHasAlphaAtIndex(size_t index) const
</del><ins>+bool ImageDecoder::frameIsCompleteAtIndex(size_t index) const
</ins><span class="cx"> {
</span><span class="cx">     if (m_frameBufferCache.size() &lt;= index)
</span><del>-        return true;
-    if (m_frameBufferCache[index].status() == ImageFrame::FrameComplete)
-        return m_frameBufferCache[index].hasAlpha();
-    return true;
</del><ins>+        return false;
+    return m_frameBufferCache[index].status() == ImageFrame::FrameComplete;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool ImageDecoder::frameHasAlphaAtIndex(size_t index) const
+{
+    return !frameIsCompleteAtIndex(index) || m_frameBufferCache[index].hasAlpha();
+}
+
</ins><span class="cx"> unsigned ImageDecoder::frameBytesAtIndex(size_t index) const
</span><span class="cx"> {
</span><span class="cx">     if (m_frameBufferCache.size() &lt;= index)
</span><span class="lines">@@ -287,6 +291,42 @@
</span><span class="cx">     return m_size.area() * sizeof(ImageFrame::PixelData);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+float ImageDecoder::frameDurationAtIndex(size_t index) const
+{
+    if (m_frameBufferCache.size() &lt;= index)
+        return 0;
+
+    if (m_frameBufferCache[index].status() == ImageFrame::FrameEmpty)
+        return 0;
+
+    // Many annoying ads specify a 0 duration to make an image flash as quickly as possible.
+    // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify
+    // a duration of &lt;= 10 ms. See &lt;rdar://problem/7689300&gt; and &lt;http://webkit.org/b/36082&gt;
+    // for more information.
+    const float duration = m_frameBufferCache[index].duration() / 1000.0f;
+    if (duration &lt; 0.011f)
+        return 0.100f;
+    return duration;
+}
+
+NativeImagePtr ImageDecoder::createFrameImageAtIndex(size_t index, SubsamplingLevel) const
+{
+    if (m_frameBufferCache.size() &lt;= index)
+        return nullptr;
+
+    // Zero-height images can cause problems for some ports. If we have an
+    // empty image dimension, just bail.
+    if (size().isEmpty())
+        return nullptr;
+
+    if (m_frameBufferCache[index].status() == ImageFrame::FrameEmpty)
+        return nullptr;
+
+    // Return the buffer contents as a native image. For some ports, the data
+    // is already in a native container, and this just increments its refcount.
+    return m_frameBufferCache[index].asNewNativeImage();
+}
+
</ins><span class="cx"> void ImageDecoder::prepareScaleDataIfNecessary()
</span><span class="cx"> {
</span><span class="cx">     m_scaled = false;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersImageDecoderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006 Apple Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2006, 2016 Apple Inc.  All rights reserved.
</ins><span class="cx">  * Copyright (C) 2008-2009 Torch Mobile, Inc.
</span><span class="cx">  * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
</span><span class="cx">  * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &quot;PlatformScreen.h&quot;
</span><span class="cx"> #include &quot;SharedBuffer.h&quot;
</span><span class="cx"> #include &lt;wtf/Assertions.h&gt;
</span><ins>+#include &lt;wtf/Optional.h&gt;
</ins><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="lines">@@ -235,15 +236,14 @@
</span><span class="cx">         WTF_MAKE_NONCOPYABLE(ImageDecoder); WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx">     public:
</span><span class="cx">         ImageDecoder(ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption)
</span><del>-            : m_scaled(false)
-            , m_premultiplyAlpha(alphaOption == ImageSource::AlphaPremultiplied)
</del><ins>+            : m_premultiplyAlpha(alphaOption == ImageSource::AlphaPremultiplied)
</ins><span class="cx">             , m_ignoreGammaAndColorProfile(gammaAndColorProfileOption == ImageSource::GammaAndColorProfileIgnored)
</span><del>-            , m_sizeAvailable(false)
-            , m_maxNumPixels(-1)
-            , m_isAllDataReceived(false)
-            , m_failed(false) { }
</del><ins>+        {
+        }
</ins><span class="cx"> 
</span><del>-        virtual ~ImageDecoder() { }
</del><ins>+        virtual ~ImageDecoder()
+        {
+        }
</ins><span class="cx"> 
</span><span class="cx">         // Returns a caller-owned decoder of the appropriate type.  Returns 0 if
</span><span class="cx">         // we can't sniff a supported type from the provided data (possibly
</span><span class="lines">@@ -254,11 +254,11 @@
</span><span class="cx"> 
</span><span class="cx">         bool isAllDataReceived() const { return m_isAllDataReceived; }
</span><span class="cx"> 
</span><del>-        virtual void setData(SharedBuffer* data, bool allDataReceived)
</del><ins>+        virtual void setData(SharedBuffer&amp; data, bool allDataReceived)
</ins><span class="cx">         {
</span><span class="cx">             if (m_failed)
</span><span class="cx">                 return;
</span><del>-            m_data = data;
</del><ins>+            m_data = &amp;data;
</ins><span class="cx">             m_isAllDataReceived = allDataReceived;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -282,7 +282,7 @@
</span><span class="cx">         // sizes.  This does NOT differ from size() for GIF, since decoding GIFs
</span><span class="cx">         // composites any smaller frames against previous frames to create full-
</span><span class="cx">         // size frames.
</span><del>-        virtual IntSize frameSizeAtIndex(size_t) const
</del><ins>+        virtual IntSize frameSizeAtIndex(size_t, SubsamplingLevel) const
</ins><span class="cx">         {
</span><span class="cx">             return size();
</span><span class="cx">         }
</span><span class="lines">@@ -310,16 +310,24 @@
</span><span class="cx">         // ImageDecoder-owned pointer.
</span><span class="cx">         virtual ImageFrame* frameBufferAtIndex(size_t) = 0;
</span><span class="cx"> 
</span><ins>+        bool frameIsCompleteAtIndex(size_t) const;
+
</ins><span class="cx">         // Make the best effort guess to check if the requested frame has alpha channel.
</span><del>-        virtual bool frameHasAlphaAtIndex(size_t) const;
</del><ins>+        bool frameHasAlphaAtIndex(size_t) const;
</ins><span class="cx"> 
</span><span class="cx">         // Number of bytes in the decoded frame requested. Return 0 if not yet decoded.
</span><del>-        virtual unsigned frameBytesAtIndex(size_t) const;
</del><ins>+        unsigned frameBytesAtIndex(size_t) const;
+        
+        float frameDurationAtIndex(size_t) const;
+        
+        NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel) const;
</ins><span class="cx"> 
</span><span class="cx">         void setIgnoreGammaAndColorProfile(bool flag) { m_ignoreGammaAndColorProfile = flag; }
</span><span class="cx">         bool ignoresGammaAndColorProfile() const { return m_ignoreGammaAndColorProfile; }
</span><span class="cx"> 
</span><del>-        ImageOrientation orientation() const { return m_orientation; }
</del><ins>+        ImageOrientation orientationAtIndex(size_t) const { return m_orientation; }
+        
+        bool allowSubsamplingOfFrameAtIndex(size_t) const { return false; }
</ins><span class="cx"> 
</span><span class="cx">         enum { iccColorProfileHeaderLength = 128 };
</span><span class="cx"> 
</span><span class="lines">@@ -330,6 +338,10 @@
</span><span class="cx">             return !memcmp(&amp;profileData[16], &quot;RGB &quot;, 4);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        static size_t bytesDecodedToDetermineProperties() { return 0; }
+        
+        static SubsamplingLevel subsamplingLevelForScale(float, SubsamplingLevel) { return 0; }
+
</ins><span class="cx">         static bool inputDeviceColorProfile(const char* profileData, unsigned profileLength)
</span><span class="cx">         {
</span><span class="cx">             ASSERT_UNUSED(profileLength, profileLength &gt;= iccColorProfileHeaderLength);
</span><span class="lines">@@ -354,13 +366,9 @@
</span><span class="cx">         // compositing).
</span><span class="cx">         virtual void clearFrameBufferCache(size_t) { }
</span><span class="cx"> 
</span><del>-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
-        void setMaxNumPixels(int m) { m_maxNumPixels = m; }
-#endif
-
</del><span class="cx">         // If the image has a cursor hot-spot, stores it in the argument
</span><span class="cx">         // and returns true. Otherwise returns false.
</span><del>-        virtual bool hotSpot(IntPoint&amp;) const { return false; }
</del><ins>+        virtual Optional&lt;IntPoint&gt; hotSpot() const { return Nullopt; }
</ins><span class="cx"> 
</span><span class="cx">     protected:
</span><span class="cx">         void prepareScaleDataIfNecessary();
</span><span class="lines">@@ -374,7 +382,7 @@
</span><span class="cx">         Vector&lt;ImageFrame, 1&gt; m_frameBufferCache;
</span><span class="cx">         // FIXME: Do we need m_colorProfile any more, for any port?
</span><span class="cx">         ColorProfile m_colorProfile;
</span><del>-        bool m_scaled;
</del><ins>+        bool m_scaled { false };
</ins><span class="cx">         Vector&lt;int&gt; m_scaledColumns;
</span><span class="cx">         Vector&lt;int&gt; m_scaledRows;
</span><span class="cx">         bool m_premultiplyAlpha;
</span><span class="lines">@@ -392,10 +400,14 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         IntSize m_size;
</span><del>-        bool m_sizeAvailable;
-        int m_maxNumPixels;
-        bool m_isAllDataReceived;
-        bool m_failed;
</del><ins>+        bool m_sizeAvailable { false };
+#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
+        static const int m_maxNumPixels { 1024 * 1024 };
+#else
+        static const int m_maxNumPixels { -1 };
+#endif
+        bool m_isAllDataReceived { false };
+        bool m_failed { false };
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersbmpBMPImageDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -47,14 +47,14 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void BMPImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
</del><ins>+void BMPImageDecoder::setData(SharedBuffer&amp; data, bool allDataReceived)
</ins><span class="cx"> {
</span><span class="cx">     if (failed())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     ImageDecoder::setData(data, allDataReceived);
</span><span class="cx">     if (m_reader)
</span><del>-        m_reader-&gt;setData(data);
</del><ins>+        m_reader-&gt;setData(&amp;data);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool BMPImageDecoder::isSizeAvailable()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersbmpBMPImageDecoderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx"> 
</span><span class="cx">         // ImageDecoder
</span><span class="cx">         virtual String filenameExtension() const { return &quot;bmp&quot;; }
</span><del>-        virtual void setData(SharedBuffer*, bool allDataReceived);
</del><ins>+        virtual void setData(SharedBuffer&amp;, bool allDataReceived);
</ins><span class="cx">         virtual bool isSizeAvailable();
</span><span class="cx">         virtual ImageFrame* frameBufferAtIndex(size_t index);
</span><span class="cx">         // CAUTION: setFailed() deletes |m_reader|.  Be careful to avoid
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersgifGIFImageDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -42,14 +42,14 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GIFImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
</del><ins>+void GIFImageDecoder::setData(SharedBuffer&amp; data, bool allDataReceived)
</ins><span class="cx"> {
</span><span class="cx">     if (failed())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     ImageDecoder::setData(data, allDataReceived);
</span><span class="cx">     if (m_reader)
</span><del>-        m_reader-&gt;setData(data);
</del><ins>+        m_reader-&gt;setData(&amp;data);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool GIFImageDecoder::isSizeAvailable()
</span><span class="lines">@@ -303,7 +303,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (!m_reader) {
</span><span class="cx">         m_reader = std::make_unique&lt;GIFImageReader&gt;(this);
</span><del>-        m_reader-&gt;setData(m_data);
</del><ins>+        m_reader-&gt;setData(m_data.get());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (query == GIFSizeQuery) {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersgifGIFImageDecoderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx"> 
</span><span class="cx">         // ImageDecoder
</span><span class="cx">         virtual String filenameExtension() const { return &quot;gif&quot;; }
</span><del>-        virtual void setData(SharedBuffer* data, bool allDataReceived);
</del><ins>+        virtual void setData(SharedBuffer&amp; data, bool allDataReceived);
</ins><span class="cx">         virtual bool isSizeAvailable();
</span><span class="cx">         virtual bool setSize(unsigned width, unsigned height);
</span><span class="cx">         virtual size_t frameCount();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersgifGIFImageReaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/gif/GIFImageReader.h (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/gif/GIFImageReader.h        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/image-decoders/gif/GIFImageReader.h        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -246,7 +246,7 @@
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    void setData(PassRefPtr&lt;WebCore::SharedBuffer&gt; data) { m_data = data; }
</del><ins>+    void setData(WebCore::SharedBuffer* data) { m_data = data; }
</ins><span class="cx">     // FIXME: haltAtFrame should be size_t.
</span><span class="cx">     bool decode(WebCore::GIFImageDecoder::GIFQuery, unsigned haltAtFrame);
</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 (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ICOImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
</del><ins>+void ICOImageDecoder::setData(SharedBuffer&amp; data, bool allDataReceived)
</ins><span class="cx"> {
</span><span class="cx">     if (failed())
</span><span class="cx">         return;
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx"> 
</span><span class="cx">     for (BMPReaders::iterator i(m_bmpReaders.begin()); i != m_bmpReaders.end(); ++i) {
</span><span class="cx">         if (*i)
</span><del>-            (*i)-&gt;setData(data);
</del><ins>+            (*i)-&gt;setData(&amp;data);
</ins><span class="cx">     }
</span><span class="cx">     for (size_t i = 0; i &lt; m_pngDecoders.size(); ++i)
</span><span class="cx">         setDataForPNGDecoderAtIndex(i);
</span><span class="lines">@@ -128,21 +128,20 @@
</span><span class="cx">     return ImageDecoder::setFailed();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ICOImageDecoder::hotSpot(IntPoint&amp; hotSpot) const
</del><ins>+Optional&lt;IntPoint&gt; ICOImageDecoder::hotSpot() const
</ins><span class="cx"> {
</span><span class="cx">     // When unspecified, the default frame is always frame 0. This is consistent with
</span><span class="cx">     // BitmapImage where currentFrame() starts at 0 and only increases when animation is
</span><span class="cx">     // requested.
</span><del>-    return hotSpotAtIndex(0, hotSpot);
</del><ins>+    return hotSpotAtIndex(0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ICOImageDecoder::hotSpotAtIndex(size_t index, IntPoint&amp; hotSpot) const
</del><ins>+Optional&lt;IntPoint&gt; ICOImageDecoder::hotSpotAtIndex(size_t index) const
</ins><span class="cx"> {
</span><span class="cx">     if (index &gt;= m_dirEntries.size() || m_fileType != CURSOR)
</span><del>-        return false;
</del><ins>+        return Nullopt;
</ins><span class="cx"> 
</span><del>-    hotSpot = m_dirEntries[index].m_hotSpot;
-    return true;
</del><ins>+    return m_dirEntries[index].m_hotSpot;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -165,7 +164,7 @@
</span><span class="cx">     // FIXME: Save this copy by making the PNG decoder able to take an
</span><span class="cx">     // optional offset.
</span><span class="cx">     RefPtr&lt;SharedBuffer&gt; pngData(SharedBuffer::create(&amp;m_data-&gt;data()[dirEntry.m_imageOffset], m_data-&gt;size() - dirEntry.m_imageOffset));
</span><del>-    m_pngDecoders[index]-&gt;setData(pngData.get(), isAllDataReceived());
</del><ins>+    m_pngDecoders[index]-&gt;setData(*pngData, isAllDataReceived());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ICOImageDecoder::decode(size_t index, bool onlySize)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformimagedecodersicoICOImageDecoderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx"> 
</span><span class="cx">         // ImageDecoder
</span><span class="cx">         virtual String filenameExtension() const { return &quot;ico&quot;; }
</span><del>-        virtual void setData(SharedBuffer*, bool allDataReceived);
</del><ins>+        virtual void setData(SharedBuffer&amp;, bool allDataReceived);
</ins><span class="cx">         virtual bool isSizeAvailable();
</span><span class="cx">         virtual IntSize size() const;
</span><span class="cx">         virtual IntSize frameSizeAtIndex(size_t) const;
</span><span class="lines">@@ -56,7 +56,7 @@
</span><span class="cx">         // avoid accessing deleted memory, especially when calling this from
</span><span class="cx">         // inside BMPImageReader!
</span><span class="cx">         virtual bool setFailed();
</span><del>-        virtual bool hotSpot(IntPoint&amp;) const;
</del><ins>+        virtual Optional&lt;IntPoint&gt; hotSpot() const;
</ins><span class="cx"> 
</span><span class="cx">     private:
</span><span class="cx">         enum ImageType {
</span><span class="lines">@@ -116,9 +116,8 @@
</span><span class="cx">         // could be decoded.
</span><span class="cx">         bool processDirectoryEntries();
</span><span class="cx"> 
</span><del>-        // Stores the hot-spot for |index| in |hotSpot| and returns true,
-        // or returns false if there is none.
-        bool hotSpotAtIndex(size_t index, IntPoint&amp; hotSpot) const;
</del><ins>+        // Returns the hot-spot for |index|, returns Nullopt if there is none.
+        Optional&lt;IntPoint&gt; hotSpotAtIndex(size_t) const;
</ins><span class="cx"> 
</span><span class="cx">         // Reads and returns a directory entry from the current offset into
</span><span class="cx">         // |data|.
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebKit2/ChangeLog        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-04-11  Said Abou-Hallawa  &lt;sabouhallawa@apple,com&gt;
+
+        Merge CG ImageSource and non CG ImageSource implementation in one file
+        https://bugs.webkit.org/show_bug.cgi?id=155456
+
+        Reviewed by Darin Adler.
+
+        * UIProcess/API/efl/EwkView.cpp:
+        (EwkView::setCursor):
+        Replace the call to Image::getHotSpot() by Image::hotSpot().
+
</ins><span class="cx"> 2016-04-11  Fujii Hironori  &lt;Hironori.Fujii@jp.sony.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CMake] Make FOLDER property INHERITED
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIeflEwkViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp (199289 => 199290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp        2016-04-11 07:28:42 UTC (rev 199289)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp        2016-04-11 07:29:33 UTC (rev 199290)
</span><span class="lines">@@ -450,10 +450,9 @@
</span><span class="cx">         if (cursorImage == m_cursorIdentifier.image)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        IntPoint hotSpot;
-        cursorImage-&gt;getHotSpot(hotSpot);
-
-        Ecore_X_Cursor customCursor = createCustomCursor(window, cursorImage, IntSize(cursorImage-&gt;size()), hotSpot);
</del><ins>+        
+        Optional&lt;IntPoint&gt; hotSpot = cursorImage-&gt;hotSpot();
+        Ecore_X_Cursor customCursor = createCustomCursor(window, cursorImage, IntSize(cursorImage-&gt;size()), hotSpot ? hotSpot.value() : IntPoint());
</ins><span class="cx">         if (!customCursor)
</span><span class="cx">             return;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>