<!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>[211365] trunk/Source/WebKit2</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/211365">211365</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2017-01-30 08:42:12 -0800 (Mon, 30 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK] Do not release OpenGL resource immediately when leaving accelerated compositing mode
https://bugs.webkit.org/show_bug.cgi?id=167544
Reviewed by Michael Catanzaro.
Sometimes the conditions to be in AC mode or not change quickly, and then we leave AC mode just enter it again
after a very short period of time. In those cases we are dropping all the GL resources and the compositor
thread, and creating it again. We could keep the layer tree host alive for a while when exiting AC mode, and
reuse it if we enter AC mode before the previous one has been discarded. While the previous layer tree host is
alive we still need to keep it up to date, for example if the web view is resized or contents size change, and
synchronize with the threaded compositor when it becomes the layer tree host again.
* WebProcess/WebPage/AcceleratedDrawingArea.cpp:
(WebKit::AcceleratedDrawingArea::~AcceleratedDrawingArea): Discard the previous layer tree host.
(WebKit::AcceleratedDrawingArea::AcceleratedDrawingArea): Initialize the timer to discard the previous layer
tree host.
(WebKit::AcceleratedDrawingArea::pageBackgroundTransparencyChanged): Notify the previous layer tree host if needed.
(WebKit::AcceleratedDrawingArea::mainFrameContentSizeChanged): Ditto.
(WebKit::AcceleratedDrawingArea::updateBackingStoreState): Ditto.
(WebKit::AcceleratedDrawingArea::enterAcceleratedCompositingMode): Reuse the previous layer tree host if possible.
(WebKit::AcceleratedDrawingArea::exitAcceleratedCompositingModeNow): Exit AC mode and save the layer tree host
starting a timer of 5 seconds to discard it if not reused.
(WebKit::AcceleratedDrawingArea::discardPreviousLayerTreeHost): Invalidate and destroy the previous layer tree host.
(WebKit::AcceleratedDrawingArea::didChangeViewportAttributes): Notify the previous layer tree host if needed.
(WebKit::AcceleratedDrawingArea::deviceOrPageScaleFactorChanged): Ditto.
* WebProcess/WebPage/AcceleratedDrawingArea.h:
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
(WebKit::ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents): If it's discardable add the action to
be synchronized instead.
(WebKit::ThreadedCoordinatedLayerTreeHost::contentsSizeChanged): Ditto.
(WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): Ditto.
(WebKit::ThreadedCoordinatedLayerTreeHost::pageBackgroundTransparencyChanged): Ditto.
(WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange): Ditto.
(WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewportAttributes): Ditto.
(WebKit::ThreadedCoordinatedLayerTreeHost::setIsDiscardable): When the layer tree host becomes discardable,
reset the sync actions and return. When it becomes the real layer tree host again, apply all pending actions to
synchronize with the threaded compositor.
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::scroll): Notify the previous layer tree host if needed.
(WebKit::DrawingAreaImpl::mainFrameContentSizeChanged): Ditto.
(WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode): Use AcceleratedDrawingArea::exitAcceleratedCompositingModeNow().
* WebProcess/WebPage/LayerTreeHost.h:
(WebKit::LayerTreeHost::setIsDiscardable): Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageAcceleratedDrawingAreacpp">trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageAcceleratedDrawingAreah">trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsThreadedCoordinatedLayerTreeHostcpp">trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsThreadedCoordinatedLayerTreeHosth">trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageDrawingAreaImplcpp">trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageLayerTreeHosth">trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (211364 => 211365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-01-30 16:35:03 UTC (rev 211364)
+++ trunk/Source/WebKit2/ChangeLog        2017-01-30 16:42:12 UTC (rev 211365)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2017-01-30 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Do not release OpenGL resource immediately when leaving accelerated compositing mode
+ https://bugs.webkit.org/show_bug.cgi?id=167544
+
+ Reviewed by Michael Catanzaro.
+
+ Sometimes the conditions to be in AC mode or not change quickly, and then we leave AC mode just enter it again
+ after a very short period of time. In those cases we are dropping all the GL resources and the compositor
+ thread, and creating it again. We could keep the layer tree host alive for a while when exiting AC mode, and
+ reuse it if we enter AC mode before the previous one has been discarded. While the previous layer tree host is
+ alive we still need to keep it up to date, for example if the web view is resized or contents size change, and
+ synchronize with the threaded compositor when it becomes the layer tree host again.
+
+ * WebProcess/WebPage/AcceleratedDrawingArea.cpp:
+ (WebKit::AcceleratedDrawingArea::~AcceleratedDrawingArea): Discard the previous layer tree host.
+ (WebKit::AcceleratedDrawingArea::AcceleratedDrawingArea): Initialize the timer to discard the previous layer
+ tree host.
+ (WebKit::AcceleratedDrawingArea::pageBackgroundTransparencyChanged): Notify the previous layer tree host if needed.
+ (WebKit::AcceleratedDrawingArea::mainFrameContentSizeChanged): Ditto.
+ (WebKit::AcceleratedDrawingArea::updateBackingStoreState): Ditto.
+ (WebKit::AcceleratedDrawingArea::enterAcceleratedCompositingMode): Reuse the previous layer tree host if possible.
+ (WebKit::AcceleratedDrawingArea::exitAcceleratedCompositingModeNow): Exit AC mode and save the layer tree host
+ starting a timer of 5 seconds to discard it if not reused.
+ (WebKit::AcceleratedDrawingArea::discardPreviousLayerTreeHost): Invalidate and destroy the previous layer tree host.
+ (WebKit::AcceleratedDrawingArea::didChangeViewportAttributes): Notify the previous layer tree host if needed.
+ (WebKit::AcceleratedDrawingArea::deviceOrPageScaleFactorChanged): Ditto.
+ * WebProcess/WebPage/AcceleratedDrawingArea.h:
+ * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+ (WebKit::ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents): If it's discardable add the action to
+ be synchronized instead.
+ (WebKit::ThreadedCoordinatedLayerTreeHost::contentsSizeChanged): Ditto.
+ (WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): Ditto.
+ (WebKit::ThreadedCoordinatedLayerTreeHost::pageBackgroundTransparencyChanged): Ditto.
+ (WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange): Ditto.
+ (WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewportAttributes): Ditto.
+ (WebKit::ThreadedCoordinatedLayerTreeHost::setIsDiscardable): When the layer tree host becomes discardable,
+ reset the sync actions and return. When it becomes the real layer tree host again, apply all pending actions to
+ synchronize with the threaded compositor.
+ * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
+ * WebProcess/WebPage/DrawingAreaImpl.cpp:
+ (WebKit::DrawingAreaImpl::scroll): Notify the previous layer tree host if needed.
+ (WebKit::DrawingAreaImpl::mainFrameContentSizeChanged): Ditto.
+ (WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode): Use AcceleratedDrawingArea::exitAcceleratedCompositingModeNow().
+ * WebProcess/WebPage/LayerTreeHost.h:
+ (WebKit::LayerTreeHost::setIsDiscardable): Added.
+
</ins><span class="cx"> 2017-01-30 Manuel Rego Casasnovas <rego@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK] Remove support to enable/disable experimental features
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageAcceleratedDrawingAreacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp (211364 => 211365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp        2017-01-30 16:35:03 UTC (rev 211364)
+++ trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp        2017-01-30 16:42:12 UTC (rev 211365)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx">
</span><span class="cx"> AcceleratedDrawingArea::~AcceleratedDrawingArea()
</span><span class="cx"> {
</span><ins>+ discardPreviousLayerTreeHost();
</ins><span class="cx"> if (m_layerTreeHost)
</span><span class="cx"> m_layerTreeHost->invalidate();
</span><span class="cx"> }
</span><span class="lines">@@ -55,6 +56,7 @@
</span><span class="cx"> : DrawingArea(DrawingAreaTypeImpl, webPage)
</span><span class="cx"> #endif
</span><span class="cx"> , m_exitCompositingTimer(RunLoop::main(), this, &AcceleratedDrawingArea::exitAcceleratedCompositingMode)
</span><ins>+ , m_discardPreviousLayerTreeHostTimer(RunLoop::main(), this, &AcceleratedDrawingArea::discardPreviousLayerTreeHost)
</ins><span class="cx"> {
</span><span class="cx"> if (!m_webPage.isVisible())
</span><span class="cx"> suspendPainting();
</span><span class="lines">@@ -91,6 +93,8 @@
</span><span class="cx"> {
</span><span class="cx"> if (m_layerTreeHost)
</span><span class="cx"> m_layerTreeHost->pageBackgroundTransparencyChanged();
</span><ins>+ else if (m_previousLayerTreeHost)
+ m_previousLayerTreeHost->pageBackgroundTransparencyChanged();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void AcceleratedDrawingArea::setLayerTreeStateIsFrozen(bool isFrozen)
</span><span class="lines">@@ -150,8 +154,12 @@
</span><span class="cx">
</span><span class="cx"> void AcceleratedDrawingArea::mainFrameContentSizeChanged(const IntSize& size)
</span><span class="cx"> {
</span><del>- if (m_webPage.useFixedLayout() && m_layerTreeHost)
- m_layerTreeHost->sizeDidChange(size);
</del><ins>+ if (m_webPage.useFixedLayout()) {
+ if (m_layerTreeHost)
+ m_layerTreeHost->sizeDidChange(size);
+ else if (m_previousLayerTreeHost)
+ m_previousLayerTreeHost->sizeDidChange(size);
+ }
</ins><span class="cx"> m_webPage.mainFrame()->pageOverlayController().didChangeDocumentSize();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -234,6 +242,8 @@
</span><span class="cx"> #else
</span><span class="cx"> if (m_layerTreeHost)
</span><span class="cx"> m_layerTreeHost->sizeDidChange(m_webPage.size());
</span><ins>+ else if (m_previousLayerTreeHost)
+ m_previousLayerTreeHost->sizeDidChange(m_webPage.size());
</ins><span class="cx"> #endif
</span><span class="cx"> } else {
</span><span class="cx"> ASSERT(size == m_webPage.size());
</span><span class="lines">@@ -317,11 +327,26 @@
</span><span class="cx">
</span><span class="cx"> void AcceleratedDrawingArea::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer)
</span><span class="cx"> {
</span><ins>+ m_discardPreviousLayerTreeHostTimer.stop();
+
</ins><span class="cx"> m_exitCompositingTimer.stop();
</span><span class="cx"> m_wantsToExitAcceleratedCompositingMode = false;
</span><span class="cx">
</span><span class="cx"> ASSERT(!m_layerTreeHost);
</span><del>- m_layerTreeHost = LayerTreeHost::create(m_webPage);
</del><ins>+ if (m_previousLayerTreeHost) {
+ m_layerTreeHost = WTFMove(m_previousLayerTreeHost);
+ m_layerTreeHost->setIsDiscardable(false);
+ if (!m_isPaintingSuspended)
+ m_layerTreeHost->resumeRendering();
+ if (!m_layerTreeStateIsFrozen)
+ m_layerTreeHost->setLayerFlushSchedulingEnabled(true);
+ } else {
+ m_layerTreeHost = LayerTreeHost::create(m_webPage);
+
+ if (m_isPaintingSuspended)
+ m_layerTreeHost->pauseRendering();
+ }
+
</ins><span class="cx"> #if USE(TEXTURE_MAPPER_GL) && PLATFORM(GTK) && PLATFORM(X11) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</span><span class="cx"> if (m_nativeSurfaceHandleForCompositing)
</span><span class="cx"> m_layerTreeHost->setNativeSurfaceHandleForCompositing(m_nativeSurfaceHandleForCompositing);
</span><span class="lines">@@ -328,8 +353,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> if (!m_inUpdateBackingStoreState)
</span><span class="cx"> m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
</span><del>- if (m_isPaintingSuspended)
- m_layerTreeHost->pauseRendering();
</del><span class="cx">
</span><span class="cx"> m_layerTreeHost->setRootCompositingLayer(graphicsLayer);
</span><span class="cx"> }
</span><span class="lines">@@ -347,6 +370,32 @@
</span><span class="cx"> m_exitCompositingTimer.startOneShot(0);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void AcceleratedDrawingArea::exitAcceleratedCompositingModeNow()
+{
+ ASSERT(!m_alwaysUseCompositing);
+ ASSERT(!m_layerTreeStateIsFrozen);
+
+ m_exitCompositingTimer.stop();
+ m_wantsToExitAcceleratedCompositingMode = false;
+
+ ASSERT(m_layerTreeHost);
+ m_previousLayerTreeHost = WTFMove(m_layerTreeHost);
+ m_previousLayerTreeHost->setIsDiscardable(true);
+ m_previousLayerTreeHost->pauseRendering();
+ m_previousLayerTreeHost->setLayerFlushSchedulingEnabled(false);
+ m_discardPreviousLayerTreeHostTimer.startOneShot(5);
+}
+
+void AcceleratedDrawingArea::discardPreviousLayerTreeHost()
+{
+ m_discardPreviousLayerTreeHostTimer.stop();
+ if (!m_previousLayerTreeHost)
+ return;
+
+ m_previousLayerTreeHost->invalidate();
+ m_previousLayerTreeHost = nullptr;
+}
+
</ins><span class="cx"> #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
</span><span class="cx"> void AcceleratedDrawingArea::didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection& connection, IPC::Decoder& decoder)
</span><span class="cx"> {
</span><span class="lines">@@ -376,6 +425,8 @@
</span><span class="cx"> {
</span><span class="cx"> if (m_layerTreeHost)
</span><span class="cx"> m_layerTreeHost->didChangeViewportAttributes(WTFMove(attrs));
</span><ins>+ else if (m_previousLayerTreeHost)
+ m_previousLayerTreeHost->didChangeViewportAttributes(WTFMove(attrs));
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -384,6 +435,8 @@
</span><span class="cx"> {
</span><span class="cx"> if (m_layerTreeHost)
</span><span class="cx"> m_layerTreeHost->deviceOrPageScaleFactorChanged();
</span><ins>+ else if (m_previousLayerTreeHost)
+ m_previousLayerTreeHost->deviceOrPageScaleFactorChanged();
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageAcceleratedDrawingAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h (211364 => 211365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h        2017-01-30 16:35:03 UTC (rev 211364)
+++ trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h        2017-01-30 16:42:12 UTC (rev 211365)
</span><span class="lines">@@ -86,6 +86,8 @@
</span><span class="cx">
</span><span class="cx"> void exitAcceleratedCompositingModeSoon();
</span><span class="cx"> bool exitAcceleratedCompositingModePending() const { return m_exitCompositingTimer.isActive(); }
</span><ins>+ void exitAcceleratedCompositingModeNow();
+ void discardPreviousLayerTreeHost();
</ins><span class="cx">
</span><span class="cx"> virtual void suspendPainting();
</span><span class="cx"> virtual void resumePainting();
</span><span class="lines">@@ -127,6 +129,9 @@
</span><span class="cx">
</span><span class="cx"> // The layer tree host that handles accelerated compositing.
</span><span class="cx"> RefPtr<LayerTreeHost> m_layerTreeHost;
</span><ins>+
+ RefPtr<LayerTreeHost> m_previousLayerTreeHost;
+ RunLoop::Timer<AcceleratedDrawingArea> m_discardPreviousLayerTreeHostTimer;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsThreadedCoordinatedLayerTreeHostcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp (211364 => 211365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp        2017-01-30 16:35:03 UTC (rev 211364)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp        2017-01-30 16:42:12 UTC (rev 211365)
</span><span class="lines">@@ -102,17 +102,28 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> m_viewportController.didScroll(rect.location());
</span><del>- didChangeViewport();
</del><ins>+ if (m_isDiscardable)
+ m_discardableSyncActions |= DiscardableSyncActions::UpdateViewport;
+ else
+ didChangeViewport();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ThreadedCoordinatedLayerTreeHost::contentsSizeChanged(const IntSize& newSize)
</span><span class="cx"> {
</span><span class="cx"> m_viewportController.didChangeContentsSize(newSize);
</span><del>- didChangeViewport();
</del><ins>+ if (m_isDiscardable)
+ m_discardableSyncActions |= DiscardableSyncActions::UpdateViewport;
+ else
+ didChangeViewport();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
</span><span class="cx"> {
</span><ins>+ if (m_isDiscardable) {
+ m_discardableSyncActions |= DiscardableSyncActions::UpdateScale;
+ return;
+ }
+
</ins><span class="cx"> if (m_surface && m_surface->resize(m_webPage.size()))
</span><span class="cx"> m_layerTreeContext.contextID = m_surface->surfaceID();
</span><span class="cx">
</span><span class="lines">@@ -122,6 +133,11 @@
</span><span class="cx">
</span><span class="cx"> void ThreadedCoordinatedLayerTreeHost::pageBackgroundTransparencyChanged()
</span><span class="cx"> {
</span><ins>+ if (m_isDiscardable) {
+ m_discardableSyncActions |= DiscardableSyncActions::UpdateBackground;
+ return;
+ }
+
</ins><span class="cx"> CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged();
</span><span class="cx"> m_compositor->setDrawsBackground(m_webPage.drawsBackground());
</span><span class="cx"> }
</span><span class="lines">@@ -128,6 +144,12 @@
</span><span class="cx">
</span><span class="cx"> void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize& size)
</span><span class="cx"> {
</span><ins>+ if (m_isDiscardable) {
+ m_discardableSyncActions |= DiscardableSyncActions::UpdateSize;
+ m_viewportController.didChangeViewportSize(size);
+ return;
+ }
+
</ins><span class="cx"> if (m_surface && m_surface->resize(size))
</span><span class="cx"> m_layerTreeContext.contextID = m_surface->surfaceID();
</span><span class="cx">
</span><span class="lines">@@ -142,7 +164,10 @@
</span><span class="cx"> void ThreadedCoordinatedLayerTreeHost::didChangeViewportAttributes(ViewportAttributes&& attr)
</span><span class="cx"> {
</span><span class="cx"> m_viewportController.didChangeViewportAttributes(WTFMove(attr));
</span><del>- didChangeViewport();
</del><ins>+ if (m_isDiscardable)
+ m_discardableSyncActions |= DiscardableSyncActions::UpdateViewport;
+ else
+ didChangeViewport();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(GTK) && PLATFORM(X11) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</span><span class="lines">@@ -195,6 +220,33 @@
</span><span class="cx"> m_compositor->updateSceneState(state);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void ThreadedCoordinatedLayerTreeHost::setIsDiscardable(bool discardable)
+{
+ m_isDiscardable = discardable;
+ if (m_isDiscardable) {
+ m_discardableSyncActions = OptionSet<DiscardableSyncActions>();
+ return;
+ }
+
+ if (m_discardableSyncActions.isEmpty())
+ return;
+
+ if (m_discardableSyncActions.contains(DiscardableSyncActions::UpdateBackground))
+ pageBackgroundTransparencyChanged();
+
+ if (m_discardableSyncActions.contains(DiscardableSyncActions::UpdateSize)) {
+ // Size changes already sets the scale factor and updates the viewport.
+ sizeDidChange(m_webPage.size());
+ return;
+ }
+
+ if (m_discardableSyncActions.contains(DiscardableSyncActions::UpdateScale))
+ deviceOrPageScaleFactorChanged();
+
+ if (m_discardableSyncActions.contains(DiscardableSyncActions::UpdateViewport))
+ didChangeViewport();
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx">
</span><span class="cx"> #endif // USE(COORDINATED_GRAPHICS)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsThreadedCoordinatedLayerTreeHosth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h (211364 => 211365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h        2017-01-30 16:35:03 UTC (rev 211364)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h        2017-01-30 16:42:12 UTC (rev 211365)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include "CoordinatedLayerTreeHost.h"
</span><span class="cx"> #include "SimpleViewportController.h"
</span><span class="cx"> #include "ThreadedCompositor.h"
</span><ins>+#include <wtf/OptionSet.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class GraphicsContext;
</span><span class="lines">@@ -66,6 +67,8 @@
</span><span class="cx"> void forceRepaint() override;
</span><span class="cx"> bool forceRepaintAsync(uint64_t callbackID) override { return false; }
</span><span class="cx">
</span><ins>+ void setIsDiscardable(bool) override;
+
</ins><span class="cx"> #if PLATFORM(GTK) && PLATFORM(X11) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</span><span class="cx"> void setNativeSurfaceHandleForCompositing(uint64_t) override;
</span><span class="cx"> #endif
</span><span class="lines">@@ -98,6 +101,13 @@
</span><span class="cx"> void didFlushRootLayer(const WebCore::FloatRect&) override { }
</span><span class="cx"> void commitSceneState(const WebCore::CoordinatedGraphicsState&) override;
</span><span class="cx">
</span><ins>+ enum class DiscardableSyncActions {
+ UpdateSize = 1 << 1,
+ UpdateViewport = 1 << 2,
+ UpdateScale = 1 << 3,
+ UpdateBackground = 1 << 4
+ };
+
</ins><span class="cx"> CompositorClient m_compositorClient;
</span><span class="cx"> std::unique_ptr<AcceleratedSurface> m_surface;
</span><span class="cx"> RefPtr<ThreadedCompositor> m_compositor;
</span><span class="lines">@@ -104,6 +114,8 @@
</span><span class="cx"> SimpleViewportController m_viewportController;
</span><span class="cx"> float m_lastPageScaleFactor { 1 };
</span><span class="cx"> WebCore::IntPoint m_lastScrollPosition;
</span><ins>+ bool m_isDiscardable { false };
+ OptionSet<DiscardableSyncActions> m_discardableSyncActions;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageDrawingAreaImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp (211364 => 211365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp        2017-01-30 16:35:03 UTC (rev 211364)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp        2017-01-30 16:42:12 UTC (rev 211365)
</span><span class="lines">@@ -98,6 +98,9 @@
</span><span class="cx"> if (scrollRect.isEmpty())
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ if (m_previousLayerTreeHost)
+ m_previousLayerTreeHost->scrollNonCompositedContents(scrollRect);
+
</ins><span class="cx"> if (!m_scrollRect.isEmpty() && scrollRect != m_scrollRect) {
</span><span class="cx"> unsigned scrollArea = scrollRect.width() * scrollRect.height();
</span><span class="cx"> unsigned currentScrollArea = m_scrollRect.width() * m_scrollRect.height();
</span><span class="lines">@@ -164,6 +167,8 @@
</span><span class="cx"> #if USE(COORDINATED_GRAPHICS_THREADED)
</span><span class="cx"> if (m_layerTreeHost)
</span><span class="cx"> m_layerTreeHost->contentsSizeChanged(newSize);
</span><ins>+ else if (m_previousLayerTreeHost)
+ m_previousLayerTreeHost->contentsSizeChanged(newSize);
</ins><span class="cx"> #else
</span><span class="cx"> UNUSED_PARAM(newSize);
</span><span class="cx"> #endif
</span><span class="lines">@@ -289,15 +294,7 @@
</span><span class="cx"> if (m_alwaysUseCompositing)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- ASSERT(!m_layerTreeStateIsFrozen);
-
- m_exitCompositingTimer.stop();
- m_wantsToExitAcceleratedCompositingMode = false;
-
- ASSERT(m_layerTreeHost);
-
- m_layerTreeHost->invalidate();
- m_layerTreeHost = nullptr;
</del><ins>+ AcceleratedDrawingArea::exitAcceleratedCompositingModeNow();
</ins><span class="cx"> m_dirtyRegion = m_webPage.bounds();
</span><span class="cx">
</span><span class="cx"> if (m_inUpdateBackingStoreState)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageLayerTreeHosth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h (211364 => 211365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h        2017-01-30 16:35:03 UTC (rev 211364)
+++ trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h        2017-01-30 16:42:12 UTC (rev 211365)
</span><span class="lines">@@ -89,6 +89,7 @@
</span><span class="cx">
</span><span class="cx"> #if USE(COORDINATED_GRAPHICS)
</span><span class="cx"> virtual void scheduleAnimation() = 0;
</span><ins>+ virtual void setIsDiscardable(bool) { };
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL) && PLATFORM(GTK)
</span></span></pre>
</div>
</div>
</body>
</html>