<!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>[189821] trunk/Source/WebCore</title>
</head>
<body>

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

<h3>Log Message</h3>
<pre>[Win] Tiled drawing is rendering more times than it should
https://bugs.webkit.org/show_bug.cgi?id=149144
&lt;rdar://problem/22313905&gt;

Reviewed by Simon Fraser.

Provide a more faithful implemenation of the Objective C tiled drawing logic.
(1) Create a new WebTiledBackingLayerWin class that represents a the
    container of tiles. This matches the Objective C design.
(2) Move implementation of several methods (e.g., isOpaque) to the internal
    class implementation so that the Tile Drawing logic can perform special
    handling in these cases.
(3) Remove the duplicated Tiled Drawing logic from PlatformCALayerWinInternal,
    since it was just duplicating code in TileController and TileGrid.
(4) Clean up the display callback code to avoid performing incorrect flipping
    of the coordinate system.

* PlatformAppleWin.cmake: Add new WebTiledBackingLayerWin file.            
* WebCore.vcxproj/WebCore.vcxproj: Add the new WebTiledBackingLayerWin files.
* WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
* platform/graphics/ca/PlatformCALayer.cpp:
(PlatformCALayer::flipContext): Added convenience method.
(PlatformCALayer::drawRepaintIndicator): Ditto.
* platform/graphics/ca/TileGrid.cpp:
(TileGrid::platformCALayerPaintContents): Flip the context before drawing the repaint
indicator on Windows.
* platform/graphics/ca/win/PlatformCALayerWin.cpp:
(PlatformCALayerWin::PlatformCALayerWin): Create a WebTiledBackingLayerWin
object if using tiled drawing.
(PlatformCALayerWin::~PlatformCALayerWin):
(PlatformCALayerWin::isOpaque): Move implementation to internal class.
(PlatformCALayerWin::setOpaque): Ditto.
(PlatformCALayerWin::setBorderWidth): Ditto.
(PlatformCALayerWin::setBorderColor): Ditto.
(PlatformCALayerWin::contentsScale): Ditto.
(PlatformCALayerWin::setContentsScale): Ditto.
(PlatformCALayerWin::cornerRadius): Ditto.
(PlatformCALayerWin::tiledBacking): Ditto.
(PlatformCALayerWin::drawTextAtPoint): New helper method to draw repaint counter
text. Needed to work around bug in CG.
* platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
(PlatformCALayerWinInternal::PlatformCALayerWinInternal): Remove tiling-logic
related member variables.
(PlatformCALayerWinInternal::~PlatformCALayerWinInternal):
(shouldInvertBeforeDrawingContent): Added convenience method.
(shouldInvertBeforeDrawingRepaintCounters): Ditto.
(PlatformCALayerWinInternal::displayCallback):
(PlatformCALayerWinInternal::drawRepaintCounters): Helper method to
share code between the two layer classes.
(PlatformCALayerWinInternal::internalSetNeedsDisplay): use nullptr.
(PlatformCALayerWinInternal::setNeedsDisplay): Ditto.
(PlatformCALayerWinInternal::setNeedsDisplayInRect): Move tiled code
to WebTiledBackingLayerWin and simplify the remaing code.
(PlatformCALayerWinInternal::setSublayers): Remove tile code.
(PlatformCALayerWinInternal::getSublayers): Ditto.
(PlatformCALayerWinInternal::removeAllSublayers): Ditto.
(PlatformCALayerWinInternal::insertSublayer): Ditto.
(PlatformCALayerWinInternal::sublayerCount): Ditto.
(PlatformCALayerWinInternal::indexOfSublayer): Ditto.
(PlatformCALayerWinInternal::sublayerAtIndex): Ditto.
(PlatformCALayerWinInternal::setBounds): Ditto.
(PlatformCALayerWinInternal::setFrame): Ditto.
(PlatformCALayerWinInternal::isOpaque): Ditto.
(PlatformCALayerWinInternal::setOpaque): Ditto.
(PlatformCALayerWinInternal::contentsScale): Ditto.
(PlatformCALayerWinInternal::setContentsScale): Ditto.
(PlatformCALayerWinInternal::setBorderWidth): Ditto.
(PlatformCALayerWinInternal::setBorderColor): Ditto.
(layerTypeIsTiled): Deleted.
(PlatformCALayerWinInternal::constrainedSize): Deleted.
(PlatformCALayerWinInternal::tileDisplayCallback): Deleted.
(PlatformCALayerWinInternal::addTile): Deleted.
(PlatformCALayerWinInternal::removeTile): Deleted.
(PlatformCALayerWinInternal::tileAtIndex): Deleted.
(PlatformCALayerWinInternal::tileCount): Deleted.
(PlatformCALayerWinInternal::updateTiles): Deleted.
(PlatformCALayerWinInternal::drawTile): Deleted.
(PlatformCALayerWinInternal::createTileController): Deleted.
(PlatformCALayerWinInternal::tiledBacking): Deleted.
* platform/graphics/ca/win/PlatformCALayerWinInternal.h:
(WebCore::PlatformCALayerWinInternal::owner):
* platform/graphics/ca/win/WebTiledBackingLayerWin.cpp: Added.
(WebTiledBackingLayerWin::WebTiledBackingLayerWin):
(WebTiledBackingLayerWin::~WebTiledBackingLayerWin):
(DisplayOnMainThreadContext::DisplayOnMainThreadContext):
(redispatchOnMainQueue):
(WebTiledBackingLayerWin::displayCallback):
(WebTiledBackingLayerWin::setNeedsDisplay):
(WebTiledBackingLayerWin::setNeedsDisplayInRect):
(WebTiledBackingLayerWin::setBounds):
(WebTiledBackingLayerWin::isOpaque):
(WebTiledBackingLayerWin::setOpaque):
(WebTiledBackingLayerWin::contentsScale):
(WebTiledBackingLayerWin::setContentsScale):
(WebTiledBackingLayerWin::setBorderWidth):
(WebTiledBackingLayerWin::setBorderColor):
(WebTiledBackingLayerWin::createTileController):
(WebTiledBackingLayerWin::tiledBacking):
(WebTiledBackingLayerWin::invalidate):
* platform/graphics/ca/win/WebTiledBackingLayerWin.h: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformAppleWincmake">trunk/Source/WebCore/PlatformAppleWin.cmake</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaPlatformCALayercpp">trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaPlatformCALayerh">trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaTileGridcpp">trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscawinPlatformCALayerWincpp">trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscawinPlatformCALayerWinh">trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscawinPlatformCALayerWinInternalcpp">trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscawinPlatformCALayerWinInternalh">trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicscawinWebTiledBackingLayerWincpp">trunk/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscawinWebTiledBackingLayerWinh">trunk/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (189820 => 189821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-09-15 19:47:34 UTC (rev 189820)
+++ trunk/Source/WebCore/ChangeLog        2015-09-15 19:56:34 UTC (rev 189821)
</span><span class="lines">@@ -1,3 +1,106 @@
</span><ins>+2015-09-15  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        [Win] Tiled drawing is rendering more times than it should
+        https://bugs.webkit.org/show_bug.cgi?id=149144
+        &lt;rdar://problem/22313905&gt;
+
+        Reviewed by Simon Fraser.
+
+        Provide a more faithful implemenation of the Objective C tiled drawing logic.
+        (1) Create a new WebTiledBackingLayerWin class that represents a the
+            container of tiles. This matches the Objective C design.
+        (2) Move implementation of several methods (e.g., isOpaque) to the internal
+            class implementation so that the Tile Drawing logic can perform special
+            handling in these cases.
+        (3) Remove the duplicated Tiled Drawing logic from PlatformCALayerWinInternal,
+            since it was just duplicating code in TileController and TileGrid.
+        (4) Clean up the display callback code to avoid performing incorrect flipping
+            of the coordinate system.
+
+        * PlatformAppleWin.cmake: Add new WebTiledBackingLayerWin file.            
+        * WebCore.vcxproj/WebCore.vcxproj: Add the new WebTiledBackingLayerWin files.
+        * WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
+        * platform/graphics/ca/PlatformCALayer.cpp:
+        (PlatformCALayer::flipContext): Added convenience method.
+        (PlatformCALayer::drawRepaintIndicator): Ditto.
+        * platform/graphics/ca/TileGrid.cpp:
+        (TileGrid::platformCALayerPaintContents): Flip the context before drawing the repaint
+        indicator on Windows.
+        * platform/graphics/ca/win/PlatformCALayerWin.cpp:
+        (PlatformCALayerWin::PlatformCALayerWin): Create a WebTiledBackingLayerWin
+        object if using tiled drawing.
+        (PlatformCALayerWin::~PlatformCALayerWin):
+        (PlatformCALayerWin::isOpaque): Move implementation to internal class.
+        (PlatformCALayerWin::setOpaque): Ditto.
+        (PlatformCALayerWin::setBorderWidth): Ditto.
+        (PlatformCALayerWin::setBorderColor): Ditto.
+        (PlatformCALayerWin::contentsScale): Ditto.
+        (PlatformCALayerWin::setContentsScale): Ditto.
+        (PlatformCALayerWin::cornerRadius): Ditto.
+        (PlatformCALayerWin::tiledBacking): Ditto.
+        (PlatformCALayerWin::drawTextAtPoint): New helper method to draw repaint counter
+        text. Needed to work around bug in CG.
+        * platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
+        (PlatformCALayerWinInternal::PlatformCALayerWinInternal): Remove tiling-logic
+        related member variables.
+        (PlatformCALayerWinInternal::~PlatformCALayerWinInternal):
+        (shouldInvertBeforeDrawingContent): Added convenience method.
+        (shouldInvertBeforeDrawingRepaintCounters): Ditto.
+        (PlatformCALayerWinInternal::displayCallback):
+        (PlatformCALayerWinInternal::drawRepaintCounters): Helper method to
+        share code between the two layer classes.
+        (PlatformCALayerWinInternal::internalSetNeedsDisplay): use nullptr.
+        (PlatformCALayerWinInternal::setNeedsDisplay): Ditto.
+        (PlatformCALayerWinInternal::setNeedsDisplayInRect): Move tiled code
+        to WebTiledBackingLayerWin and simplify the remaing code.
+        (PlatformCALayerWinInternal::setSublayers): Remove tile code.
+        (PlatformCALayerWinInternal::getSublayers): Ditto.
+        (PlatformCALayerWinInternal::removeAllSublayers): Ditto.
+        (PlatformCALayerWinInternal::insertSublayer): Ditto.
+        (PlatformCALayerWinInternal::sublayerCount): Ditto.
+        (PlatformCALayerWinInternal::indexOfSublayer): Ditto.
+        (PlatformCALayerWinInternal::sublayerAtIndex): Ditto.
+        (PlatformCALayerWinInternal::setBounds): Ditto.
+        (PlatformCALayerWinInternal::setFrame): Ditto.
+        (PlatformCALayerWinInternal::isOpaque): Ditto.
+        (PlatformCALayerWinInternal::setOpaque): Ditto.
+        (PlatformCALayerWinInternal::contentsScale): Ditto.
+        (PlatformCALayerWinInternal::setContentsScale): Ditto.
+        (PlatformCALayerWinInternal::setBorderWidth): Ditto.
+        (PlatformCALayerWinInternal::setBorderColor): Ditto.
+        (layerTypeIsTiled): Deleted.
+        (PlatformCALayerWinInternal::constrainedSize): Deleted.
+        (PlatformCALayerWinInternal::tileDisplayCallback): Deleted.
+        (PlatformCALayerWinInternal::addTile): Deleted.
+        (PlatformCALayerWinInternal::removeTile): Deleted.
+        (PlatformCALayerWinInternal::tileAtIndex): Deleted.
+        (PlatformCALayerWinInternal::tileCount): Deleted.
+        (PlatformCALayerWinInternal::updateTiles): Deleted.
+        (PlatformCALayerWinInternal::drawTile): Deleted.
+        (PlatformCALayerWinInternal::createTileController): Deleted.
+        (PlatformCALayerWinInternal::tiledBacking): Deleted.
+        * platform/graphics/ca/win/PlatformCALayerWinInternal.h:
+        (WebCore::PlatformCALayerWinInternal::owner):
+        * platform/graphics/ca/win/WebTiledBackingLayerWin.cpp: Added.
+        (WebTiledBackingLayerWin::WebTiledBackingLayerWin):
+        (WebTiledBackingLayerWin::~WebTiledBackingLayerWin):
+        (DisplayOnMainThreadContext::DisplayOnMainThreadContext):
+        (redispatchOnMainQueue):
+        (WebTiledBackingLayerWin::displayCallback):
+        (WebTiledBackingLayerWin::setNeedsDisplay):
+        (WebTiledBackingLayerWin::setNeedsDisplayInRect):
+        (WebTiledBackingLayerWin::setBounds):
+        (WebTiledBackingLayerWin::isOpaque):
+        (WebTiledBackingLayerWin::setOpaque):
+        (WebTiledBackingLayerWin::contentsScale):
+        (WebTiledBackingLayerWin::setContentsScale):
+        (WebTiledBackingLayerWin::setBorderWidth):
+        (WebTiledBackingLayerWin::setBorderColor):
+        (WebTiledBackingLayerWin::createTileController):
+        (WebTiledBackingLayerWin::tiledBacking):
+        (WebTiledBackingLayerWin::invalidate):
+        * platform/graphics/ca/win/WebTiledBackingLayerWin.h: Added.
+
</ins><span class="cx"> 2015-09-14  David Hyatt  &lt;hyatt@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [New Block-Inside-Inline Model] Implement margin collapsing across contiguous anonymous inline blocks.
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformAppleWincmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformAppleWin.cmake (189820 => 189821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformAppleWin.cmake        2015-09-15 19:47:34 UTC (rev 189820)
+++ trunk/Source/WebCore/PlatformAppleWin.cmake        2015-09-15 19:56:34 UTC (rev 189821)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx">     platform/graphics/ca/win/PlatformCAFiltersWin.cpp
</span><span class="cx">     platform/graphics/ca/win/PlatformCALayerWin.cpp
</span><span class="cx">     platform/graphics/ca/win/PlatformCALayerWinInternal.cpp
</span><ins>+    platform/graphics/ca/win/WebTiledBackingLayerWin.cpp
</ins><span class="cx">     platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp
</span><span class="cx"> 
</span><span class="cx">     platform/graphics/cg/BitmapImageCG.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (189820 => 189821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-09-15 19:47:34 UTC (rev 189820)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-09-15 19:56:34 UTC (rev 189821)
</span><span class="lines">@@ -7484,6 +7484,12 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\FileSystem.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\graphics\avfoundation\cf\CDMSessionAVFoundationCF.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\graphics\avfoundation\cf\WebCoreAVCFResourceLoader.cpp&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\platform\graphics\ca\win\WebTiledBackingLayerWin.cpp&quot;&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+    &lt;/ClCompile&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\platform\graphics\ISOVTTCue.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\audio\AudioSession.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\audio\PlatformMediaSession.cpp&quot; /&gt;
</span><span class="lines">@@ -20849,6 +20855,12 @@
</span><span class="cx">     &lt;/ClInclude&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\ca\win\PlatformCAAnimationWin.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\ca\win\PlatformCALayerWin.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\platform\graphics\ca\win\WebTiledBackingLayerWin.h&quot;&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\GLContext.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\GraphicsContext3DPrivate.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\cg\SubimageCacheWithTimer.h&quot;&gt;
</span><span class="lines">@@ -22832,4 +22844,4 @@
</span><span class="cx">   &lt;ImportGroup Label=&quot;ExtensionTargets&quot;&gt;
</span><span class="cx">     &lt;Import Project=&quot;$(VCTargetsPath)\BuildCustomizations\masm.targets&quot; /&gt;
</span><span class="cx">   &lt;/ImportGroup&gt;
</span><del>-&lt;/Project&gt;
</del><ins>+&lt;/Project&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (189820 => 189821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2015-09-15 19:47:34 UTC (rev 189820)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2015-09-15 19:56:34 UTC (rev 189821)
</span><span class="lines">@@ -3033,9 +3033,6 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\dom\ChildNodeList.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;dom&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><del>-    &lt;ClCompile Include=&quot;..\dom\ClassNodeList.cpp&quot;&gt;
-      &lt;Filter&gt;dom&lt;/Filter&gt;
-    &lt;/ClCompile&gt;
</del><span class="cx">     &lt;ClCompile Include=&quot;..\dom\ClientRect.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;dom&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><span class="lines">@@ -3234,9 +3231,6 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\dom\Node.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;dom&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><del>-    &lt;ClCompile Include=&quot;..\dom\NodeFilter.cpp&quot;&gt;
-      &lt;Filter&gt;dom&lt;/Filter&gt;
-    &lt;/ClCompile&gt;
</del><span class="cx">     &lt;ClCompile Include=&quot;..\dom\NodeFilterCondition.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;dom&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><span class="lines">@@ -7263,6 +7257,12 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\page\DOMSecurityPolicy.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;page&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\platform\network\DataURLDecoder.cpp&quot; /&gt;
+    &lt;ClCompile Include=&quot;..\dom\ClassCollection.cpp&quot; /&gt;
+    &lt;ClCompile Include=&quot;..\html\GenericCachedHTMLCollection.cpp&quot; /&gt;
+    &lt;ClCompile Include=&quot;..\platform\graphics\ca\win\WebTiledBackingLayerWin.cpp&quot;&gt;
+      &lt;Filter&gt;platform\graphics\ca\win&lt;/Filter&gt;
+    &lt;/ClCompile&gt;
</ins><span class="cx">   &lt;/ItemGroup&gt;
</span><span class="cx">   &lt;ItemGroup&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\Modules\geolocation\Coordinates.h&quot;&gt;
</span><span class="lines">@@ -10097,9 +10097,6 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dom\ChildNodeList.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;dom&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><del>-    &lt;ClInclude Include=&quot;..\dom\ClassNodeList.h&quot;&gt;
-      &lt;Filter&gt;dom&lt;/Filter&gt;
-    &lt;/ClInclude&gt;
</del><span class="cx">     &lt;ClInclude Include=&quot;..\dom\ClientRect.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;dom&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><span class="lines">@@ -15249,6 +15246,12 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\page\DOMSecurityPolicy.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;page&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\ForwardingHeaders\inspector\InspectorFrontendRouter.h&quot; /&gt;
+    &lt;ClInclude Include=&quot;..\platform\network\DataURLDecoder.h&quot; /&gt;
+    &lt;ClInclude Include=&quot;..\dom\ClassCollection.h&quot; /&gt;
+    &lt;ClInclude Include=&quot;..\platform\graphics\ca\win\WebTiledBackingLayerWin.h&quot;&gt;
+      &lt;Filter&gt;platform\graphics\ca\win&lt;/Filter&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">   &lt;/ItemGroup&gt;
</span><span class="cx">   &lt;ItemGroup&gt;
</span><span class="cx">     &lt;None Include=&quot;..\css\CSSGrammar.y.in&quot;&gt;
</span><span class="lines">@@ -15453,4 +15456,4 @@
</span><span class="cx">       &lt;Filter&gt;platform\win&lt;/Filter&gt;
</span><span class="cx">     &lt;/MASM&gt;
</span><span class="cx">   &lt;/ItemGroup&gt;
</span><del>-&lt;/Project&gt;
</del><ins>+&lt;/Project&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaPlatformCALayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp (189820 => 189821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp        2015-09-15 19:47:34 UTC (rev 189820)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp        2015-09-15 19:56:34 UTC (rev 189821)
</span><span class="lines">@@ -62,9 +62,11 @@
</span><span class="cx">     snprintf(text, sizeof(text), &quot;%d&quot;, repaintCount);
</span><span class="cx">     
</span><span class="cx">     CGRect indicatorBox = platformCALayer-&gt;bounds();
</span><ins>+
+    CGContextSaveGState(context);
+
</ins><span class="cx">     indicatorBox.size.width = 12 + 10 * strlen(text);
</span><span class="cx">     indicatorBox.size.height = 27;
</span><del>-    CGContextSaveGState(context);
</del><span class="cx">     
</span><span class="cx">     CGContextSetAlpha(context, 0.5f);
</span><span class="cx">     CGContextBeginTransparencyLayerWithRect(context, indicatorBox, 0);
</span><span class="lines">@@ -81,15 +83,27 @@
</span><span class="cx">     else
</span><span class="cx">         CGContextSetRGBFillColor(context, 1, 1, 1, 1);
</span><span class="cx">     
</span><ins>+    platformCALayer-&gt;drawTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, text, strlen(text));
+    
+    CGContextEndTransparencyLayer(context);
+    CGContextRestoreGState(context);
+}
+
+void PlatformCALayer::flipContext(CGContextRef context, CGFloat height)
+{
+    CGContextScaleCTM(context, 1, -1);
+    CGContextTranslateCTM(context, 0, -height);
+}
+
+// This function is needed to work around a bug in Windows CG &lt;rdar://problem/22703470&gt;
+void PlatformCALayer::drawTextAtPoint(CGContextRef context, CGFloat x, CGFloat y, const char* text, size_t length) const
+{
</ins><span class="cx"> #pragma clang diagnostic push
</span><span class="cx"> #pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
</span><span class="cx">     CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));
</span><span class="cx">     CGContextSelectFont(context, &quot;Helvetica&quot;, 22, kCGEncodingMacRoman);
</span><del>-    CGContextShowTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, text, strlen(text));
</del><ins>+    CGContextShowTextAtPoint(context, x, y, text, length);
</ins><span class="cx"> #pragma clang diagnostic pop
</span><del>-    
-    CGContextEndTransparencyLayer(context);
-    CGContextRestoreGState(context);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;PlatformCALayer&gt; PlatformCALayer::createCompatibleLayerOrTakeFromPool(PlatformCALayer::LayerType layerType, PlatformCALayerClient* client, IntSize size)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaPlatformCALayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h (189820 => 189821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h        2015-09-15 19:47:34 UTC (rev 189820)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h        2015-09-15 19:56:34 UTC (rev 189821)
</span><span class="lines">@@ -226,6 +226,10 @@
</span><span class="cx"> 
</span><span class="cx">     virtual TiledBacking* tiledBacking() = 0;
</span><span class="cx"> 
</span><ins>+    virtual void drawTextAtPoint(CGContextRef, CGFloat x, CGFloat y, const char* text, size_t length) const;
+
+    static void flipContext(CGContextRef, CGFloat height);
+
</ins><span class="cx"> #if PLATFORM(WIN)
</span><span class="cx">     virtual PlatformCALayer* rootLayer() const = 0;
</span><span class="cx">     virtual void setNeedsLayout() = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaTileGridcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp (189820 => 189821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp        2015-09-15 19:47:34 UTC (rev 189820)
+++ trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp        2015-09-15 19:56:34 UTC (rev 189821)
</span><span class="lines">@@ -673,8 +673,13 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     int repaintCount = platformCALayerIncrementRepaintCount(platformCALayer);
</span><del>-    if (m_controller.rootLayer().owner()-&gt;platformCALayerShowRepaintCounter(0))
</del><ins>+    if (m_controller.rootLayer().owner()-&gt;platformCALayerShowRepaintCounter(0)) {
+#if OS(WINDOWS)
+        // Tiled layers in Windows have flipped coordinates
+        PlatformCALayer::flipContext(context.platformContext(), platformCALayer-&gt;bounds().size().height());
+#endif
</ins><span class="cx">         PlatformCALayer::drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_controller.tileDebugBorderColor(), ColorSpaceDeviceRGB));
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     if (m_controller.scrollingPerformanceLoggingEnabled()) {
</span><span class="cx">         FloatRect visiblePart(platformCALayer-&gt;position().x(), platformCALayer-&gt;position().y(), platformCALayer-&gt;bounds().size().width(), platformCALayer-&gt;bounds().size().height());
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscawinPlatformCALayerWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp (189820 => 189821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp        2015-09-15 19:47:34 UTC (rev 189820)
+++ trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp        2015-09-15 19:56:34 UTC (rev 189821)
</span><span class="lines">@@ -32,8 +32,10 @@
</span><span class="cx"> #include &quot;GraphicsContext.h&quot;
</span><span class="cx"> #include &quot;PlatformCAAnimationWin.h&quot;
</span><span class="cx"> #include &quot;PlatformCALayerWinInternal.h&quot;
</span><ins>+#include &quot;TextRun.h&quot;
</ins><span class="cx"> #include &quot;TileController.h&quot;
</span><span class="cx"> #include &quot;WebCoreHeaderDetection.h&quot;
</span><ins>+#include &quot;WebTiledBackingLayerWin.h&quot;
</ins><span class="cx"> #include &lt;QuartzCore/CoreAnimationCF.h&gt;
</span><span class="cx"> #include &lt;WebKitSystemInterface/WebKitSystemInterface.h&gt;
</span><span class="cx"> #include &lt;wtf/CurrentTime.h&gt;
</span><span class="lines">@@ -142,17 +144,20 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     // Create the PlatformCALayerWinInternal object and point to it in the userdata.
</span><del>-    PlatformCALayerWinInternal* intern = new PlatformCALayerWinInternal(this);
</del><ins>+    PlatformCALayerWinInternal* intern = nullptr;
+
+    if (usesTiledBackingLayer()) {
+        intern = new WebTiledBackingLayerWin(this);
+        TileController* tileController = reinterpret_cast&lt;WebTiledBackingLayerWin*&gt;(intern)-&gt;createTileController(this);
+        m_customSublayers = std::make_unique&lt;PlatformCALayerList&gt;(tileController-&gt;containerLayers());
+    } else
+        intern = new PlatformCALayerWinInternal(this);
+
</ins><span class="cx">     CACFLayerSetUserData(m_layer.get(), intern);
</span><span class="cx"> 
</span><span class="cx">     // Set the display callback
</span><span class="cx">     CACFLayerSetDisplayCallback(m_layer.get(), displayCallback);
</span><span class="cx">     CACFLayerSetLayoutCallback(m_layer.get(), layoutSublayersProc);
</span><del>-
-    if (usesTiledBackingLayer()) {
-        TileController* tileController = intern-&gt;createTileController(this);
-        m_customSublayers = std::make_unique&lt;PlatformCALayerList&gt;(tileController-&gt;containerLayers());
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PlatformCALayerWin::~PlatformCALayerWin()
</span><span class="lines">@@ -160,10 +165,13 @@
</span><span class="cx">     // Toss all the kids
</span><span class="cx">     removeAllSublayers();
</span><span class="cx"> 
</span><del>-    // Get rid of the user data
</del><span class="cx">     PlatformCALayerWinInternal* layerIntern = intern(this);
</span><del>-    CACFLayerSetUserData(m_layer.get(), 0);
</del><ins>+    if (usesTiledBackingLayer())
+        reinterpret_cast&lt;WebTiledBackingLayerWin*&gt;(layerIntern)-&gt;invalidate();
</ins><span class="cx"> 
</span><ins>+    // Get rid of the user data
+    CACFLayerSetUserData(m_layer.get(), nullptr);
+
</ins><span class="cx">     CACFLayerRemoveFromSuperlayer(m_layer.get());
</span><span class="cx"> 
</span><span class="cx">     delete layerIntern;
</span><span class="lines">@@ -358,12 +366,12 @@
</span><span class="cx"> 
</span><span class="cx"> bool PlatformCALayerWin::isOpaque() const
</span><span class="cx"> {
</span><del>-    return CACFLayerIsOpaque(m_layer.get());
</del><ins>+    return intern(this)-&gt;isOpaque();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PlatformCALayerWin::setOpaque(bool value)
</span><span class="cx"> {
</span><del>-    CACFLayerSetOpaque(m_layer.get(), value);
</del><ins>+    intern(this)-&gt;setOpaque(value);
</ins><span class="cx">     setNeedsCommit();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -526,19 +534,13 @@
</span><span class="cx"> 
</span><span class="cx"> void PlatformCALayerWin::setBorderWidth(float value)
</span><span class="cx"> {
</span><del>-    CACFLayerSetBorderWidth(m_layer.get(), value);
</del><ins>+    intern(this)-&gt;setBorderWidth(value);
</ins><span class="cx">     setNeedsCommit();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PlatformCALayerWin::setBorderColor(const Color&amp; value)
</span><span class="cx"> {
</span><del>-    CGFloat components[4];
-    value.getRGBA(components[0], components[1], components[2], components[3]);
-
-    RetainPtr&lt;CGColorSpaceRef&gt; colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
-    RetainPtr&lt;CGColorRef&gt; color = adoptCF(CGColorCreate(colorSpace.get(), components));
-
-    CACFLayerSetBorderColor(m_layer.get(), color.get());
</del><ins>+    intern(this)-&gt;setBorderColor(value);
</ins><span class="cx">     setNeedsCommit();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -587,18 +589,13 @@
</span><span class="cx"> 
</span><span class="cx"> float PlatformCALayerWin::contentsScale() const
</span><span class="cx"> {
</span><del>-#if HAVE(CACFLAYER_SETCONTENTSSCALE)
-    return CACFLayerGetContentsScale(m_layer.get());
-#else
-    return 1.0f;
-#endif
</del><ins>+    return intern(this)-&gt;contentsScale();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PlatformCALayerWin::setContentsScale(float scaleFactor)
</span><span class="cx"> {
</span><del>-#if HAVE(CACFLAYER_SETCONTENTSSCALE)
-    CACFLayerSetContentsScale(m_layer.get(), scaleFactor);
-#endif
</del><ins>+    intern(this)-&gt;setContentsScale(scaleFactor);
+    setNeedsCommit();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> float PlatformCALayerWin::cornerRadius() const
</span><span class="lines">@@ -776,5 +773,26 @@
</span><span class="cx">     if (!usesTiledBackingLayer())
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    return intern(this)-&gt;tiledBacking();
</del><ins>+    return reinterpret_cast&lt;WebTiledBackingLayerWin*&gt;(intern(this))-&gt;tiledBacking();
</ins><span class="cx"> }
</span><ins>+
+void PlatformCALayerWin::drawTextAtPoint(CGContextRef context, CGFloat x, CGFloat y, const char* message, size_t length) const
+{
+    String text(message, length);
+
+    FontDescription desc;
+
+    NONCLIENTMETRICS metrics;
+    metrics.cbSize = sizeof(metrics);
+    SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &amp;metrics, 0);
+    desc.setOneFamily(metrics.lfSmCaptionFont.lfFaceName);
+
+    desc.setComputedSize(18);
+
+    FontCascade font = FontCascade(desc, 0, 0);
+    font.update(nullptr);
+
+    GraphicsContext cg(context);
+    cg.setFillColor(Color::black, ColorSpaceDeviceRGB);
+    cg.drawText(font, TextRun(text), IntPoint(x, y));
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscawinPlatformCALayerWinh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h (189820 => 189821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h        2015-09-15 19:47:34 UTC (rev 189820)
+++ trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h        2015-09-15 19:56:34 UTC (rev 189821)
</span><span class="lines">@@ -148,6 +148,7 @@
</span><span class="cx">     virtual PlatformCALayer* rootLayer() const override;
</span><span class="cx">     virtual void setNeedsLayout() override;
</span><span class="cx">     virtual void setNeedsCommit() override;
</span><ins>+    virtual void drawTextAtPoint(CGContextRef, CGFloat x, CGFloat y, const char* text, size_t length) const override;
</ins><span class="cx"> 
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     virtual void printTree() const override;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscawinPlatformCALayerWinInternalcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp (189820 => 189821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp        2015-09-15 19:47:34 UTC (rev 189820)
+++ trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp        2015-09-15 19:56:34 UTC (rev 189821)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> #include &quot;FontCascade.h&quot;
</span><span class="cx"> #include &quot;GraphicsContext.h&quot;
</span><span class="cx"> #include &quot;PlatformCALayer.h&quot;
</span><del>-#include &quot;TextRun.h&quot;
</del><span class="cx"> #include &quot;TileController.h&quot;
</span><span class="cx"> #include &quot;TiledBacking.h&quot;
</span><span class="cx"> #include &quot;WebCoreHeaderDetection.h&quot;
</span><span class="lines">@@ -40,33 +39,9 @@
</span><span class="cx"> using namespace std;
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><del>-// The width and height of a single tile in a tiled layer. Should be large enough to
-// avoid lots of small tiles (and therefore lots of drawing callbacks), but small enough
-// to keep the overall tile cost low.
-static const int cTiledLayerTileSize = 512;
-
-static bool layerTypeIsTiled(const PlatformCALayer::LayerType layerType)
-{
-    return layerType == PlatformCALayer::LayerTypeWebTiledLayer
-        || layerType == PlatformCALayer::LayerTypePageTiledBackingLayer
-        || layerType == PlatformCALayer::LayerTypeTiledBackingLayer;
-}
-
</del><span class="cx"> PlatformCALayerWinInternal::PlatformCALayerWinInternal(PlatformCALayer* owner)
</span><del>-    : m_tileSize(CGSizeMake(cTiledLayerTileSize, cTiledLayerTileSize))
-    , m_constrainedSize(constrainedSize(owner-&gt;bounds().size()))
-    , m_owner(owner)
</del><ins>+    : m_owner(owner)
</ins><span class="cx"> {
</span><del>-    if (layerTypeIsTiled(m_owner-&gt;layerType())) {
-        // Tiled layers are placed in a child layer that is always the first child of the TiledLayer
-        m_tileParent = adoptCF(CACFLayerCreate(kCACFLayer));
-        CACFLayerInsertSublayer(m_owner-&gt;platformLayer(), m_tileParent.get(), 0);
-#if HAVE(CACFLAYER_SETCONTENTSSCALE)
-        CACFLayerSetContentsScale(m_tileParent.get(), CACFLayerGetContentsScale(m_owner-&gt;platformLayer()));
-#endif
-
-        updateTiles();
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PlatformCALayerWinInternal::~PlatformCALayerWinInternal()
</span><span class="lines">@@ -96,6 +71,17 @@
</span><span class="cx">     self-&gt;displayCallback(retainedContext-&gt;layer.get(), retainedContext-&gt;context.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static bool shouldInvertBeforeDrawingContent(PlatformCALayer::LayerType layerType, GraphicsLayer::CompositingCoordinatesOrientation coordinateOrientation)
+{
+    return (layerType != PlatformCALayer::LayerTypeTiledBackingTileLayer)
+        &amp;&amp; (coordinateOrientation == GraphicsLayer::CompositingCoordinatesTopDown);
+}
+
+static bool repaintCountersAreDrawnByGridController(PlatformCALayer::LayerType layerType)
+{
+    return layerType == PlatformCALayer::LayerTypeTiledBackingTileLayer;
+}
+
</ins><span class="cx"> void PlatformCALayerWinInternal::displayCallback(CACFLayerRef caLayer, CGContextRef context)
</span><span class="cx"> {
</span><span class="cx">     if (!isMainThread()) {
</span><span class="lines">@@ -109,127 +95,90 @@
</span><span class="cx">     CGContextSaveGState(context);
</span><span class="cx"> 
</span><span class="cx">     CGRect layerBounds = owner()-&gt;bounds();
</span><del>-    if (owner()-&gt;owner()-&gt;platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {
-        CGContextScaleCTM(context, 1, -1);
-        CGContextTranslateCTM(context, 0, -layerBounds.size.height);
-    }
</del><ins>+    PlatformCALayer::LayerType layerType = owner()-&gt;layerType();
</ins><span class="cx"> 
</span><del>-    if (owner()-&gt;owner()) {
-        GraphicsContext graphicsContext(context);
</del><ins>+    PlatformCALayerClient* client = owner()-&gt;owner();
+    GraphicsLayer::CompositingCoordinatesOrientation orientation = client-&gt;platformCALayerContentsOrientation();
</ins><span class="cx"> 
</span><del>-        // It's important to get the clip from the context, because it may be significantly
-        // smaller than the layer bounds (e.g. tiled layers)
-        CGRect clipBounds = CGContextGetClipBoundingBox(context);
-        IntRect clip(enclosingIntRect(clipBounds));
-        owner()-&gt;owner()-&gt;platformCALayerPaintContents(owner(), graphicsContext, clip);
-    }
-#ifndef NDEBUG
-    else {
-        ASSERT_NOT_REACHED();
</del><ins>+    if (shouldInvertBeforeDrawingContent(layerType, orientation))
+        PlatformCALayer::flipContext(context, layerBounds.size.height);
</ins><span class="cx"> 
</span><del>-        // FIXME: ideally we'd avoid calling -setNeedsDisplay on a layer that is a plain color,
-        // so CA never makes backing store for it (which is what -setNeedsDisplay will do above).
-        CGContextSetRGBFillColor(context, 0.0f, 1.0f, 0.0f, 1.0f);
-        CGContextFillRect(context, layerBounds);
-    }
-#endif
</del><ins>+    GraphicsContext graphicsContext(context);
</ins><span class="cx"> 
</span><del>-    if (owner()-&gt;owner()-&gt;platformCALayerShowRepaintCounter(owner())) {
-        String text = String::number(owner()-&gt;owner()-&gt;platformCALayerIncrementRepaintCount(owner()));
</del><ins>+    // It's important to get the clip from the context, because it may be significantly
+    // smaller than the layer bounds (e.g. tiled layers)
+    CGRect clipBounds = CGContextGetClipBoundingBox(context);
+    IntRect clip(enclosingIntRect(clipBounds));
+    client-&gt;platformCALayerPaintContents(owner(), graphicsContext, clip);
</ins><span class="cx"> 
</span><del>-        CGContextSaveGState(context);
-
-        // Make the background of the counter the same as the border color,
-        // unless there is no border, then make it red
-        float borderWidth = CACFLayerGetBorderWidth(caLayer);
-        if (borderWidth &gt; 0) {
-            CGColorRef borderColor = CACFLayerGetBorderColor(caLayer);
-            const CGFloat* colors = CGColorGetComponents(borderColor);
-            CGContextSetRGBFillColor(context, colors[0], colors[1], colors[2], colors[3]);
-        } else
-            CGContextSetRGBFillColor(context, 1.0f, 0.0f, 0.0f, 0.8f);
-        
-        CGRect aBounds = layerBounds;
-
-        aBounds.size.width = 10 + 10 * text.length();
-        aBounds.size.height = 22;
-        CGContextFillRect(context, aBounds);
-        
-        FontDescription desc;
-
-        NONCLIENTMETRICS metrics;
-        metrics.cbSize = sizeof(metrics);
-        SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &amp;metrics, 0);
-        desc.setOneFamily(metrics.lfSmCaptionFont.lfFaceName);
-
-        desc.setComputedSize(18);
-        
-        FontCascade font = FontCascade(desc, 0, 0);
-        font.update(0);
-
-        GraphicsContext cg(context);
-        cg.setFillColor(Color::black, ColorSpaceDeviceRGB);
-        cg.drawText(font, TextRun(text), IntPoint(aBounds.origin.x + 5, aBounds.origin.y + 17));
-
-        CGContextRestoreGState(context);        
</del><ins>+    if (client-&gt;platformCALayerShowRepaintCounter(owner())
+        &amp;&amp; !repaintCountersAreDrawnByGridController(layerType)) {
+        int drawCount = client-&gt;platformCALayerIncrementRepaintCount(owner());
+        drawRepaintCounters(caLayer, context, layerBounds, drawCount);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     CGContextRestoreGState(context);
</span><span class="cx"> 
</span><del>-    owner()-&gt;owner()-&gt;platformCALayerLayerDidDisplay(owner());
</del><ins>+    client-&gt;platformCALayerLayerDidDisplay(owner());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PlatformCALayerWinInternal::drawRepaintCounters(CACFLayerRef caLayer, CGContextRef context, CGRect layerBounds, int drawCount)
+{
+    CGColorRef backgroundColor = nullptr;
+    // Make the background of the counter the same as the border color,
+    // unless there is no border, then make it red
+    float borderWidth = CACFLayerGetBorderWidth(caLayer);
+    if (borderWidth &gt; 0)
+        backgroundColor = CACFLayerGetBorderColor(caLayer);
+    else
+        backgroundColor = cachedCGColor(Color(255, 0, 0), ColorSpaceDeviceRGB);
+
+    PlatformCALayer::drawRepaintIndicator(context, owner(), drawCount, backgroundColor);
+}
+
</ins><span class="cx"> void PlatformCALayerWinInternal::internalSetNeedsDisplay(const FloatRect* dirtyRect)
</span><span class="cx"> {
</span><span class="cx">     if (dirtyRect) {
</span><span class="cx">         CGRect rect = *dirtyRect;
</span><span class="cx">         CACFLayerSetNeedsDisplay(owner()-&gt;platformLayer(), &amp;rect);
</span><span class="cx">     } else
</span><del>-        CACFLayerSetNeedsDisplay(owner()-&gt;platformLayer(), 0);
</del><ins>+        CACFLayerSetNeedsDisplay(owner()-&gt;platformLayer(), nullptr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PlatformCALayerWinInternal::setNeedsDisplay()
</span><span class="cx"> {
</span><del>-    internalSetNeedsDisplay(0);
</del><ins>+    internalSetNeedsDisplay(nullptr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PlatformCALayerWinInternal::setNeedsDisplayInRect(const FloatRect&amp; dirtyRect)
</span><span class="cx"> {
</span><del>-    if (layerTypeIsTiled(m_owner-&gt;layerType())) {
-        // FIXME: Only setNeedsDisplay for tiles that are currently visible
-        int numTileLayers = tileCount();
-        CGRect rect = dirtyRect;
-        for (int i = 0; i &lt; numTileLayers; ++i)
-            CACFLayerSetNeedsDisplay(tileAtIndex(i), &amp;rect);
</del><ins>+    if (!owner())
+        return;
</ins><span class="cx"> 
</span><del>-        if (m_owner-&gt;owner() &amp;&amp; m_owner-&gt;owner()-&gt;platformCALayerShowRepaintCounter(m_owner)) {
-            CGRect layerBounds = m_owner-&gt;bounds();
-            CGRect indicatorRect = CGRectMake(layerBounds.origin.x, layerBounds.origin.y, 80, 25);
-            CACFLayerSetNeedsDisplay(tileAtIndex(0), &amp;indicatorRect);
-        }
-    } else if (owner()-&gt;layerType() == PlatformCALayer::LayerTypeWebLayer) {
-        if (owner() &amp;&amp; owner()-&gt;owner()) {
-            if (owner()-&gt;owner()-&gt;platformCALayerShowRepaintCounter(owner())) {
-                FloatRect layerBounds = owner()-&gt;bounds();
-                FloatRect repaintCounterRect = layerBounds;
</del><ins>+    ASSERT(owner()-&gt;layerType() != PlatformCALayer::LayerTypeTiledBackingLayer);
</ins><span class="cx"> 
</span><del>-                // We assume a maximum of 4 digits and a font size of 18.
-                repaintCounterRect.setWidth(80);
-                repaintCounterRect.setHeight(22);
-                if (owner()-&gt;owner()-&gt;platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown)
-                    repaintCounterRect.setY(layerBounds.height() - (layerBounds.y() + repaintCounterRect.height()));
-                internalSetNeedsDisplay(&amp;repaintCounterRect);
-            }
-            if (owner()-&gt;owner()-&gt;platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {
-                FloatRect flippedDirtyRect = dirtyRect;
-                flippedDirtyRect.setY(owner()-&gt;bounds().height() - (flippedDirtyRect.y() + flippedDirtyRect.height()));
-                internalSetNeedsDisplay(&amp;flippedDirtyRect);
-                return;
-            }
-        }
</del><ins>+    if (owner()-&gt;owner()) {
+        if (owner()-&gt;owner()-&gt;platformCALayerShowRepaintCounter(owner())) {
+            FloatRect layerBounds = owner()-&gt;bounds();
+            FloatRect repaintCounterRect = layerBounds;
</ins><span class="cx"> 
</span><del>-        internalSetNeedsDisplay(&amp;dirtyRect);
</del><ins>+            // We assume a maximum of 4 digits and a font size of 18.
+            repaintCounterRect.setWidth(80);
+            repaintCounterRect.setHeight(22);
+            if (owner()-&gt;owner()-&gt;platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown)
+                repaintCounterRect.setY(layerBounds.height() - (layerBounds.y() + repaintCounterRect.height()));
+            internalSetNeedsDisplay(&amp;repaintCounterRect);
+        }
+        if (owner()-&gt;owner()-&gt;platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {
+            FloatRect flippedDirtyRect = dirtyRect;
+            flippedDirtyRect.setY(owner()-&gt;bounds().height() - (flippedDirtyRect.y() + flippedDirtyRect.height()));
+            internalSetNeedsDisplay(&amp;flippedDirtyRect);
+            return;
+        }
</ins><span class="cx">     }
</span><ins>+
+    internalSetNeedsDisplay(&amp;dirtyRect);
+
</ins><span class="cx">     owner()-&gt;setNeedsCommit();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -247,11 +196,6 @@
</span><span class="cx">         CACFLayerInsertSublayer(owner()-&gt;platformLayer(), list[i]-&gt;platformLayer(), i);
</span><span class="cx"> 
</span><span class="cx">     owner()-&gt;setNeedsCommit();
</span><del>-
-    if (layerTypeIsTiled(m_owner-&gt;layerType())) {
-        // Preserve the tile parent after set
-        CACFLayerInsertSublayer(owner()-&gt;platformLayer(), m_tileParent.get(), 0);
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PlatformCALayerWinInternal::getSublayers(PlatformCALayerList&amp; list) const
</span><span class="lines">@@ -264,35 +208,20 @@
</span><span class="cx"> 
</span><span class="cx">     size_t count = CFArrayGetCount(sublayers);
</span><span class="cx"> 
</span><del>-    size_t layersToSkip = 0;
-    if (layerTypeIsTiled(m_owner-&gt;layerType())) {
-        // Exclude the tile parent layer.
-        layersToSkip = 1;
-    }
-
-    list.resize(count - layersToSkip);
-    for (size_t arrayIndex = layersToSkip; arrayIndex &lt; count; ++arrayIndex)
-        list[arrayIndex - layersToSkip] = PlatformCALayer::platformCALayer(const_cast&lt;void*&gt;(CFArrayGetValueAtIndex(sublayers, arrayIndex)));
</del><ins>+    list.resize(count);
+    for (size_t arrayIndex = 0; arrayIndex &lt; count; ++arrayIndex)
+        list[arrayIndex] = PlatformCALayer::platformCALayer(const_cast&lt;void*&gt;(CFArrayGetValueAtIndex(sublayers, arrayIndex)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PlatformCALayerWinInternal::removeAllSublayers()
</span><span class="cx"> {
</span><del>-    CACFLayerSetSublayers(owner()-&gt;platformLayer(), 0);
</del><ins>+    CACFLayerSetSublayers(owner()-&gt;platformLayer(), nullptr);
</ins><span class="cx">     owner()-&gt;setNeedsCommit();
</span><del>-
-    if (layerTypeIsTiled(m_owner-&gt;layerType())) {
-        // Restore the tile parent after removal
-        CACFLayerInsertSublayer(owner()-&gt;platformLayer(), m_tileParent.get(), 0);
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PlatformCALayerWinInternal::insertSublayer(PlatformCALayer&amp; layer, size_t index)
</span><span class="cx"> {
</span><span class="cx">     index = min(index, sublayerCount());
</span><del>-    if (layerTypeIsTiled(m_owner-&gt;layerType())) {
-        // Add 1 to account for the tile parent layer
-        ++index;
-    }
</del><span class="cx"> 
</span><span class="cx">     layer.removeFromSuperlayer();
</span><span class="cx">     CACFLayerInsertSublayer(owner()-&gt;platformLayer(), layer.platformLayer(), index);
</span><span class="lines">@@ -302,15 +231,7 @@
</span><span class="cx"> size_t PlatformCALayerWinInternal::sublayerCount() const
</span><span class="cx"> {
</span><span class="cx">     CFArrayRef sublayers = CACFLayerGetSublayers(owner()-&gt;platformLayer());
</span><del>-    size_t count = sublayers ? CFArrayGetCount(sublayers) : 0;
-
-    if (layerTypeIsTiled(m_owner-&gt;layerType())) {
-        // Subtract 1 to account for the tile parent layer
-        ASSERT(count &gt; 0);
-        count--;
-    }
-
-    return count;
</del><ins>+    return sublayers ? CFArrayGetCount(sublayers) : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int PlatformCALayerWinInternal::indexOfSublayer(const PlatformCALayer* reference)
</span><span class="lines">@@ -325,16 +246,9 @@
</span><span class="cx"> 
</span><span class="cx">     size_t n = CFArrayGetCount(sublayers);
</span><span class="cx"> 
</span><del>-    if (layerTypeIsTiled(m_owner-&gt;layerType())) {
-        for (size_t i = 1; i &lt; n; ++i) {
-            if (CFArrayGetValueAtIndex(sublayers, i) == ref)
-                return i - 1;
-        }
-    } else {
-        for (size_t i = 0; i &lt; n; ++i) {
-            if (CFArrayGetValueAtIndex(sublayers, i) == ref)
-                return i;
-        }
</del><ins>+    for (size_t i = 0; i &lt; n; ++i) {
+        if (CFArrayGetValueAtIndex(sublayers, i) == ref)
+            return i;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return -1;
</span><span class="lines">@@ -342,14 +256,9 @@
</span><span class="cx"> 
</span><span class="cx"> PlatformCALayer* PlatformCALayerWinInternal::sublayerAtIndex(int index) const
</span><span class="cx"> {
</span><del>-    if (layerTypeIsTiled(m_owner-&gt;layerType())) {
-        // Add 1 to account for the tile parent layer
-        index++;
-    }
-
</del><span class="cx">     CFArrayRef sublayers = CACFLayerGetSublayers(owner()-&gt;platformLayer());
</span><span class="cx">     if (!sublayers || index &lt; 0 || CFArrayGetCount(sublayers) &lt;= index)
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     
</span><span class="cx">     return PlatformCALayer::platformCALayer(static_cast&lt;CACFLayerRef&gt;(const_cast&lt;void*&gt;(CFArrayGetValueAtIndex(sublayers, index))));
</span><span class="cx"> }
</span><span class="lines">@@ -361,11 +270,6 @@
</span><span class="cx"> 
</span><span class="cx">     CACFLayerSetBounds(owner()-&gt;platformLayer(), rect);
</span><span class="cx">     owner()-&gt;setNeedsCommit();
</span><del>-
-    if (layerTypeIsTiled(m_owner-&gt;layerType())) {
-        m_constrainedSize = constrainedSize(rect.size());
-        updateTiles();
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PlatformCALayerWinInternal::setFrame(const FloatRect&amp; rect)
</span><span class="lines">@@ -376,166 +280,48 @@
</span><span class="cx"> 
</span><span class="cx">     CACFLayerSetFrame(owner()-&gt;platformLayer(), rect);
</span><span class="cx">     owner()-&gt;setNeedsCommit();
</span><del>-
-    if (layerTypeIsTiled(m_owner-&gt;layerType()))
-        updateTiles();
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-CGSize PlatformCALayerWinInternal::constrainedSize(const CGSize&amp; size) const
</del><ins>+bool PlatformCALayerWinInternal::isOpaque() const
</ins><span class="cx"> {
</span><del>-    const int cMaxTileCount = 512;
-    const float cSqrtMaxTileCount = sqrtf(cMaxTileCount);
-
-    CGSize constrainedSize = size;
-
-    int tileColumns = ceilf(constrainedSize.width / m_tileSize.width);
-    int tileRows = ceilf(constrainedSize.height / m_tileSize.height);
-
-    bool tooManyTiles = tileColumns &amp;&amp; numeric_limits&lt;int&gt;::max() / tileColumns &lt; tileRows || tileColumns * tileRows &gt; cMaxTileCount;
-
-    // If number of tiles vertically or horizontally is &lt; sqrt(cMaxTileCount)
-    // just shorten the longer dimension. Otherwise shorten both dimensions
-    // according to the ratio of width to height
-
-    if (tooManyTiles) {
-        if (tileRows &lt; cSqrtMaxTileCount)
-            tileColumns = floorf(cMaxTileCount / tileRows);
-        else if (tileColumns &lt; cSqrtMaxTileCount)
-            tileRows = floorf(cMaxTileCount / tileColumns);
-        else {
-            tileRows = ceilf(sqrtf(cMaxTileCount * constrainedSize.height / constrainedSize.width));
-            tileColumns = floorf(cMaxTileCount / tileRows);
-        }
-        
-        constrainedSize.width = tileColumns * m_tileSize.width;
-        constrainedSize.height = tileRows * m_tileSize.height;
-    }
-    
-    return constrainedSize;
</del><ins>+    return CACFLayerIsOpaque(owner()-&gt;platformLayer());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PlatformCALayerWinInternal::tileDisplayCallback(CACFLayerRef layer, CGContextRef context)
</del><ins>+void PlatformCALayerWinInternal::setOpaque(bool value)
</ins><span class="cx"> {
</span><del>-    static_cast&lt;PlatformCALayerWinInternal*&gt;(CACFLayerGetUserData(layer))-&gt;drawTile(layer, context);
</del><ins>+    CACFLayerSetOpaque(owner()-&gt;platformLayer(), value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PlatformCALayerWinInternal::addTile()
</del><ins>+float PlatformCALayerWinInternal::contentsScale() const
</ins><span class="cx"> {
</span><del>-    RetainPtr&lt;CACFLayerRef&gt; newLayer = adoptCF(CACFLayerCreate(kCACFLayer));
-    CACFLayerSetAnchorPoint(newLayer.get(), CGPointMake(0, 1));
-    CACFLayerSetUserData(newLayer.get(), this);
-    CACFLayerSetDisplayCallback(newLayer.get(), tileDisplayCallback);
</del><span class="cx"> #if HAVE(CACFLAYER_SETCONTENTSSCALE)
</span><del>-    CACFLayerSetContentsScale(newLayer.get(), CACFLayerGetContentsScale(m_tileParent.get()));
</del><ins>+    return CACFLayerGetContentsScale(owner()-&gt;platformLayer());
+#else
+    return 1.0f;
</ins><span class="cx"> #endif
</span><del>-
-    CFArrayRef sublayers = CACFLayerGetSublayers(m_tileParent.get());
-    CACFLayerInsertSublayer(m_tileParent.get(), newLayer.get(), sublayers ? CFArrayGetCount(sublayers) : 0);
-
-    if (owner()-&gt;owner()-&gt;platformCALayerShowDebugBorders()) {
-        CGColorRef borderColor = CGColorCreateGenericRGB(0.5, 0, 0.5, 0.7);
-        CACFLayerSetBorderColor(newLayer.get(), borderColor);
-        CGColorRelease(borderColor);
-        CACFLayerSetBorderWidth(newLayer.get(), 2);
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PlatformCALayerWinInternal::removeTile()
</del><ins>+void PlatformCALayerWinInternal::setContentsScale(float scaleFactor)
</ins><span class="cx"> {
</span><del>-    CACFLayerRemoveFromSuperlayer(tileAtIndex(tileCount() - 1));
</del><ins>+#if HAVE(CACFLAYER_SETCONTENTSSCALE)
+    CACFLayerSetContentsScale(owner()-&gt;platformLayer(), scaleFactor);
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-CACFLayerRef PlatformCALayerWinInternal::tileAtIndex(int index)
</del><ins>+void PlatformCALayerWinInternal::setBorderWidth(float value)
</ins><span class="cx"> {
</span><del>-    CFArrayRef sublayers = CACFLayerGetSublayers(m_tileParent.get());
-    if (!sublayers || index &lt; 0 || index &gt;= tileCount())
-        return 0;
-    
-    return static_cast&lt;CACFLayerRef&gt;(const_cast&lt;void*&gt;(CFArrayGetValueAtIndex(sublayers, index)));
</del><ins>+    CACFLayerSetBorderWidth(owner()-&gt;platformLayer(), value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-int PlatformCALayerWinInternal::tileCount() const
</del><ins>+void PlatformCALayerWinInternal::setBorderColor(const Color&amp; value)
</ins><span class="cx"> {
</span><del>-    CFArrayRef sublayers = CACFLayerGetSublayers(m_tileParent.get());
-    return sublayers ? CFArrayGetCount(sublayers) : 0;
-}
</del><ins>+    CGFloat components[4] = { 0, 0, 0, 0 };
+    RetainPtr&lt;CGColorSpaceRef&gt; colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
</ins><span class="cx"> 
</span><del>-void PlatformCALayerWinInternal::updateTiles()
-{
-    // FIXME: In addition to redoing the number of tiles, we need to only render and have backing
-    // store for visible layers
-    int numTilesHorizontal = ceil(m_constrainedSize.width / m_tileSize.width);
-    int numTilesVertical = ceil(m_constrainedSize.height / m_tileSize.height);
-    int numTilesTotal = numTilesHorizontal * numTilesVertical;
-    ASSERT(!m_constrainedSize.height || !m_constrainedSize.width || numTilesTotal &gt; 0);
</del><ins>+    if (value.isValid())
+        value.getRGBA(components[0], components[1], components[2], components[3]);
</ins><span class="cx"> 
</span><del>-    int numTilesToChange = numTilesTotal - tileCount();
-    if (numTilesToChange &gt;= 0) {
-        // Add new tiles
-        for (int i = 0; i &lt; numTilesToChange; ++i)
-            addTile();
-    } else {
-        // Remove old tiles
-        numTilesToChange = -numTilesToChange;
-        for (int i = 0; i &lt; numTilesToChange; ++i)
-            removeTile();
-    }
</del><ins>+    RetainPtr&lt;CGColorRef&gt; color = adoptCF(CGColorCreate(colorSpace.get(), components));
</ins><span class="cx"> 
</span><del>-    // Set coordinates for all tiles
-    CFArrayRef tileArray = CACFLayerGetSublayers(m_tileParent.get());
-
-    for (int i = 0; i &lt; numTilesHorizontal; ++i) {
-        for (int j = 0; j &lt; numTilesVertical; ++j) {
-            CACFLayerRef tile = static_cast&lt;CACFLayerRef&gt;(const_cast&lt;void*&gt;(CFArrayGetValueAtIndex(tileArray, i * numTilesVertical + j)));
-            CACFLayerSetPosition(tile, CGPointMake(i * m_tileSize.width, j * m_tileSize.height));
-            int width = min(m_tileSize.width, m_constrainedSize.width - i * m_tileSize.width);
-            int height = min(m_tileSize.height, m_constrainedSize.height - j * m_tileSize.height);
-            CACFLayerSetBounds(tile, CGRectMake(i * m_tileSize.width, j * m_tileSize.height, width, height));
-
-            // Flip Y to compensate for the flipping that happens during render to match the CG context coordinate space
-            CATransform3D transform = CATransform3DMakeScale(1, -1, 1);
-            CATransform3DTranslate(transform, 0, height, 0);
-            CACFLayerSetTransform(tile, transform);
-
-#ifndef NDEBUG
-            String name = &quot;Tile (&quot; + String::number(i) + &quot;,&quot; + String::number(j) + &quot;)&quot;;
-            CACFLayerSetName(tile, name.createCFString().get());
-#endif
-        }
-    }
</del><ins>+    CACFLayerSetBorderColor(owner()-&gt;platformLayer(), color.get());
</ins><span class="cx"> }
</span><del>-
-void PlatformCALayerWinInternal::drawTile(CACFLayerRef tile, CGContextRef context)
-{
-    CGPoint tilePosition = CACFLayerGetPosition(tile);
-    CGRect tileBounds = CACFLayerGetBounds(tile);
-
-    CGContextSaveGState(context);
-
-    // Set the context clipping rectangle to the current tile
-    CGContextClipToRect(context, CGRectMake(tilePosition.x, tilePosition.y, tileBounds.size.width, tileBounds.size.height));
-
-    if (owner()-&gt;owner()-&gt;platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {
-        // If the layer is rendering top-down, it will flip the coordinates in y. Tiled layers are
-        // already flipping, so we need to undo that here.
-        CGContextTranslateCTM(context, 0, owner()-&gt;bounds().height());
-        CGContextScaleCTM(context, 1, -1);
-    }
-
-    // Draw the tile
-    displayCallback(owner()-&gt;platformLayer(), context);
-
-    CGContextRestoreGState(context);
-}
-
-TileController* PlatformCALayerWinInternal::createTileController(PlatformCALayer* rootLayer)
-{
-    ASSERT(!m_tileController);
-    m_tileController = std::make_unique&lt;TileController&gt;(rootLayer);
-    return m_tileController.get();
-}
-
-TiledBacking* PlatformCALayerWinInternal::tiledBacking()
-{
-    return m_tileController.get();
-}
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscawinPlatformCALayerWinInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.h (189820 => 189821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.h        2015-09-15 19:47:34 UTC (rev 189820)
+++ trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.h        2015-09-15 19:56:34 UTC (rev 189821)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2011 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2011, 2014-2015 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class Color;
</ins><span class="cx"> class FloatRect;
</span><span class="cx"> class PlatformCALayer;
</span><span class="cx"> class TileController;
</span><span class="lines">@@ -47,9 +48,9 @@
</span><span class="cx">     PlatformCALayerWinInternal(PlatformCALayer*);
</span><span class="cx">     ~PlatformCALayerWinInternal();
</span><span class="cx"> 
</span><del>-    void displayCallback(CACFLayerRef, CGContextRef);
-    void setNeedsDisplayInRect(const FloatRect&amp;);
-    void setNeedsDisplay();
</del><ins>+    virtual void displayCallback(CACFLayerRef, CGContextRef);
+    virtual void setNeedsDisplayInRect(const FloatRect&amp;);
+    virtual void setNeedsDisplay();
</ins><span class="cx">     PlatformCALayer* owner() const { return m_owner; }
</span><span class="cx"> 
</span><span class="cx">     void setSublayers(const PlatformCALayerList&amp;);
</span><span class="lines">@@ -59,32 +60,26 @@
</span><span class="cx">     size_t sublayerCount() const;
</span><span class="cx">     int indexOfSublayer(const PlatformCALayer* reference);
</span><span class="cx"> 
</span><del>-    void setBounds(const FloatRect&amp;);
</del><ins>+    virtual bool isOpaque() const;
+    virtual void setOpaque(bool);
+
+    virtual void setBounds(const FloatRect&amp;);
</ins><span class="cx">     void setFrame(const FloatRect&amp;);
</span><span class="cx"> 
</span><del>-    TileController* createTileController(PlatformCALayer* rootLayer);
-    TiledBacking* tiledBacking();
</del><ins>+    virtual float contentsScale() const;
+    virtual void setContentsScale(float);
</ins><span class="cx"> 
</span><ins>+    virtual void setBorderWidth(float);
+
+    virtual void setBorderColor(const Color&amp;);
+
+    void drawRepaintCounters(CACFLayerRef, CGContextRef, CGRect layerBounds, int drawCount);
+
</ins><span class="cx"> private:
</span><span class="cx">     void internalSetNeedsDisplay(const FloatRect*);
</span><span class="cx">     PlatformCALayer* sublayerAtIndex(int) const;
</span><span class="cx"> 
</span><del>-    static void tileDisplayCallback(CACFLayerRef, CGContextRef);
-
-    void drawTile(CACFLayerRef, CGContextRef);
-    CGSize constrainedSize(const CGSize&amp;) const;
-    void addTile();
-    void removeTile();
-    CACFLayerRef tileAtIndex(int);
-    int tileCount() const;
-    void updateTiles();
-
</del><span class="cx">     PlatformCALayer* m_owner;
</span><del>-
-    CGSize m_tileSize;
-    CGSize m_constrainedSize;
-    RetainPtr&lt;CACFLayerRef&gt; m_tileParent;
-    std::unique_ptr&lt;TileController&gt; m_tileController;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscawinWebTiledBackingLayerWincpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.cpp (0 => 189821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.cpp        2015-09-15 19:56:34 UTC (rev 189821)
</span><span class="lines">@@ -0,0 +1,184 @@
</span><ins>+/*
+ * Copyright (C) 2015 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;WebTiledBackingLayerWin.h&quot;
+
+#include &quot;GraphicsContext.h&quot;
+#include &quot;PlatformCALayer.h&quot;
+#include &quot;TileController.h&quot;
+#include &quot;TiledBacking.h&quot;
+#include &lt;QuartzCore/CACFLayer.h&gt;
+#include &lt;wtf/MainThread.h&gt;
+
+using namespace std;
+using namespace WebCore;
+
+WebTiledBackingLayerWin::WebTiledBackingLayerWin(PlatformCALayer* owner)
+    : PlatformCALayerWinInternal(owner)
+{
+}
+
+WebTiledBackingLayerWin::~WebTiledBackingLayerWin()
+{
+}
+
+struct DisplayOnMainThreadContext {
+    RetainPtr&lt;CACFLayerRef&gt; layer;
+    RetainPtr&lt;CGContextRef&gt; context;
+
+    DisplayOnMainThreadContext(CACFLayerRef caLayer, CGContextRef caContext)
+        : layer(caLayer)
+        , context(caContext)
+    {
+    }
+};
+
+static void redispatchOnMainQueue(void* context)
+{
+    ASSERT(isMainThread());
+    std::unique_ptr&lt;DisplayOnMainThreadContext&gt; retainedContext(reinterpret_cast&lt;DisplayOnMainThreadContext*&gt;(context));
+    if (!retainedContext)
+        return;
+
+    PlatformCALayerWinInternal* self = static_cast&lt;PlatformCALayerWinInternal*&gt;(CACFLayerGetUserData(retainedContext-&gt;layer.get()));
+
+    self-&gt;displayCallback(retainedContext-&gt;layer.get(), retainedContext-&gt;context.get());
+}
+
+void WebTiledBackingLayerWin::displayCallback(CACFLayerRef caLayer, CGContextRef context)
+{
+    if (!isMainThread()) {
+        dispatch_async_f(dispatch_get_main_queue(), new DisplayOnMainThreadContext(caLayer, context), redispatchOnMainQueue);
+        return;
+    }
+    
+    if (!owner() || !owner()-&gt;owner())
+        return;
+
+    CGContextSaveGState(context);
+
+    CGRect layerBounds = owner()-&gt;bounds();
+    PlatformCALayer::LayerType layerType = owner()-&gt;layerType();
+    ASSERT(layerType == PlatformCALayer::LayerTypeTiledBackingLayer);
+
+    PlatformCALayerClient* client = owner()-&gt;owner();
+    GraphicsLayer::CompositingCoordinatesOrientation orientation = client-&gt;platformCALayerContentsOrientation();
+
+    PlatformCALayer::flipContext(context, layerBounds.size.height);
+
+    GraphicsContext graphicsContext(context);
+
+    // It's important to get the clip from the context, because it may be significantly
+    // smaller than the layer bounds (e.g. tiled layers)
+    CGRect clipBounds = CGContextGetClipBoundingBox(context);
+    IntRect clip(enclosingIntRect(clipBounds));
+    client-&gt;platformCALayerPaintContents(owner(), graphicsContext, clip);
+
+    if (client-&gt;platformCALayerShowRepaintCounter(owner())) {
+        int drawCount = client-&gt;platformCALayerIncrementRepaintCount(owner());
+        drawRepaintCounters(caLayer, context, layerBounds, drawCount);
+    }
+
+    CGContextRestoreGState(context);
+
+    client-&gt;platformCALayerLayerDidDisplay(owner());
+}
+
+void WebTiledBackingLayerWin::setNeedsDisplay()
+{
+    if (m_tileController)
+        return m_tileController-&gt;setNeedsDisplay();
+}
+
+void WebTiledBackingLayerWin::setNeedsDisplayInRect(const FloatRect&amp; dirtyRect)
+{
+    if (m_tileController)
+        return m_tileController-&gt;setNeedsDisplayInRect(enclosingIntRect(dirtyRect));
+}
+
+void WebTiledBackingLayerWin::setBounds(const FloatRect&amp; bounds)
+{
+    if (CGRectEqualToRect(bounds, owner()-&gt;bounds()))
+        return;
+
+    PlatformCALayerWinInternal::setBounds(bounds);
+
+    if (m_tileController)
+        m_tileController-&gt;tileCacheLayerBoundsChanged();
+}
+
+bool WebTiledBackingLayerWin::isOpaque() const
+{
+    return m_tileController ? m_tileController-&gt;tilesAreOpaque() : true;
+}
+
+void WebTiledBackingLayerWin::setOpaque(bool value)
+{
+    if (m_tileController)
+        return m_tileController-&gt;setTilesOpaque(value);
+}
+
+float WebTiledBackingLayerWin::contentsScale() const
+{
+    return m_tileController ? m_tileController-&gt;contentsScale() : 1.0f;
+}
+
+void WebTiledBackingLayerWin::setContentsScale(float scaleFactor)
+{
+    if (m_tileController)
+        return m_tileController-&gt;setContentsScale(scaleFactor);
+}
+
+void WebTiledBackingLayerWin::setBorderWidth(float value)
+{
+    if (m_tileController)
+        return m_tileController-&gt;setTileDebugBorderWidth(value / 2);
+}
+
+void WebTiledBackingLayerWin::setBorderColor(const Color&amp; value)
+{
+    if (m_tileController)
+        return m_tileController-&gt;setTileDebugBorderColor(value);
+}
+
+TileController* WebTiledBackingLayerWin::createTileController(PlatformCALayer* rootLayer)
+{
+    ASSERT(!m_tileController);
+    m_tileController = std::make_unique&lt;TileController&gt;(rootLayer);
+    return m_tileController.get();
+}
+
+TiledBacking* WebTiledBackingLayerWin::tiledBacking()
+{
+    return m_tileController.get();
+}
+
+void WebTiledBackingLayerWin::invalidate()
+{
+    ASSERT(isMainThread());
+    ASSERT(m_tileController);
+    m_tileController = nullptr;
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscawinWebTiledBackingLayerWinh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.h (0 => 189821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.h        2015-09-15 19:56:34 UTC (rev 189821)
</span><span class="lines">@@ -0,0 +1,66 @@
</span><ins>+/*
+ * Copyright (C) 2015 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. 
+ */
+
+#ifndef WebTiledBackingLayerWin_h
+#define WebTiledBackingLayerWin_h
+
+#include &quot;PlatformCALayerWinInternal.h&quot;
+
+namespace WebCore {
+
+class WebTiledBackingLayerWin : public PlatformCALayerWinInternal {
+public:
+    WebTiledBackingLayerWin(PlatformCALayer*);
+    ~WebTiledBackingLayerWin();
+
+    void displayCallback(CACFLayerRef, CGContextRef) override;
+    void setNeedsDisplayInRect(const FloatRect&amp;) override;
+    void setNeedsDisplay() override;
+
+    bool isOpaque() const override;
+    void setOpaque(bool) override;
+
+    void setBounds(const FloatRect&amp;) override;
+
+    float contentsScale() const override;
+    void setContentsScale(float) override;
+
+    void setBorderWidth(float) override;
+
+    void setBorderColor(const Color&amp;) override;
+
+    // WebTiledBackingLayer Features
+    TileController* createTileController(PlatformCALayer* rootLayer);
+    TiledBacking* tiledBacking();
+    void invalidate();
+
+private:
+    RetainPtr&lt;CACFLayerRef&gt; m_tileParent;
+    std::unique_ptr&lt;TileController&gt; m_tileController;
+};
+
+}
+
+#endif // WebTiledBackingLayerWin_h
</ins></span></pre>
</div>
</div>

</body>
</html>