<!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>[214635] 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/214635">214635</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-03-30 15:41:14 -0700 (Thu, 30 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/213764">r213764</a>): Background image from sprite sheet incorrectly scaled
https://bugs.webkit.org/show_bug.cgi?id=169547

Patch by Said Abou-Hallawa &lt;sabouhallawa@apple.com&gt; on 2017-03-30
Reviewed by Simon Fraser.

Source/WebCore:

The bug happens when drawing only a rectangle of an image not the whole
image. In BitmapImage::draw(), sizeForDrawing was calculated as the destRect
scaled by the transformation which is applied to the GraphicsContext. Two
problems with this approach. The first one is destRect can be only part of
the image. The second problem is, the ratio destRect / srcRect is another
scaling that needs to be considered.

To fix this issue, first the base size has to be size of the image and not
destRect.size(). Secondly, we need to scale this base size with the context
transformation multiplied by the ratio destRect / srcRect. This scaling is
exactly the same scaling which is calculated in subsamplingScale(). Finally
we use this scaled size as the sizeForDrawing to send to the ImageDecoder.

Test: fast/images/sprite-sheet-image-draw.html

* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::draw): Fix the bug.
(WebCore::BitmapImage::stopAnimation): Stops the async image decoding for animated images only.
The decoding for large images will be stopped when BitmapImage::newFrameNativeImageAvailableAtIndex()
is called and the decoding queue is idle.
(WebCore::BitmapImage::newFrameNativeImageAvailableAtIndex): Add image logging.
* platform/graphics/BitmapImage.h: Move sourceURL() to the Image class.
* platform/graphics/GraphicsContext.cpp: Pass imagePaintingOptions.m_decodingMode to Image::drawTiled().
(WebCore::GraphicsContext::drawTiledImage): Pass imagePaintingOptions.m_decodingMode) to Image::drawTiled().
* platform/graphics/Image.cpp:
(WebCore::Image::sourceURL): Moved from BitmapImage.
(WebCore::Image::drawTiled): Add a DecodingMode argument instead of calling always with DecodingMode::Synchronous.
* platform/graphics/Image.h:
* platform/graphics/ImageFrameCache.cpp:
(WebCore::ImageFrameCache::cacheAsyncFrameNativeImageAtIndex): Add image logging.
(WebCore::ImageFrameCache::startAsyncDecodingQueue): Ditto,
(WebCore::ImageFrameCache::requestFrameAsyncDecodingAtIndex): Ditto.
(WebCore::ImageFrameCache::stopAsyncDecodingQueue): Ditto.
(WebCore::ImageFrameCache::sourceURL): A helper function to avoid checking the value of m_image.
* platform/graphics/ImageFrameCache.h:
* platform/graphics/NativeImage.h: Rename subsamplingScale() to nativeImageDrawingScale() and return image scaling instead.
* platform/graphics/cairo/NativeImageCairo.cpp:
(WebCore::nativeImageDrawingScale): Ditto.
(WebCore::subsamplingScale): Deleted.
* platform/graphics/cg/NativeImageCG.cpp:
(WebCore::nativeImageDrawingScale): Ditto.
(WebCore::subsamplingScale): Deleted.
* platform/graphics/win/NativeImageDirect2D.cpp:
(WebCore::nativeImageDrawingScale): Ditto.
(WebCore::subsamplingScale): Deleted.

LayoutTests:

