<!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>[189903] branches/safari-601-branch/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/189903">189903</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2015-09-16 22:15:11 -0700 (Wed, 16 Sep 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/189821">r189821</a>. rdar://problem/22722908</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari601branchSourceWebCoreChangeLog">branches/safari-601-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceWebCoreWebCorevcxprojWebCorevcxproj">branches/safari-601-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#branchessafari601branchSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">branches/safari-601-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#branchessafari601branchSourceWebCoreplatformgraphicscaPlatformCALayercpp">branches/safari-601-branch/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp</a></li>
<li><a href="#branchessafari601branchSourceWebCoreplatformgraphicscaPlatformCALayerh">branches/safari-601-branch/Source/WebCore/platform/graphics/ca/PlatformCALayer.h</a></li>
<li><a href="#branchessafari601branchSourceWebCoreplatformgraphicscaTileGridcpp">branches/safari-601-branch/Source/WebCore/platform/graphics/ca/TileGrid.cpp</a></li>
<li><a href="#branchessafari601branchSourceWebCoreplatformgraphicscawinPlatformCALayerWincpp">branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp</a></li>
<li><a href="#branchessafari601branchSourceWebCoreplatformgraphicscawinPlatformCALayerWinh">branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h</a></li>
<li><a href="#branchessafari601branchSourceWebCoreplatformgraphicscawinPlatformCALayerWinInternalcpp">branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp</a></li>
<li><a href="#branchessafari601branchSourceWebCoreplatformgraphicscawinPlatformCALayerWinInternalh">branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari601branchSourceWebCoreplatformgraphicscawinWebTiledBackingLayerWincpp">branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.cpp</a></li>
<li><a href="#branchessafari601branchSourceWebCoreplatformgraphicscawinWebTiledBackingLayerWinh">branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari601branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/ChangeLog (189902 => 189903)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/ChangeLog        2015-09-17 04:40:25 UTC (rev 189902)
+++ branches/safari-601-branch/Source/WebCore/ChangeLog        2015-09-17 05:15:11 UTC (rev 189903)
</span><span class="lines">@@ -1,3 +1,110 @@
</span><ins>+2015-09-16 Babak Shafiei <bshafiei@apple.com>
+
+ Merge r189821.
+
+ 2015-09-15 Brent Fulgham <bfulgham@apple.com>
+
+ [Win] Tiled drawing is rendering more times than it should
+ https://bugs.webkit.org/show_bug.cgi?id=149144
+ <rdar://problem/22313905>
+
+ 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-11 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r189598.
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (189902 => 189903)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-09-17 04:40:25 UTC (rev 189902)
+++ branches/safari-601-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-09-17 05:15:11 UTC (rev 189903)
</span><span class="lines">@@ -7444,6 +7444,12 @@
</span><span class="cx"> <ClCompile Include="..\platform\FileSystem.cpp" />
</span><span class="cx"> <ClCompile Include="..\platform\graphics\avfoundation\cf\CDMSessionAVFoundationCF.cpp" />
</span><span class="cx"> <ClCompile Include="..\platform\graphics\avfoundation\cf\WebCoreAVCFResourceLoader.cpp" />
</span><ins>+ <ClCompile Include="..\platform\graphics\ca\win\WebTiledBackingLayerWin.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+ </ClCompile>
</ins><span class="cx"> <ClCompile Include="..\platform\graphics\ISOVTTCue.cpp" />
</span><span class="cx"> <ClCompile Include="..\platform\audio\AudioSession.cpp" />
</span><span class="cx"> <ClCompile Include="..\platform\audio\PlatformMediaSession.cpp" />
</span><span class="lines">@@ -20018,6 +20024,12 @@
</span><span class="cx"> </ClInclude>
</span><span class="cx"> <ClInclude Include="..\platform\graphics\ca\win\PlatformCAAnimationWin.h" />
</span><span class="cx"> <ClInclude Include="..\platform\graphics\ca\win\PlatformCALayerWin.h" />
</span><ins>+ <ClInclude Include="..\platform\graphics\ca\win\WebTiledBackingLayerWin.h">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+ </ClInclude>
</ins><span class="cx"> <ClInclude Include="..\platform\graphics\GLContext.h" />
</span><span class="cx"> <ClInclude Include="..\platform\graphics\GraphicsContext3DPrivate.h" />
</span><span class="cx"> <ClInclude Include="..\platform\graphics\cg\SubimageCacheWithTimer.h">
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (189902 => 189903)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2015-09-17 04:40:25 UTC (rev 189902)
+++ branches/safari-601-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2015-09-17 05:15:11 UTC (rev 189903)
</span><span class="lines">@@ -3039,9 +3039,6 @@
</span><span class="cx"> <ClCompile Include="..\dom\ChildNodeList.cpp">
</span><span class="cx"> <Filter>dom</Filter>
</span><span class="cx"> </ClCompile>
</span><del>- <ClCompile Include="..\dom\ClassNodeList.cpp">
- <Filter>dom</Filter>
- </ClCompile>
</del><span class="cx"> <ClCompile Include="..\dom\ClientRect.cpp">
</span><span class="cx"> <Filter>dom</Filter>
</span><span class="cx"> </ClCompile>
</span><span class="lines">@@ -3240,9 +3237,6 @@
</span><span class="cx"> <ClCompile Include="..\dom\Node.cpp">
</span><span class="cx"> <Filter>dom</Filter>
</span><span class="cx"> </ClCompile>
</span><del>- <ClCompile Include="..\dom\NodeFilter.cpp">
- <Filter>dom</Filter>
- </ClCompile>
</del><span class="cx"> <ClCompile Include="..\dom\NodeFilterCondition.cpp">
</span><span class="cx"> <Filter>dom</Filter>
</span><span class="cx"> </ClCompile>
</span><span class="lines">@@ -7269,6 +7263,12 @@
</span><span class="cx"> <ClCompile Include="..\platform\graphics\PathUtilities.cpp">
</span><span class="cx"> <Filter>platform\graphics</Filter>
</span><span class="cx"> </ClCompile>
</span><ins>+ <ClCompile Include="..\platform\network\DataURLDecoder.cpp" />
+ <ClCompile Include="..\dom\ClassCollection.cpp" />
+ <ClCompile Include="..\html\GenericCachedHTMLCollection.cpp" />
+ <ClCompile Include="..\platform\graphics\ca\win\WebTiledBackingLayerWin.cpp">
+ <Filter>platform\graphics\ca\win</Filter>
+ </ClCompile>
</ins><span class="cx"> </ItemGroup>
</span><span class="cx"> <ItemGroup>
</span><span class="cx"> <ClInclude Include="..\Modules\geolocation\Coordinates.h">
</span><span class="lines">@@ -10106,9 +10106,6 @@
</span><span class="cx"> <ClInclude Include="..\dom\ChildNodeList.h">
</span><span class="cx"> <Filter>dom</Filter>
</span><span class="cx"> </ClInclude>
</span><del>- <ClInclude Include="..\dom\ClassNodeList.h">
- <Filter>dom</Filter>
- </ClInclude>
</del><span class="cx"> <ClInclude Include="..\dom\ClientRect.h">
</span><span class="cx"> <Filter>dom</Filter>
</span><span class="cx"> </ClInclude>
</span><span class="lines">@@ -15258,6 +15255,12 @@
</span><span class="cx"> <ClInclude Include="..\platform\graphics\PathUtilities.h">
</span><span class="cx"> <Filter>platform\graphics</Filter>
</span><span class="cx"> </ClInclude>
</span><ins>+ <ClInclude Include="..\ForwardingHeaders\inspector\InspectorFrontendRouter.h" />
+ <ClInclude Include="..\platform\network\DataURLDecoder.h" />
+ <ClInclude Include="..\dom\ClassCollection.h" />
+ <ClInclude Include="..\platform\graphics\ca\win\WebTiledBackingLayerWin.h">
+ <Filter>platform\graphics\ca\win</Filter>
+ </ClInclude>
</ins><span class="cx"> </ItemGroup>
</span><span class="cx"> <ItemGroup>
</span><span class="cx"> <None Include="..\css\CSSGrammar.y.in">
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCoreplatformgraphicscaPlatformCALayercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp (189902 => 189903)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp        2015-09-17 04:40:25 UTC (rev 189902)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp        2015-09-17 05:15:11 UTC (rev 189903)
</span><span class="lines">@@ -62,9 +62,11 @@
</span><span class="cx"> snprintf(text, sizeof(text), "%d", repaintCount);
</span><span class="cx">
</span><span class="cx"> CGRect indicatorBox = platformCALayer->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->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 <rdar://problem/22703470>
+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 "-Wdeprecated-declarations"
</span><span class="cx"> CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));
</span><span class="cx"> CGContextSelectFont(context, "Helvetica", 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<PlatformCALayer> PlatformCALayer::createCompatibleLayerOrTakeFromPool(PlatformCALayer::LayerType layerType, PlatformCALayerClient* client, IntSize size)
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCoreplatformgraphicscaPlatformCALayerh"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/PlatformCALayer.h (189902 => 189903)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/PlatformCALayer.h        2015-09-17 04:40:25 UTC (rev 189902)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/PlatformCALayer.h        2015-09-17 05:15:11 UTC (rev 189903)
</span><span class="lines">@@ -229,6 +229,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="branchessafari601branchSourceWebCoreplatformgraphicscaTileGridcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/TileGrid.cpp (189902 => 189903)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/TileGrid.cpp        2015-09-17 04:40:25 UTC (rev 189902)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/TileGrid.cpp        2015-09-17 05:15:11 UTC (rev 189903)
</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()->platformCALayerShowRepaintCounter(0))
</del><ins>+ if (m_controller.rootLayer().owner()->platformCALayerShowRepaintCounter(0)) {
+#if OS(WINDOWS)
+ // Tiled layers in Windows have flipped coordinates
+ PlatformCALayer::flipContext(context.platformContext(), platformCALayer->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->position().x(), platformCALayer->position().y(), platformCALayer->bounds().size().width(), platformCALayer->bounds().size().height());
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCoreplatformgraphicscawinPlatformCALayerWincpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp (189902 => 189903)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp        2015-09-17 04:40:25 UTC (rev 189902)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp        2015-09-17 05:15:11 UTC (rev 189903)
</span><span class="lines">@@ -32,8 +32,10 @@
</span><span class="cx"> #include "GraphicsContext.h"
</span><span class="cx"> #include "PlatformCAAnimationWin.h"
</span><span class="cx"> #include "PlatformCALayerWinInternal.h"
</span><ins>+#include "TextRun.h"
</ins><span class="cx"> #include "TileController.h"
</span><span class="cx"> #include "WebCoreHeaderDetection.h"
</span><ins>+#include "WebTiledBackingLayerWin.h"
</ins><span class="cx"> #include <QuartzCore/CoreAnimationCF.h>
</span><span class="cx"> #include <WebKitSystemInterface/WebKitSystemInterface.h>
</span><span class="cx"> #include <wtf/CurrentTime.h>
</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<WebTiledBackingLayerWin*>(intern)->createTileController(this);
+ m_customSublayers = std::make_unique<PlatformCALayerList>(tileController->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->createTileController(this);
- m_customSublayers = std::make_unique<PlatformCALayerList>(tileController->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<WebTiledBackingLayerWin*>(layerIntern)->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)->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)->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)->setBorderWidth(value);
</ins><span class="cx"> setNeedsCommit();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PlatformCALayerWin::setBorderColor(const Color& value)
</span><span class="cx"> {
</span><del>- CGFloat components[4];
- value.getRGBA(components[0], components[1], components[2], components[3]);
-
- RetainPtr<CGColorSpaceRef> colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
- RetainPtr<CGColorRef> color = adoptCF(CGColorCreate(colorSpace.get(), components));
-
- CACFLayerSetBorderColor(m_layer.get(), color.get());
</del><ins>+ intern(this)->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)->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)->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)->tiledBacking();
</del><ins>+ return reinterpret_cast<WebTiledBackingLayerWin*>(intern(this))->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, &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="branchessafari601branchSourceWebCoreplatformgraphicscawinPlatformCALayerWinh"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h (189902 => 189903)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h        2015-09-17 04:40:25 UTC (rev 189902)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h        2015-09-17 05:15:11 UTC (rev 189903)
</span><span class="lines">@@ -147,6 +147,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="branchessafari601branchSourceWebCoreplatformgraphicscawinPlatformCALayerWinInternalcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp (189902 => 189903)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp        2015-09-17 04:40:25 UTC (rev 189902)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp        2015-09-17 05:15:11 UTC (rev 189903)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> #include "FontCascade.h"
</span><span class="cx"> #include "GraphicsContext.h"
</span><span class="cx"> #include "PlatformCALayer.h"
</span><del>-#include "TextRun.h"
</del><span class="cx"> #include "TileController.h"
</span><span class="cx"> #include "TiledBacking.h"
</span><span class="cx"> #include "WebCoreHeaderDetection.h"
</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->bounds().size()))
- , m_owner(owner)
</del><ins>+ : m_owner(owner)
</ins><span class="cx"> {
</span><del>- if (layerTypeIsTiled(m_owner->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->platformLayer(), m_tileParent.get(), 0);
-#if HAVE(CACFLAYER_SETCONTENTSSCALE)
- CACFLayerSetContentsScale(m_tileParent.get(), CACFLayerGetContentsScale(m_owner->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->displayCallback(retainedContext->layer.get(), retainedContext->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)
+ && (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()->bounds();
</span><del>- if (owner()->owner()->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {
- CGContextScaleCTM(context, 1, -1);
- CGContextTranslateCTM(context, 0, -layerBounds.size.height);
- }
</del><ins>+ PlatformCALayer::LayerType layerType = owner()->layerType();
</ins><span class="cx">
</span><del>- if (owner()->owner()) {
- GraphicsContext graphicsContext(context);
</del><ins>+ PlatformCALayerClient* client = owner()->owner();
+ GraphicsLayer::CompositingCoordinatesOrientation orientation = client->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()->owner()->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()->owner()->platformCALayerShowRepaintCounter(owner())) {
- String text = String::number(owner()->owner()->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->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 > 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, &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->platformCALayerShowRepaintCounter(owner())
+ && !repaintCountersAreDrawnByGridController(layerType)) {
+ int drawCount = client->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()->owner()->platformCALayerLayerDidDisplay(owner());
</del><ins>+ client->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 > 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()->platformLayer(), &rect);
</span><span class="cx"> } else
</span><del>- CACFLayerSetNeedsDisplay(owner()->platformLayer(), 0);
</del><ins>+ CACFLayerSetNeedsDisplay(owner()->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& dirtyRect)
</span><span class="cx"> {
</span><del>- if (layerTypeIsTiled(m_owner->layerType())) {
- // FIXME: Only setNeedsDisplay for tiles that are currently visible
- int numTileLayers = tileCount();
- CGRect rect = dirtyRect;
- for (int i = 0; i < numTileLayers; ++i)
- CACFLayerSetNeedsDisplay(tileAtIndex(i), &rect);
</del><ins>+ if (!owner())
+ return;
</ins><span class="cx">
</span><del>- if (m_owner->owner() && m_owner->owner()->platformCALayerShowRepaintCounter(m_owner)) {
- CGRect layerBounds = m_owner->bounds();
- CGRect indicatorRect = CGRectMake(layerBounds.origin.x, layerBounds.origin.y, 80, 25);
- CACFLayerSetNeedsDisplay(tileAtIndex(0), &indicatorRect);
- }
- } else if (owner()->layerType() == PlatformCALayer::LayerTypeWebLayer) {
- if (owner() && owner()->owner()) {
- if (owner()->owner()->platformCALayerShowRepaintCounter(owner())) {
- FloatRect layerBounds = owner()->bounds();
- FloatRect repaintCounterRect = layerBounds;
</del><ins>+ ASSERT(owner()->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()->owner()->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown)
- repaintCounterRect.setY(layerBounds.height() - (layerBounds.y() + repaintCounterRect.height()));
- internalSetNeedsDisplay(&repaintCounterRect);
- }
- if (owner()->owner()->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {
- FloatRect flippedDirtyRect = dirtyRect;
- flippedDirtyRect.setY(owner()->bounds().height() - (flippedDirtyRect.y() + flippedDirtyRect.height()));
- internalSetNeedsDisplay(&flippedDirtyRect);
- return;
- }
- }
</del><ins>+ if (owner()->owner()) {
+ if (owner()->owner()->platformCALayerShowRepaintCounter(owner())) {
+ FloatRect layerBounds = owner()->bounds();
+ FloatRect repaintCounterRect = layerBounds;
</ins><span class="cx">
</span><del>- internalSetNeedsDisplay(&dirtyRect);
</del><ins>+ // We assume a maximum of 4 digits and a font size of 18.
+ repaintCounterRect.setWidth(80);
+ repaintCounterRect.setHeight(22);
+ if (owner()->owner()->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown)
+ repaintCounterRect.setY(layerBounds.height() - (layerBounds.y() + repaintCounterRect.height()));
+ internalSetNeedsDisplay(&repaintCounterRect);
+ }
+ if (owner()->owner()->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {
+ FloatRect flippedDirtyRect = dirtyRect;
+ flippedDirtyRect.setY(owner()->bounds().height() - (flippedDirtyRect.y() + flippedDirtyRect.height()));
+ internalSetNeedsDisplay(&flippedDirtyRect);
+ return;
+ }
</ins><span class="cx"> }
</span><ins>+
+ internalSetNeedsDisplay(&dirtyRect);
+
</ins><span class="cx"> owner()->setNeedsCommit();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -247,11 +196,6 @@
</span><span class="cx"> CACFLayerInsertSublayer(owner()->platformLayer(), list[i]->platformLayer(), i);
</span><span class="cx">
</span><span class="cx"> owner()->setNeedsCommit();
</span><del>-
- if (layerTypeIsTiled(m_owner->layerType())) {
- // Preserve the tile parent after set
- CACFLayerInsertSublayer(owner()->platformLayer(), m_tileParent.get(), 0);
- }
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PlatformCALayerWinInternal::getSublayers(PlatformCALayerList& 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->layerType())) {
- // Exclude the tile parent layer.
- layersToSkip = 1;
- }
-
- list.resize(count - layersToSkip);
- for (size_t arrayIndex = layersToSkip; arrayIndex < count; ++arrayIndex)
- list[arrayIndex - layersToSkip] = PlatformCALayer::platformCALayer(const_cast<void*>(CFArrayGetValueAtIndex(sublayers, arrayIndex)));
</del><ins>+ list.resize(count);
+ for (size_t arrayIndex = 0; arrayIndex < count; ++arrayIndex)
+ list[arrayIndex] = PlatformCALayer::platformCALayer(const_cast<void*>(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()->platformLayer(), 0);
</del><ins>+ CACFLayerSetSublayers(owner()->platformLayer(), nullptr);
</ins><span class="cx"> owner()->setNeedsCommit();
</span><del>-
- if (layerTypeIsTiled(m_owner->layerType())) {
- // Restore the tile parent after removal
- CACFLayerInsertSublayer(owner()->platformLayer(), m_tileParent.get(), 0);
- }
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PlatformCALayerWinInternal::insertSublayer(PlatformCALayer& layer, size_t index)
</span><span class="cx"> {
</span><span class="cx"> index = min(index, sublayerCount());
</span><del>- if (layerTypeIsTiled(m_owner->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()->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()->platformLayer());
</span><del>- size_t count = sublayers ? CFArrayGetCount(sublayers) : 0;
-
- if (layerTypeIsTiled(m_owner->layerType())) {
- // Subtract 1 to account for the tile parent layer
- ASSERT(count > 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->layerType())) {
- for (size_t i = 1; i < n; ++i) {
- if (CFArrayGetValueAtIndex(sublayers, i) == ref)
- return i - 1;
- }
- } else {
- for (size_t i = 0; i < n; ++i) {
- if (CFArrayGetValueAtIndex(sublayers, i) == ref)
- return i;
- }
</del><ins>+ for (size_t i = 0; i < 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->layerType())) {
- // Add 1 to account for the tile parent layer
- index++;
- }
-
</del><span class="cx"> CFArrayRef sublayers = CACFLayerGetSublayers(owner()->platformLayer());
</span><span class="cx"> if (!sublayers || index < 0 || CFArrayGetCount(sublayers) <= index)
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><span class="cx"> return PlatformCALayer::platformCALayer(static_cast<CACFLayerRef>(const_cast<void*>(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()->platformLayer(), rect);
</span><span class="cx"> owner()->setNeedsCommit();
</span><del>-
- if (layerTypeIsTiled(m_owner->layerType())) {
- m_constrainedSize = constrainedSize(rect.size());
- updateTiles();
- }
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PlatformCALayerWinInternal::setFrame(const FloatRect& rect)
</span><span class="lines">@@ -376,169 +280,48 @@
</span><span class="cx">
</span><span class="cx"> CACFLayerSetFrame(owner()->platformLayer(), rect);
</span><span class="cx"> owner()->setNeedsCommit();
</span><del>-
- if (layerTypeIsTiled(m_owner->layerType()))
- updateTiles();
</del><span class="cx"> }
</span><span class="cx">
</span><del>-CGSize PlatformCALayerWinInternal::constrainedSize(const CGSize& 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 && numeric_limits<int>::max() / tileColumns < tileRows || tileColumns * tileRows > cMaxTileCount;
-
- // If number of tiles vertically or horizontally is < sqrt(cMaxTileCount)
- // just shorten the longer dimension. Otherwise shorten both dimensions
- // according to the ratio of width to height
-
- if (tooManyTiles) {
- if (tileRows < cSqrtMaxTileCount)
- tileColumns = floorf(cMaxTileCount / tileRows);
- else if (tileColumns < 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()->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<PlatformCALayerWinInternal*>(CACFLayerGetUserData(layer))->drawTile(layer, context);
</del><ins>+ CACFLayerSetOpaque(owner()->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<CACFLayerRef> 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()->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()->owner()->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()->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 < 0 || index >= tileCount())
- return 0;
-
- return static_cast<CACFLayerRef>(const_cast<void*>(CFArrayGetValueAtIndex(sublayers, index)));
</del><ins>+ CACFLayerSetBorderWidth(owner()->platformLayer(), value);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-int PlatformCALayerWinInternal::tileCount() const
</del><ins>+void PlatformCALayerWinInternal::setBorderColor(const Color& 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<CGColorSpaceRef> 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 > 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 >= 0) {
- // Add new tiles
- for (int i = 0; i < numTilesToChange; ++i)
- addTile();
- } else {
- // Remove old tiles
- numTilesToChange = -numTilesToChange;
- for (int i = 0; i < numTilesToChange; ++i)
- removeTile();
- }
</del><ins>+ RetainPtr<CGColorRef> 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 < numTilesHorizontal; ++i) {
- for (int j = 0; j < numTilesVertical; ++j) {
- CACFLayerRef tile = static_cast<CACFLayerRef>(const_cast<void*>(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 = "Tile (" + String::number(i) + "," + String::number(j) + ")";
- CACFLayerSetName(tile, name.createCFString().get());
-#endif
- }
- }
</del><ins>+ CACFLayerSetBorderColor(owner()->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);
-
- // Transform context to be at the origin of the parent layer
- CGContextTranslateCTM(context, -tilePosition.x, -tilePosition.y);
-
- // Set the context clipping rectangle to the current tile
- CGContextClipToRect(context, CGRectMake(tilePosition.x, tilePosition.y, tileBounds.size.width, tileBounds.size.height));
-
- if (owner()->owner()->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()->bounds().height());
- CGContextScaleCTM(context, 1, -1);
- }
-
- // Draw the tile
- displayCallback(owner()->platformLayer(), context);
-
- CGContextRestoreGState(context);
-}
-
-TileController* PlatformCALayerWinInternal::createTileController(PlatformCALayer* rootLayer)
-{
- ASSERT(!m_tileController);
- m_tileController = std::make_unique<TileController>(rootLayer);
- return m_tileController.get();
-}
-
-TiledBacking* PlatformCALayerWinInternal::tiledBacking()
-{
- return m_tileController.get();
-}
</del></span></pre></div>
<a id="branchessafari601branchSourceWebCoreplatformgraphicscawinPlatformCALayerWinInternalh"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.h (189902 => 189903)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.h        2015-09-17 04:40:25 UTC (rev 189902)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.h        2015-09-17 05:15:11 UTC (rev 189903)
</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&);
- void setNeedsDisplay();
</del><ins>+ virtual void displayCallback(CACFLayerRef, CGContextRef);
+ virtual void setNeedsDisplayInRect(const FloatRect&);
+ 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&);
</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&);
</del><ins>+ virtual bool isOpaque() const;
+ virtual void setOpaque(bool);
+
+ virtual void setBounds(const FloatRect&);
</ins><span class="cx"> void setFrame(const FloatRect&);
</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&);
+
+ 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&) 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<CACFLayerRef> m_tileParent;
- std::unique_ptr<TileController> m_tileController;
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCoreplatformgraphicscawinWebTiledBackingLayerWincppfromrev189821trunkSourceWebCoreplatformgraphicscawinWebTiledBackingLayerWincpp"></a>
<div class="copfile"><h4>Copied: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.cpp (from rev 189821, trunk/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.cpp) (0 => 189903)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.cpp         (rev 0)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.cpp        2015-09-17 05:15:11 UTC (rev 189903)
</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 "config.h"
+#include "WebTiledBackingLayerWin.h"
+
+#include "GraphicsContext.h"
+#include "PlatformCALayer.h"
+#include "TileController.h"
+#include "TiledBacking.h"
+#include <QuartzCore/CACFLayer.h>
+#include <wtf/MainThread.h>
+
+using namespace std;
+using namespace WebCore;
+
+WebTiledBackingLayerWin::WebTiledBackingLayerWin(PlatformCALayer* owner)
+ : PlatformCALayerWinInternal(owner)
+{
+}
+
+WebTiledBackingLayerWin::~WebTiledBackingLayerWin()
+{
+}
+
+struct DisplayOnMainThreadContext {
+ RetainPtr<CACFLayerRef> layer;
+ RetainPtr<CGContextRef> context;
+
+ DisplayOnMainThreadContext(CACFLayerRef caLayer, CGContextRef caContext)
+ : layer(caLayer)
+ , context(caContext)
+ {
+ }
+};
+
+static void redispatchOnMainQueue(void* context)
+{
+ ASSERT(isMainThread());
+ std::unique_ptr<DisplayOnMainThreadContext> retainedContext(reinterpret_cast<DisplayOnMainThreadContext*>(context));
+ if (!retainedContext)
+ return;
+
+ PlatformCALayerWinInternal* self = static_cast<PlatformCALayerWinInternal*>(CACFLayerGetUserData(retainedContext->layer.get()));
+
+ self->displayCallback(retainedContext->layer.get(), retainedContext->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()->owner())
+ return;
+
+ CGContextSaveGState(context);
+
+ CGRect layerBounds = owner()->bounds();
+ PlatformCALayer::LayerType layerType = owner()->layerType();
+ ASSERT(layerType == PlatformCALayer::LayerTypeTiledBackingLayer);
+
+ PlatformCALayerClient* client = owner()->owner();
+ GraphicsLayer::CompositingCoordinatesOrientation orientation = client->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->platformCALayerPaintContents(owner(), graphicsContext, clip);
+
+ if (client->platformCALayerShowRepaintCounter(owner())) {
+ int drawCount = client->platformCALayerIncrementRepaintCount(owner());
+ drawRepaintCounters(caLayer, context, layerBounds, drawCount);
+ }
+
+ CGContextRestoreGState(context);
+
+ client->platformCALayerLayerDidDisplay(owner());
+}
+
+void WebTiledBackingLayerWin::setNeedsDisplay()
+{
+ if (m_tileController)
+ return m_tileController->setNeedsDisplay();
+}
+
+void WebTiledBackingLayerWin::setNeedsDisplayInRect(const FloatRect& dirtyRect)
+{
+ if (m_tileController)
+ return m_tileController->setNeedsDisplayInRect(enclosingIntRect(dirtyRect));
+}
+
+void WebTiledBackingLayerWin::setBounds(const FloatRect& bounds)
+{
+ if (CGRectEqualToRect(bounds, owner()->bounds()))
+ return;
+
+ PlatformCALayerWinInternal::setBounds(bounds);
+
+ if (m_tileController)
+ m_tileController->tileCacheLayerBoundsChanged();
+}
+
+bool WebTiledBackingLayerWin::isOpaque() const
+{
+ return m_tileController ? m_tileController->tilesAreOpaque() : true;
+}
+
+void WebTiledBackingLayerWin::setOpaque(bool value)
+{
+ if (m_tileController)
+ return m_tileController->setTilesOpaque(value);
+}
+
+float WebTiledBackingLayerWin::contentsScale() const
+{
+ return m_tileController ? m_tileController->contentsScale() : 1.0f;
+}
+
+void WebTiledBackingLayerWin::setContentsScale(float scaleFactor)
+{
+ if (m_tileController)
+ return m_tileController->setContentsScale(scaleFactor);
+}
+
+void WebTiledBackingLayerWin::setBorderWidth(float value)
+{
+ if (m_tileController)
+ return m_tileController->setTileDebugBorderWidth(value / 2);
+}
+
+void WebTiledBackingLayerWin::setBorderColor(const Color& value)
+{
+ if (m_tileController)
+ return m_tileController->setTileDebugBorderColor(value);
+}
+
+TileController* WebTiledBackingLayerWin::createTileController(PlatformCALayer* rootLayer)
+{
+ ASSERT(!m_tileController);
+ m_tileController = std::make_unique<TileController>(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="branchessafari601branchSourceWebCoreplatformgraphicscawinWebTiledBackingLayerWinhfromrev189821trunkSourceWebCoreplatformgraphicscawinWebTiledBackingLayerWinh"></a>
<div class="copfile"><h4>Copied: branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.h (from rev 189821, trunk/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.h) (0 => 189903)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.h         (rev 0)
+++ branches/safari-601-branch/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.h        2015-09-17 05:15:11 UTC (rev 189903)
</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 "PlatformCALayerWinInternal.h"
+
+namespace WebCore {
+
+class WebTiledBackingLayerWin : public PlatformCALayerWinInternal {
+public:
+ WebTiledBackingLayerWin(PlatformCALayer*);
+ ~WebTiledBackingLayerWin();
+
+ void displayCallback(CACFLayerRef, CGContextRef) override;
+ void setNeedsDisplayInRect(const FloatRect&) override;
+ void setNeedsDisplay() override;
+
+ bool isOpaque() const override;
+ void setOpaque(bool) override;
+
+ void setBounds(const FloatRect&) override;
+
+ float contentsScale() const override;
+ void setContentsScale(float) override;
+
+ void setBorderWidth(float) override;
+
+ void setBorderColor(const Color&) override;
+
+ // WebTiledBackingLayer Features
+ TileController* createTileController(PlatformCALayer* rootLayer);
+ TiledBacking* tiledBacking();
+ void invalidate();
+
+private:
+ RetainPtr<CACFLayerRef> m_tileParent;
+ std::unique_ptr<TileController> m_tileController;
+};
+
+}
+
+#endif // WebTiledBackingLayerWin_h
</ins></span></pre>
</div>
</div>
</body>
</html>