<!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>[167498] 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/167498">167498</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2014-04-18 11:37:04 -0700 (Fri, 18 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Worse animation performance on pages with 3D transforms
https://bugs.webkit.org/show_bug.cgi?id=131838
&lt;rdar://problem/16428630&amp;15705876&gt;

Reviewed by Dean Jackson.

Source/WebCore:
<a href="http://trac.webkit.org/projects/webkit/changeset/155977">r155977</a> added logic to adjust the contentsScale of compositing layers
based on a root-relative transform. However, this resulted in
the contentsScale continually changing on layers whose transforms
are changed dynamically, which caused lots of expensive painting.

Fix by bucketing the part of the scale computed from the root-relative transform
into buckets of 0.25 via rounding.

Test: compositing/contents-scale/rounded-contents-scale.html

* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::clampedContentsScaleForScale):
(WebCore::GraphicsLayerCA::updateContentsOpaque):
(WebCore::GraphicsLayerCA::updateContentsScale):
(WebCore::GraphicsLayerCA::updateContentsVisibility): Deleted.
(WebCore::GraphicsLayerCA::animatedLayerClones): Deleted.

LayoutTests:
Testcase having layers at various z translates which shows the bucketing
of contentsScale, and fix results affected by the patch.

* compositing/contents-scale/rounded-contents-scale-expected.txt: Added.
* compositing/contents-scale/rounded-contents-scale.html: Added.
* compositing/contents-scale/z-translate-expected.txt:
* platform/mac-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt:
* platform/mac-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt:
* platform/mac/compositing/overflow/composited-scrolling-paint-phases-expected.txt:
* platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt:
* platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt:
* platform/mac/compositing/visible-rect/3d-transform-style-expected.txt:
* platform/mac/compositing/visible-rect/3d-transformed-expected.txt:
* platform/mac/compositing/visible-rect/nested-transform-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestscompositingcontentsscaleztranslateexpectedtxt">trunk/LayoutTests/compositing/contents-scale/z-translate-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaccompositingoverflowcompositedscrollingpaintphasesexpectedtxt">trunk/LayoutTests/platform/mac/compositing/overflow/composited-scrolling-paint-phases-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaccompositingtilingrotatedtiledclampedexpectedtxt">trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaccompositingtilingrotatedtiledpreserve3dclampedexpectedtxt">trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaccompositingvisiblerect3dtransformstyleexpectedtxt">trunk/LayoutTests/platform/mac/compositing/visible-rect/3d-transform-style-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaccompositingvisiblerect3dtransformedexpectedtxt">trunk/LayoutTests/platform/mac/compositing/visible-rect/3d-transformed-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaccompositingvisiblerectnestedtransformexpectedtxt">trunk/LayoutTests/platform/mac/compositing/visible-rect/nested-transform-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2compositingtilingrotatedtiledclampedexpectedtxt">trunk/LayoutTests/platform/mac-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2compositingtilingrotatedtiledpreserve3dclampedexpectedtxt">trunk/LayoutTests/platform/mac-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAcpp">trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscompositingcontentsscaleroundedcontentsscaleexpectedtxt">trunk/LayoutTests/compositing/contents-scale/rounded-contents-scale-expected.txt</a></li>
<li><a href="#trunkLayoutTestscompositingcontentsscaleroundedcontentsscalehtml">trunk/LayoutTests/compositing/contents-scale/rounded-contents-scale.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (167497 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-04-18 18:35:20 UTC (rev 167497)
+++ trunk/LayoutTests/ChangeLog        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2014-04-18  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Worse animation performance on pages with 3D transforms
+        https://bugs.webkit.org/show_bug.cgi?id=131838
+        &lt;rdar://problem/16428630&amp;15705876&gt;
+
+        Reviewed by Dean Jackson.
+        
+        Testcase having layers at various z translates which shows the bucketing
+        of contentsScale, and fix results affected by the patch.
+
+        * compositing/contents-scale/rounded-contents-scale-expected.txt: Added.
+        * compositing/contents-scale/rounded-contents-scale.html: Added.
+        * compositing/contents-scale/z-translate-expected.txt:
+        * platform/mac-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt:
+        * platform/mac-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt:
+        * platform/mac/compositing/overflow/composited-scrolling-paint-phases-expected.txt:
+        * platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt:
+        * platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt:
+        * platform/mac/compositing/visible-rect/3d-transform-style-expected.txt:
+        * platform/mac/compositing/visible-rect/3d-transformed-expected.txt:
+        * platform/mac/compositing/visible-rect/nested-transform-expected.txt:
+
</ins><span class="cx"> 2014-04-18  Radu Stavila  &lt;stavila@adobe.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Regions] Content overflowing a transformed region is clipped
</span></span></pre></div>
<a id="trunkLayoutTestscompositingcontentsscaleroundedcontentsscaleexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/contents-scale/rounded-contents-scale-expected.txt (0 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/contents-scale/rounded-contents-scale-expected.txt                                (rev 0)
+++ trunk/LayoutTests/compositing/contents-scale/rounded-contents-scale-expected.txt        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -0,0 +1,77 @@
</span><ins>+(GraphicsLayer
+  (bounds 800.00 600.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (contentsScale 1.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (contentsScale 1.00)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 784.00 512.00)
+          (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.78 0.51 1.00 -0.00] [0.00 0.00 0.00 1.00])
+          (visible rect 0.00, 0.00 784.00 x 512.00)
+          (contentsScale 1.00)
+          (children 6
+            (GraphicsLayer
+              (bounds 102.00 102.00)
+              (contentsOpaque 1)
+              (drawsContent 1)
+              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 -200.00 1.00])
+              (visible rect 0.00, 0.00 102.00 x 102.00)
+              (contentsScale 0.75)
+            )
+            (GraphicsLayer
+              (position 0.00 82.00)
+              (bounds 102.00 102.00)
+              (contentsOpaque 1)
+              (drawsContent 1)
+              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 -100.00 1.00])
+              (visible rect 0.00, 0.00 102.00 x 102.00)
+              (contentsScale 0.75)
+            )
+            (GraphicsLayer
+              (position 0.00 164.00)
+              (bounds 102.00 102.00)
+              (contentsOpaque 1)
+              (drawsContent 1)
+              (visible rect 0.00, 0.00 102.00 x 102.00)
+              (contentsScale 1.00)
+            )
+            (GraphicsLayer
+              (position 0.00 246.00)
+              (bounds 102.00 102.00)
+              (contentsOpaque 1)
+              (drawsContent 1)
+              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 50.00 1.00])
+              (visible rect 0.00, 0.00 102.00 x 102.00)
+              (contentsScale 1.00)
+            )
+            (GraphicsLayer
+              (position 0.00 328.00)
+              (bounds 102.00 102.00)
+              (contentsOpaque 1)
+              (drawsContent 1)
+              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 100.00 1.00])
+              (visible rect 0.00, 0.00 102.00 x 102.00)
+              (contentsScale 1.25)
+            )
+            (GraphicsLayer
+              (position 0.00 410.00)
+              (bounds 102.00 102.00)
+              (contentsOpaque 1)
+              (drawsContent 1)
+              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 150.00 1.00])
+              (visible rect 0.00, 0.00 102.00 x 4.40)
+              (contentsScale 1.50)
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingcontentsscaleroundedcontentsscalehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/contents-scale/rounded-contents-scale.html (0 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/contents-scale/rounded-contents-scale.html                                (rev 0)
+++ trunk/LayoutTests/compositing/contents-scale/rounded-contents-scale.html        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        body {
+            -webkit-perspective: 500px;
+            -webkit-perspective-origin: top left;
+        }
+        
+        .box {
+            height: 100px;
+            width: 100px;
+            margin-bottom: -20px;
+            background-color: silver;
+            border: 1px solid black;
+        }
+    &lt;/style&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        function doTest()
+        {
+            if (window.internals)
+                document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS)
+        }
+        window.addEventListener('load', doTest, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div class=&quot;box&quot; style=&quot;-webkit-transform: translateZ(-200px)&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;box&quot; style=&quot;-webkit-transform: translateZ(-100px)&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;box&quot; style=&quot;-webkit-transform: translateZ(0)&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;box&quot; style=&quot;-webkit-transform: translateZ(50px)&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;box&quot; style=&quot;-webkit-transform: translateZ(100px)&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;box&quot; style=&quot;-webkit-transform: translateZ(150px)&quot;&gt;&lt;/div&gt;
+&lt;pre id=&quot;layers&quot;&gt;&lt;/pre&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingcontentsscaleztranslateexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/compositing/contents-scale/z-translate-expected.txt (167497 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/contents-scale/z-translate-expected.txt        2014-04-18 18:35:20 UTC (rev 167497)
+++ trunk/LayoutTests/compositing/contents-scale/z-translate-expected.txt        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -36,7 +36,7 @@
</span><span class="cx">                   (drawsContent 1)
</span><span class="cx">                   (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 100.00 1.00])
</span><span class="cx">                   (visible rect 0.00, 0.00 100.00 x 100.00)
</span><del>-                  (contentsScale 1.67)
</del><ins>+                  (contentsScale 1.75)
</ins><span class="cx">                 )
</span><span class="cx">               )
</span><span class="cx">             )
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmaccompositingoverflowcompositedscrollingpaintphasesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/compositing/overflow/composited-scrolling-paint-phases-expected.txt (167497 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/compositing/overflow/composited-scrolling-paint-phases-expected.txt        2014-04-18 18:35:20 UTC (rev 167497)
+++ trunk/LayoutTests/platform/mac/compositing/overflow/composited-scrolling-paint-phases-expected.txt        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx">                     (GraphicsLayer
</span><span class="cx">                       (position 0.00 10.00)
</span><span class="cx">                       (bounds 80.00 10.00)
</span><ins>+                      (contentsOpaque 1)
</ins><span class="cx">                       (paintingPhases
</span><span class="cx">                         GraphicsLayerPaintBackground
</span><span class="cx">                         GraphicsLayerPaintForeground
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmaccompositingtilingrotatedtiledclampedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt (167497 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt        2014-04-18 18:35:20 UTC (rev 167497)
+++ trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -31,8 +31,8 @@
</span><span class="cx">                   (drawsContent 1)
</span><span class="cx">                   (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
</span><span class="cx">                   (visible rect 0.00, 0.00 2800.00 x 300.00)
</span><del>-                  (contentsScale 0.85)
-                  (tile cache coverage 0, 0 2799 x 299)
</del><ins>+                  (contentsScale 0.75)
+                  (tile cache coverage 0, 0 2800 x 300)
</ins><span class="cx">                   (tile size 512 x 512)
</span><span class="cx">                   (top left tile 0, 0 tiles grid 5 x 1)
</span><span class="cx">                 )
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmaccompositingtilingrotatedtiledpreserve3dclampedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt (167497 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt        2014-04-18 18:35:20 UTC (rev 167497)
+++ trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -37,8 +37,8 @@
</span><span class="cx">                       (drawsContent 1)
</span><span class="cx">                       (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
</span><span class="cx">                       (visible rect 0.00, 0.00 2800.00 x 300.00)
</span><del>-                      (contentsScale 0.85)
-                      (tile cache coverage 0, 0 2799 x 299)
</del><ins>+                      (contentsScale 0.75)
+                      (tile cache coverage 0, 0 2800 x 300)
</ins><span class="cx">                       (tile size 512 x 512)
</span><span class="cx">                       (top left tile 0, 0 tiles grid 5 x 1)
</span><span class="cx">                     )
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmaccompositingvisiblerect3dtransformstyleexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/compositing/visible-rect/3d-transform-style-expected.txt (167497 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/compositing/visible-rect/3d-transform-style-expected.txt        2014-04-18 18:35:20 UTC (rev 167497)
+++ trunk/LayoutTests/platform/mac/compositing/visible-rect/3d-transform-style-expected.txt        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx">                       (contentsOpaque 1)
</span><span class="cx">                       (transform [1.00 0.00 0.00 0.00] [0.00 0.91 0.42 0.00] [0.00 -0.42 0.91 0.00] [0.00 0.00 0.00 1.00])
</span><span class="cx">                       (visible rect 0.00, 0.00 213.67 x 200.68)
</span><del>-                      (contentsScale 0.93)
</del><ins>+                      (contentsScale 1.00)
</ins><span class="cx">                     )
</span><span class="cx">                   )
</span><span class="cx">                 )
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx">                       (contentsOpaque 1)
</span><span class="cx">                       (transform [0.91 0.00 0.42 0.00] [0.00 1.00 0.00 0.00] [-0.42 0.00 0.91 0.00] [0.00 0.00 0.00 1.00])
</span><span class="cx">                       (visible rect 0.00, 0.00 200.68 x 213.67)
</span><del>-                      (contentsScale 0.92)
</del><ins>+                      (contentsScale 1.00)
</ins><span class="cx">                     )
</span><span class="cx">                   )
</span><span class="cx">                 )
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmaccompositingvisiblerect3dtransformedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/compositing/visible-rect/3d-transformed-expected.txt (167497 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/compositing/visible-rect/3d-transformed-expected.txt        2014-04-18 18:35:20 UTC (rev 167497)
+++ trunk/LayoutTests/platform/mac/compositing/visible-rect/3d-transformed-expected.txt        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx">                   (contentsOpaque 1)
</span><span class="cx">                   (transform [1.00 0.00 0.00 0.00] [0.00 0.71 0.71 0.00] [0.00 -0.71 0.71 0.00] [0.00 0.00 0.00 1.00])
</span><span class="cx">                   (visible rect 0.00, 0.00 220.62 x 218.46)
</span><del>-                  (contentsScale 0.92)
</del><ins>+                  (contentsScale 1.00)
</ins><span class="cx">                 )
</span><span class="cx">               )
</span><span class="cx">             )
</span><span class="lines">@@ -53,7 +53,7 @@
</span><span class="cx">                   (contentsOpaque 1)
</span><span class="cx">                   (transform [0.71 0.00 0.71 0.00] [0.00 1.00 0.00 0.00] [-0.71 0.00 0.71 0.00] [0.00 0.00 0.00 1.00])
</span><span class="cx">                   (visible rect 0.00, 0.00 218.46 x 220.62)
</span><del>-                  (contentsScale 0.91)
</del><ins>+                  (contentsScale 1.00)
</ins><span class="cx">                 )
</span><span class="cx">               )
</span><span class="cx">             )
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmaccompositingvisiblerectnestedtransformexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/compositing/visible-rect/nested-transform-expected.txt (167497 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/compositing/visible-rect/nested-transform-expected.txt        2014-04-18 18:35:20 UTC (rev 167497)
+++ trunk/LayoutTests/platform/mac/compositing/visible-rect/nested-transform-expected.txt        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -27,21 +27,21 @@
</span><span class="cx">                   (preserves3D 1)
</span><span class="cx">                   (transform [0.94 0.00 -0.34 0.00] [0.00 1.00 0.00 0.00] [0.34 0.00 0.94 0.00] [0.00 0.00 0.00 1.00])
</span><span class="cx">                   (visible rect 0.00, 0.00 0.00 x 0.00)
</span><del>-                  (contentsScale 1.21)
</del><ins>+                  (contentsScale 1.25)
</ins><span class="cx">                   (children 1
</span><span class="cx">                     (GraphicsLayer
</span><span class="cx">                       (bounds 300.00 0.00)
</span><span class="cx">                       (preserves3D 1)
</span><span class="cx">                       (transform [0.94 0.00 -0.34 0.00] [0.00 1.00 0.00 0.00] [0.34 0.00 0.94 0.00] [0.00 0.00 0.00 1.00])
</span><span class="cx">                       (visible rect 0.00, 0.00 0.00 x 0.00)
</span><del>-                      (contentsScale 1.44)
</del><ins>+                      (contentsScale 1.50)
</ins><span class="cx">                       (children 1
</span><span class="cx">                         (GraphicsLayer
</span><span class="cx">                           (bounds 500.00 500.00)
</span><span class="cx">                           (contentsOpaque 1)
</span><span class="cx">                           (transform [1.00 0.00 0.00 0.00] [0.00 0.82 0.57 0.00] [0.00 -0.57 0.82 0.00] [0.00 0.00 0.00 1.00])
</span><span class="cx">                           (visible rect 0.00, 0.00 500.00 x 369.91)
</span><del>-                          (contentsScale 1.05)
</del><ins>+                          (contentsScale 1.00)
</ins><span class="cx">                         )
</span><span class="cx">                       )
</span><span class="cx">                     )
</span><span class="lines">@@ -75,14 +75,14 @@
</span><span class="cx">                       (preserves3D 1)
</span><span class="cx">                       (transform [0.77 0.00 -0.64 0.00] [0.00 1.00 0.00 0.00] [0.64 0.00 0.77 0.00] [0.00 0.00 0.00 1.00])
</span><span class="cx">                       (visible rect 0.00, 0.00 0.00 x 0.00)
</span><del>-                      (contentsScale 1.64)
</del><ins>+                      (contentsScale 1.75)
</ins><span class="cx">                       (children 1
</span><span class="cx">                         (GraphicsLayer
</span><span class="cx">                           (bounds 500.00 500.00)
</span><span class="cx">                           (contentsOpaque 1)
</span><span class="cx">                           (transform [1.00 0.00 0.00 0.00] [0.00 0.82 0.57 0.00] [0.00 -0.57 0.82 0.00] [0.00 0.00 0.00 1.00])
</span><span class="cx">                           (visible rect 0.00, 0.00 500.00 x 351.87)
</span><del>-                          (contentsScale 1.20)
</del><ins>+                          (contentsScale 1.25)
</ins><span class="cx">                         )
</span><span class="cx">                       )
</span><span class="cx">                     )
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2compositingtilingrotatedtiledclampedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt (167497 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt        2014-04-18 18:35:20 UTC (rev 167497)
+++ trunk/LayoutTests/platform/mac-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -34,8 +34,8 @@
</span><span class="cx">                   (drawsContent 1)
</span><span class="cx">                   (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
</span><span class="cx">                   (visible rect 0.00, 0.00 2800.00 x 300.00)
</span><del>-                  (contentsScale 0.85)
-                  (tile cache coverage 0, 0 2799 x 299)
</del><ins>+                  (contentsScale 0.75)
+                  (tile cache coverage 0, 0 2800 x 300)
</ins><span class="cx">                   (tile size 512 x 512)
</span><span class="cx">                   (top left tile 0, 0 tiles grid 5 x 1)
</span><span class="cx">                 )
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2compositingtilingrotatedtiledpreserve3dclampedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt (167497 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt        2014-04-18 18:35:20 UTC (rev 167497)
+++ trunk/LayoutTests/platform/mac-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -40,8 +40,8 @@
</span><span class="cx">                       (drawsContent 1)
</span><span class="cx">                       (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
</span><span class="cx">                       (visible rect 0.00, 0.00 2800.00 x 300.00)
</span><del>-                      (contentsScale 0.85)
-                      (tile cache coverage 0, 0 2799 x 299)
</del><ins>+                      (contentsScale 0.75)
+                      (tile cache coverage 0, 0 2800 x 300)
</ins><span class="cx">                       (tile size 512 x 512)
</span><span class="cx">                       (top left tile 0, 0 tiles grid 5 x 1)
</span><span class="cx">                     )
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (167497 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-04-18 18:35:20 UTC (rev 167497)
+++ trunk/Source/WebCore/ChangeLog        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -1,5 +1,30 @@
</span><span class="cx"> 2014-04-18  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Worse animation performance on pages with 3D transforms
+        https://bugs.webkit.org/show_bug.cgi?id=131838
+        &lt;rdar://problem/16428630&amp;15705876&gt;
+
+        Reviewed by Dean Jackson.
+        
+        r155977 added logic to adjust the contentsScale of compositing layers
+        based on a root-relative transform. However, this resulted in
+        the contentsScale continually changing on layers whose transforms
+        are changed dynamically, which caused lots of expensive painting.
+        
+        Fix by bucketing the part of the scale computed from the root-relative transform
+        into buckets of 0.25 via rounding.
+
+        Test: compositing/contents-scale/rounded-contents-scale.html
+
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::clampedContentsScaleForScale):
+        (WebCore::GraphicsLayerCA::updateContentsOpaque):
+        (WebCore::GraphicsLayerCA::updateContentsScale):
+        (WebCore::GraphicsLayerCA::updateContentsVisibility): Deleted.
+        (WebCore::GraphicsLayerCA::animatedLayerClones): Deleted.
+
+2014-04-18  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
</ins><span class="cx">         Remove some includes from image-related headers, and Document.h
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=131797
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (167497 => 167498)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp        2014-04-18 18:35:20 UTC (rev 167497)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp        2014-04-18 18:37:04 UTC (rev 167498)
</span><span class="lines">@@ -87,12 +87,19 @@
</span><span class="cx">     return static_cast&lt;int&gt;(value) == value;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static float clampedContentsScaleForScale(float scale)
</del><ins>+static float clampedContentsScaleForScale(float rootRelativeScale, float fixedScale)
</ins><span class="cx"> {
</span><del>-    // Define some limits as a sanity check for the incoming scale value
-    // those too small to see.
-    const float maxScale = 10.0f;
</del><ins>+    // To avoid too many repaints when the root-relative scale of layers changes, round
+    // the scale to the nearest 0.25.
+    const float roundingFactor = 4;
+    float scale = roundf(rootRelativeScale * roundingFactor) / roundingFactor;
+
+    scale *= fixedScale;
+    
+    // Define some reasonable limits.
+    const float maxScale = 8;
</ins><span class="cx">     const float minScale = 0.01f;
</span><ins>+
</ins><span class="cx">     return std::max(minScale, std::min(scale, maxScale));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1691,7 +1698,7 @@
</span><span class="cx"> {
</span><span class="cx">     bool contentsOpaque = m_contentsOpaque;
</span><span class="cx">     if (contentsOpaque) {
</span><del>-        float contentsScale = clampedContentsScaleForScale(m_rootRelativeScaleFactor * pageScaleFactor * deviceScaleFactor());
</del><ins>+        float contentsScale = clampedContentsScaleForScale(m_rootRelativeScaleFactor, pageScaleFactor * deviceScaleFactor());
</ins><span class="cx">         if (!isIntegral(contentsScale) &amp;&amp; !m_client-&gt;paintsOpaquelyAtNonIntegralScales(this))
</span><span class="cx">             contentsOpaque = false;
</span><span class="cx">     }
</span><span class="lines">@@ -2981,7 +2988,7 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayerCA::updateContentsScale(float pageScaleFactor)
</span><span class="cx"> {
</span><del>-    float contentsScale = clampedContentsScaleForScale(m_rootRelativeScaleFactor * pageScaleFactor * deviceScaleFactor());
</del><ins>+    float contentsScale = clampedContentsScaleForScale(m_rootRelativeScaleFactor, pageScaleFactor * deviceScaleFactor());
</ins><span class="cx"> 
</span><span class="cx">     if (m_isPageTiledBackingLayer &amp;&amp; tiledBacking()) {
</span><span class="cx">         float zoomedOutScale = m_client-&gt;zoomedOutPageScaleFactor() * deviceScaleFactor();
</span></span></pre>
</div>
</div>

</body>
</html>