* fast/images/async-image-background-image.html:
* fast/images/resources/sprite-sheet-red-green-blue.png: Added.
* fast/images/sprite-sheet-image-draw-expected.html: Added.
* fast/images/sprite-sheet-image-draw.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastimagesasyncimagebackgroundimageexpectedhtml">trunk/LayoutTests/fast/images/async-image-background-image-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastimagesasyncimagebackgroundimagehtml">trunk/LayoutTests/fast/images/async-image-background-image.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</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="#trunkSourceWebCoreplatformgraphicsGraphicsContextcpp">trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImagecpp">trunk/Source/WebCore/platform/graphics/Image.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageh">trunk/Source/WebCore/platform/graphics/Image.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageFrameCachecpp">trunk/Source/WebCore/platform/graphics/ImageFrameCache.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageFrameCacheh">trunk/Source/WebCore/platform/graphics/ImageFrameCache.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsNativeImageh">trunk/Source/WebCore/platform/graphics/NativeImage.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoNativeImageCairocpp">trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgNativeImageCGcpp">trunk/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinNativeImageDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastimagesresourcesspritesheetredgreenbluepng">trunk/LayoutTests/fast/images/resources/sprite-sheet-red-green-blue.png</a></li>
<li><a href="#trunkLayoutTestsfastimagesspritesheetimagedrawexpectedhtml">trunk/LayoutTests/fast/images/sprite-sheet-image-draw-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastimagesspritesheetimagedrawhtml">trunk/LayoutTests/fast/images/sprite-sheet-image-draw.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/LayoutTests/ChangeLog        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2017-03-30  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        REGRESSION (r213764): Background image from sprite sheet incorrectly scaled
+        https://bugs.webkit.org/show_bug.cgi?id=169547
+
+        Reviewed by Simon Fraser.
+
+        * fast/images/async-image-background-image.html:
+        * fast/images/resources/sprite-sheet-red-green-blue.png: Added.
+        * fast/images/sprite-sheet-image-draw-expected.html: Added.
+        * fast/images/sprite-sheet-image-draw.html: Added.
+
</ins><span class="cx"> 2017-03-30  Matt Baker  &lt;mattbaker@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Assertion failure in InspectorStyleProperty::setRawTextFromStyleDeclaration
</span></span></pre></div>
<a id="trunkLayoutTestsfastimagesasyncimagebackgroundimageexpectedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/images/async-image-background-image-expected.html (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/async-image-background-image-expected.html        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/LayoutTests/fast/images/async-image-background-image-expected.html        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -1,10 +1,21 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
</ins><span class="cx"> &lt;style&gt;
</span><del>-    div {
</del><ins>+    .box {
</ins><span class="cx">         width: 300px;
</span><span class="cx">         height: 300px;
</span><ins>+    }
+    .rgb-background {
</ins><span class="cx">         background-color: green;
</span><span class="cx">     }
</span><ins>+    @media (-webkit-min-device-pixel-ratio: 2) {
+        .box {
+            width: 150px;
+            height: 150px;
+        }
+    }
</ins><span class="cx"> &lt;/style&gt;
</span><span class="cx"> &lt;body&gt;
</span><del>-    &lt;div&gt;&lt;/div&gt;
</del><ins>+    &lt;div class=&quot;box rgb-background&quot;&gt;&lt;/div&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><ins>+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastimagesasyncimagebackgroundimagehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/images/async-image-background-image.html (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/async-image-background-image.html        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/LayoutTests/fast/images/async-image-background-image.html        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -1,18 +1,52 @@
</span><span class="cx"> &lt;!DOCTYPE html&gt;
</span><span class="cx"> &lt;html&gt;
</span><span class="cx"> &lt;style&gt;
</span><del>-    div {
</del><ins>+    .box {
</ins><span class="cx">         width: 300px;
</span><span class="cx">         height: 300px;
</span><ins>+    }
+    .image-background {
</ins><span class="cx">         background-image: url(resources/red-green-blue-900-300.png);
</span><span class="cx">         background-position: -300px 0px;
</span><span class="cx">     }
</span><ins>+    @media (-webkit-min-device-pixel-ratio: 2) {
+        .box {
+            width: 150px;
+            height: 150px;
+        }
+        .image-background {
+            background-position: -150px 0px;
+            background-size: 450px, 150px;
+        }
+    }
</ins><span class="cx"> &lt;/style&gt;
</span><del>-&lt;script&gt;
-    if (window.internals)
-        internals.settings.setLargeImageAsyncDecodingEnabled(true);
-&lt;/script&gt;
</del><span class="cx"> &lt;body&gt;
</span><del>-    &lt;div&gt;&lt;/div&gt;
</del><ins>+    &lt;div class=&quot;box image-background&quot;&gt;&lt;/div&gt;
+    &lt;script&gt;
+        function forceRedraw(element) {
+            var disp = element.style.display;
+            element.style.display = 'none';
+            var trick = element.offsetHeight;
+            element.style.display = disp;
+        }
+
+        (function() {
+            var divElement = document.getElementsByClassName(&quot;image-background&quot;)[0];
+
+            if (window.internals) {
+                internals.clearMemoryCache();
+                internals.settings.setLargeImageAsyncDecodingEnabled(true);
+            }
+
+            if (window.testRunner) {
+                testRunner.waitUntilDone();
+                forceRedraw(divElement);
+                setTimeout(function() {
+                    forceRedraw(divElement);
+                    testRunner.notifyDone();
+                }, 50);
+            }
+        }
+    &lt;/script&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfastimagesresourcesspritesheetredgreenbluepng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/fast/images/resources/sprite-sheet-red-green-blue.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Index: trunk/LayoutTests/fast/images/resources/sprite-sheet-red-green-blue.png
</span><span class="cx">===================================================================
</span><del>--- trunk/LayoutTests/fast/images/resources/sprite-sheet-red-green-blue.png        2017-03-30 22:37:34 UTC (rev 214634)
</del><ins>+++ trunk/LayoutTests/fast/images/resources/sprite-sheet-red-green-blue.png        2017-03-30 22:41:14 UTC (rev 214635)
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/images/resources/sprite-sheet-red-green-blue.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+image/png
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfastimagesspritesheetimagedrawexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/images/sprite-sheet-image-draw-expected.html (0 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/sprite-sheet-image-draw-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/images/sprite-sheet-image-draw-expected.html        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;style&gt;
+    .box {
+        width: 200px;
+        height: 100px;
+        display: inline-block;
+    }
+    .rgb-background {
+        background: linear-gradient(
+            to right,
+            red,
+            red 25%,
+            green 25%,
+            green 75%,
+            blue 75%
+        );
+    }
+    @media (-webkit-min-device-pixel-ratio: 2) {
+        .box {
+            width: 100px;
+            height: 50px;
+        }
+    }
+&lt;/style&gt;
+&lt;body&gt;
+    &lt;div class=&quot;box rgb-background&quot;&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastimagesspritesheetimagedrawhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/images/sprite-sheet-image-draw.html (0 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/sprite-sheet-image-draw.html                                (rev 0)
+++ trunk/LayoutTests/fast/images/sprite-sheet-image-draw.html        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;style&gt;
+    .box {
+        width: 200px;
+        height: 100px;
+        display: inline-block;
+    }
+    .image-background {
+        background-image: url(resources/sprite-sheet-red-green-blue.png);
+        background-position: 0px -1000px;
+    }
+    @media (-webkit-min-device-pixel-ratio: 2) {
+        .box {
+            width: 100px;
+            height: 50px;
+        }
+        .image-background {
+            background-position: 0px -500px;
+            background-size: 100px, 1050px;
+        }
+    }
+&lt;/style&gt;
+&lt;body&gt;
+    &lt;div class=&quot;box image-background&quot;&gt;&lt;/div&gt;
+    &lt;script&gt;
+        function forceRedraw(element) {
+            var disp = element.style.display;
+            element.style.display = 'none';
+            var trick = element.offsetHeight;
+            element.style.display = disp;
+        }
+
+        (function() {
+            var divElement = document.getElementsByClassName(&quot;image-background&quot;)[0];
+
+            if (window.internals) {
+                internals.clearMemoryCache();
+                internals.settings.setLargeImageAsyncDecodingEnabled(true);
+            }
+
+            if (window.testRunner) {
+                testRunner.waitUntilDone();
+                forceRedraw(divElement);
+                setTimeout(function() {
+                    forceRedraw(divElement);
+                    testRunner.notifyDone();
+                }, 50);
+            }
+        }
+    &lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/Source/WebCore/ChangeLog        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -1,3 +1,56 @@
</span><ins>+2017-03-30  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        REGRESSION (r213764): Background image from sprite sheet incorrectly scaled
+        https://bugs.webkit.org/show_bug.cgi?id=169547
+
+        Reviewed by Simon Fraser.
+
+        The bug happens when drawing only a rectangle of an image not the whole
+        image. In BitmapImage::draw(), sizeForDrawing was calculated as the destRect
+        scaled by the transformation which is applied to the GraphicsContext. Two
+        problems with this approach. The first one is destRect can be only part of
+        the image. The second problem is, the ratio destRect / srcRect is another
+        scaling that needs to be considered.
+
+        To fix this issue, first the base size has to be size of the image and not
+        destRect.size(). Secondly, we need to scale this base size with the context
+        transformation multiplied by the ratio destRect / srcRect. This scaling is
+        exactly the same scaling which is calculated in subsamplingScale(). Finally
+        we use this scaled size as the sizeForDrawing to send to the ImageDecoder.
+
+        Test: fast/images/sprite-sheet-image-draw.html
+
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::draw): Fix the bug.
+        (WebCore::BitmapImage::stopAnimation): Stops the async image decoding for animated images only.
+        The decoding for large images will be stopped when BitmapImage::newFrameNativeImageAvailableAtIndex()
+        is called and the decoding queue is idle.
+        (WebCore::BitmapImage::newFrameNativeImageAvailableAtIndex): Add image logging.
+        * platform/graphics/BitmapImage.h: Move sourceURL() to the Image class.
+        * platform/graphics/GraphicsContext.cpp: Pass imagePaintingOptions.m_decodingMode to Image::drawTiled().
+        (WebCore::GraphicsContext::drawTiledImage): Pass imagePaintingOptions.m_decodingMode) to Image::drawTiled().
+        * platform/graphics/Image.cpp:
+        (WebCore::Image::sourceURL): Moved from BitmapImage.
+        (WebCore::Image::drawTiled): Add a DecodingMode argument instead of calling always with DecodingMode::Synchronous.
+        * platform/graphics/Image.h:
+        * platform/graphics/ImageFrameCache.cpp:
+        (WebCore::ImageFrameCache::cacheAsyncFrameNativeImageAtIndex): Add image logging.
+        (WebCore::ImageFrameCache::startAsyncDecodingQueue): Ditto,
+        (WebCore::ImageFrameCache::requestFrameAsyncDecodingAtIndex): Ditto.
+        (WebCore::ImageFrameCache::stopAsyncDecodingQueue): Ditto.
+        (WebCore::ImageFrameCache::sourceURL): A helper function to avoid checking the value of m_image.
+        * platform/graphics/ImageFrameCache.h:
+        * platform/graphics/NativeImage.h: Rename subsamplingScale() to nativeImageDrawingScale() and return image scaling instead.
+        * platform/graphics/cairo/NativeImageCairo.cpp:
+        (WebCore::nativeImageDrawingScale): Ditto.
+        (WebCore::subsamplingScale): Deleted.
+        * platform/graphics/cg/NativeImageCG.cpp:
+        (WebCore::nativeImageDrawingScale): Ditto.
+        (WebCore::subsamplingScale): Deleted.
+        * platform/graphics/win/NativeImageDirect2D.cpp:
+        (WebCore::nativeImageDrawingScale): Ditto.
+        (WebCore::subsamplingScale): Deleted.
+
</ins><span class="cx"> 2017-03-30  Matt Baker  &lt;mattbaker@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Assertion failure in InspectorStyleProperty::setRawTextFromStyleDeclaration
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsBitmapImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -163,11 +163,12 @@
</span><span class="cx">     if (destRect.isEmpty() || srcRect.isEmpty())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    float scale = subsamplingScale(context, destRect, srcRect);
-    m_currentSubsamplingLevel = allowSubsampling() ? m_source.subsamplingLevelForScale(scale) : SubsamplingLevel::Default;
-    IntSize sizeForDrawing = enclosingIntRect(context.getCTM().mapRect(destRect)).size();
</del><ins>+    FloatSize scale = nativeImageDrawingScale(context, destRect, srcRect);
+    float subsamplingScale = std::min(float(1), std::max(scale.width(), scale.height()));
+    m_currentSubsamplingLevel = allowSubsampling() ? m_source.subsamplingLevelForScale(subsamplingScale) : SubsamplingLevel::Default;
+    IntSize sizeForDrawing = expandedIntSize(size() * scale);
</ins><span class="cx"> 
</span><del>-    LOG(Images, &quot;BitmapImage::%s - %p - url: %s [subsamplingLevel = %d scale = %.4f]&quot;, __FUNCTION__, this, sourceURL().utf8().data(), static_cast&lt;int&gt;(m_currentSubsamplingLevel), scale);
</del><ins>+    LOG(Images, &quot;BitmapImage::%s - %p - url: %s [subsamplingLevel = %d scale = %.4f]&quot;, __FUNCTION__, this, sourceURL().utf8().data(), static_cast&lt;int&gt;(m_currentSubsamplingLevel), subsamplingScale);
</ins><span class="cx"> 
</span><span class="cx">     NativeImagePtr image;
</span><span class="cx">     if (decodingMode == DecodingMode::Asynchronous &amp;&amp; shouldUseAsyncDecodingForLargeImages()) {
</span><span class="lines">@@ -175,8 +176,8 @@
</span><span class="cx"> 
</span><span class="cx">         if (!frameHasDecodedNativeImageCompatibleWithOptionsAtIndex(m_currentFrame, m_currentSubsamplingLevel, DecodingOptions(sizeForDrawing))
</span><span class="cx">             &amp;&amp; !frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(m_currentFrame, DecodingOptions(sizeForDrawing))) {
</span><ins>+            LOG(Images, &quot;BitmapImage::%s - %p - url: %s [requesting large async decoding]&quot;, __FUNCTION__, this, sourceURL().utf8().data());
</ins><span class="cx">             m_source.requestFrameAsyncDecodingAtIndex(0, m_currentSubsamplingLevel, sizeForDrawing);
</span><del>-            LOG(Images, &quot;BitmapImage::%s - %p - url: %s [requesting large async decoding]&quot;, __FUNCTION__, this, sourceURL().utf8().data());
</del><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (!frameHasDecodedNativeImageCompatibleWithOptionsAtIndex(m_currentFrame, m_currentSubsamplingLevel, DecodingMode::Asynchronous)) {
</span><span class="lines">@@ -186,6 +187,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         image = frameImageAtIndex(m_currentFrame);
</span><ins>+        LOG(Images, &quot;BitmapImage::%s - %p - url: %s [a decoded image frame is available for drawing]&quot;, __FUNCTION__, this, sourceURL().utf8().data());
</ins><span class="cx">     } else {
</span><span class="cx">         StartAnimationStatus status = internalStartAnimation();
</span><span class="cx">         ASSERT_IMPLIES(status == StartAnimationStatus::DecodingActive, frameHasFullSizeNativeImageAtIndex(m_currentFrame, m_currentSubsamplingLevel));
</span><span class="lines">@@ -416,7 +418,8 @@
</span><span class="cx">     // This timer is used to animate all occurrences of this image. Don't invalidate
</span><span class="cx">     // the timer unless all renderers have stopped drawing.
</span><span class="cx">     clearTimer();
</span><del>-    m_source.stopAsyncDecodingQueue();
</del><ins>+    if (canAnimate())
+        m_source.stopAsyncDecodingQueue();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void BitmapImage::resetAnimation()
</span><span class="lines">@@ -434,6 +437,8 @@
</span><span class="cx"> void BitmapImage::newFrameNativeImageAvailableAtIndex(size_t index)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(index);
</span><ins>+    LOG(Images, &quot;BitmapImage::%s - %p - url: %s [requested frame %ld is now available]&quot;, __FUNCTION__, this, sourceURL().utf8().data(), index);
+
</ins><span class="cx">     if (canAnimate()) {
</span><span class="cx">         ASSERT(index == (m_currentFrame + 1) % frameCount());
</span><span class="cx">         
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsBitmapImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/BitmapImage.h        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -136,7 +136,6 @@
</span><span class="cx">     NativeImagePtr frameImageAtIndex(size_t index) { return m_source.frameImageAtIndex(index); }
</span><span class="cx">     NativeImagePtr frameImageAtIndexCacheIfNeeded(size_t, SubsamplingLevel = SubsamplingLevel::Default, const GraphicsContext* = nullptr);
</span><span class="cx"> 
</span><del>-    String sourceURL() const { return imageObserver() ? imageObserver()-&gt;sourceUrl().string() : emptyString(); }
</del><span class="cx">     bool allowSubsampling() const { return imageObserver() &amp;&amp; imageObserver()-&gt;allowSubsampling(); }
</span><span class="cx">     bool allowLargeImageAsyncDecoding() const { return imageObserver() &amp;&amp; imageObserver()-&gt;allowLargeImageAsyncDecoding(); }
</span><span class="cx">     bool allowAnimatedImageAsyncDecoding() const { return imageObserver() &amp;&amp; imageObserver()-&gt;allowAnimatedImageAsyncDecoding(); }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -742,7 +742,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     InterpolationQualityMaintainer interpolationQualityForThisScope(*this, imagePaintingOptions.m_interpolationQuality);
</span><del>-    image.drawTiled(*this, destination, source, tileSize, spacing, imagePaintingOptions.m_compositeOperator, imagePaintingOptions.m_blendMode);
</del><ins>+    image.drawTiled(*this, destination, source, tileSize, spacing, imagePaintingOptions.m_compositeOperator, imagePaintingOptions.m_blendMode, imagePaintingOptions.m_decodingMode);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::drawTiledImage(Image&amp; image, const FloatRect&amp; destination, const FloatRect&amp; source, const FloatSize&amp; tileScaleFactor,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Image.cpp (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Image.cpp        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/Source/WebCore/platform/graphics/Image.cpp        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -79,6 +79,11 @@
</span><span class="cx">     return dataChanged(allDataReceived);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String Image::sourceURL() const
+{
+    return imageObserver() ? imageObserver()-&gt;sourceUrl().string() : emptyString();
+}
+
</ins><span class="cx"> void Image::fillWithSolidColor(GraphicsContext&amp; ctxt, const FloatRect&amp; dstRect, const Color&amp; color, CompositeOperator op)
</span><span class="cx"> {
</span><span class="cx">     if (!color.isVisible())
</span><span class="lines">@@ -90,7 +95,7 @@
</span><span class="cx">     ctxt.setCompositeOperation(previousOperator);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Image::drawTiled(GraphicsContext&amp; ctxt, const FloatRect&amp; destRect, const FloatPoint&amp; srcPoint, const FloatSize&amp; scaledTileSize, const FloatSize&amp; spacing, CompositeOperator op, BlendMode blendMode)
</del><ins>+void Image::drawTiled(GraphicsContext&amp; ctxt, const FloatRect&amp; destRect, const FloatPoint&amp; srcPoint, const FloatSize&amp; scaledTileSize, const FloatSize&amp; spacing, CompositeOperator op, BlendMode blendMode, DecodingMode decodingMode)
</ins><span class="cx"> {
</span><span class="cx">     Color color = singlePixelSolidColor();
</span><span class="cx">     if (color.isValid()) {
</span><span class="lines">@@ -126,7 +131,7 @@
</span><span class="cx">         visibleSrcRect.setY((destRect.y() - oneTileRect.y()) / scale.height());
</span><span class="cx">         visibleSrcRect.setWidth(destRect.width() / scale.width());
</span><span class="cx">         visibleSrcRect.setHeight(destRect.height() / scale.height());
</span><del>-        draw(ctxt, destRect, visibleSrcRect, op, blendMode, DecodingMode::Synchronous, ImageOrientationDescription());
</del><ins>+        draw(ctxt, destRect, visibleSrcRect, op, blendMode, decodingMode, ImageOrientationDescription());
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -139,7 +144,7 @@
</span><span class="cx">             visibleSrcRect.setY((destRect.y() - oneTileRect.y()) / scale.height());
</span><span class="cx">             visibleSrcRect.setWidth(1);
</span><span class="cx">             visibleSrcRect.setHeight(destRect.height() / scale.height());
</span><del>-            draw(ctxt, destRect, visibleSrcRect, op, BlendModeNormal, DecodingMode::Synchronous, ImageOrientationDescription());
</del><ins>+            draw(ctxt, destRect, visibleSrcRect, op, BlendModeNormal, decodingMode, ImageOrientationDescription());
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         if (size().height() == 1 &amp;&amp; intersection(oneTileRect, destRect).width() == destRect.width()) {
</span><span class="lines">@@ -148,7 +153,7 @@
</span><span class="cx">             visibleSrcRect.setY(0);
</span><span class="cx">             visibleSrcRect.setWidth(destRect.width() / scale.width());
</span><span class="cx">             visibleSrcRect.setHeight(1);
</span><del>-            draw(ctxt, destRect, visibleSrcRect, op, BlendModeNormal, DecodingMode::Synchronous, ImageOrientationDescription());
</del><ins>+            draw(ctxt, destRect, visibleSrcRect, op, BlendModeNormal, decodingMode, ImageOrientationDescription());
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -180,7 +185,7 @@
</span><span class="cx">                 FloatRect fromRect(toFloatPoint(currentTileRect.location() - oneTileRect.location()), currentTileRect.size());
</span><span class="cx">                 fromRect.scale(1 / scale.width(), 1 / scale.height());
</span><span class="cx"> 
</span><del>-                draw(ctxt, toRect, fromRect, op, BlendModeNormal, DecodingMode::Synchronous, ImageOrientationDescription());
</del><ins>+                draw(ctxt, toRect, fromRect, op, BlendModeNormal, decodingMode, ImageOrientationDescription());
</ins><span class="cx">                 toX += currentTileRect.width();
</span><span class="cx">                 currentTileRect.shiftXEdgeTo(oneTileRect.x());
</span><span class="cx">             }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Image.h (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Image.h        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/Source/WebCore/platform/graphics/Image.h        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -136,6 +136,7 @@
</span><span class="cx">     // Typically the CachedImage that owns us.
</span><span class="cx">     ImageObserver* imageObserver() const { return m_imageObserver; }
</span><span class="cx">     void setImageObserver(ImageObserver* observer) { m_imageObserver = observer; }
</span><ins>+    String sourceURL() const;
</ins><span class="cx"> 
</span><span class="cx">     enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile };
</span><span class="cx"> 
</span><span class="lines">@@ -187,7 +188,7 @@
</span><span class="cx">     virtual void drawFrameMatchingSourceSize(GraphicsContext&amp;, const FloatRect&amp; dstRect, const IntSize&amp; srcSize, CompositeOperator) { }
</span><span class="cx"> #endif
</span><span class="cx">     virtual void draw(GraphicsContext&amp;, const FloatRect&amp; dstRect, const FloatRect&amp; srcRect, CompositeOperator, BlendMode, DecodingMode, ImageOrientationDescription) = 0;
</span><del>-    void drawTiled(GraphicsContext&amp;, const FloatRect&amp; dstRect, const FloatPoint&amp; srcPoint, const FloatSize&amp; tileSize, const FloatSize&amp; spacing, CompositeOperator, BlendMode);
</del><ins>+    void drawTiled(GraphicsContext&amp;, const FloatRect&amp; dstRect, const FloatPoint&amp; srcPoint, const FloatSize&amp; tileSize, const FloatSize&amp; spacing, CompositeOperator, BlendMode, DecodingMode);
</ins><span class="cx">     void drawTiled(GraphicsContext&amp;, const FloatRect&amp; dstRect, const FloatRect&amp; srcRect, const FloatSize&amp; tileScaleFactor, TileRule hRule, TileRule vRule, CompositeOperator);
</span><span class="cx"> 
</span><span class="cx">     // Supporting tiled drawing
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageFrameCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageFrameCache.cpp (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageFrameCache.cpp        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/Source/WebCore/platform/graphics/ImageFrameCache.cpp        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Image.h&quot;
</span><span class="cx"> #include &quot;ImageObserver.h&quot;
</span><ins>+#include &quot;Logging.h&quot;
</ins><span class="cx"> #include &lt;wtf/SystemTracing.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if USE(CG)
</span><span class="lines">@@ -249,6 +250,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Clean the old native image and set a new one
</span><span class="cx">     cacheFrameNativeImageAtIndex(WTFMove(nativeImage), index, subsamplingLevel, decodingOptions);
</span><ins>+    LOG(Images, &quot;ImageFrameCache::%s - %p - url: %s [frame %ld has been cached]&quot;, __FUNCTION__, this, sourceURL().utf8().data(), index);
</ins><span class="cx"> 
</span><span class="cx">     // Notify the image with the readiness of the new frame NativeImage.
</span><span class="cx">     if (m_image)
</span><span class="lines">@@ -283,6 +285,10 @@
</span><span class="cx"> 
</span><span class="cx">             // Get the frame NativeImage on the decoding thread.
</span><span class="cx">             NativeImagePtr nativeImage = protectedDecoder-&gt;createFrameImageAtIndex(frameRequest.index, frameRequest.subsamplingLevel, frameRequest.decodingOptions);
</span><ins>+            if (nativeImage)
+                LOG(Images, &quot;ImageFrameCache::%s - %p - url: %s [frame %ld has been decoded]&quot;, __FUNCTION__, this, sourceURL().utf8().data(), frameRequest.index);
+            else
+                LOG(Images, &quot;ImageFrameCache::%s - %p - url: %s [decoding for frame %ld has failed]&quot;, __FUNCTION__, this, sourceURL().utf8().data(), frameRequest.index);
</ins><span class="cx"> 
</span><span class="cx">             // Update the cached frames on the main thread to avoid updating the MemoryCache from a different thread.
</span><span class="cx">             callOnMainThread([this, protectedQueue = protectedQueue.copyRef(), nativeImage, frameRequest] () mutable {
</span><span class="lines">@@ -291,7 +297,8 @@
</span><span class="cx">                     ASSERT(m_frameCommitQueue.first() == frameRequest);
</span><span class="cx">                     m_frameCommitQueue.removeFirst();
</span><span class="cx">                     cacheAsyncFrameNativeImageAtIndex(WTFMove(nativeImage), frameRequest.index, frameRequest.subsamplingLevel, frameRequest.decodingOptions);
</span><del>-                }
</del><ins>+                } else
+                    LOG(Images, &quot;ImageFrameCache::%s - %p - url: %s [frame %ld will not cached]&quot;, __FUNCTION__, this, sourceURL().utf8().data(), frameRequest.index);
</ins><span class="cx">             });
</span><span class="cx">         }
</span><span class="cx">     });
</span><span class="lines">@@ -316,6 +323,7 @@
</span><span class="cx">     if (!hasAsyncDecodingQueue())
</span><span class="cx">         startAsyncDecodingQueue();
</span><span class="cx"> 
</span><ins>+    LOG(Images, &quot;ImageFrameCache::%s - %p - url: %s [enqueuing frame %ld for decoding]&quot;, __FUNCTION__, this, sourceURL().utf8().data(), index);
</ins><span class="cx">     m_frameRequestQueue.enqueue({ index, subsamplingLevel, sizeForDrawing });
</span><span class="cx">     m_frameCommitQueue.append({ index, subsamplingLevel, sizeForDrawing });
</span><span class="cx">     return true;
</span><span class="lines">@@ -333,13 +341,16 @@
</span><span class="cx">     
</span><span class="cx">     std::for_each(m_frameCommitQueue.begin(), m_frameCommitQueue.end(), [this](const ImageFrameRequest&amp; frameRequest) {
</span><span class="cx">         ImageFrame&amp; frame = m_frames[frameRequest.index];
</span><del>-        if (!frame.isEmpty())
</del><ins>+        if (!frame.isEmpty()) {
+            LOG(Images, &quot;ImageFrameCache::%s - %p - url: %s [decoding has been cancelled for frame %ld]&quot;, __FUNCTION__, this, sourceURL().utf8().data(), frameRequest.index);
</ins><span class="cx">             frame.clear();
</span><ins>+        }
</ins><span class="cx">     });
</span><span class="cx"> 
</span><span class="cx">     m_frameRequestQueue.close();
</span><span class="cx">     m_frameCommitQueue.clear();
</span><span class="cx">     m_decodingQueue = nullptr;
</span><ins>+    LOG(Images, &quot;ImageFrameCache::%s - %p - url: %s [decoding has been stopped]&quot;, __FUNCTION__, this, sourceURL().utf8().data());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const ImageFrame&amp; ImageFrameCache::frameAtIndexCacheIfNeeded(size_t index, ImageFrame::Caching caching, const std::optional&lt;SubsamplingLevel&gt;&amp; subsamplingLevel)
</span><span class="lines">@@ -379,6 +390,11 @@
</span><span class="cx">     m_singlePixelSolidColor = std::nullopt;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String ImageFrameCache::sourceURL() const
+{
+    return m_image ? m_image-&gt;sourceURL() : emptyString();
+}
+
</ins><span class="cx"> template&lt;typename T, T (ImageDecoder::*functor)() const&gt;
</span><span class="cx"> T ImageFrameCache::metadata(const T&amp; defaultValue, std::optional&lt;T&gt;* cachedValue)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageFrameCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageFrameCache.h (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageFrameCache.h        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/Source/WebCore/platform/graphics/ImageFrameCache.h        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -66,6 +66,7 @@
</span><span class="cx"> 
</span><span class="cx">     void growFrames();
</span><span class="cx">     void clearMetadata();
</span><ins>+    String sourceURL() const;
</ins><span class="cx">     
</span><span class="cx">     // Asynchronous image decoding
</span><span class="cx">     void startAsyncDecodingQueue();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsNativeImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/NativeImage.h (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/NativeImage.h        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/Source/WebCore/platform/graphics/NativeImage.h        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx"> bool nativeImageHasAlpha(const NativeImagePtr&amp;);
</span><span class="cx"> Color nativeImageSinglePixelSolidColor(const NativeImagePtr&amp;);
</span><span class="cx"> 
</span><del>-float subsamplingScale(GraphicsContext&amp;, const FloatRect&amp; destRect, const FloatRect&amp; srcRect);
</del><ins>+FloatSize nativeImageDrawingScale(GraphicsContext&amp;, const FloatRect&amp; destRect, const FloatRect&amp; srcRect);
</ins><span class="cx"> 
</span><span class="cx"> void drawNativeImage(const NativeImagePtr&amp;, GraphicsContext&amp;, const FloatRect&amp;, const FloatRect&amp;, const IntSize&amp;, CompositeOperator, BlendMode, const ImageOrientation&amp;);
</span><span class="cx"> void clearNativeImageSubimages(const NativeImagePtr&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoNativeImageCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -56,9 +56,10 @@
</span><span class="cx">     return colorFromPremultipliedARGB(*pixel);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-float subsamplingScale(GraphicsContext&amp;, const FloatRect&amp;, const FloatRect&amp;)
</del><ins>+FloatSize nativeImageDrawingScale(GraphicsContext&amp; context, const FloatRect&amp; destRect, const FloatRect&amp; srcRect)
</ins><span class="cx"> {
</span><del>-    return 1;
</del><ins>+    auto transformedDestinationRect = context.getCTM().mapRect(destRect);
+    return { static_cast&lt;float&gt;(transformedDestinationRect.width() / srcRect.width()), static_cast&lt;float&gt;(transformedDestinationRect.height() / srcRect.height()) };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void drawNativeImage(const NativeImagePtr&amp; image, GraphicsContext&amp; context, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, const IntSize&amp;, CompositeOperator op, BlendMode mode, const ImageOrientation&amp; orientation)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgNativeImageCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -73,14 +73,14 @@
</span><span class="cx">     return Color(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-float subsamplingScale(GraphicsContext&amp; context, const FloatRect&amp; destRect, const FloatRect&amp; srcRect)
</del><ins>+FloatSize nativeImageDrawingScale(GraphicsContext&amp; context, const FloatRect&amp; destRect, const FloatRect&amp; srcRect)
</ins><span class="cx"> {
</span><span class="cx">     // Never use subsampled images for drawing into PDF contexts.
</span><span class="cx">     if (wkCGContextIsPDFContext(context.platformContext()))
</span><del>-        return 1;
</del><ins>+        return { 1, 1 };
</ins><span class="cx"> 
</span><span class="cx">     CGRect transformedDestinationRect = CGRectApplyAffineTransform(destRect, CGContextGetCTM(context.platformContext()));
</span><del>-    return std::min&lt;float&gt;(1, std::max(transformedDestinationRect.size.width / srcRect.width(), transformedDestinationRect.size.height / srcRect.height()));
</del><ins>+    return { static_cast&lt;float&gt;(transformedDestinationRect.size.width / srcRect.width()), static_cast&lt;float&gt;(transformedDestinationRect.size.height / srcRect.height()) };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void drawNativeImage(const NativeImagePtr&amp; image, GraphicsContext&amp; context, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, const IntSize&amp; srcSize, CompositeOperator op, BlendMode mode, const ImageOrientation&amp; orientation)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinNativeImageDirect2Dcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp (214634 => 214635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp        2017-03-30 22:37:34 UTC (rev 214634)
+++ trunk/Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp        2017-03-30 22:41:14 UTC (rev 214635)
</span><span class="lines">@@ -60,7 +60,7 @@
</span><span class="cx">     return Color();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-float subsamplingScale(GraphicsContext&amp; context, const FloatRect&amp; destRect, const FloatRect&amp; srcRect)
</del><ins>+FloatSize nativeImageDrawingScale(GraphicsContext&amp; context, const FloatRect&amp; destRect, const FloatRect&amp; srcRect)
</ins><span class="cx"> {
</span><span class="cx">     D2D1_MATRIX_3X2_F ctm;
</span><span class="cx">     context.platformContext()-&gt;GetTransform(&amp;ctm);
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx">     AffineTransform transform(ctm);
</span><span class="cx"> 
</span><span class="cx">     auto transformedDestinationRect = transform.mapRect(destRect);
</span><del>-    return std::min&lt;float&gt;(1, std::max(transformedDestinationRect.width() / srcRect.width(), transformedDestinationRect.height() / srcRect.height()));
</del><ins>+    return { static_cast&lt;float&gt;(transformedDestinationRect.width() / srcRect.width()), static_cast&lt;float&gt;(transformedDestinationRect.height() / srcRect.height()) };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void drawNativeImage(const NativeImagePtr&amp; image, GraphicsContext&amp; context, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, const IntSize&amp; srcSize, CompositeOperator compositeOp, BlendMode blendMode, const ImageOrientation&amp; orientation)
</span></span></pre>
</div>
</div>

</body>
</html>