<!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>[202675] trunk/Source</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/202675">202675</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-06-30 00:32:32 -0700 (Thu, 30 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Coordinated Graphics] Move CompositingCoordinator from platform to WebKit2 layer
https://bugs.webkit.org/show_bug.cgi?id=159209

Reviewed by Žan Doberšek.

Source/WebCore:

Remove CompositingCoordinator and its helper classes from the platform layer.

* platform/TextureMapper.cmake:

Source/WebKit2:

Move CompositingCoordinator and its helper classes to the WebKit2 layer.

* PlatformEfl.cmake:
* PlatformGTK.cmake:
* WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp: Renamed from Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.cpp.
(WebKit::AreaAllocator::AreaAllocator):
(WebKit::AreaAllocator::~AreaAllocator):
(WebKit::AreaAllocator::expand):
(WebKit::AreaAllocator::expandBy):
(WebKit::AreaAllocator::release):
(WebKit::AreaAllocator::overhead):
(WebKit::AreaAllocator::roundAllocation):
(WebKit::GeneralAreaAllocator::GeneralAreaAllocator):
(WebKit::GeneralAreaAllocator::~GeneralAreaAllocator):
(WebKit::GeneralAreaAllocator::freeNode):
(WebKit::GeneralAreaAllocator::expand):
(WebKit::fitsWithin):
(WebKit::GeneralAreaAllocator::allocate):
(WebKit::GeneralAreaAllocator::allocateFromNode):
(WebKit::GeneralAreaAllocator::splitNode):
(WebKit::GeneralAreaAllocator::updateLargestFree):
(WebKit::GeneralAreaAllocator::release):
(WebKit::GeneralAreaAllocator::overhead):
* WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h: Renamed from Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.h.
(WebKit::nextPowerOfTwo):
(WebKit::AreaAllocator::size):
(WebKit::AreaAllocator::minimumAllocation):
(WebKit::AreaAllocator::setMinimumAllocation):
(WebKit::AreaAllocator::margin):
(WebKit::AreaAllocator::setMargin):
* WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp: Renamed from Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp.
(WebKit::CompositingCoordinator::CompositingCoordinator):
(WebKit::CompositingCoordinator::~CompositingCoordinator):
(WebKit::CompositingCoordinator::setRootCompositingLayer):
(WebKit::CompositingCoordinator::setViewOverlayRootLayer):
(WebKit::CompositingCoordinator::sizeDidChange):
(WebKit::CompositingCoordinator::flushPendingLayerChanges):
(WebKit::CompositingCoordinator::timestamp):
(WebKit::CompositingCoordinator::syncDisplayState):
(WebKit::CompositingCoordinator::nextAnimationServiceTime):
(WebKit::CompositingCoordinator::clearPendingStateChanges):
(WebKit::CompositingCoordinator::initializeRootCompositingLayerIfNeeded):
(WebKit::CompositingCoordinator::createRootLayer):
(WebKit::CompositingCoordinator::syncLayerState):
(WebKit::CompositingCoordinator::createImageBackingIfNeeded):
(WebKit::CompositingCoordinator::createImageBacking):
(WebKit::CompositingCoordinator::updateImageBacking):
(WebKit::CompositingCoordinator::clearImageBackingContents):
(WebKit::CompositingCoordinator::removeImageBacking):
(WebKit::CompositingCoordinator::flushPendingImageBackingChanges):
(WebKit::CompositingCoordinator::notifyAnimationStarted):
(WebKit::CompositingCoordinator::notifyFlushRequired):
(WebKit::CompositingCoordinator::paintContents):
(WebKit::CompositingCoordinator::createGraphicsLayer):
(WebKit::CompositingCoordinator::deviceScaleFactor):
(WebKit::CompositingCoordinator::pageScaleFactor):
(WebKit::CompositingCoordinator::createUpdateAtlas):
(WebKit::CompositingCoordinator::removeUpdateAtlas):
(WebKit::CompositingCoordinator::visibleContentsRect):
(WebKit::CompositingCoordinator::mainContentsLayer):
(WebKit::CompositingCoordinator::setVisibleContentsRect):
(WebKit::CompositingCoordinator::deviceOrPageScaleFactorChanged):
(WebKit::CompositingCoordinator::detachLayer):
(WebKit::CompositingCoordinator::commitScrollOffset):
(WebKit::CompositingCoordinator::renderNextFrame):
(WebKit::CompositingCoordinator::purgeBackingStores):
(WebKit::CompositingCoordinator::paintToSurface):
(WebKit::CompositingCoordinator::scheduleReleaseInactiveAtlases):
(WebKit::CompositingCoordinator::releaseInactiveAtlasesTimerFired):
* WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h: Renamed from Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h.
(WebKit::CompositingCoordinator::clearRootLayer):
(WebKit::CompositingCoordinator::rootLayer):
(WebKit::CompositingCoordinator::state):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
* WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp: Renamed from Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.cpp.
(WebKit::UpdateAtlasSurfaceClient::UpdateAtlasSurfaceClient):
(WebKit::UpdateAtlas::UpdateAtlas):
(WebKit::UpdateAtlas::~UpdateAtlas):
(WebKit::UpdateAtlas::buildLayoutIfNeeded):
(WebKit::UpdateAtlas::didSwapBuffers):
(WebKit::UpdateAtlas::paintOnAvailableBuffer):
* WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h: Renamed from Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.h.
(WebKit::UpdateAtlas::size):
(WebKit::UpdateAtlas::supportsAlpha):
(WebKit::UpdateAtlas::addTimeInactive):
(WebKit::UpdateAtlas::isInactive):
(WebKit::UpdateAtlas::isInUse):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformTextureMappercmake">trunk/Source/WebCore/platform/TextureMapper.cmake</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformEflcmake">trunk/Source/WebKit2/PlatformEfl.cmake</a></li>
<li><a href="#trunkSourceWebKit2PlatformGTKcmake">trunk/Source/WebKit2/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsCoordinatedLayerTreeHosth">trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsAreaAllocatorcpp">trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsAreaAllocatorh">trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsCompositingCoordinatorcpp">trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsCompositingCoordinatorh">trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsUpdateAtlascpp">trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsUpdateAtlash">trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapcoordinatedAreaAllocatorcpp">trunk/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapcoordinatedAreaAllocatorh">trunk/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapcoordinatedCompositingCoordinatorcpp">trunk/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapcoordinatedCompositingCoordinatorh">trunk/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapcoordinatedUpdateAtlascpp">trunk/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapcoordinatedUpdateAtlash">trunk/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (202674 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-30 06:28:58 UTC (rev 202674)
+++ trunk/Source/WebCore/ChangeLog        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-06-30  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [Coordinated Graphics] Move CompositingCoordinator from platform to WebKit2 layer
+        https://bugs.webkit.org/show_bug.cgi?id=159209
+
+        Reviewed by Žan Doberšek.
+
+        Remove CompositingCoordinator and its helper classes from the platform layer.
+
+        * platform/TextureMapper.cmake:
+
</ins><span class="cx"> 2016-06-29  Youenn Fablet  &lt;youenn@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Pass SecurityOrigin as references in CORS check code
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformTextureMappercmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (202674 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/TextureMapper.cmake        2016-06-30 06:28:58 UTC (rev 202674)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -33,14 +33,11 @@
</span><span class="cx">         page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp
</span><span class="cx">         page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp
</span><span class="cx"> 
</span><del>-        platform/graphics/texmap/coordinated/AreaAllocator.cpp
-        platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
</del><span class="cx">         platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
</span><span class="cx">         platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp
</span><span class="cx">         platform/graphics/texmap/coordinated/CoordinatedSurface.cpp
</span><span class="cx">         platform/graphics/texmap/coordinated/Tile.cpp
</span><span class="cx">         platform/graphics/texmap/coordinated/TiledBackingStore.cpp
</span><del>-        platform/graphics/texmap/coordinated/UpdateAtlas.cpp
</del><span class="cx">     )
</span><span class="cx"> endif ()
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapcoordinatedAreaAllocatorcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.cpp (202674 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.cpp        2016-06-30 06:28:58 UTC (rev 202674)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.cpp        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -1,335 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#include &quot;config.h&quot;
-
-#if USE(COORDINATED_GRAPHICS)
-
-#include &quot;AreaAllocator.h&quot;
-
-namespace WebCore {
-
-AreaAllocator::AreaAllocator(const IntSize&amp; size)
-    : m_size(size)
-    , m_minAlloc(1, 1)
-    , m_margin(0, 0)
-{
-}
-
-AreaAllocator::~AreaAllocator()
-{
-}
-
-void AreaAllocator::expand(const IntSize&amp; size)
-{
-    m_size = m_size.expandedTo(size);
-}
-
-void AreaAllocator::expandBy(const IntSize&amp; size)
-{
-    m_size += size;
-}
-
-void AreaAllocator::release(const IntRect&amp;)
-{
-}
-
-int AreaAllocator::overhead() const
-{
-    return 0;
-}
-
-IntSize AreaAllocator::roundAllocation(const IntSize&amp; size) const
-{
-    int width = size.width() + m_margin.width();
-    int height = size.height() + m_margin.height();
-    int extra = width % m_minAlloc.width();
-    if (extra)
-        width += m_minAlloc.width() - extra;
-    extra = height % m_minAlloc.height();
-    if (extra)
-        height += m_minAlloc.height() - extra;
-
-    return IntSize(width, height);
-}
-
-GeneralAreaAllocator::GeneralAreaAllocator(const IntSize&amp; size)
-    : AreaAllocator(nextPowerOfTwo(size))
-{
-    m_root = new Node();
-    m_root-&gt;rect = IntRect(0, 0, m_size.width(), m_size.height());
-    m_root-&gt;largestFree = m_size;
-    m_root-&gt;parent = 0;
-    m_root-&gt;left = 0;
-    m_root-&gt;right = 0;
-    m_nodeCount = 1;
-    setMinimumAllocation(IntSize(8, 8));
-}
-
-GeneralAreaAllocator::~GeneralAreaAllocator()
-{
-    freeNode(m_root);
-}
-
-void GeneralAreaAllocator::freeNode(Node* node)
-{
-    if (node) {
-        freeNode(node-&gt;left);
-        freeNode(node-&gt;right);
-    }
-    delete node;
-}
-
-void GeneralAreaAllocator::expand(const IntSize&amp; size)
-{
-    AreaAllocator::expand(nextPowerOfTwo(size));
-
-    if (m_root-&gt;rect.size() == m_size)
-        return; // No change.
-
-    if (!m_root-&gt;left &amp;&amp; m_root-&gt;largestFree.width() &gt; 0) {
-        // No allocations have occurred, so just adjust the root size.
-        m_root-&gt;rect = IntRect(0, 0, m_size.width(), m_size.height());
-        m_root-&gt;largestFree = m_size;
-        return;
-    }
-
-    // Add extra nodes above the current root to expand the tree.
-    Node* oldRoot = m_root;
-    Split split;
-    if (m_size.width() &gt;= m_size.height())
-        split = SplitOnX;
-    else
-        split = SplitOnY;
-
-    while (m_root-&gt;rect.size() != m_size) {
-        if (m_root-&gt;rect.width() == m_size.width())
-            split = SplitOnY;
-        else if (m_root-&gt;rect.height() == m_size.height())
-            split = SplitOnX;
-        Node* parent = new Node();
-        Node* right = new Node();
-        m_nodeCount += 2;
-        m_root-&gt;parent = parent;
-        parent-&gt;parent = 0;
-        parent-&gt;left = m_root;
-        parent-&gt;right = right;
-        parent-&gt;largestFree = m_root-&gt;rect.size();
-        right-&gt;parent = parent;
-        right-&gt;left = 0;
-        right-&gt;right = 0;
-        right-&gt;largestFree = m_root-&gt;rect.size();
-        if (split == SplitOnX) {
-            parent-&gt;rect = IntRect(m_root-&gt;rect.x(), m_root-&gt;rect.y(),
-                m_root-&gt;rect.width() * 2, m_root-&gt;rect.height());
-            right-&gt;rect = IntRect(m_root-&gt;rect.x() + m_root-&gt;rect.width(), m_root-&gt;rect.y(),
-                m_root-&gt;rect.width(), m_root-&gt;rect.height());
-        } else {
-            parent-&gt;rect = IntRect(m_root-&gt;rect.x(), m_root-&gt;rect.y(),
-                m_root-&gt;rect.width(), m_root-&gt;rect.height() * 2);
-            right-&gt;rect = IntRect(m_root-&gt;rect.x(), m_root-&gt;rect.y() + m_root-&gt;rect.width(),
-                m_root-&gt;rect.width(), m_root-&gt;rect.height());
-        }
-        split = (split == SplitOnX ? SplitOnY : SplitOnX);
-        m_root = parent;
-    }
-    updateLargestFree(oldRoot);
-}
-
-static inline bool fitsWithin(const IntSize&amp; size1, const IntSize&amp; size2)
-{
-    return size1.width() &lt;= size2.width() &amp;&amp; size1.height() &lt;= size2.height();
-}
-
-IntRect GeneralAreaAllocator::allocate(const IntSize&amp; size)
-{
-    IntSize rounded = roundAllocation(size);
-    rounded = nextPowerOfTwo(rounded);
-    if (rounded.width() &lt;= 0 || rounded.width() &gt; m_size.width()
-        || rounded.height() &lt;= 0 || rounded.height() &gt; m_size.height())
-        return IntRect();
-
-    IntPoint point = allocateFromNode(rounded, m_root);
-    if (point.x() &gt;= 0)
-        return IntRect(point, size);
-    return IntRect();
-}
-
-IntPoint GeneralAreaAllocator::allocateFromNode(const IntSize&amp; size, Node* node)
-{
-    // Find the best node to insert into, which should be
-    // a node with the least amount of unused space that is
-    // big enough to contain the requested size.
-    while (node) {
-        // Go down a level and determine if the left or right
-        // sub-tree contains the best chance of allocation.
-        Node* left = node-&gt;left;
-        Node* right = node-&gt;right;
-        if (left &amp;&amp; fitsWithin(size, left-&gt;largestFree)) {
-            if (right &amp;&amp; fitsWithin(size, right-&gt;largestFree)) {
-                if (left-&gt;largestFree.width() &lt; right-&gt;largestFree.width()
-                    || left-&gt;largestFree.height() &lt; right-&gt;largestFree.height()) {
-                    // The largestFree values may be a little oversized,
-                    // so try the left sub-tree and then the right sub-tree.
-                    IntPoint point = allocateFromNode(size, left);
-                    if (point.x() &gt;= 0)
-                        return point;
-                    return allocateFromNode(size, right);
-                }
-                node = right;
-            } else
-                node = left;
-        } else if (right &amp;&amp; fitsWithin(size, right-&gt;largestFree))
-            node = right;
-        else if (left || right) {
-            // Neither sub-node has enough space to allocate from.
-            return IntPoint(-1, -1);
-        } else if (fitsWithin(size, node-&gt;largestFree)) {
-            // Do we need to split this node into smaller pieces?
-            Split split;
-            if (fitsWithin(IntSize(size.width() * 2, size.height() * 2), node-&gt;largestFree)) {
-                // Split in either direction: choose the inverse of
-                // the parent node's split direction to try to balance
-                // out the wasted space as further subdivisions happen.
-                if (node-&gt;parent
-                    &amp;&amp; node-&gt;parent-&gt;left-&gt;rect.x() == node-&gt;parent-&gt;right-&gt;rect.x())
-                    split = SplitOnX;
-                else if (node-&gt;parent)
-                    split = SplitOnY;
-                else if (node-&gt;rect.width() &gt;= node-&gt;rect.height())
-                    split = SplitOnX;
-                else
-                    split = SplitOnY;
-            } else if (fitsWithin(IntSize(size.width() * 2, size.height()), node-&gt;largestFree)) {
-                // Split along the X direction.
-                split = SplitOnX;
-            } else if (fitsWithin(IntSize(size.width(), size.height() * 2), node-&gt;largestFree)) {
-                // Split along the Y direction.
-                split = SplitOnY;
-            } else {
-                // Cannot split further - allocate this node.
-                node-&gt;largestFree = IntSize(0, 0);
-                updateLargestFree(node);
-                return node-&gt;rect.location();
-            }
-
-            // Split the node, then go around again using the left sub-tree.
-            node = splitNode(node, split);
-        } else {
-            // Cannot possibly fit into this node.
-            break;
-        }
-    }
-    return IntPoint(-1, -1);
-}
-
-GeneralAreaAllocator::Node* GeneralAreaAllocator::splitNode
-    (Node* node, Split split)
-{
-    Node* left = new Node();
-    Node* right = new Node();
-    m_nodeCount += 2;
-    left-&gt;parent = node;
-    left-&gt;left = 0;
-    left-&gt;right = 0;
-    right-&gt;parent = node;
-    right-&gt;left = 0;
-    right-&gt;right = 0;
-    node-&gt;left = left;
-    node-&gt;right = right;
-
-    if (split == SplitOnX) {
-        left-&gt;rect = IntRect(node-&gt;rect.x(), node-&gt;rect.y(),
-            node-&gt;rect.width() / 2, node-&gt;rect.height());
-        right-&gt;rect = IntRect(left-&gt;rect.maxX(), node-&gt;rect.y(),
-            node-&gt;rect.width() / 2, node-&gt;rect.height());
-    } else {
-        left-&gt;rect = IntRect(node-&gt;rect.x(), node-&gt;rect.y(),
-            node-&gt;rect.width(), node-&gt;rect.height() / 2);
-        right-&gt;rect = IntRect(node-&gt;rect.x(), left-&gt;rect.maxY(),
-            node-&gt;rect.width(), node-&gt;rect.height() / 2);
-    }
-
-    left-&gt;largestFree = left-&gt;rect.size();
-    right-&gt;largestFree = right-&gt;rect.size();
-    node-&gt;largestFree = right-&gt;largestFree;
-    return left;
-}
-
-void GeneralAreaAllocator::updateLargestFree(Node* node)
-{
-    while ((node = node-&gt;parent)) {
-        node-&gt;largestFree = IntSize(
-            std::max(node-&gt;left-&gt;largestFree.width(), node-&gt;right-&gt;largestFree.width()),
-            std::max(node-&gt;left-&gt;largestFree.height(), node-&gt;right-&gt;largestFree.height())
-            );
-    }
-}
-
-void GeneralAreaAllocator::release(const IntRect&amp; rect)
-{
-    // Locate the node that contains the allocated region.
-    Node* node = m_root;
-    IntPoint point = rect.location();
-    while (node) {
-        if (node-&gt;left &amp;&amp; node-&gt;left-&gt;rect.contains(point))
-            node = node-&gt;left;
-        else if (node-&gt;right &amp;&amp; node-&gt;right-&gt;rect.contains(point))
-            node = node-&gt;right;
-        else if (node-&gt;rect.contains(point))
-            break;
-        else
-            return; // Point is completely outside the tree.
-    }
-    if (!node)
-        return;
-
-    // Mark the node as free and then work upwards through the tree
-    // recombining and deleting nodes until we reach a sibling
-    // that is still allocated.
-    node-&gt;largestFree = node-&gt;rect.size();
-    while (node-&gt;parent) {
-        if (node-&gt;parent-&gt;left == node) {
-            if (node-&gt;parent-&gt;right-&gt;largestFree != node-&gt;parent-&gt;right-&gt;rect.size())
-                break;
-        } else {
-            if (node-&gt;parent-&gt;left-&gt;largestFree != node-&gt;parent-&gt;left-&gt;rect.size())
-                break;
-        }
-        node = node-&gt;parent;
-        freeNode(node-&gt;left);
-        freeNode(node-&gt;right);
-        m_nodeCount -= 2;
-        node-&gt;left = 0;
-        node-&gt;right = 0;
-        node-&gt;largestFree = node-&gt;rect.size();
-    }
-
-    // Make the rest of our ancestors have the correct &quot;largest free size&quot;.
-    updateLargestFree(node);
-}
-
-int GeneralAreaAllocator::overhead() const
-{
-    return m_nodeCount * sizeof(Node);
-}
-
-} // namespace WebCore
-
-#endif // USE(COORDINATED_GRAPHICS)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapcoordinatedAreaAllocatorh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.h (202674 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.h        2016-06-30 06:28:58 UTC (rev 202674)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.h        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -1,114 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#ifndef AreaAllocator_h
-#define AreaAllocator_h
-
-#include &quot;IntPoint.h&quot;
-#include &quot;IntRect.h&quot;
-#include &quot;IntSize.h&quot;
-
-#if USE(COORDINATED_GRAPHICS)
-
-namespace WebCore {
-
-inline int nextPowerOfTwo(int number)
-{
-    // This is a fast trick to get nextPowerOfTwo for an integer.
-    --number;
-    number |= number &gt;&gt; 1;
-    number |= number &gt;&gt; 2;
-    number |= number &gt;&gt; 4;
-    number |= number &gt;&gt; 8;
-    number |= number &gt;&gt; 16;
-    number++;
-    return number;
-}
-
-inline IntSize nextPowerOfTwo(const IntSize&amp; size)
-{
-    return IntSize(nextPowerOfTwo(size.width()), nextPowerOfTwo(size.height()));
-}
-
-class AreaAllocator {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    explicit AreaAllocator(const IntSize&amp;);
-    virtual ~AreaAllocator();
-
-    IntSize size() const { return m_size; }
-
-    IntSize minimumAllocation() const { return m_minAlloc; }
-    void setMinimumAllocation(const IntSize&amp; size) { m_minAlloc = size; }
-
-    IntSize margin() const { return m_margin; }
-    void setMargin(const IntSize &amp;margin) { m_margin = margin; }
-
-    virtual void expand(const IntSize&amp;);
-    void expandBy(const IntSize&amp;);
-
-    virtual IntRect allocate(const IntSize&amp;) = 0;
-    virtual void release(const IntRect&amp;);
-
-    virtual int overhead() const;
-
-protected:
-    IntSize m_size;
-    IntSize m_minAlloc;
-    IntSize m_margin;
-
-    IntSize roundAllocation(const IntSize&amp;) const;
-};
-
-class GeneralAreaAllocator : public AreaAllocator {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    explicit GeneralAreaAllocator(const IntSize&amp;);
-    virtual ~GeneralAreaAllocator();
-
-    void expand(const IntSize&amp;);
-    IntRect allocate(const IntSize&amp;);
-    void release(const IntRect&amp;);
-    int overhead() const;
-
-private:
-    enum Split { SplitOnX, SplitOnY };
-
-    struct Node {
-        IntRect rect;
-        IntSize largestFree;
-        Node* parent;
-        Node* left;
-        Node* right;
-    };
-
-    Node* m_root;
-    int m_nodeCount;
-
-    static void freeNode(Node*);
-    IntPoint allocateFromNode(const IntSize&amp;, Node*);
-    Node* splitNode(Node*, Split);
-    static void updateLargestFree(Node*);
-};
-
-} // namespace WebCore
-
-#endif // USE(COORDINATED_GRAPHICS)
-
-#endif // AreaAllocator_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapcoordinatedCompositingCoordinatorcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp (202674 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp        2016-06-30 06:28:58 UTC (rev 202674)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -1,453 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2013 Company 100, 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. AND ITS CONTRIBUTORS ``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 ITS 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;
-
-#if USE(COORDINATED_GRAPHICS)
-
-#include &quot;CompositingCoordinator.h&quot;
-
-#include &quot;DOMWindow.h&quot;
-#include &quot;Document.h&quot;
-#include &quot;FrameView.h&quot;
-#include &quot;GraphicsContext.h&quot;
-#include &quot;InspectorController.h&quot;
-#include &quot;MainFrame.h&quot;
-#include &quot;Page.h&quot;
-#include &quot;Settings.h&quot;
-#include &lt;wtf/CurrentTime.h&gt;
-#include &lt;wtf/TemporaryChange.h&gt;
-
-// FIXME: Having this in the platform directory is a layering violation. This does not belong here.
-
-namespace WebCore {
-
-CompositingCoordinator::CompositingCoordinator(Page* page, CompositingCoordinator::Client* client)
-    : m_page(page)
-    , m_client(client)
-    , m_rootCompositingLayer(nullptr)
-    , m_overlayCompositingLayer(nullptr)
-    , m_isDestructing(false)
-    , m_isPurging(false)
-    , m_isFlushingLayerChanges(false)
-    , m_shouldSyncFrame(false)
-    , m_didInitializeRootCompositingLayer(false)
-    , m_releaseInactiveAtlasesTimer(*this, &amp;CompositingCoordinator::releaseInactiveAtlasesTimerFired)
-#if ENABLE(REQUEST_ANIMATION_FRAME)
-    , m_lastAnimationServiceTime(0)
-#endif
-{
-}
-
-CompositingCoordinator::~CompositingCoordinator()
-{
-    m_isDestructing = true;
-
-    purgeBackingStores();
-
-    for (auto&amp; registeredLayer : m_registeredLayers.values())
-        registeredLayer-&gt;setCoordinator(nullptr);
-}
-
-void CompositingCoordinator::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
-{
-    if (m_rootCompositingLayer == graphicsLayer)
-        return;
-
-    if (m_rootCompositingLayer)
-        m_rootCompositingLayer-&gt;removeFromParent();
-
-    m_rootCompositingLayer = graphicsLayer;
-    if (m_rootCompositingLayer)
-        m_rootLayer-&gt;addChildAtIndex(m_rootCompositingLayer, 0);
-}
-
-void CompositingCoordinator::setViewOverlayRootLayer(GraphicsLayer* graphicsLayer)
-{
-    if (m_overlayCompositingLayer == graphicsLayer)
-        return;
-
-    if (m_overlayCompositingLayer)
-        m_overlayCompositingLayer-&gt;removeFromParent();
-
-    m_overlayCompositingLayer = graphicsLayer;
-    if (m_overlayCompositingLayer)
-        m_rootLayer-&gt;addChild(m_overlayCompositingLayer);
-}
-
-void CompositingCoordinator::sizeDidChange(const IntSize&amp; newSize)
-{
-    m_rootLayer-&gt;setSize(newSize);
-    notifyFlushRequired(m_rootLayer.get());
-}
-
-bool CompositingCoordinator::flushPendingLayerChanges()
-{
-    TemporaryChange&lt;bool&gt; protector(m_isFlushingLayerChanges, true);
-
-    initializeRootCompositingLayerIfNeeded();
-
-    bool viewportIsStable = m_page-&gt;mainFrame().view()-&gt;viewportIsStable();
-    m_rootLayer-&gt;flushCompositingStateForThisLayerOnly(viewportIsStable);
-    m_client-&gt;didFlushRootLayer(m_visibleContentsRect);
-
-    if (m_overlayCompositingLayer)
-        m_overlayCompositingLayer-&gt;flushCompositingState(FloatRect(FloatPoint(), m_rootLayer-&gt;size()), viewportIsStable);
-
-    bool didSync = m_page-&gt;mainFrame().view()-&gt;flushCompositingStateIncludingSubframes();
-
-    toCoordinatedGraphicsLayer(m_rootLayer.get())-&gt;updateContentBuffersIncludingSubLayers();
-    toCoordinatedGraphicsLayer(m_rootLayer.get())-&gt;syncPendingStateChangesIncludingSubLayers();
-
-    flushPendingImageBackingChanges();
-
-    if (m_shouldSyncFrame) {
-        didSync = true;
-
-        if (m_rootCompositingLayer) {
-            m_state.contentsSize = roundedIntSize(m_rootCompositingLayer-&gt;size());
-            if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
-                m_state.coveredRect = contentsLayer-&gt;coverRect();
-        }
-        m_state.scrollPosition = m_visibleContentsRect.location();
-
-        m_client-&gt;commitSceneState(m_state);
-
-        clearPendingStateChanges();
-        m_shouldSyncFrame = false;
-    }
-
-    return didSync;
-}
-
-double CompositingCoordinator::timestamp() const
-{
-    auto* document = m_page-&gt;mainFrame().document();
-    if (!document)
-        return 0;
-    return document-&gt;domWindow() ? document-&gt;domWindow()-&gt;nowTimestamp() : document-&gt;monotonicTimestamp();
-}
-
-void CompositingCoordinator::syncDisplayState()
-{
-#if ENABLE(REQUEST_ANIMATION_FRAME) &amp;&amp; !USE(REQUEST_ANIMATION_FRAME_TIMER) &amp;&amp; !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
-    // Make sure that any previously registered animation callbacks are being executed before we flush the layers.
-    m_lastAnimationServiceTime = timestamp();
-    m_page-&gt;mainFrame().view()-&gt;serviceScriptedAnimations();
-#endif
-    m_page-&gt;mainFrame().view()-&gt;updateLayoutAndStyleIfNeededRecursive();
-}
-
-#if ENABLE(REQUEST_ANIMATION_FRAME)
-double CompositingCoordinator::nextAnimationServiceTime() const
-{
-    // According to the requestAnimationFrame spec, rAF callbacks should not be faster than 60FPS.
-    static const double MinimalTimeoutForAnimations = 1. / 60.;
-    return std::max&lt;double&gt;(0., MinimalTimeoutForAnimations - timestamp() + m_lastAnimationServiceTime);
-}
-#endif
-
-void CompositingCoordinator::clearPendingStateChanges()
-{
-    m_state.layersToCreate.clear();
-    m_state.layersToUpdate.clear();
-    m_state.layersToRemove.clear();
-
-    m_state.imagesToCreate.clear();
-    m_state.imagesToRemove.clear();
-    m_state.imagesToUpdate.clear();
-    m_state.imagesToClear.clear();
-
-    m_state.updateAtlasesToCreate.clear();
-    m_state.updateAtlasesToRemove.clear();
-}
-
-void CompositingCoordinator::initializeRootCompositingLayerIfNeeded()
-{
-    if (m_didInitializeRootCompositingLayer)
-        return;
-
-    m_state.rootCompositingLayer = toCoordinatedGraphicsLayer(m_rootLayer.get())-&gt;id();
-    m_didInitializeRootCompositingLayer = true;
-    m_shouldSyncFrame = true;
-}
-
-void CompositingCoordinator::createRootLayer(const IntSize&amp; size)
-{
-    ASSERT(!m_rootLayer);
-    // Create a root layer.
-    m_rootLayer = GraphicsLayer::create(this, *this);
-#ifndef NDEBUG
-    m_rootLayer-&gt;setName(&quot;CompositingCoordinator root layer&quot;);
-#endif
-    m_rootLayer-&gt;setDrawsContent(false);
-    m_rootLayer-&gt;setSize(size);
-}
-
-void CompositingCoordinator::syncLayerState(CoordinatedLayerID id, CoordinatedGraphicsLayerState&amp; state)
-{
-    m_shouldSyncFrame = true;
-    m_state.layersToUpdate.append(std::make_pair(id, state));
-}
-
-PassRefPtr&lt;CoordinatedImageBacking&gt; CompositingCoordinator::createImageBackingIfNeeded(Image* image)
-{
-    CoordinatedImageBackingID imageID = CoordinatedImageBacking::getCoordinatedImageBackingID(image);
-    ImageBackingMap::iterator it = m_imageBackings.find(imageID);
-    RefPtr&lt;CoordinatedImageBacking&gt; imageBacking;
-    if (it == m_imageBackings.end()) {
-        imageBacking = CoordinatedImageBacking::create(this, image);
-        m_imageBackings.add(imageID, imageBacking);
-    } else
-        imageBacking = it-&gt;value;
-
-    return imageBacking;
-}
-
-void CompositingCoordinator::createImageBacking(CoordinatedImageBackingID imageID)
-{
-    m_state.imagesToCreate.append(imageID);
-}
-
-void CompositingCoordinator::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr&lt;CoordinatedSurface&gt; coordinatedSurface)
-{
-    m_shouldSyncFrame = true;
-    m_state.imagesToUpdate.append(std::make_pair(imageID, coordinatedSurface));
-}
-
-void CompositingCoordinator::clearImageBackingContents(CoordinatedImageBackingID imageID)
-{
-    m_shouldSyncFrame = true;
-    m_state.imagesToClear.append(imageID);
-}
-
-void CompositingCoordinator::removeImageBacking(CoordinatedImageBackingID imageID)
-{
-    if (m_isPurging)
-        return;
-
-    ASSERT(m_imageBackings.contains(imageID));
-    m_imageBackings.remove(imageID);
-
-    m_state.imagesToRemove.append(imageID);
-
-    size_t imageIDPosition = m_state.imagesToClear.find(imageID);
-    if (imageIDPosition != notFound)
-        m_state.imagesToClear.remove(imageIDPosition);
-}
-
-void CompositingCoordinator::flushPendingImageBackingChanges()
-{
-    for (auto&amp; imageBacking : m_imageBackings.values())
-        imageBacking-&gt;update();
-}
-
-void CompositingCoordinator::notifyAnimationStarted(const GraphicsLayer*, const String&amp;, double /* time */)
-{
-}
-
-void CompositingCoordinator::notifyFlushRequired(const GraphicsLayer*)
-{
-    if (!m_isDestructing &amp;&amp; !isFlushingLayerChanges())
-        m_client-&gt;notifyFlushRequired();
-}
-
-void CompositingCoordinator::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext&amp; graphicsContext, GraphicsLayerPaintingPhase, const FloatRect&amp; clipRect)
-{
-    m_client-&gt;paintLayerContents(graphicsLayer, graphicsContext, enclosingIntRect(clipRect));
-}
-
-std::unique_ptr&lt;GraphicsLayer&gt; CompositingCoordinator::createGraphicsLayer(GraphicsLayer::Type layerType, GraphicsLayerClient&amp; client)
-{
-    CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(layerType, client);
-    layer-&gt;setCoordinator(this);
-    m_registeredLayers.add(layer-&gt;id(), layer);
-    m_state.layersToCreate.append(layer-&gt;id());
-    layer-&gt;setNeedsVisibleRectAdjustment();
-    notifyFlushRequired(layer);
-    return std::unique_ptr&lt;GraphicsLayer&gt;(layer);
-}
-
-float CompositingCoordinator::deviceScaleFactor() const
-{
-    return m_page-&gt;deviceScaleFactor();
-}
-
-float CompositingCoordinator::pageScaleFactor() const
-{
-    return m_page-&gt;pageScaleFactor();
-}
-
-void CompositingCoordinator::createUpdateAtlas(uint32_t atlasID, PassRefPtr&lt;CoordinatedSurface&gt; coordinatedSurface)
-{
-    m_state.updateAtlasesToCreate.append(std::make_pair(atlasID, coordinatedSurface));
-}
-
-void CompositingCoordinator::removeUpdateAtlas(uint32_t atlasID)
-{
-    if (m_isPurging)
-        return;
-    m_state.updateAtlasesToRemove.append(atlasID);
-}
-
-FloatRect CompositingCoordinator::visibleContentsRect() const
-{
-    return m_visibleContentsRect;
-}
-
-CoordinatedGraphicsLayer* CompositingCoordinator::mainContentsLayer()
-{
-    if (!m_rootCompositingLayer)
-        return 0;
-
-    return toCoordinatedGraphicsLayer(m_rootCompositingLayer)-&gt;findFirstDescendantWithContentsRecursively();
-}
-
-void CompositingCoordinator::setVisibleContentsRect(const FloatRect&amp; rect, const FloatPoint&amp; trajectoryVector)
-{
-    // A zero trajectoryVector indicates that tiles all around the viewport are requested.
-    if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
-        contentsLayer-&gt;setVisibleContentRectTrajectoryVector(trajectoryVector);
-
-    bool contentsRectDidChange = rect != m_visibleContentsRect;
-    if (contentsRectDidChange) {
-        m_visibleContentsRect = rect;
-
-        for (auto&amp; registeredLayer : m_registeredLayers.values())
-            registeredLayer-&gt;setNeedsVisibleRectAdjustment();
-    }
-
-    FrameView* view = m_page-&gt;mainFrame().view();
-    if (view-&gt;useFixedLayout() &amp;&amp; contentsRectDidChange) {
-        // Round the rect instead of enclosing it to make sure that its size stays
-        // the same while panning. This can have nasty effects on layout.
-        view-&gt;setFixedVisibleContentRect(roundedIntRect(rect));
-    }
-}
-
-void CompositingCoordinator::deviceOrPageScaleFactorChanged()
-{
-    m_rootLayer-&gt;deviceOrPageScaleFactorChanged();
-}
-
-void CompositingCoordinator::detachLayer(CoordinatedGraphicsLayer* layer)
-{
-    if (m_isPurging)
-        return;
-
-    m_registeredLayers.remove(layer-&gt;id());
-
-    size_t index = m_state.layersToCreate.find(layer-&gt;id());
-    if (index != notFound) {
-        m_state.layersToCreate.remove(index);
-        return;
-    }
-
-    m_state.layersToRemove.append(layer-&gt;id());
-    notifyFlushRequired(layer);
-}
-
-void CompositingCoordinator::commitScrollOffset(uint32_t layerID, const WebCore::IntSize&amp; offset)
-{
-    LayerMap::iterator i = m_registeredLayers.find(layerID);
-    if (i == m_registeredLayers.end())
-        return;
-
-    i-&gt;value-&gt;commitScrollOffset(offset);
-}
-
-void CompositingCoordinator::renderNextFrame()
-{
-    for (auto&amp; atlas : m_updateAtlases)
-        atlas-&gt;didSwapBuffers();
-}
-
-void CompositingCoordinator::purgeBackingStores()
-{
-    TemporaryChange&lt;bool&gt; purgingToggle(m_isPurging, true);
-
-    for (auto&amp; registeredLayer : m_registeredLayers.values())
-        registeredLayer-&gt;purgeBackingStores();
-
-    m_imageBackings.clear();
-    m_updateAtlases.clear();
-}
-
-bool CompositingCoordinator::paintToSurface(const IntSize&amp; size, CoordinatedSurface::Flags flags, uint32_t&amp; atlasID, IntPoint&amp; offset, CoordinatedSurface::Client* client)
-{
-    for (auto&amp; updateAtlas : m_updateAtlases) {
-        UpdateAtlas* atlas = updateAtlas.get();
-        if (atlas-&gt;supportsAlpha() == (flags &amp; CoordinatedSurface::SupportsAlpha)) {
-            // This will be false if there is no available buffer space.
-            if (atlas-&gt;paintOnAvailableBuffer(size, atlasID, offset, client))
-                return true;
-        }
-    }
-
-    static const int ScratchBufferDimension = 1024; // Should be a power of two.
-    m_updateAtlases.append(std::make_unique&lt;UpdateAtlas&gt;(this, ScratchBufferDimension, flags));
-    scheduleReleaseInactiveAtlases();
-    return m_updateAtlases.last()-&gt;paintOnAvailableBuffer(size, atlasID, offset, client);
-}
-
-const double ReleaseInactiveAtlasesTimerInterval = 0.5;
-
-void CompositingCoordinator::scheduleReleaseInactiveAtlases()
-{
-    if (!m_releaseInactiveAtlasesTimer.isActive())
-        m_releaseInactiveAtlasesTimer.startRepeating(ReleaseInactiveAtlasesTimerInterval);
-}
-
-void CompositingCoordinator::releaseInactiveAtlasesTimerFired()
-{
-    // We always want to keep one atlas for root contents layer.
-    std::unique_ptr&lt;UpdateAtlas&gt; atlasToKeepAnyway;
-    bool foundActiveAtlasForRootContentsLayer = false;
-    for (int i = m_updateAtlases.size() - 1;  i &gt;= 0; --i) {
-        UpdateAtlas* atlas = m_updateAtlases[i].get();
-        if (!atlas-&gt;isInUse())
-            atlas-&gt;addTimeInactive(ReleaseInactiveAtlasesTimerInterval);
-        bool usableForRootContentsLayer = !atlas-&gt;supportsAlpha();
-        if (atlas-&gt;isInactive()) {
-            if (!foundActiveAtlasForRootContentsLayer &amp;&amp; !atlasToKeepAnyway &amp;&amp; usableForRootContentsLayer)
-                atlasToKeepAnyway = WTFMove(m_updateAtlases[i]);
-            m_updateAtlases.remove(i);
-        } else if (usableForRootContentsLayer)
-            foundActiveAtlasForRootContentsLayer = true;
-    }
-
-    if (!foundActiveAtlasForRootContentsLayer &amp;&amp; atlasToKeepAnyway)
-        m_updateAtlases.append(atlasToKeepAnyway.release());
-
-    m_updateAtlases.shrinkToFit();
-
-    if (m_updateAtlases.size() &lt;= 1)
-        m_releaseInactiveAtlasesTimer.stop();
-}
-
-} // namespace WebCore
-
-#endif // USE(COORDINATED_GRAPHICS)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapcoordinatedCompositingCoordinatorh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h (202674 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h        2016-06-30 06:28:58 UTC (rev 202674)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -1,165 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- * Copyright (C) 2013 Company 100, 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. AND ITS CONTRIBUTORS ``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 ITS 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 CompositingCoordinator_h
-#define CompositingCoordinator_h
-
-#if USE(COORDINATED_GRAPHICS)
-
-#include &quot;CoordinatedGraphicsLayer.h&quot;
-#include &quot;CoordinatedGraphicsState.h&quot;
-#include &quot;CoordinatedImageBacking.h&quot;
-#include &quot;FloatPoint.h&quot;
-#include &quot;GraphicsLayerClient.h&quot;
-#include &quot;GraphicsLayerFactory.h&quot;
-#include &quot;IntRect.h&quot;
-#include &quot;Timer.h&quot;
-#include &quot;UpdateAtlas.h&quot;
-
-namespace WebCore {
-
-class Page;
-class GraphicsContext;
-class GraphicsLayer;
-class CoordinatedSurface;
-
-class CompositingCoordinator : public GraphicsLayerClient
-    , public CoordinatedGraphicsLayerClient
-    , public CoordinatedImageBacking::Client
-    , public UpdateAtlas::Client
-    , public GraphicsLayerFactory {
-    WTF_MAKE_NONCOPYABLE(CompositingCoordinator); WTF_MAKE_FAST_ALLOCATED;
-public:
-    class Client {
-    public:
-        virtual void didFlushRootLayer(const FloatRect&amp; visibleContentRect) = 0;
-        virtual void notifyFlushRequired() = 0;
-        virtual void commitSceneState(const CoordinatedGraphicsState&amp;) = 0;
-        virtual void paintLayerContents(const GraphicsLayer*, GraphicsContext&amp;, const IntRect&amp; clipRect) = 0;
-    };
-
-    CompositingCoordinator(Page*, CompositingCoordinator::Client*);
-    virtual ~CompositingCoordinator();
-
-    void setRootCompositingLayer(GraphicsLayer*);
-    void setViewOverlayRootLayer(GraphicsLayer*);
-    void sizeDidChange(const IntSize&amp; newSize);
-    void deviceOrPageScaleFactorChanged();
-
-    void setVisibleContentsRect(const FloatRect&amp;, const FloatPoint&amp;);
-    void renderNextFrame();
-    void purgeBackingStores();
-    void commitScrollOffset(uint32_t layerID, const IntSize&amp; offset);
-
-    void createRootLayer(const IntSize&amp;);
-    void clearRootLayer() { m_rootLayer = nullptr; }
-    GraphicsLayer* rootLayer() const { return m_rootLayer.get(); }
-    CoordinatedGraphicsLayer* mainContentsLayer();
-
-    bool flushPendingLayerChanges();
-    CoordinatedGraphicsState&amp; state() { return m_state; }
-
-    void syncDisplayState();
-
-#if ENABLE(REQUEST_ANIMATION_FRAME)
-    double nextAnimationServiceTime() const;
-#endif
-
-private:
-    // GraphicsLayerClient
-    void notifyAnimationStarted(const GraphicsLayer*, const String&amp;, double time) override;
-    void notifyFlushRequired(const GraphicsLayer*) override;
-    void paintContents(const GraphicsLayer*, GraphicsContext&amp;, GraphicsLayerPaintingPhase, const FloatRect&amp; clipRect) override;
-    float deviceScaleFactor() const override;
-    float pageScaleFactor() const override;
-
-    // CoordinatedImageBacking::Client
-    void createImageBacking(CoordinatedImageBackingID) override;
-    void updateImageBacking(CoordinatedImageBackingID, PassRefPtr&lt;CoordinatedSurface&gt;) override;
-    void clearImageBackingContents(CoordinatedImageBackingID) override;
-    void removeImageBacking(CoordinatedImageBackingID) override;
-
-    // CoordinatedGraphicsLayerClient
-    bool isFlushingLayerChanges() const override { return m_isFlushingLayerChanges; }
-    FloatRect visibleContentsRect() const override;
-    PassRefPtr&lt;CoordinatedImageBacking&gt; createImageBackingIfNeeded(Image*) override;
-    void detachLayer(CoordinatedGraphicsLayer*) override;
-    bool paintToSurface(const WebCore::IntSize&amp;, WebCore::CoordinatedSurface::Flags, uint32_t&amp; /* atlasID */, WebCore::IntPoint&amp;, WebCore::CoordinatedSurface::Client*) override;
-    void syncLayerState(CoordinatedLayerID, CoordinatedGraphicsLayerState&amp;) override;
-
-    // UpdateAtlas::Client
-    void createUpdateAtlas(uint32_t atlasID, PassRefPtr&lt;CoordinatedSurface&gt;) override;
-    void removeUpdateAtlas(uint32_t atlasID) override;
-
-    // GraphicsLayerFactory
-    std::unique_ptr&lt;GraphicsLayer&gt; createGraphicsLayer(GraphicsLayer::Type, GraphicsLayerClient&amp;) override;
-
-    void initializeRootCompositingLayerIfNeeded();
-    void flushPendingImageBackingChanges();
-    void clearPendingStateChanges();
-
-    void scheduleReleaseInactiveAtlases();
-
-    void releaseInactiveAtlasesTimerFired();
-
-    double timestamp() const;
-
-    Page* m_page;
-    CompositingCoordinator::Client* m_client;
-
-    std::unique_ptr&lt;GraphicsLayer&gt; m_rootLayer;
-    GraphicsLayer* m_rootCompositingLayer;
-    GraphicsLayer* m_overlayCompositingLayer;
-
-    CoordinatedGraphicsState m_state;
-
-    typedef HashMap&lt;CoordinatedLayerID, CoordinatedGraphicsLayer*&gt; LayerMap;
-    LayerMap m_registeredLayers;
-    typedef HashMap&lt;CoordinatedImageBackingID, RefPtr&lt;CoordinatedImageBacking&gt; &gt; ImageBackingMap;
-    ImageBackingMap m_imageBackings;
-    Vector&lt;std::unique_ptr&lt;UpdateAtlas&gt;&gt; m_updateAtlases;
-
-    // We don't send the messages related to releasing resources to renderer during purging, because renderer already had removed all resources.
-    bool m_isDestructing;
-    bool m_isPurging;
-    bool m_isFlushingLayerChanges;
-
-    FloatRect m_visibleContentsRect;
-
-    bool m_shouldSyncFrame;
-    bool m_didInitializeRootCompositingLayer;
-    Timer m_releaseInactiveAtlasesTimer;
-
-#if ENABLE(REQUEST_ANIMATION_FRAME)
-    double m_lastAnimationServiceTime;
-#endif
-};
-
-}
-
-#endif
-
-#endif // CompositingCoordinator_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapcoordinatedUpdateAtlascpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.cpp (202674 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.cpp        2016-06-30 06:28:58 UTC (rev 202674)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.cpp        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -1,116 +0,0 @@
</span><del>-/*
- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
- Copyright (C) 2012 Company 100, Inc.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB.  If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
- */
-
-#include &quot;config.h&quot;
-#include &quot;UpdateAtlas.h&quot;
-
-#if USE(COORDINATED_GRAPHICS)
-
-#include &quot;CoordinatedGraphicsState.h&quot;
-#include &quot;GraphicsContext.h&quot;
-#include &quot;IntRect.h&quot;
-#include &lt;wtf/MathExtras.h&gt;
-
-namespace WebCore {
-
-class UpdateAtlasSurfaceClient : public CoordinatedSurface::Client {
-public:
-    UpdateAtlasSurfaceClient(CoordinatedSurface::Client* client, const IntSize&amp; size, bool supportsAlpha)
-        : m_client(client)
-        , m_size(size)
-        , m_supportsAlpha(supportsAlpha)
-    {
-    }
-
-    void paintToSurfaceContext(GraphicsContext&amp; context) override
-    {
-        if (m_supportsAlpha) {
-            context.setCompositeOperation(CompositeCopy);
-            context.fillRect(IntRect(IntPoint::zero(), m_size), Color::transparent);
-            context.setCompositeOperation(CompositeSourceOver);
-        }
-
-        m_client-&gt;paintToSurfaceContext(context);
-    }
-
-private:
-    CoordinatedSurface::Client* m_client;
-    IntSize m_size;
-    bool m_supportsAlpha;
-};
-
-UpdateAtlas::UpdateAtlas(Client* client, int dimension, CoordinatedSurface::Flags flags)
-    : m_client(client)
-    , m_inactivityInSeconds(0)
-{
-    static uint32_t nextID = 0;
-    m_ID = ++nextID;
-    IntSize size = nextPowerOfTwo(IntSize(dimension, dimension));
-    m_surface = CoordinatedSurface::create(size, flags);
-
-    m_client-&gt;createUpdateAtlas(m_ID, m_surface);
-}
-
-UpdateAtlas::~UpdateAtlas()
-{
-    if (m_surface)
-        m_client-&gt;removeUpdateAtlas(m_ID);
-}
-
-void UpdateAtlas::buildLayoutIfNeeded()
-{
-    if (!m_areaAllocator) {
-        m_areaAllocator = std::make_unique&lt;GeneralAreaAllocator&gt;(size());
-        m_areaAllocator-&gt;setMinimumAllocation(IntSize(32, 32));
-    }
-}
-
-void UpdateAtlas::didSwapBuffers()
-{
-    m_areaAllocator = nullptr;
-}
-
-
-bool UpdateAtlas::paintOnAvailableBuffer(const IntSize&amp; size, uint32_t&amp; atlasID, IntPoint&amp; offset, CoordinatedSurface::Client* client)
-{
-    m_inactivityInSeconds = 0;
-    buildLayoutIfNeeded();
-    IntRect rect = m_areaAllocator-&gt;allocate(size);
-
-    // No available buffer was found.
-    if (rect.isEmpty())
-        return false;
-
-    if (!m_surface)
-        return false;
-
-    atlasID = m_ID;
-
-    // FIXME: Use tri-state buffers, to allow faster updates.
-    offset = rect.location();
-
-    UpdateAtlasSurfaceClient surfaceClient(client, size, supportsAlpha());
-    m_surface-&gt;paintToSurface(rect, &amp;surfaceClient);
-
-    return true;
-}
-
-} // namespace WebCore
-#endif // USE(COORDINATED_GRAPHICS)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapcoordinatedUpdateAtlash"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.h (202674 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.h        2016-06-30 06:28:58 UTC (rev 202674)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.h        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -1,80 +0,0 @@
</span><del>-/*
- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
- Copyright (C) 2012 Company 100, Inc.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB.  If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
- */
-
-#ifndef UpdateAtlas_h
-#define UpdateAtlas_h
-
-#include &quot;AreaAllocator.h&quot;
-#include &quot;CoordinatedSurface.h&quot;
-#include &quot;IntSize.h&quot;
-#include &lt;wtf/PassRefPtr.h&gt;
-#include &lt;wtf/RefPtr.h&gt;
-
-#if USE(COORDINATED_GRAPHICS)
-
-namespace WebCore {
-class GraphicsContext;
-class IntPoint;
-
-class UpdateAtlas {
-    WTF_MAKE_NONCOPYABLE(UpdateAtlas);
-public:
-    class Client {
-    public:
-        virtual void createUpdateAtlas(uint32_t /* id */, PassRefPtr&lt;CoordinatedSurface&gt;) = 0;
-        virtual void removeUpdateAtlas(uint32_t /* id */) = 0;
-    };
-
-    UpdateAtlas(Client*, int dimension, CoordinatedSurface::Flags);
-    ~UpdateAtlas();
-
-    inline IntSize size() const { return m_surface-&gt;size(); }
-
-    // Returns false if there is no available buffer.
-    bool paintOnAvailableBuffer(const IntSize&amp;, uint32_t&amp; atlasID, IntPoint&amp; offset, CoordinatedSurface::Client*);
-    void didSwapBuffers();
-    bool supportsAlpha() const { return m_surface-&gt;supportsAlpha(); }
-
-    void addTimeInactive(double seconds)
-    {
-        ASSERT(!isInUse());
-        m_inactivityInSeconds += seconds;
-    }
-    bool isInactive() const
-    {
-        const double inactiveSecondsTolerance = 3;
-        return m_inactivityInSeconds &gt; inactiveSecondsTolerance;
-    }
-    bool isInUse() const { return !!m_areaAllocator; }
-
-private:
-    void buildLayoutIfNeeded();
-
-private:
-    Client* m_client;
-    std::unique_ptr&lt;GeneralAreaAllocator&gt; m_areaAllocator;
-    RefPtr&lt;CoordinatedSurface&gt; m_surface;
-    double m_inactivityInSeconds;
-    uint32_t m_ID;
-};
-
-} // namespace WebCore
-#endif // USE(COORDINATED_GRAPHICS)
-#endif // UpdateAtlas_h
</del></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (202674 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-06-30 06:28:58 UTC (rev 202674)
+++ trunk/Source/WebKit2/ChangeLog        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -1,3 +1,98 @@
</span><ins>+2016-06-30  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [Coordinated Graphics] Move CompositingCoordinator from platform to WebKit2 layer
+        https://bugs.webkit.org/show_bug.cgi?id=159209
+
+        Reviewed by Žan Doberšek.
+
+        Move CompositingCoordinator and its helper classes to the WebKit2 layer.
+
+        * PlatformEfl.cmake:
+        * PlatformGTK.cmake:
+        * WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp: Renamed from Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.cpp.
+        (WebKit::AreaAllocator::AreaAllocator):
+        (WebKit::AreaAllocator::~AreaAllocator):
+        (WebKit::AreaAllocator::expand):
+        (WebKit::AreaAllocator::expandBy):
+        (WebKit::AreaAllocator::release):
+        (WebKit::AreaAllocator::overhead):
+        (WebKit::AreaAllocator::roundAllocation):
+        (WebKit::GeneralAreaAllocator::GeneralAreaAllocator):
+        (WebKit::GeneralAreaAllocator::~GeneralAreaAllocator):
+        (WebKit::GeneralAreaAllocator::freeNode):
+        (WebKit::GeneralAreaAllocator::expand):
+        (WebKit::fitsWithin):
+        (WebKit::GeneralAreaAllocator::allocate):
+        (WebKit::GeneralAreaAllocator::allocateFromNode):
+        (WebKit::GeneralAreaAllocator::splitNode):
+        (WebKit::GeneralAreaAllocator::updateLargestFree):
+        (WebKit::GeneralAreaAllocator::release):
+        (WebKit::GeneralAreaAllocator::overhead):
+        * WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h: Renamed from Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.h.
+        (WebKit::nextPowerOfTwo):
+        (WebKit::AreaAllocator::size):
+        (WebKit::AreaAllocator::minimumAllocation):
+        (WebKit::AreaAllocator::setMinimumAllocation):
+        (WebKit::AreaAllocator::margin):
+        (WebKit::AreaAllocator::setMargin):
+        * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp: Renamed from Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp.
+        (WebKit::CompositingCoordinator::CompositingCoordinator):
+        (WebKit::CompositingCoordinator::~CompositingCoordinator):
+        (WebKit::CompositingCoordinator::setRootCompositingLayer):
+        (WebKit::CompositingCoordinator::setViewOverlayRootLayer):
+        (WebKit::CompositingCoordinator::sizeDidChange):
+        (WebKit::CompositingCoordinator::flushPendingLayerChanges):
+        (WebKit::CompositingCoordinator::timestamp):
+        (WebKit::CompositingCoordinator::syncDisplayState):
+        (WebKit::CompositingCoordinator::nextAnimationServiceTime):
+        (WebKit::CompositingCoordinator::clearPendingStateChanges):
+        (WebKit::CompositingCoordinator::initializeRootCompositingLayerIfNeeded):
+        (WebKit::CompositingCoordinator::createRootLayer):
+        (WebKit::CompositingCoordinator::syncLayerState):
+        (WebKit::CompositingCoordinator::createImageBackingIfNeeded):
+        (WebKit::CompositingCoordinator::createImageBacking):
+        (WebKit::CompositingCoordinator::updateImageBacking):
+        (WebKit::CompositingCoordinator::clearImageBackingContents):
+        (WebKit::CompositingCoordinator::removeImageBacking):
+        (WebKit::CompositingCoordinator::flushPendingImageBackingChanges):
+        (WebKit::CompositingCoordinator::notifyAnimationStarted):
+        (WebKit::CompositingCoordinator::notifyFlushRequired):
+        (WebKit::CompositingCoordinator::paintContents):
+        (WebKit::CompositingCoordinator::createGraphicsLayer):
+        (WebKit::CompositingCoordinator::deviceScaleFactor):
+        (WebKit::CompositingCoordinator::pageScaleFactor):
+        (WebKit::CompositingCoordinator::createUpdateAtlas):
+        (WebKit::CompositingCoordinator::removeUpdateAtlas):
+        (WebKit::CompositingCoordinator::visibleContentsRect):
+        (WebKit::CompositingCoordinator::mainContentsLayer):
+        (WebKit::CompositingCoordinator::setVisibleContentsRect):
+        (WebKit::CompositingCoordinator::deviceOrPageScaleFactorChanged):
+        (WebKit::CompositingCoordinator::detachLayer):
+        (WebKit::CompositingCoordinator::commitScrollOffset):
+        (WebKit::CompositingCoordinator::renderNextFrame):
+        (WebKit::CompositingCoordinator::purgeBackingStores):
+        (WebKit::CompositingCoordinator::paintToSurface):
+        (WebKit::CompositingCoordinator::scheduleReleaseInactiveAtlases):
+        (WebKit::CompositingCoordinator::releaseInactiveAtlasesTimerFired):
+        * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h: Renamed from Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h.
+        (WebKit::CompositingCoordinator::clearRootLayer):
+        (WebKit::CompositingCoordinator::rootLayer):
+        (WebKit::CompositingCoordinator::state):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
+        * WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp: Renamed from Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.cpp.
+        (WebKit::UpdateAtlasSurfaceClient::UpdateAtlasSurfaceClient):
+        (WebKit::UpdateAtlas::UpdateAtlas):
+        (WebKit::UpdateAtlas::~UpdateAtlas):
+        (WebKit::UpdateAtlas::buildLayoutIfNeeded):
+        (WebKit::UpdateAtlas::didSwapBuffers):
+        (WebKit::UpdateAtlas::paintOnAvailableBuffer):
+        * WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h: Renamed from Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.h.
+        (WebKit::UpdateAtlas::size):
+        (WebKit::UpdateAtlas::supportsAlpha):
+        (WebKit::UpdateAtlas::addTimeInactive):
+        (WebKit::UpdateAtlas::isInactive):
+        (WebKit::UpdateAtlas::isInUse):
+
</ins><span class="cx"> 2016-06-29  Hunseop Jeong  &lt;hs85.jeong@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, CMake build fix.
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformEflcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PlatformEfl.cmake (202674 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PlatformEfl.cmake        2016-06-30 06:28:58 UTC (rev 202674)
+++ trunk/Source/WebKit2/PlatformEfl.cmake        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -198,8 +198,11 @@
</span><span class="cx"> 
</span><span class="cx">     WebProcess/WebPage/DrawingAreaImpl.cpp
</span><span class="cx"> 
</span><ins>+    WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp
+    WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp
</ins><span class="cx">     WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp
</span><span class="cx">     WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
</span><ins>+    WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp
</ins><span class="cx">     WebProcess/WebPage/CoordinatedGraphics/WebPageCoordinatedGraphics.cpp
</span><span class="cx"> 
</span><span class="cx">     WebProcess/WebPage/atk/WebPageAccessibilityObjectAtk.cpp
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PlatformGTK.cmake (202674 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PlatformGTK.cmake        2016-06-30 06:28:58 UTC (rev 202674)
+++ trunk/Source/WebKit2/PlatformGTK.cmake        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -826,8 +826,11 @@
</span><span class="cx">         Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp
</span><span class="cx">         Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
</span><span class="cx"> 
</span><ins>+        WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp
+        WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp
</ins><span class="cx">         WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
</span><span class="cx">         WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp
</span><ins>+        WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp
</ins><span class="cx">     )
</span><span class="cx">     list(APPEND WebKit2_INCLUDE_DIRECTORIES
</span><span class="cx">         &quot;${WEBCORE_DIR}/platform/graphics/texmap/coordinated&quot;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsAreaAllocatorcppfromrev202674trunkSourceWebCoreplatformgraphicstexmapcoordinatedAreaAllocatorcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp (from rev 202674, trunk/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.cpp) (0 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -0,0 +1,336 @@
</span><ins>+/*
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include &quot;config.h&quot;
+#include &quot;AreaAllocator.h&quot;
+
+#if USE(COORDINATED_GRAPHICS)
+
+using namespace WebCore;
+
+namespace WebKit {
+
+AreaAllocator::AreaAllocator(const IntSize&amp; size)
+    : m_size(size)
+    , m_minAlloc(1, 1)
+    , m_margin(0, 0)
+{
+}
+
+AreaAllocator::~AreaAllocator()
+{
+}
+
+void AreaAllocator::expand(const IntSize&amp; size)
+{
+    m_size = m_size.expandedTo(size);
+}
+
+void AreaAllocator::expandBy(const IntSize&amp; size)
+{
+    m_size += size;
+}
+
+void AreaAllocator::release(const IntRect&amp;)
+{
+}
+
+int AreaAllocator::overhead() const
+{
+    return 0;
+}
+
+IntSize AreaAllocator::roundAllocation(const IntSize&amp; size) const
+{
+    int width = size.width() + m_margin.width();
+    int height = size.height() + m_margin.height();
+    int extra = width % m_minAlloc.width();
+    if (extra)
+        width += m_minAlloc.width() - extra;
+    extra = height % m_minAlloc.height();
+    if (extra)
+        height += m_minAlloc.height() - extra;
+
+    return IntSize(width, height);
+}
+
+GeneralAreaAllocator::GeneralAreaAllocator(const IntSize&amp; size)
+    : AreaAllocator(nextPowerOfTwo(size))
+{
+    m_root = new Node();
+    m_root-&gt;rect = IntRect(0, 0, m_size.width(), m_size.height());
+    m_root-&gt;largestFree = m_size;
+    m_root-&gt;parent = 0;
+    m_root-&gt;left = 0;
+    m_root-&gt;right = 0;
+    m_nodeCount = 1;
+    setMinimumAllocation(IntSize(8, 8));
+}
+
+GeneralAreaAllocator::~GeneralAreaAllocator()
+{
+    freeNode(m_root);
+}
+
+void GeneralAreaAllocator::freeNode(Node* node)
+{
+    if (node) {
+        freeNode(node-&gt;left);
+        freeNode(node-&gt;right);
+    }
+    delete node;
+}
+
+void GeneralAreaAllocator::expand(const IntSize&amp; size)
+{
+    AreaAllocator::expand(nextPowerOfTwo(size));
+
+    if (m_root-&gt;rect.size() == m_size)
+        return; // No change.
+
+    if (!m_root-&gt;left &amp;&amp; m_root-&gt;largestFree.width() &gt; 0) {
+        // No allocations have occurred, so just adjust the root size.
+        m_root-&gt;rect = IntRect(0, 0, m_size.width(), m_size.height());
+        m_root-&gt;largestFree = m_size;
+        return;
+    }
+
+    // Add extra nodes above the current root to expand the tree.
+    Node* oldRoot = m_root;
+    Split split;
+    if (m_size.width() &gt;= m_size.height())
+        split = SplitOnX;
+    else
+        split = SplitOnY;
+
+    while (m_root-&gt;rect.size() != m_size) {
+        if (m_root-&gt;rect.width() == m_size.width())
+            split = SplitOnY;
+        else if (m_root-&gt;rect.height() == m_size.height())
+            split = SplitOnX;
+        Node* parent = new Node();
+        Node* right = new Node();
+        m_nodeCount += 2;
+        m_root-&gt;parent = parent;
+        parent-&gt;parent = 0;
+        parent-&gt;left = m_root;
+        parent-&gt;right = right;
+        parent-&gt;largestFree = m_root-&gt;rect.size();
+        right-&gt;parent = parent;
+        right-&gt;left = 0;
+        right-&gt;right = 0;
+        right-&gt;largestFree = m_root-&gt;rect.size();
+        if (split == SplitOnX) {
+            parent-&gt;rect = IntRect(m_root-&gt;rect.x(), m_root-&gt;rect.y(),
+                m_root-&gt;rect.width() * 2, m_root-&gt;rect.height());
+            right-&gt;rect = IntRect(m_root-&gt;rect.x() + m_root-&gt;rect.width(), m_root-&gt;rect.y(),
+                m_root-&gt;rect.width(), m_root-&gt;rect.height());
+        } else {
+            parent-&gt;rect = IntRect(m_root-&gt;rect.x(), m_root-&gt;rect.y(),
+                m_root-&gt;rect.width(), m_root-&gt;rect.height() * 2);
+            right-&gt;rect = IntRect(m_root-&gt;rect.x(), m_root-&gt;rect.y() + m_root-&gt;rect.width(),
+                m_root-&gt;rect.width(), m_root-&gt;rect.height());
+        }
+        split = (split == SplitOnX ? SplitOnY : SplitOnX);
+        m_root = parent;
+    }
+    updateLargestFree(oldRoot);
+}
+
+static inline bool fitsWithin(const IntSize&amp; size1, const IntSize&amp; size2)
+{
+    return size1.width() &lt;= size2.width() &amp;&amp; size1.height() &lt;= size2.height();
+}
+
+IntRect GeneralAreaAllocator::allocate(const IntSize&amp; size)
+{
+    IntSize rounded = roundAllocation(size);
+    rounded = nextPowerOfTwo(rounded);
+    if (rounded.width() &lt;= 0 || rounded.width() &gt; m_size.width()
+        || rounded.height() &lt;= 0 || rounded.height() &gt; m_size.height())
+        return IntRect();
+
+    IntPoint point = allocateFromNode(rounded, m_root);
+    if (point.x() &gt;= 0)
+        return IntRect(point, size);
+    return IntRect();
+}
+
+IntPoint GeneralAreaAllocator::allocateFromNode(const IntSize&amp; size, Node* node)
+{
+    // Find the best node to insert into, which should be
+    // a node with the least amount of unused space that is
+    // big enough to contain the requested size.
+    while (node) {
+        // Go down a level and determine if the left or right
+        // sub-tree contains the best chance of allocation.
+        Node* left = node-&gt;left;
+        Node* right = node-&gt;right;
+        if (left &amp;&amp; fitsWithin(size, left-&gt;largestFree)) {
+            if (right &amp;&amp; fitsWithin(size, right-&gt;largestFree)) {
+                if (left-&gt;largestFree.width() &lt; right-&gt;largestFree.width()
+                    || left-&gt;largestFree.height() &lt; right-&gt;largestFree.height()) {
+                    // The largestFree values may be a little oversized,
+                    // so try the left sub-tree and then the right sub-tree.
+                    IntPoint point = allocateFromNode(size, left);
+                    if (point.x() &gt;= 0)
+                        return point;
+                    return allocateFromNode(size, right);
+                }
+                node = right;
+            } else
+                node = left;
+        } else if (right &amp;&amp; fitsWithin(size, right-&gt;largestFree))
+            node = right;
+        else if (left || right) {
+            // Neither sub-node has enough space to allocate from.
+            return IntPoint(-1, -1);
+        } else if (fitsWithin(size, node-&gt;largestFree)) {
+            // Do we need to split this node into smaller pieces?
+            Split split;
+            if (fitsWithin(IntSize(size.width() * 2, size.height() * 2), node-&gt;largestFree)) {
+                // Split in either direction: choose the inverse of
+                // the parent node's split direction to try to balance
+                // out the wasted space as further subdivisions happen.
+                if (node-&gt;parent
+                    &amp;&amp; node-&gt;parent-&gt;left-&gt;rect.x() == node-&gt;parent-&gt;right-&gt;rect.x())
+                    split = SplitOnX;
+                else if (node-&gt;parent)
+                    split = SplitOnY;
+                else if (node-&gt;rect.width() &gt;= node-&gt;rect.height())
+                    split = SplitOnX;
+                else
+                    split = SplitOnY;
+            } else if (fitsWithin(IntSize(size.width() * 2, size.height()), node-&gt;largestFree)) {
+                // Split along the X direction.
+                split = SplitOnX;
+            } else if (fitsWithin(IntSize(size.width(), size.height() * 2), node-&gt;largestFree)) {
+                // Split along the Y direction.
+                split = SplitOnY;
+            } else {
+                // Cannot split further - allocate this node.
+                node-&gt;largestFree = IntSize(0, 0);
+                updateLargestFree(node);
+                return node-&gt;rect.location();
+            }
+
+            // Split the node, then go around again using the left sub-tree.
+            node = splitNode(node, split);
+        } else {
+            // Cannot possibly fit into this node.
+            break;
+        }
+    }
+    return IntPoint(-1, -1);
+}
+
+GeneralAreaAllocator::Node* GeneralAreaAllocator::splitNode
+    (Node* node, Split split)
+{
+    Node* left = new Node();
+    Node* right = new Node();
+    m_nodeCount += 2;
+    left-&gt;parent = node;
+    left-&gt;left = 0;
+    left-&gt;right = 0;
+    right-&gt;parent = node;
+    right-&gt;left = 0;
+    right-&gt;right = 0;
+    node-&gt;left = left;
+    node-&gt;right = right;
+
+    if (split == SplitOnX) {
+        left-&gt;rect = IntRect(node-&gt;rect.x(), node-&gt;rect.y(),
+            node-&gt;rect.width() / 2, node-&gt;rect.height());
+        right-&gt;rect = IntRect(left-&gt;rect.maxX(), node-&gt;rect.y(),
+            node-&gt;rect.width() / 2, node-&gt;rect.height());
+    } else {
+        left-&gt;rect = IntRect(node-&gt;rect.x(), node-&gt;rect.y(),
+            node-&gt;rect.width(), node-&gt;rect.height() / 2);
+        right-&gt;rect = IntRect(node-&gt;rect.x(), left-&gt;rect.maxY(),
+            node-&gt;rect.width(), node-&gt;rect.height() / 2);
+    }
+
+    left-&gt;largestFree = left-&gt;rect.size();
+    right-&gt;largestFree = right-&gt;rect.size();
+    node-&gt;largestFree = right-&gt;largestFree;
+    return left;
+}
+
+void GeneralAreaAllocator::updateLargestFree(Node* node)
+{
+    while ((node = node-&gt;parent)) {
+        node-&gt;largestFree = IntSize(
+            std::max(node-&gt;left-&gt;largestFree.width(), node-&gt;right-&gt;largestFree.width()),
+            std::max(node-&gt;left-&gt;largestFree.height(), node-&gt;right-&gt;largestFree.height())
+            );
+    }
+}
+
+void GeneralAreaAllocator::release(const IntRect&amp; rect)
+{
+    // Locate the node that contains the allocated region.
+    Node* node = m_root;
+    IntPoint point = rect.location();
+    while (node) {
+        if (node-&gt;left &amp;&amp; node-&gt;left-&gt;rect.contains(point))
+            node = node-&gt;left;
+        else if (node-&gt;right &amp;&amp; node-&gt;right-&gt;rect.contains(point))
+            node = node-&gt;right;
+        else if (node-&gt;rect.contains(point))
+            break;
+        else
+            return; // Point is completely outside the tree.
+    }
+    if (!node)
+        return;
+
+    // Mark the node as free and then work upwards through the tree
+    // recombining and deleting nodes until we reach a sibling
+    // that is still allocated.
+    node-&gt;largestFree = node-&gt;rect.size();
+    while (node-&gt;parent) {
+        if (node-&gt;parent-&gt;left == node) {
+            if (node-&gt;parent-&gt;right-&gt;largestFree != node-&gt;parent-&gt;right-&gt;rect.size())
+                break;
+        } else {
+            if (node-&gt;parent-&gt;left-&gt;largestFree != node-&gt;parent-&gt;left-&gt;rect.size())
+                break;
+        }
+        node = node-&gt;parent;
+        freeNode(node-&gt;left);
+        freeNode(node-&gt;right);
+        m_nodeCount -= 2;
+        node-&gt;left = 0;
+        node-&gt;right = 0;
+        node-&gt;largestFree = node-&gt;rect.size();
+    }
+
+    // Make the rest of our ancestors have the correct &quot;largest free size&quot;.
+    updateLargestFree(node);
+}
+
+int GeneralAreaAllocator::overhead() const
+{
+    return m_nodeCount * sizeof(Node);
+}
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsAreaAllocatorhfromrev202674trunkSourceWebCoreplatformgraphicstexmapcoordinatedAreaAllocatorh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h (from rev 202674, trunk/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.h) (0 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -0,0 +1,113 @@
</span><ins>+/*
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef AreaAllocator_h
+#define AreaAllocator_h
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include &lt;WebCore/IntPoint.h&gt;
+#include &lt;WebCore/IntRect.h&gt;
+#include &lt;WebCore/IntSize.h&gt;
+
+namespace WebKit {
+
+inline int nextPowerOfTwo(int number)
+{
+    // This is a fast trick to get nextPowerOfTwo for an integer.
+    --number;
+    number |= number &gt;&gt; 1;
+    number |= number &gt;&gt; 2;
+    number |= number &gt;&gt; 4;
+    number |= number &gt;&gt; 8;
+    number |= number &gt;&gt; 16;
+    number++;
+    return number;
+}
+
+inline WebCore::IntSize nextPowerOfTwo(const WebCore::IntSize&amp; size)
+{
+    return WebCore::IntSize(nextPowerOfTwo(size.width()), nextPowerOfTwo(size.height()));
+}
+
+class AreaAllocator {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    explicit AreaAllocator(const WebCore::IntSize&amp;);
+    virtual ~AreaAllocator();
+
+    WebCore::IntSize size() const { return m_size; }
+
+    WebCore::IntSize minimumAllocation() const { return m_minAlloc; }
+    void setMinimumAllocation(const WebCore::IntSize&amp; size) { m_minAlloc = size; }
+
+    WebCore::IntSize margin() const { return m_margin; }
+    void setMargin(const WebCore::IntSize &amp;margin) { m_margin = margin; }
+
+    virtual void expand(const WebCore::IntSize&amp;);
+    void expandBy(const WebCore::IntSize&amp;);
+
+    virtual WebCore::IntRect allocate(const WebCore::IntSize&amp;) = 0;
+    virtual void release(const WebCore::IntRect&amp;);
+
+    virtual int overhead() const;
+
+protected:
+    WebCore::IntSize m_size;
+    WebCore::IntSize m_minAlloc;
+    WebCore::IntSize m_margin;
+
+    WebCore::IntSize roundAllocation(const WebCore::IntSize&amp;) const;
+};
+
+class GeneralAreaAllocator : public AreaAllocator {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    explicit GeneralAreaAllocator(const WebCore::IntSize&amp;);
+    virtual ~GeneralAreaAllocator();
+
+    void expand(const WebCore::IntSize&amp;);
+    WebCore::IntRect allocate(const WebCore::IntSize&amp;);
+    void release(const WebCore::IntRect&amp;);
+    int overhead() const;
+
+private:
+    enum Split { SplitOnX, SplitOnY };
+
+    struct Node {
+        WebCore::IntRect rect;
+        WebCore::IntSize largestFree;
+        Node* parent;
+        Node* left;
+        Node* right;
+    };
+
+    Node* m_root;
+    int m_nodeCount;
+
+    static void freeNode(Node*);
+    WebCore::IntPoint allocateFromNode(const WebCore::IntSize&amp;, Node*);
+    Node* splitNode(Node*, Split);
+    static void updateLargestFree(Node*);
+};
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
+#endif // AreaAllocator_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsCompositingCoordinatorcppfromrev202674trunkSourceWebCoreplatformgraphicstexmapcoordinatedCompositingCoordinatorcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp (from rev 202674, trunk/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp) (0 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -0,0 +1,452 @@
</span><ins>+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (C) 2013 Company 100, 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. AND ITS CONTRIBUTORS ``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 ITS 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;CompositingCoordinator.h&quot;
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include &lt;WebCore/DOMWindow.h&gt;
+#include &lt;WebCore/Document.h&gt;
+#include &lt;WebCore/FrameView.h&gt;
+#include &lt;WebCore/GraphicsContext.h&gt;
+#include &lt;WebCore/InspectorController.h&gt;
+#include &lt;WebCore/MainFrame.h&gt;
+#include &lt;WebCore/Page.h&gt;
+#include &lt;WebCore/Settings.h&gt;
+#include &lt;wtf/CurrentTime.h&gt;
+#include &lt;wtf/TemporaryChange.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+CompositingCoordinator::CompositingCoordinator(Page* page, CompositingCoordinator::Client* client)
+    : m_page(page)
+    , m_client(client)
+    , m_rootCompositingLayer(nullptr)
+    , m_overlayCompositingLayer(nullptr)
+    , m_isDestructing(false)
+    , m_isPurging(false)
+    , m_isFlushingLayerChanges(false)
+    , m_shouldSyncFrame(false)
+    , m_didInitializeRootCompositingLayer(false)
+    , m_releaseInactiveAtlasesTimer(*this, &amp;CompositingCoordinator::releaseInactiveAtlasesTimerFired)
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    , m_lastAnimationServiceTime(0)
+#endif
+{
+}
+
+CompositingCoordinator::~CompositingCoordinator()
+{
+    m_isDestructing = true;
+
+    purgeBackingStores();
+
+    for (auto&amp; registeredLayer : m_registeredLayers.values())
+        registeredLayer-&gt;setCoordinator(nullptr);
+}
+
+void CompositingCoordinator::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
+{
+    if (m_rootCompositingLayer == graphicsLayer)
+        return;
+
+    if (m_rootCompositingLayer)
+        m_rootCompositingLayer-&gt;removeFromParent();
+
+    m_rootCompositingLayer = graphicsLayer;
+    if (m_rootCompositingLayer)
+        m_rootLayer-&gt;addChildAtIndex(m_rootCompositingLayer, 0);
+}
+
+void CompositingCoordinator::setViewOverlayRootLayer(GraphicsLayer* graphicsLayer)
+{
+    if (m_overlayCompositingLayer == graphicsLayer)
+        return;
+
+    if (m_overlayCompositingLayer)
+        m_overlayCompositingLayer-&gt;removeFromParent();
+
+    m_overlayCompositingLayer = graphicsLayer;
+    if (m_overlayCompositingLayer)
+        m_rootLayer-&gt;addChild(m_overlayCompositingLayer);
+}
+
+void CompositingCoordinator::sizeDidChange(const IntSize&amp; newSize)
+{
+    m_rootLayer-&gt;setSize(newSize);
+    notifyFlushRequired(m_rootLayer.get());
+}
+
+bool CompositingCoordinator::flushPendingLayerChanges()
+{
+    TemporaryChange&lt;bool&gt; protector(m_isFlushingLayerChanges, true);
+
+    initializeRootCompositingLayerIfNeeded();
+
+    bool viewportIsStable = m_page-&gt;mainFrame().view()-&gt;viewportIsStable();
+    m_rootLayer-&gt;flushCompositingStateForThisLayerOnly(viewportIsStable);
+    m_client-&gt;didFlushRootLayer(m_visibleContentsRect);
+
+    if (m_overlayCompositingLayer)
+        m_overlayCompositingLayer-&gt;flushCompositingState(FloatRect(FloatPoint(), m_rootLayer-&gt;size()), viewportIsStable);
+
+    bool didSync = m_page-&gt;mainFrame().view()-&gt;flushCompositingStateIncludingSubframes();
+
+    toCoordinatedGraphicsLayer(m_rootLayer.get())-&gt;updateContentBuffersIncludingSubLayers();
+    toCoordinatedGraphicsLayer(m_rootLayer.get())-&gt;syncPendingStateChangesIncludingSubLayers();
+
+    flushPendingImageBackingChanges();
+
+    if (m_shouldSyncFrame) {
+        didSync = true;
+
+        if (m_rootCompositingLayer) {
+            m_state.contentsSize = roundedIntSize(m_rootCompositingLayer-&gt;size());
+            if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
+                m_state.coveredRect = contentsLayer-&gt;coverRect();
+        }
+        m_state.scrollPosition = m_visibleContentsRect.location();
+
+        m_client-&gt;commitSceneState(m_state);
+
+        clearPendingStateChanges();
+        m_shouldSyncFrame = false;
+    }
+
+    return didSync;
+}
+
+double CompositingCoordinator::timestamp() const
+{
+    auto* document = m_page-&gt;mainFrame().document();
+    if (!document)
+        return 0;
+    return document-&gt;domWindow() ? document-&gt;domWindow()-&gt;nowTimestamp() : document-&gt;monotonicTimestamp();
+}
+
+void CompositingCoordinator::syncDisplayState()
+{
+#if ENABLE(REQUEST_ANIMATION_FRAME) &amp;&amp; !USE(REQUEST_ANIMATION_FRAME_TIMER) &amp;&amp; !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
+    // Make sure that any previously registered animation callbacks are being executed before we flush the layers.
+    m_lastAnimationServiceTime = timestamp();
+    m_page-&gt;mainFrame().view()-&gt;serviceScriptedAnimations();
+#endif
+    m_page-&gt;mainFrame().view()-&gt;updateLayoutAndStyleIfNeededRecursive();
+}
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+double CompositingCoordinator::nextAnimationServiceTime() const
+{
+    // According to the requestAnimationFrame spec, rAF callbacks should not be faster than 60FPS.
+    static const double MinimalTimeoutForAnimations = 1. / 60.;
+    return std::max&lt;double&gt;(0., MinimalTimeoutForAnimations - timestamp() + m_lastAnimationServiceTime);
+}
+#endif
+
+void CompositingCoordinator::clearPendingStateChanges()
+{
+    m_state.layersToCreate.clear();
+    m_state.layersToUpdate.clear();
+    m_state.layersToRemove.clear();
+
+    m_state.imagesToCreate.clear();
+    m_state.imagesToRemove.clear();
+    m_state.imagesToUpdate.clear();
+    m_state.imagesToClear.clear();
+
+    m_state.updateAtlasesToCreate.clear();
+    m_state.updateAtlasesToRemove.clear();
+}
+
+void CompositingCoordinator::initializeRootCompositingLayerIfNeeded()
+{
+    if (m_didInitializeRootCompositingLayer)
+        return;
+
+    m_state.rootCompositingLayer = toCoordinatedGraphicsLayer(m_rootLayer.get())-&gt;id();
+    m_didInitializeRootCompositingLayer = true;
+    m_shouldSyncFrame = true;
+}
+
+void CompositingCoordinator::createRootLayer(const IntSize&amp; size)
+{
+    ASSERT(!m_rootLayer);
+    // Create a root layer.
+    m_rootLayer = GraphicsLayer::create(this, *this);
+#ifndef NDEBUG
+    m_rootLayer-&gt;setName(&quot;CompositingCoordinator root layer&quot;);
+#endif
+    m_rootLayer-&gt;setDrawsContent(false);
+    m_rootLayer-&gt;setSize(size);
+}
+
+void CompositingCoordinator::syncLayerState(CoordinatedLayerID id, CoordinatedGraphicsLayerState&amp; state)
+{
+    m_shouldSyncFrame = true;
+    m_state.layersToUpdate.append(std::make_pair(id, state));
+}
+
+PassRefPtr&lt;CoordinatedImageBacking&gt; CompositingCoordinator::createImageBackingIfNeeded(Image* image)
+{
+    CoordinatedImageBackingID imageID = CoordinatedImageBacking::getCoordinatedImageBackingID(image);
+    ImageBackingMap::iterator it = m_imageBackings.find(imageID);
+    RefPtr&lt;CoordinatedImageBacking&gt; imageBacking;
+    if (it == m_imageBackings.end()) {
+        imageBacking = CoordinatedImageBacking::create(this, image);
+        m_imageBackings.add(imageID, imageBacking);
+    } else
+        imageBacking = it-&gt;value;
+
+    return imageBacking;
+}
+
+void CompositingCoordinator::createImageBacking(CoordinatedImageBackingID imageID)
+{
+    m_state.imagesToCreate.append(imageID);
+}
+
+void CompositingCoordinator::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr&lt;CoordinatedSurface&gt; coordinatedSurface)
+{
+    m_shouldSyncFrame = true;
+    m_state.imagesToUpdate.append(std::make_pair(imageID, coordinatedSurface));
+}
+
+void CompositingCoordinator::clearImageBackingContents(CoordinatedImageBackingID imageID)
+{
+    m_shouldSyncFrame = true;
+    m_state.imagesToClear.append(imageID);
+}
+
+void CompositingCoordinator::removeImageBacking(CoordinatedImageBackingID imageID)
+{
+    if (m_isPurging)
+        return;
+
+    ASSERT(m_imageBackings.contains(imageID));
+    m_imageBackings.remove(imageID);
+
+    m_state.imagesToRemove.append(imageID);
+
+    size_t imageIDPosition = m_state.imagesToClear.find(imageID);
+    if (imageIDPosition != notFound)
+        m_state.imagesToClear.remove(imageIDPosition);
+}
+
+void CompositingCoordinator::flushPendingImageBackingChanges()
+{
+    for (auto&amp; imageBacking : m_imageBackings.values())
+        imageBacking-&gt;update();
+}
+
+void CompositingCoordinator::notifyAnimationStarted(const GraphicsLayer*, const String&amp;, double /* time */)
+{
+}
+
+void CompositingCoordinator::notifyFlushRequired(const GraphicsLayer*)
+{
+    if (!m_isDestructing &amp;&amp; !isFlushingLayerChanges())
+        m_client-&gt;notifyFlushRequired();
+}
+
+void CompositingCoordinator::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext&amp; graphicsContext, GraphicsLayerPaintingPhase, const FloatRect&amp; clipRect)
+{
+    m_client-&gt;paintLayerContents(graphicsLayer, graphicsContext, enclosingIntRect(clipRect));
+}
+
+std::unique_ptr&lt;GraphicsLayer&gt; CompositingCoordinator::createGraphicsLayer(GraphicsLayer::Type layerType, GraphicsLayerClient&amp; client)
+{
+    CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(layerType, client);
+    layer-&gt;setCoordinator(this);
+    m_registeredLayers.add(layer-&gt;id(), layer);
+    m_state.layersToCreate.append(layer-&gt;id());
+    layer-&gt;setNeedsVisibleRectAdjustment();
+    notifyFlushRequired(layer);
+    return std::unique_ptr&lt;GraphicsLayer&gt;(layer);
+}
+
+float CompositingCoordinator::deviceScaleFactor() const
+{
+    return m_page-&gt;deviceScaleFactor();
+}
+
+float CompositingCoordinator::pageScaleFactor() const
+{
+    return m_page-&gt;pageScaleFactor();
+}
+
+void CompositingCoordinator::createUpdateAtlas(uint32_t atlasID, PassRefPtr&lt;CoordinatedSurface&gt; coordinatedSurface)
+{
+    m_state.updateAtlasesToCreate.append(std::make_pair(atlasID, coordinatedSurface));
+}
+
+void CompositingCoordinator::removeUpdateAtlas(uint32_t atlasID)
+{
+    if (m_isPurging)
+        return;
+    m_state.updateAtlasesToRemove.append(atlasID);
+}
+
+FloatRect CompositingCoordinator::visibleContentsRect() const
+{
+    return m_visibleContentsRect;
+}
+
+CoordinatedGraphicsLayer* CompositingCoordinator::mainContentsLayer()
+{
+    if (!m_rootCompositingLayer)
+        return 0;
+
+    return toCoordinatedGraphicsLayer(m_rootCompositingLayer)-&gt;findFirstDescendantWithContentsRecursively();
+}
+
+void CompositingCoordinator::setVisibleContentsRect(const FloatRect&amp; rect, const FloatPoint&amp; trajectoryVector)
+{
+    // A zero trajectoryVector indicates that tiles all around the viewport are requested.
+    if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
+        contentsLayer-&gt;setVisibleContentRectTrajectoryVector(trajectoryVector);
+
+    bool contentsRectDidChange = rect != m_visibleContentsRect;
+    if (contentsRectDidChange) {
+        m_visibleContentsRect = rect;
+
+        for (auto&amp; registeredLayer : m_registeredLayers.values())
+            registeredLayer-&gt;setNeedsVisibleRectAdjustment();
+    }
+
+    FrameView* view = m_page-&gt;mainFrame().view();
+    if (view-&gt;useFixedLayout() &amp;&amp; contentsRectDidChange) {
+        // Round the rect instead of enclosing it to make sure that its size stays
+        // the same while panning. This can have nasty effects on layout.
+        view-&gt;setFixedVisibleContentRect(roundedIntRect(rect));
+    }
+}
+
+void CompositingCoordinator::deviceOrPageScaleFactorChanged()
+{
+    m_rootLayer-&gt;deviceOrPageScaleFactorChanged();
+}
+
+void CompositingCoordinator::detachLayer(CoordinatedGraphicsLayer* layer)
+{
+    if (m_isPurging)
+        return;
+
+    m_registeredLayers.remove(layer-&gt;id());
+
+    size_t index = m_state.layersToCreate.find(layer-&gt;id());
+    if (index != notFound) {
+        m_state.layersToCreate.remove(index);
+        return;
+    }
+
+    m_state.layersToRemove.append(layer-&gt;id());
+    notifyFlushRequired(layer);
+}
+
+void CompositingCoordinator::commitScrollOffset(uint32_t layerID, const WebCore::IntSize&amp; offset)
+{
+    LayerMap::iterator i = m_registeredLayers.find(layerID);
+    if (i == m_registeredLayers.end())
+        return;
+
+    i-&gt;value-&gt;commitScrollOffset(offset);
+}
+
+void CompositingCoordinator::renderNextFrame()
+{
+    for (auto&amp; atlas : m_updateAtlases)
+        atlas-&gt;didSwapBuffers();
+}
+
+void CompositingCoordinator::purgeBackingStores()
+{
+    TemporaryChange&lt;bool&gt; purgingToggle(m_isPurging, true);
+
+    for (auto&amp; registeredLayer : m_registeredLayers.values())
+        registeredLayer-&gt;purgeBackingStores();
+
+    m_imageBackings.clear();
+    m_updateAtlases.clear();
+}
+
+bool CompositingCoordinator::paintToSurface(const IntSize&amp; size, CoordinatedSurface::Flags flags, uint32_t&amp; atlasID, IntPoint&amp; offset, CoordinatedSurface::Client* client)
+{
+    for (auto&amp; updateAtlas : m_updateAtlases) {
+        UpdateAtlas* atlas = updateAtlas.get();
+        if (atlas-&gt;supportsAlpha() == (flags &amp; CoordinatedSurface::SupportsAlpha)) {
+            // This will be false if there is no available buffer space.
+            if (atlas-&gt;paintOnAvailableBuffer(size, atlasID, offset, client))
+                return true;
+        }
+    }
+
+    static const int ScratchBufferDimension = 1024; // Should be a power of two.
+    m_updateAtlases.append(std::make_unique&lt;UpdateAtlas&gt;(this, ScratchBufferDimension, flags));
+    scheduleReleaseInactiveAtlases();
+    return m_updateAtlases.last()-&gt;paintOnAvailableBuffer(size, atlasID, offset, client);
+}
+
+const double ReleaseInactiveAtlasesTimerInterval = 0.5;
+
+void CompositingCoordinator::scheduleReleaseInactiveAtlases()
+{
+    if (!m_releaseInactiveAtlasesTimer.isActive())
+        m_releaseInactiveAtlasesTimer.startRepeating(ReleaseInactiveAtlasesTimerInterval);
+}
+
+void CompositingCoordinator::releaseInactiveAtlasesTimerFired()
+{
+    // We always want to keep one atlas for root contents layer.
+    std::unique_ptr&lt;UpdateAtlas&gt; atlasToKeepAnyway;
+    bool foundActiveAtlasForRootContentsLayer = false;
+    for (int i = m_updateAtlases.size() - 1;  i &gt;= 0; --i) {
+        UpdateAtlas* atlas = m_updateAtlases[i].get();
+        if (!atlas-&gt;isInUse())
+            atlas-&gt;addTimeInactive(ReleaseInactiveAtlasesTimerInterval);
+        bool usableForRootContentsLayer = !atlas-&gt;supportsAlpha();
+        if (atlas-&gt;isInactive()) {
+            if (!foundActiveAtlasForRootContentsLayer &amp;&amp; !atlasToKeepAnyway &amp;&amp; usableForRootContentsLayer)
+                atlasToKeepAnyway = WTFMove(m_updateAtlases[i]);
+            m_updateAtlases.remove(i);
+        } else if (usableForRootContentsLayer)
+            foundActiveAtlasForRootContentsLayer = true;
+    }
+
+    if (!foundActiveAtlasForRootContentsLayer &amp;&amp; atlasToKeepAnyway)
+        m_updateAtlases.append(atlasToKeepAnyway.release());
+
+    m_updateAtlases.shrinkToFit();
+
+    if (m_updateAtlases.size() &lt;= 1)
+        m_releaseInactiveAtlasesTimer.stop();
+}
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsCompositingCoordinatorhfromrev202674trunkSourceWebCoreplatformgraphicstexmapcoordinatedCompositingCoordinatorh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h (from rev 202674, trunk/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h) (0 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -0,0 +1,167 @@
</span><ins>+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2013 Company 100, 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. AND ITS CONTRIBUTORS ``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 ITS 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 CompositingCoordinator_h
+#define CompositingCoordinator_h
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include &quot;UpdateAtlas.h&quot;
+#include &lt;WebCore/CoordinatedGraphicsLayer.h&gt;
+#include &lt;WebCore/CoordinatedGraphicsState.h&gt;
+#include &lt;WebCore/CoordinatedImageBacking.h&gt;
+#include &lt;WebCore/FloatPoint.h&gt;
+#include &lt;WebCore/GraphicsLayerClient.h&gt;
+#include &lt;WebCore/GraphicsLayerFactory.h&gt;
+#include &lt;WebCore/IntRect.h&gt;
+#include &lt;WebCore/Timer.h&gt;
+
+namespace WebCore {
+class Page;
+class GraphicsContext;
+class GraphicsLayer;
+class CoordinatedSurface;
+}
+
+namespace WebKit {
+
+class CompositingCoordinator : public WebCore::GraphicsLayerClient
+    , public WebCore::CoordinatedGraphicsLayerClient
+    , public WebCore::CoordinatedImageBacking::Client
+    , public UpdateAtlas::Client
+    , public WebCore::GraphicsLayerFactory {
+    WTF_MAKE_NONCOPYABLE(CompositingCoordinator); WTF_MAKE_FAST_ALLOCATED;
+public:
+    class Client {
+    public:
+        virtual void didFlushRootLayer(const WebCore::FloatRect&amp; visibleContentRect) = 0;
+        virtual void notifyFlushRequired() = 0;
+        virtual void commitSceneState(const WebCore::CoordinatedGraphicsState&amp;) = 0;
+        virtual void paintLayerContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&amp;, const WebCore::IntRect&amp; clipRect) = 0;
+    };
+
+    CompositingCoordinator(WebCore::Page*, CompositingCoordinator::Client*);
+    virtual ~CompositingCoordinator();
+
+    void setRootCompositingLayer(WebCore::GraphicsLayer*);
+    void setViewOverlayRootLayer(WebCore::GraphicsLayer*);
+    void sizeDidChange(const WebCore::IntSize&amp;);
+    void deviceOrPageScaleFactorChanged();
+
+    void setVisibleContentsRect(const WebCore::FloatRect&amp;, const WebCore::FloatPoint&amp;);
+    void renderNextFrame();
+    void purgeBackingStores();
+    void commitScrollOffset(uint32_t layerID, const WebCore::IntSize&amp; offset);
+
+    void createRootLayer(const WebCore::IntSize&amp;);
+    void clearRootLayer() { m_rootLayer = nullptr; }
+    WebCore::GraphicsLayer* rootLayer() const { return m_rootLayer.get(); }
+    WebCore::CoordinatedGraphicsLayer* mainContentsLayer();
+
+    bool flushPendingLayerChanges();
+    WebCore::CoordinatedGraphicsState&amp; state() { return m_state; }
+
+    void syncDisplayState();
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    double nextAnimationServiceTime() const;
+#endif
+
+private:
+    // GraphicsLayerClient
+    void notifyAnimationStarted(const WebCore::GraphicsLayer*, const String&amp;, double time) override;
+    void notifyFlushRequired(const WebCore::GraphicsLayer*) override;
+    void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&amp;, WebCore::GraphicsLayerPaintingPhase, const WebCore::FloatRect&amp; clipRect) override;
+    float deviceScaleFactor() const override;
+    float pageScaleFactor() const override;
+
+    // CoordinatedImageBacking::Client
+    void createImageBacking(WebCore::CoordinatedImageBackingID) override;
+    void updateImageBacking(WebCore::CoordinatedImageBackingID, PassRefPtr&lt;WebCore::CoordinatedSurface&gt;) override;
+    void clearImageBackingContents(WebCore::CoordinatedImageBackingID) override;
+    void removeImageBacking(WebCore::CoordinatedImageBackingID) override;
+
+    // CoordinatedGraphicsLayerClient
+    bool isFlushingLayerChanges() const override { return m_isFlushingLayerChanges; }
+    WebCore::FloatRect visibleContentsRect() const override;
+    PassRefPtr&lt;WebCore::CoordinatedImageBacking&gt; createImageBackingIfNeeded(WebCore::Image*) override;
+    void detachLayer(WebCore::CoordinatedGraphicsLayer*) override;
+    bool paintToSurface(const WebCore::IntSize&amp;, WebCore::CoordinatedSurface::Flags, uint32_t&amp; /* atlasID */, WebCore::IntPoint&amp;, WebCore::CoordinatedSurface::Client*) override;
+    void syncLayerState(WebCore::CoordinatedLayerID, WebCore::CoordinatedGraphicsLayerState&amp;) override;
+
+    // UpdateAtlas::Client
+    void createUpdateAtlas(uint32_t atlasID, PassRefPtr&lt;WebCore::CoordinatedSurface&gt;) override;
+    void removeUpdateAtlas(uint32_t atlasID) override;
+
+    // GraphicsLayerFactory
+    std::unique_ptr&lt;WebCore::GraphicsLayer&gt; createGraphicsLayer(WebCore::GraphicsLayer::Type, WebCore::GraphicsLayerClient&amp;) override;
+
+    void initializeRootCompositingLayerIfNeeded();
+    void flushPendingImageBackingChanges();
+    void clearPendingStateChanges();
+
+    void scheduleReleaseInactiveAtlases();
+
+    void releaseInactiveAtlasesTimerFired();
+
+    double timestamp() const;
+
+    WebCore::Page* m_page;
+    CompositingCoordinator::Client* m_client;
+
+    std::unique_ptr&lt;WebCore::GraphicsLayer&gt; m_rootLayer;
+    WebCore::GraphicsLayer* m_rootCompositingLayer;
+    WebCore::GraphicsLayer* m_overlayCompositingLayer;
+
+    WebCore::CoordinatedGraphicsState m_state;
+
+    typedef HashMap&lt;WebCore::CoordinatedLayerID, WebCore::CoordinatedGraphicsLayer*&gt; LayerMap;
+    LayerMap m_registeredLayers;
+    typedef HashMap&lt;WebCore::CoordinatedImageBackingID, RefPtr&lt;WebCore::CoordinatedImageBacking&gt; &gt; ImageBackingMap;
+    ImageBackingMap m_imageBackings;
+    Vector&lt;std::unique_ptr&lt;UpdateAtlas&gt;&gt; m_updateAtlases;
+
+    // We don't send the messages related to releasing resources to renderer during purging, because renderer already had removed all resources.
+    bool m_isDestructing;
+    bool m_isPurging;
+    bool m_isFlushingLayerChanges;
+
+    WebCore::FloatRect m_visibleContentsRect;
+
+    bool m_shouldSyncFrame;
+    bool m_didInitializeRootCompositingLayer;
+    WebCore::Timer m_releaseInactiveAtlasesTimer;
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    double m_lastAnimationServiceTime;
+#endif
+};
+
+}
+
+#endif // namespace WebKit
+
+#endif // CompositingCoordinator_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsCoordinatedLayerTreeHosth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h (202674 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h        2016-06-30 06:28:58 UTC (rev 202674)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -23,8 +23,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(COORDINATED_GRAPHICS)
</span><span class="cx"> 
</span><ins>+#include &quot;CompositingCoordinator.h&quot;
</ins><span class="cx"> #include &quot;LayerTreeHost.h&quot;
</span><del>-#include &lt;WebCore/CompositingCoordinator.h&gt;
</del><span class="cx"> #include &lt;wtf/RunLoop.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -36,7 +36,7 @@
</span><span class="cx"> 
</span><span class="cx"> class WebPage;
</span><span class="cx"> 
</span><del>-class CoordinatedLayerTreeHost : public LayerTreeHost, public WebCore::CompositingCoordinator::Client
</del><ins>+class CoordinatedLayerTreeHost : public LayerTreeHost, public CompositingCoordinator::Client
</ins><span class="cx"> {
</span><span class="cx"> public:
</span><span class="cx">     static Ref&lt;CoordinatedLayerTreeHost&gt; create(WebPage&amp;);
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx"> 
</span><span class="cx">     static RefPtr&lt;WebCore::CoordinatedSurface&gt; createCoordinatedSurface(const WebCore::IntSize&amp;, WebCore::CoordinatedSurface::Flags);
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;WebCore::CompositingCoordinator&gt; m_coordinator;
</del><ins>+    std::unique_ptr&lt;CompositingCoordinator&gt; m_coordinator;
</ins><span class="cx">     bool m_isWaitingForRenderer { true };
</span><span class="cx">     uint64_t m_forceRepaintAsyncCallbackID { 0 };
</span><span class="cx">     RunLoop::Timer&lt;CoordinatedLayerTreeHost&gt; m_layerFlushTimer;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsUpdateAtlascppfromrev202674trunkSourceWebCoreplatformgraphicstexmapcoordinatedUpdateAtlascpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp (from rev 202674, trunk/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.cpp) (0 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -0,0 +1,118 @@
</span><ins>+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2012 Company 100, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB.  If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;UpdateAtlas.h&quot;
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include &lt;WebCore/CoordinatedGraphicsState.h&gt;
+#include &lt;WebCore/GraphicsContext.h&gt;
+#include &lt;WebCore/IntRect.h&gt;
+#include &lt;wtf/MathExtras.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class UpdateAtlasSurfaceClient : public CoordinatedSurface::Client {
+public:
+    UpdateAtlasSurfaceClient(CoordinatedSurface::Client* client, const IntSize&amp; size, bool supportsAlpha)
+        : m_client(client)
+        , m_size(size)
+        , m_supportsAlpha(supportsAlpha)
+    {
+    }
+
+    void paintToSurfaceContext(GraphicsContext&amp; context) override
+    {
+        if (m_supportsAlpha) {
+            context.setCompositeOperation(CompositeCopy);
+            context.fillRect(IntRect(IntPoint::zero(), m_size), Color::transparent);
+            context.setCompositeOperation(CompositeSourceOver);
+        }
+
+        m_client-&gt;paintToSurfaceContext(context);
+    }
+
+private:
+    CoordinatedSurface::Client* m_client;
+    IntSize m_size;
+    bool m_supportsAlpha;
+};
+
+UpdateAtlas::UpdateAtlas(Client* client, int dimension, CoordinatedSurface::Flags flags)
+    : m_client(client)
+    , m_inactivityInSeconds(0)
+{
+    static uint32_t nextID = 0;
+    m_ID = ++nextID;
+    IntSize size = nextPowerOfTwo(IntSize(dimension, dimension));
+    m_surface = CoordinatedSurface::create(size, flags);
+
+    m_client-&gt;createUpdateAtlas(m_ID, m_surface);
+}
+
+UpdateAtlas::~UpdateAtlas()
+{
+    if (m_surface)
+        m_client-&gt;removeUpdateAtlas(m_ID);
+}
+
+void UpdateAtlas::buildLayoutIfNeeded()
+{
+    if (!m_areaAllocator) {
+        m_areaAllocator = std::make_unique&lt;GeneralAreaAllocator&gt;(size());
+        m_areaAllocator-&gt;setMinimumAllocation(IntSize(32, 32));
+    }
+}
+
+void UpdateAtlas::didSwapBuffers()
+{
+    m_areaAllocator = nullptr;
+}
+
+
+bool UpdateAtlas::paintOnAvailableBuffer(const IntSize&amp; size, uint32_t&amp; atlasID, IntPoint&amp; offset, CoordinatedSurface::Client* client)
+{
+    m_inactivityInSeconds = 0;
+    buildLayoutIfNeeded();
+    IntRect rect = m_areaAllocator-&gt;allocate(size);
+
+    // No available buffer was found.
+    if (rect.isEmpty())
+        return false;
+
+    if (!m_surface)
+        return false;
+
+    atlasID = m_ID;
+
+    // FIXME: Use tri-state buffers, to allow faster updates.
+    offset = rect.location();
+
+    UpdateAtlasSurfaceClient surfaceClient(client, size, supportsAlpha());
+    m_surface-&gt;paintToSurface(rect, &amp;surfaceClient);
+
+    return true;
+}
+
+} // namespace WebCore
+#endif // USE(COORDINATED_GRAPHICS)
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsUpdateAtlashfromrev202674trunkSourceWebCoreplatformgraphicstexmapcoordinatedUpdateAtlash"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h (from rev 202674, trunk/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.h) (0 => 202675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h        2016-06-30 07:32:32 UTC (rev 202675)
</span><span class="lines">@@ -0,0 +1,84 @@
</span><ins>+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2012 Company 100, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB.  If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef UpdateAtlas_h
+#define UpdateAtlas_h
+
+#include &quot;AreaAllocator.h&quot;
+#include &lt;WebCore/CoordinatedSurface.h&gt;
+#include &lt;WebCore/IntSize.h&gt;
+#include &lt;wtf/PassRefPtr.h&gt;
+#include &lt;wtf/RefPtr.h&gt;
+
+#if USE(COORDINATED_GRAPHICS)
+
+namespace WebCore {
+class GraphicsContext;
+class IntPoint;
+}
+
+namespace WebKit {
+
+class UpdateAtlas {
+    WTF_MAKE_NONCOPYABLE(UpdateAtlas);
+public:
+    class Client {
+    public:
+        virtual void createUpdateAtlas(uint32_t /* id */, PassRefPtr&lt;WebCore::CoordinatedSurface&gt;) = 0;
+        virtual void removeUpdateAtlas(uint32_t /* id */) = 0;
+    };
+
+    UpdateAtlas(Client*, int dimension, WebCore::CoordinatedSurface::Flags);
+    ~UpdateAtlas();
+
+    inline WebCore::IntSize size() const { return m_surface-&gt;size(); }
+
+    // Returns false if there is no available buffer.
+    bool paintOnAvailableBuffer(const WebCore::IntSize&amp;, uint32_t&amp; atlasID, WebCore::IntPoint&amp; offset, WebCore::CoordinatedSurface::Client*);
+    void didSwapBuffers();
+    bool supportsAlpha() const { return m_surface-&gt;supportsAlpha(); }
+
+    void addTimeInactive(double seconds)
+    {
+        ASSERT(!isInUse());
+        m_inactivityInSeconds += seconds;
+    }
+    bool isInactive() const
+    {
+        const double inactiveSecondsTolerance = 3;
+        return m_inactivityInSeconds &gt; inactiveSecondsTolerance;
+    }
+    bool isInUse() const { return !!m_areaAllocator; }
+
+private:
+    void buildLayoutIfNeeded();
+
+private:
+    Client* m_client;
+    std::unique_ptr&lt;GeneralAreaAllocator&gt; m_areaAllocator;
+    RefPtr&lt;WebCore::CoordinatedSurface&gt; m_surface;
+    double m_inactivityInSeconds;
+    uint32_t m_ID;
+};
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
+#endif // UpdateAtlas_h
</ins></span></pre>
</div>
</div>

</body>
</html>