WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-104360-20121207205705.patch (text/plain), 108.17 KB, created by
Gwang Yoon Hwang
on 2012-12-07 03:59:42 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Gwang Yoon Hwang
Created:
2012-12-07 03:59:42 PST
Size:
108.17 KB
patch
obsolete
>Subversion Revision: 136934 >diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog >index 1f3380bdaba6b1f7d763d775355c93aae29d2629..1ba9f77c85740a488a0202ebdbcda63cbf2f0f3b 100644 >--- a/Source/WebKit2/ChangeLog >+++ b/Source/WebKit2/ChangeLog >@@ -1,3 +1,178 @@ >+2012-12-07 Gwang Yoon Hwang <ryumiel@company100.net> >+ >+ Coordinated Graphics: Separeate LayerTreeCoordinator into LayerTreeCoordinator and CompositingCoordinator >+ https://bugs.webkit.org/show_bug.cgi?id=104360 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The LayerTreeCoordinator has too many responsibilities. It implements >+ LayerTreeHost, GraphicsLayerClient, CoordinatedGraphicsLayerClient, >+ CoordinatedImageBacking::Coordinator, UpdateAtlasClient, >+ GraphicsLayerFactory and WebCustomFilterProgramProxyClient. >+ >+ This refactoring reduces the responsibilities of LayerTreeCoordinator. >+ >+ By creates a new class called CompositingCoordinator, which takes the >+ responsibility of scheduling compositing task in WebProcess, >+ LayerTreeCoordinator acts like simple LayerTreeHost. >+ >+ By extracting interfaces dealing with LayerTreeCoordinatorProxy to >+ CompositingCoordinatorMessageClient, CompositingCoordinator is decoupled >+ from IPC handling. >+ >+ WebCompositingCoordinatorMessageClient implements IPC handling for >+ CompositingCoordinator and LayerTreeCoordinator. >+ WebCustomFilterProgramProxyClient is stands for IPC handling, so >+ WebCompositingCoordiantorMessageClient implements this interface, too. >+ >+ No new tests because no change in behavior. >+ >+ * CMakeLists.txt: >+ * Target.pri: >+ * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp: >+ Added. It takes responsibiliy for scheduling compositing tasks and >+ managing resources. >+ (WebKit): >+ (WebKit::CompositingCoordinator::create): >+ (WebKit::CompositingCoordinator::~CompositingCoordinator): >+ (WebKit::CompositingCoordinator::CompositingCoordinator): >+ (WebKit::CompositingCoordinator::setLayerFlushSchedulingEnabled): >+ (WebKit::CompositingCoordinator::scheduleLayerFlush): >+ (WebKit::CompositingCoordinator::cancelPendingLayerFlush): >+ (WebKit::CompositingCoordinator::setRootCompositingLayer): >+ (WebKit::CompositingCoordinator::invalidate): >+ (WebKit::CompositingCoordinator::setNeedsDisplayInRect): >+ (WebKit::CompositingCoordinator::forceRepaint): >+ (WebKit::CompositingCoordinator::sizeDidChange): >+ (WebKit::CompositingCoordinator::flushPendingLayerChanges): >+ (WebKit::CompositingCoordinator::syncLayerState): >+ (WebKit::CompositingCoordinator::syncLayerChildren): >+ (WebKit::CompositingCoordinator::createCanvas): >+ (WebKit::CompositingCoordinator::syncCanvas): >+ (WebKit::CompositingCoordinator::destroyCanvas): >+ (WebKit::CompositingCoordinator::syncLayerFilters): >+ (WebKit::CompositingCoordinator::detachLayer): >+ (WebKit::updateOffsetFromViewportForSelf): >+ (WebKit::updateOffsetFromViewportForLayer): >+ (WebKit::CompositingCoordinator::syncFixedLayers): >+ (WebKit::CompositingCoordinator::lockAnimations): >+ (WebKit::CompositingCoordinator::unlockAnimations): >+ (WebKit::CompositingCoordinator::performScheduledLayerFlush): >+ (WebKit::CompositingCoordinator::syncDisplayState): >+ (WebKit::CompositingCoordinator::layerFlushTimerFired): >+ (WebKit::CompositingCoordinator::createPageOverlayLayer): >+ (WebKit::CompositingCoordinator::destroyPageOverlayLayer): >+ (WebKit::CompositingCoordinator::setPageOverlayNeedsDisplay): >+ (WebKit::CompositingCoordinator::setPageOverlayOpacity): >+ (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::createTile): >+ (WebKit::CompositingCoordinator::updateTile): >+ (WebKit::CompositingCoordinator::removeTile): >+ (WebKit::CompositingCoordinator::createUpdateAtlas): >+ (WebKit::CompositingCoordinator::removeUpdateAtlas): >+ (WebKit::CompositingCoordinator::visibleContentsRect): >+ (WebKit::CompositingCoordinator::setLayerAnimations): >+ (WebKit::CompositingCoordinator::setVisibleContentsRect): >+ (WebKit::CompositingCoordinator::renderNextFrame): >+ (WebKit::CompositingCoordinator::layerTreeTileUpdatesAllowed): >+ (WebKit::CompositingCoordinator::purgeBackingStores): >+ (WebKit::CompositingCoordinator::beginContentUpdate): >+ (WebKit::CompositingCoordinator::scheduleReleaseInactiveAtlases): >+ (WebKit::CompositingCoordinator::releaseInactiveAtlasesTimerFired): >+ * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h: >+ Added. >+ (WebCore): >+ (WebKit): >+ (CompositingCoordinator): >+ (WebKit::CompositingCoordinator::pauseRendering): >+ (WebKit::CompositingCoordinator::resumeRendering): >+ (WebKit::CompositingCoordinator::rootGraphicsLayer): >+ * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinatorClient.h: Added. >+ (WebKit): >+ (CompositingCoordinatorMessageClient): >+ This interface provides a way to send messages to renderer. >+ (CompositingCoordinatorClient): >+ This interface provides a way to use LayerTreeCoordinator from >+ Compositing Coordinator. >+ (WebKit::CompositingCoordinatorClient::~CompositingCoordinatorClient): >+ * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp: >+ (WebKit::LayerTreeCoordinator::~LayerTreeCoordinator): >+ (WebKit::LayerTreeCoordinator::LayerTreeCoordinator): >+ (WebKit::LayerTreeCoordinator::setLayerFlushSchedulingEnabled): >+ (WebKit::LayerTreeCoordinator::scheduleLayerFlush): >+ (WebKit::LayerTreeCoordinator::setRootCompositingLayer): >+ (WebKit::LayerTreeCoordinator::invalidate): >+ (WebKit::LayerTreeCoordinator::setNonCompositedContentsNeedDisplay): >+ (WebKit::LayerTreeCoordinator::forceRepaint): >+ (WebKit::LayerTreeCoordinator::sizeDidChange): >+ (WebKit::LayerTreeCoordinator::didInstallPageOverlay): >+ (WebKit::LayerTreeCoordinator::didUninstallPageOverlay): >+ (WebKit::LayerTreeCoordinator::setPageOverlayNeedsDisplay): >+ (WebKit::LayerTreeCoordinator::setPageOverlayOpacity): >+ (WebKit::LayerTreeCoordinator::pauseRendering): >+ (WebKit::LayerTreeCoordinator::resumeRendering): >+ (WebKit::LayerTreeCoordinator::viewSize): >+ (WebKit::LayerTreeCoordinator::layoutIfNeeded): >+ (WebKit::LayerTreeCoordinator::isOpaqueContents): >+ (WebKit::LayerTreeCoordinator::didPerformScheduledLayerFlush): >+ (WebKit::LayerTreeCoordinator::paintContents): >+ (WebKit::LayerTreeCoordinator::paintOverlayContents): >+ (WebKit::LayerTreeCoordinator::setVisibleContentsRect): >+ (WebKit::LayerTreeCoordinator::graphicsLayerFactory): >+ (WebKit::LayerTreeCoordinator::scheduleAnimation): >+ (WebKit::LayerTreeCoordinator::renderNextFrame): >+ (WebKit::LayerTreeCoordinator::purgeBackingStores): >+ (WebKit::LayerTreeCoordinator::setBackgroundColor): >+ * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h: >+ (WebCore): >+ (LayerTreeCoordinator): >+ * WebProcess/WebPage/CoordinatedGraphics/WebCompositingCoordinatorMessageClient.cpp: >+ Added. Manages sends actual IPC messages and manages >+ WebCustomFilterProgram >+ (WebKit): >+ (WebKit::WebCompositingCoordinatorMessageClient::create): >+ (WebKit::WebCompositingCoordinatorMessageClient::~WebCompositingCoordinatorMessageClient): >+ (WebKit::WebCompositingCoordinatorMessageClient::WebCompositingCoordinatorMessageClient): >+ (WebKit::WebCompositingCoordinatorMessageClient::setRootCompositingLayer): >+ (WebKit::WebCompositingCoordinatorMessageClient::setCompositingLayerState): >+ (WebKit::WebCompositingCoordinatorMessageClient::setCompositingLayerChildren): >+ (WebKit::WebCompositingCoordinatorMessageClient::setCompositingLayerFilters): >+ (WebKit::WebCompositingCoordinatorMessageClient::deleteCompositingLayer): >+ (WebKit::WebCompositingCoordinatorMessageClient::createTileForLayer): >+ (WebKit::WebCompositingCoordinatorMessageClient::updateTileForLayer): >+ (WebKit::WebCompositingCoordinatorMessageClient::removeTileForLayer): >+ (WebKit::WebCompositingCoordinatorMessageClient::createUpdateAtlas): >+ (WebKit::WebCompositingCoordinatorMessageClient::removeUpdateAtlas): >+ (WebKit::WebCompositingCoordinatorMessageClient::createImageBacking): >+ (WebKit::WebCompositingCoordinatorMessageClient::updateImageBacking): >+ (WebKit::WebCompositingCoordinatorMessageClient::clearImageBackingContents): >+ (WebKit::WebCompositingCoordinatorMessageClient::removeImageBacking): >+ (WebKit::WebCompositingCoordinatorMessageClient::didRenderFrame): >+ (WebKit::WebCompositingCoordinatorMessageClient::didChangeScrollPosition): >+ (WebKit::WebCompositingCoordinatorMessageClient::createCanvas): >+ (WebKit::WebCompositingCoordinatorMessageClient::syncCanvas): >+ (WebKit::WebCompositingCoordinatorMessageClient::destroyCanvas): >+ (WebKit::WebCompositingCoordinatorMessageClient::setLayerAnimations): >+ (WebKit::WebCompositingCoordinatorMessageClient::setAnimationsLocked): >+ (WebKit::WebCompositingCoordinatorMessageClient::setBackgroundColor): >+ (WebKit::WebCompositingCoordinatorMessageClient::requestAnimationFrame): >+ (WebKit::WebCompositingCoordinatorMessageClient::invokeForceRepaintAsyncCallback): >+ (WebKit::WebCompositingCoordinatorMessageClient::checkCustomFilterProgramProxies): >+ (WebKit::WebCompositingCoordinatorMessageClient::removeCustomFilterProgramProxy): >+ (WebKit::WebCompositingCoordinatorMessageClient::disconnectCustomFilterPrograms): >+ * WebProcess/WebPage/CoordinatedGraphics/WebCompositingCoordinatorMessageClient.h: Added. >+ (WebKit): >+ (WebCompositingCoordinatorMessageClient): >+ > 2012-12-06 Rick Byers <rbyers@chromium.org> > > CSS cursor property should support webkit-image-set >diff --git a/Source/WebKit2/CMakeLists.txt b/Source/WebKit2/CMakeLists.txt >index 8f3b6f93c0d87d1bd5c410442d6d3e161dc830e0..bae89bb696f9b9e6b8f84d6ffad7560e33df3840 100644 >--- a/Source/WebKit2/CMakeLists.txt >+++ b/Source/WebKit2/CMakeLists.txt >@@ -495,11 +495,13 @@ set(WebKit2_SOURCES > WebProcess/WebPage/WebUndoStep.cpp > > WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp >+ WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp > WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.cpp > WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp > WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.cpp > WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp > WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp >+ WebProcess/WebPage/CoordinatedGraphics/WebCompositingCoordinatorMessageClient.cpp > ) > > set(WebKit2_MESSAGES_IN_FILES >diff --git a/Source/WebKit2/Target.pri b/Source/WebKit2/Target.pri >index 1260b3c1aa46bb5cb24634abcc1b12f4d9431473..3efabf36068361cfdedb9cd6d958df54fc0a14d9 100644 >--- a/Source/WebKit2/Target.pri >+++ b/Source/WebKit2/Target.pri >@@ -369,11 +369,14 @@ HEADERS += \ > WebProcess/WebPage/EventDispatcher.h \ > WebProcess/WebPage/FindController.h \ > WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h \ >+ WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h \ >+ WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinatorClient.h \ > WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h \ > WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.h \ > WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.h \ > WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h \ > WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h \ >+ WebProcess/WebPage/CoordinatedGraphics/WebCompositingCoordinatorMessageClient.h \ > WebProcess/WebPage/TapHighlightController.h \ > WebProcess/WebPage/PageOverlay.h \ > WebProcess/WebPage/WebContextMenu.h \ >@@ -753,11 +756,13 @@ SOURCES += \ > WebProcess/WebPage/EventDispatcher.cpp \ > WebProcess/WebPage/FindController.cpp \ > WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp \ >+ WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp \ > WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp \ > WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.cpp \ > WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.cpp \ > WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp \ > WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp \ >+ WebProcess/WebPage/CoordinatedGraphics/WebCompositingCoordinatorMessageClient.cpp \ > WebProcess/WebPage/TapHighlightController.cpp \ > WebProcess/WebPage/LayerTreeHost.cpp \ > WebProcess/WebPage/PageOverlay.cpp \ >diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..acb99828b67564165e2164d17e2cf0b16a7602e7 >--- /dev/null >+++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >@@ -0,0 +1,677 @@ >+/* >+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). >+ * Copyright (C) 2012 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 "config.h" >+ >+#if USE(COORDINATED_GRAPHICS) >+#include "CompositingCoordinator.h" >+ >+#include "CoordinatedLayerInfo.h" >+#include "SurfaceUpdateInfo.h" >+#include <WebCore/Frame.h> >+#include <WebCore/FrameView.h> >+#include <WebCore/GraphicsSurface.h> >+#include <WebCore/Page.h> >+#include <WebCore/RenderLayer.h> >+#include <WebCore/RenderLayerBacking.h> >+#include <WebCore/RenderLayerCompositor.h> >+#include <WebCore/RenderView.h> >+#include <WebCore/Settings.h> >+#include <WebCore/TextureMapperPlatformLayer.h> >+#include <wtf/TemporaryChange.h> >+ >+#if ENABLE(CSS_SHADERS) >+#include "CustomFilterValidatedProgram.h" >+#include "ValidatedCustomFilterOperation.h" >+#endif >+ >+using namespace WebCore; >+ >+namespace WebKit { >+ >+PassOwnPtr<CompositingCoordinator> CompositingCoordinator::create(Page* page, CompositingCoordinatorClient* client, CompositingCoordinatorMessageClient* messageClient) >+{ >+ return adoptPtr(new CompositingCoordinator(page, client, messageClient)); >+} >+ >+CompositingCoordinator::~CompositingCoordinator() >+{ >+ // Prevent setCoordinatedGraphicsLayerClient(0) -> detachLayer() from modifying the set while we iterate it. >+ HashSet<CoordinatedGraphicsLayer*> registeredLayers; >+ registeredLayers.swap(m_registeredLayers); >+ >+ HashSet<CoordinatedGraphicsLayer*>::iterator end = registeredLayers.end(); >+ for (HashSet<CoordinatedGraphicsLayer*>::iterator it = registeredLayers.begin(); it != end; ++it) >+ (*it)->setCoordinator(0); >+} >+ >+CompositingCoordinator::CompositingCoordinator(Page* page, CompositingCoordinatorClient* client, CompositingCoordinatorMessageClient* messageClient) >+ : m_page(page) >+ , m_client(client) >+ , m_messageClient(messageClient) >+ , m_isValid(true) >+ , m_isPurging(false) >+ , m_waitingForRenderer(true) >+ , m_isSuspended(false) >+ , m_contentsScale(1) >+ , m_shouldSendScrollPositionUpdate(true) >+ , m_shouldSyncFrame(false) >+ , m_shouldSyncRootLayer(true) >+ , m_layerFlushTimer(this, &CompositingCoordinator::layerFlushTimerFired) >+ , m_releaseInactiveAtlasesTimer(this, &CompositingCoordinator::releaseInactiveAtlasesTimerFired) >+ , m_layerFlushSchedulingEnabled(true) >+ , m_forceRepaintAsyncCallbackID(0) >+ , m_animationsLocked(false) >+{ >+ // Create a root layer. >+ m_rootLayer = GraphicsLayer::create(this, this); >+ CoordinatedGraphicsLayer* coordinatedRootLayer = toCoordinatedGraphicsLayer(m_rootLayer.get()); >+ coordinatedRootLayer->setRootLayer(true); >+#ifndef NDEBUG >+ m_rootLayer->setName("CompositingCoordinator root layer"); >+#endif >+ m_rootLayer->setDrawsContent(false); >+ >+ IntSize viewSize(m_client->viewSize()); >+ m_rootLayer->setSize(viewSize); >+ >+ m_nonCompositedContentLayer = GraphicsLayer::create(this, this); >+#ifndef NDEBUG >+ m_nonCompositedContentLayer->setName("CompositingCoordinator non-composited content"); >+#endif >+ m_nonCompositedContentLayer->setDrawsContent(true); >+ m_nonCompositedContentLayer->setSize(viewSize); >+ >+ m_rootLayer->addChild(m_nonCompositedContentLayer.get()); >+ >+ scheduleLayerFlush(); >+} >+ >+void CompositingCoordinator::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled) >+{ >+ if (m_layerFlushSchedulingEnabled == layerFlushingEnabled) >+ return; >+ >+ m_layerFlushSchedulingEnabled = layerFlushingEnabled; >+ >+ if (m_layerFlushSchedulingEnabled) { >+ scheduleLayerFlush(); >+ return; >+ } >+ >+ cancelPendingLayerFlush(); >+} >+ >+void CompositingCoordinator::scheduleLayerFlush() >+{ >+ if (!m_layerFlushSchedulingEnabled) >+ return; >+ >+ if (!m_layerFlushTimer.isActive()) >+ m_layerFlushTimer.startOneShot(0); >+} >+ >+void CompositingCoordinator::cancelPendingLayerFlush() >+{ >+ m_layerFlushTimer.stop(); >+} >+ >+void CompositingCoordinator::setRootCompositingLayer(GraphicsLayer* graphicsLayer) >+{ >+ m_nonCompositedContentLayer->removeAllChildren(); >+ m_nonCompositedContentLayer->setContentsOpaque(m_client->isOpaqueContents()); >+ >+ // Add the accelerated layer tree hierarchy. >+ if (graphicsLayer) >+ m_nonCompositedContentLayer->addChild(graphicsLayer); >+} >+ >+void CompositingCoordinator::invalidate() >+{ >+ cancelPendingLayerFlush(); >+ >+ ASSERT(m_isValid); >+ m_rootLayer = nullptr; >+ m_isValid = false; >+} >+ >+void CompositingCoordinator::setNeedsDisplayInRect(const IntRect& rect) >+{ >+ m_nonCompositedContentLayer->setNeedsDisplayInRect(rect); >+ >+ if (m_pageOverlayLayer) >+ m_pageOverlayLayer->setNeedsDisplayInRect(rect); >+ >+ scheduleLayerFlush(); >+} >+ >+void CompositingCoordinator::forceRepaint() >+{ >+ // This is necessary for running layout tests. Since in this case we are not waiting for a renderer to reply nicely. >+ // Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed. >+ syncDisplayState(); >+ >+ // We need to schedule another flush, otherwise the forced paint might cancel a later expected flush. >+ // This is aligned with LayerTreeHostCA. >+ scheduleLayerFlush(); >+ flushPendingLayerChanges(); >+} >+ >+void CompositingCoordinator::sizeDidChange(const IntSize& newSize) >+{ >+ if (m_rootLayer->size() == newSize) >+ return; >+ >+ m_rootLayer->setSize(newSize); >+ >+ // If the newSize exposes new areas of the non-composited content a setNeedsDisplay is needed >+ // for those newly exposed areas. >+ FloatSize oldSize = m_nonCompositedContentLayer->size(); >+ m_nonCompositedContentLayer->setSize(newSize); >+ >+ if (newSize.width() > oldSize.width()) { >+ float height = std::min(static_cast<float>(newSize.height()), oldSize.height()); >+ m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(oldSize.width(), 0, newSize.width() - oldSize.width(), height)); >+ } >+ >+ if (newSize.height() > oldSize.height()) >+ m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(0, oldSize.height(), newSize.width(), newSize.height() - oldSize.height())); >+ >+ if (m_pageOverlayLayer) >+ m_pageOverlayLayer->setSize(newSize); >+ >+ scheduleLayerFlush(); >+} >+ >+bool CompositingCoordinator::flushPendingLayerChanges() >+{ >+ if (m_waitingForRenderer) >+ return false; >+ >+ for (size_t i = 0; i < m_detachedLayers.size(); ++i) >+ m_messageClient->deleteCompositingLayer(m_detachedLayers[i]); >+ m_detachedLayers.clear(); >+ >+ m_rootLayer->flushCompositingStateForThisLayerOnly(); >+ m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly(); >+ >+ if (m_pageOverlayLayer) >+ m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); >+ >+ bool didSync = m_page->mainFrame()->view()->flushCompositingStateIncludingSubframes(); >+ >+ flushPendingImageBackingChanges(); >+ >+ if (m_shouldSyncRootLayer) { >+ m_messageClient->setRootCompositingLayer(toCoordinatedGraphicsLayer(m_rootLayer.get())->id()); >+ m_shouldSyncRootLayer = false; >+ m_shouldSyncFrame = true; >+ } >+ >+ if (m_shouldSyncFrame) { >+ didSync = true; >+ >+ IntSize contentsSize = roundedIntSize(m_nonCompositedContentLayer->size()); >+ IntRect coveredRect = toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->coverRect(); >+ m_messageClient->didRenderFrame(contentsSize, coveredRect); >+ m_waitingForRenderer = true; >+ m_shouldSyncFrame = false; >+ } else >+ unlockAnimations(); >+ >+ return didSync; >+} >+ >+void CompositingCoordinator::syncLayerState(CoordinatedLayerID id, const CoordinatedLayerInfo& info) >+{ >+ if (m_shouldSendScrollPositionUpdate) { >+ m_messageClient->didChangeScrollPosition(m_visibleContentsRect.location()); >+ m_shouldSendScrollPositionUpdate = false; >+ } >+ >+ m_shouldSyncFrame = true; >+ m_messageClient->setCompositingLayerState(id, info); >+} >+ >+void CompositingCoordinator::syncLayerChildren(CoordinatedLayerID id, const Vector<CoordinatedLayerID>& children) >+{ >+ m_shouldSyncFrame = true; >+ m_messageClient->setCompositingLayerChildren(id, children); >+} >+ >+#if USE(GRAPHICS_SURFACE) >+void CompositingCoordinator::createCanvas(CoordinatedLayerID id, PlatformLayer* canvasPlatformLayer) >+{ >+ m_shouldSyncFrame = true; >+ GraphicsSurfaceToken token = canvasPlatformLayer->graphicsSurfaceToken(); >+ IntSize canvasSize = canvasPlatformLayer->platformLayerSize(); >+ m_messageClient->createCanvas(id, canvasSize, token); >+} >+ >+void CompositingCoordinator::syncCanvas(CoordinatedLayerID id, PlatformLayer* canvasPlatformLayer) >+{ >+ m_shouldSyncFrame = true; >+ uint32_t frontBuffer = canvasPlatformLayer->copyToGraphicsSurface(); >+ m_messageClient->syncCanvas(id, frontBuffer); >+} >+ >+void CompositingCoordinator::destroyCanvas(CoordinatedLayerID id) >+{ >+ if (m_isPurging) >+ return; >+ >+ m_shouldSyncFrame = true; >+ m_messageClient->destroyCanvas(id); >+} >+#endif >+ >+#if ENABLE(CSS_FILTERS) >+void CompositingCoordinator::syncLayerFilters(CoordinatedLayerID id, const FilterOperations& filters) >+{ >+ m_shouldSyncFrame = true; >+ m_messageClient->setCompositingLayerFilters(id, filters); >+} >+#endif >+ >+void CompositingCoordinator::detachLayer(CoordinatedGraphicsLayer* layer) >+{ >+ m_registeredLayers.remove(layer); >+ m_shouldSyncFrame = true; >+ m_detachedLayers.append(layer->id()); >+ scheduleLayerFlush(); >+} >+ >+static void updateOffsetFromViewportForSelf(RenderLayer* renderLayer) >+{ >+ // These conditions must match the conditions in RenderLayerCompositor::requiresCompositingForPosition. >+ RenderLayerBacking* backing = renderLayer->backing(); >+ if (!backing) >+ return; >+ >+ RenderStyle* style = renderLayer->renderer()->style(); >+ if (!style) >+ return; >+ >+ if (!renderLayer->renderer()->isOutOfFlowPositioned() || renderLayer->renderer()->style()->position() != FixedPosition) >+ return; >+ >+ if (!renderLayer->renderer()->container()->isRenderView()) >+ return; >+ >+ if (!renderLayer->isStackingContext()) >+ return; >+ >+ CoordinatedGraphicsLayer* graphicsLayer = toCoordinatedGraphicsLayer(backing->graphicsLayer()); >+ graphicsLayer->setFixedToViewport(true); >+} >+ >+static void updateOffsetFromViewportForLayer(RenderLayer* renderLayer) >+{ >+ updateOffsetFromViewportForSelf(renderLayer); >+ >+ if (renderLayer->firstChild()) >+ updateOffsetFromViewportForLayer(renderLayer->firstChild()); >+ if (renderLayer->nextSibling()) >+ updateOffsetFromViewportForLayer(renderLayer->nextSibling()); >+} >+ >+void CompositingCoordinator::syncFixedLayers() >+{ >+ if (!m_page->settings() || !m_page->settings()->acceleratedCompositingForFixedPositionEnabled()) >+ return; >+ >+ if (!m_page->mainFrame()->view()->hasViewportConstrainedObjects()) >+ return; >+ >+ RenderLayer* rootRenderLayer = m_page->mainFrame()->contentRenderer()->compositor()->rootRenderLayer(); >+ ASSERT(rootRenderLayer); >+ if (rootRenderLayer->firstChild()) >+ updateOffsetFromViewportForLayer(rootRenderLayer->firstChild()); >+} >+ >+void CompositingCoordinator::lockAnimations() >+{ >+ m_animationsLocked = true; >+ m_messageClient->setAnimationsLocked(true); >+} >+ >+void CompositingCoordinator::unlockAnimations() >+{ >+ if (!m_animationsLocked) >+ return; >+ >+ m_animationsLocked = false; >+ m_messageClient->setAnimationsLocked(false); >+} >+ >+void CompositingCoordinator::performScheduledLayerFlush() >+{ >+ if (m_isSuspended || m_waitingForRenderer) >+ return; >+ >+ // We lock the animations while performing layout, to avoid flickers caused by animations continuing in the renderer while >+ // the web process layout wants to cancel them. >+ lockAnimations(); >+ syncDisplayState(); >+ >+ // We can unlock the animations before flushing if there are no visible changes, for example if there are content updates >+ // in a layer with opacity 0. >+ bool canUnlockBeforeFlush = !m_isValid || !toCoordinatedGraphicsLayer(m_rootLayer.get())->hasPendingVisibleChanges(); >+ if (canUnlockBeforeFlush) >+ unlockAnimations(); >+ >+ if (!m_isValid) >+ return; >+ >+ bool didSync = flushPendingLayerChanges(); >+ m_client->didPerformScheduledLayerFlush(didSync); >+} >+ >+void CompositingCoordinator::syncDisplayState() >+{ >+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER) && !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) >+ // Make sure that any previously registered animation callbacks are being executed before we flush the layers. >+ m_page->mainFrame()->view()->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(currentTime())); >+#endif >+ >+ m_client->layoutIfNeeded(); >+} >+ >+void CompositingCoordinator::layerFlushTimerFired(Timer<CompositingCoordinator>*) >+{ >+ performScheduledLayerFlush(); >+} >+ >+void CompositingCoordinator::createPageOverlayLayer() >+{ >+ ASSERT(!m_pageOverlayLayer); >+ >+ m_pageOverlayLayer = GraphicsLayer::create(this, this); >+#ifndef NDEBUG >+ m_pageOverlayLayer->setName("CompositingCoordinator page overlay content"); >+#endif >+ >+ m_pageOverlayLayer->setDrawsContent(true); >+ m_pageOverlayLayer->setSize(m_client->viewSize()); >+ >+ m_rootLayer->addChild(m_pageOverlayLayer.get()); >+ >+ scheduleLayerFlush(); >+} >+ >+void CompositingCoordinator::destroyPageOverlayLayer() >+{ >+ ASSERT(m_pageOverlayLayer); >+ m_pageOverlayLayer->removeFromParent(); >+ m_pageOverlayLayer = nullptr; >+ >+ scheduleLayerFlush(); >+} >+ >+void CompositingCoordinator::setPageOverlayNeedsDisplay(const WebCore::IntRect& rect) >+{ >+ ASSERT(m_pageOverlayLayer); >+ m_pageOverlayLayer->setNeedsDisplayInRect(rect); >+ scheduleLayerFlush(); >+} >+ >+void CompositingCoordinator::setPageOverlayOpacity(float value) >+{ >+ ASSERT(m_pageOverlayLayer); >+ m_pageOverlayLayer->setOpacity(value); >+ scheduleLayerFlush(); >+} >+ >+PassRefPtr<CoordinatedImageBacking> CompositingCoordinator::createImageBackingIfNeeded(Image* image) >+{ >+ CoordinatedImageBackingID imageID = CoordinatedImageBacking::getCoordinatedImageBackingID(image); >+ ImageBackingMap::iterator it = m_imageBackings.find(imageID); >+ RefPtr<CoordinatedImageBacking> imageBacking; >+ if (it == m_imageBackings.end()) { >+ imageBacking = CoordinatedImageBacking::create(this, image); >+ m_imageBackings.add(imageID, imageBacking); >+ } else >+ imageBacking = it->value; >+ >+ return imageBacking; >+} >+ >+void CompositingCoordinator::createImageBacking(CoordinatedImageBackingID imageID) >+{ >+ m_shouldSyncFrame = true; >+ m_messageClient->createImageBacking(imageID); >+} >+ >+void CompositingCoordinator::updateImageBacking(CoordinatedImageBackingID imageID, const ShareableSurface::Handle& handle) >+{ >+ m_shouldSyncFrame = true; >+ m_messageClient->updateImageBacking(imageID, handle); >+} >+ >+void CompositingCoordinator::clearImageBackingContents(CoordinatedImageBackingID imageID) >+{ >+ m_shouldSyncFrame = true; >+ m_messageClient->clearImageBackingContents(imageID); >+} >+ >+void CompositingCoordinator::removeImageBacking(CoordinatedImageBackingID imageID) >+{ >+ if (m_isPurging) >+ return; >+ >+ ASSERT(m_imageBackings.contains(imageID)); >+ m_shouldSyncFrame = true; >+ m_imageBackings.remove(imageID); >+ m_messageClient->removeImageBacking(imageID); >+} >+ >+void CompositingCoordinator::flushPendingImageBackingChanges() >+{ >+ ImageBackingMap::iterator end = m_imageBackings.end(); >+ for (ImageBackingMap::iterator iter = m_imageBackings.begin(); iter != end; ++iter) >+ iter->value->update(); >+} >+ >+void CompositingCoordinator::notifyAnimationStarted(const GraphicsLayer*, double /* time */) >+{ >+} >+ >+void CompositingCoordinator::notifyFlushRequired(const GraphicsLayer*) >+{ >+} >+ >+void CompositingCoordinator::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase phase, const IntRect& clipRect) >+{ >+ bool isNonCompositingContent = (graphicsLayer == m_nonCompositedContentLayer); >+ bool isPageOverlay = (graphicsLayer == m_pageOverlayLayer); >+ >+ if (isNonCompositingContent) >+ m_client->paintContents(graphicsContext, clipRect); >+ else if (isPageOverlay) >+ m_client->paintOverlayContents(graphicsContext, clipRect); >+} >+ >+PassOwnPtr<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLayerClient* client) >+{ >+ CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(client); >+ layer->setCoordinator(this); >+ m_registeredLayers.add(layer); >+ layer->setContentsScale(m_contentsScale); >+ layer->adjustVisibleRect(); >+ return adoptPtr(layer); >+} >+ >+void CompositingCoordinator::createTile(CoordinatedLayerID layerID, uint32_t tileID, const SurfaceUpdateInfo& updateInfo, const IntRect& tileRect) >+{ >+ m_shouldSyncFrame = true; >+ m_messageClient->createTileForLayer(layerID, tileID, tileRect, updateInfo); >+} >+ >+void CompositingCoordinator::updateTile(CoordinatedLayerID layerID, uint32_t tileID, const SurfaceUpdateInfo& updateInfo, const IntRect& tileRect) >+{ >+ m_shouldSyncFrame = true; >+ m_messageClient->updateTileForLayer(layerID, tileID, tileRect, updateInfo); >+} >+ >+void CompositingCoordinator::removeTile(CoordinatedLayerID layerID, uint32_t tileID) >+{ >+ if (m_isPurging) >+ return; >+ m_shouldSyncFrame = true; >+ m_messageClient->removeTileForLayer(layerID, tileID); >+} >+ >+void CompositingCoordinator::createUpdateAtlas(int atlasID, const ShareableSurface::Handle& handle) >+{ >+ m_messageClient->createUpdateAtlas(atlasID, handle); >+} >+ >+void CompositingCoordinator::removeUpdateAtlas(int atlasID) >+{ >+ if (m_isPurging) >+ return; >+ m_messageClient->removeUpdateAtlas(atlasID); >+} >+ >+IntRect CompositingCoordinator::visibleContentsRect() const >+{ >+ return m_visibleContentsRect; >+} >+ >+void CompositingCoordinator::setLayerAnimations(CoordinatedLayerID layerID, const GraphicsLayerAnimations& animations) >+{ >+ m_shouldSyncFrame = true; >+ GraphicsLayerAnimations activeAnimations = animations.getActiveAnimations(); >+ m_messageClient->setLayerAnimations(layerID, activeAnimations); >+} >+ >+void CompositingCoordinator::setVisibleContentsRect(const IntRect& rect, float scale, const FloatPoint& trajectoryVector) >+{ >+ bool contentsRectDidChange = rect != m_visibleContentsRect; >+ bool contentsScaleDidChange = scale != m_contentsScale; >+ >+ // A zero trajectoryVector indicates that tiles all around the viewport are requested. >+ toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRectTrajectoryVector(trajectoryVector); >+ >+ if (contentsRectDidChange || contentsScaleDidChange) { >+ m_visibleContentsRect = rect; >+ m_contentsScale = scale; >+ >+ HashSet<CoordinatedGraphicsLayer*>::iterator end = m_registeredLayers.end(); >+ for (HashSet<CoordinatedGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it) { >+ if (contentsScaleDidChange) >+ (*it)->setContentsScale(scale); >+ if (contentsRectDidChange) >+ (*it)->adjustVisibleRect(); >+ } >+ } >+ >+ if (contentsRectDidChange) >+ m_shouldSendScrollPositionUpdate = true; >+ >+ scheduleLayerFlush(); >+} >+ >+void CompositingCoordinator::renderNextFrame() >+{ >+ m_waitingForRenderer = false; >+ scheduleLayerFlush(); >+ for (unsigned i = 0; i < m_updateAtlases.size(); ++i) >+ m_updateAtlases[i]->didSwapBuffers(); >+} >+ >+bool CompositingCoordinator::layerTreeTileUpdatesAllowed() const >+{ >+ return !m_isSuspended && !m_waitingForRenderer; >+} >+ >+void CompositingCoordinator::purgeBackingStores() >+{ >+ TemporaryChange<bool> purgingToggle(m_isPurging, true); >+ >+ HashSet<CoordinatedGraphicsLayer*>::iterator end = m_registeredLayers.end(); >+ for (HashSet<CoordinatedGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it) >+ (*it)->purgeBackingStores(); >+ >+ m_imageBackings.clear(); >+ m_updateAtlases.clear(); >+} >+ >+PassOwnPtr<GraphicsContext> CompositingCoordinator::beginContentUpdate(const WebCore::IntSize& size, ShareableBitmap::Flags flags, int& atlasID, WebCore::IntPoint& offset) >+{ >+ OwnPtr<GraphicsContext> graphicsContext; >+ for (unsigned i = 0; i < m_updateAtlases.size(); ++i) { >+ UpdateAtlas* atlas = m_updateAtlases[i].get(); >+ if (atlas->flags() == flags) { >+ // This will return null if there is no available buffer space. >+ graphicsContext = atlas->beginPaintingOnAvailableBuffer(atlasID, size, offset); >+ if (graphicsContext) >+ return graphicsContext.release(); >+ } >+ } >+ >+ static const int ScratchBufferDimension = 1024; // Should be a power of two. >+ m_updateAtlases.append(adoptPtr(new UpdateAtlas(this, ScratchBufferDimension, flags))); >+ scheduleReleaseInactiveAtlases(); >+ return m_updateAtlases.last()->beginPaintingOnAvailableBuffer(atlasID, size, offset); >+} >+ >+const double ReleaseInactiveAtlasesTimerInterval = 0.5; >+ >+void CompositingCoordinator::scheduleReleaseInactiveAtlases() >+{ >+ if (!m_releaseInactiveAtlasesTimer.isActive()) >+ m_releaseInactiveAtlasesTimer.startRepeating(ReleaseInactiveAtlasesTimerInterval); >+} >+ >+void CompositingCoordinator::releaseInactiveAtlasesTimerFired(Timer<CompositingCoordinator>*) >+{ >+ // We always want to keep one atlas for non-composited content. >+ OwnPtr<UpdateAtlas> atlasToKeepAnyway; >+ bool foundActiveAtlasForNonCompositedContent = false; >+ for (int i = m_updateAtlases.size() - 1; i >= 0; --i) { >+ UpdateAtlas* atlas = m_updateAtlases[i].get(); >+ if (!atlas->isInUse()) >+ atlas->addTimeInactive(ReleaseInactiveAtlasesTimerInterval); >+ bool usableForNonCompositedContent = atlas->flags() == ShareableBitmap::NoFlags; >+ if (atlas->isInactive()) { >+ if (!foundActiveAtlasForNonCompositedContent && !atlasToKeepAnyway && usableForNonCompositedContent) >+ atlasToKeepAnyway = m_updateAtlases[i].release(); >+ m_updateAtlases.remove(i); >+ } else if (usableForNonCompositedContent) >+ foundActiveAtlasForNonCompositedContent = true; >+ } >+ >+ if (!foundActiveAtlasForNonCompositedContent && atlasToKeepAnyway) >+ m_updateAtlases.append(atlasToKeepAnyway.release()); >+ >+ if (m_updateAtlases.size() <= 1) >+ m_releaseInactiveAtlasesTimer.stop(); >+} >+ >+} // namespace WebKit >+ >+#endif // USE(COORDINATED_GRAPHICS) >diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h >new file mode 100644 >index 0000000000000000000000000000000000000000..c4709a51c5220aa01f40f5230fb3a233e8fffc01 >--- /dev/null >+++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h >@@ -0,0 +1,192 @@ >+/* >+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) >+ * Copyright (C) 2012 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 "CompositingCoordinatorClient.h" >+#include "CoordinatedGraphicsLayer.h" >+#include "CoordinatedImageBacking.h" >+#include "UpdateAtlas.h" >+#include <WebCore/FloatPoint.h> >+#include <WebCore/GraphicsLayerClient.h> >+#include <WebCore/GraphicsLayerFactory.h> >+#include <WebCore/IntRect.h> >+#include <WebCore/Timer.h> >+#include <wtf/OwnPtr.h> >+ >+#if ENABLE(CSS_SHADERS) >+#include <WebCore/FilterOperations.h> >+#endif >+ >+namespace WebCore { >+class Page; >+} >+ >+namespace WebKit { >+ >+class CompositingCoordinator : public WebCore::GraphicsLayerClient >+ , public CoordinatedGraphicsLayerClient >+ , public CoordinatedImageBacking::Coordinator >+ , public UpdateAtlasClient >+ , public WebCore::GraphicsLayerFactory { >+ WTF_MAKE_NONCOPYABLE(CompositingCoordinator); WTF_MAKE_FAST_ALLOCATED; >+public: >+ static PassOwnPtr<CompositingCoordinator> create(WebCore::Page*, CompositingCoordinatorClient*, CompositingCoordinatorMessageClient*); >+ virtual ~CompositingCoordinator(); >+ >+ virtual void scheduleLayerFlush(); >+ virtual void setLayerFlushSchedulingEnabled(bool); >+ virtual void setRootCompositingLayer(WebCore::GraphicsLayer*); >+ virtual void invalidate(); >+ >+ virtual void setNeedsDisplayInRect(const WebCore::IntRect&); >+ >+ virtual void sizeDidChange(const WebCore::IntSize& newSize); >+ >+ void createPageOverlayLayer(); >+ void destroyPageOverlayLayer(); >+ void setPageOverlayNeedsDisplay(const WebCore::IntRect&); >+ void setPageOverlayOpacity(float); >+ >+ virtual void pauseRendering() { m_isSuspended = true; } >+ virtual void resumeRendering() { m_isSuspended = false; scheduleLayerFlush(); } >+ >+ virtual void forceRepaint(); >+ >+ virtual void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint&); >+ >+ // CoordinatedGraphicsLayerClient :: CoordinatedTileClient >+ virtual void createTile(CoordinatedLayerID, uint32_t tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&); >+ virtual void updateTile(CoordinatedLayerID, uint32_t tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&); >+ virtual void removeTile(CoordinatedLayerID, uint32_t tileID); >+ >+ // CoordinatedGraphicsLayerClient >+ virtual WebCore::IntRect visibleContentsRect() const; >+ virtual bool layerTreeTileUpdatesAllowed() const; >+ virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) OVERRIDE; >+ virtual void syncLayerState(CoordinatedLayerID, const CoordinatedLayerInfo&); >+ virtual void syncLayerChildren(CoordinatedLayerID, const Vector<CoordinatedLayerID>&); >+#if ENABLE(CSS_FILTERS) >+ virtual void syncLayerFilters(CoordinatedLayerID, const WebCore::FilterOperations&); >+#endif >+#if USE(GRAPHICS_SURFACE) >+ virtual void createCanvas(CoordinatedLayerID, WebCore::PlatformLayer*) OVERRIDE; >+ virtual void syncCanvas(CoordinatedLayerID, WebCore::PlatformLayer*) OVERRIDE; >+ virtual void destroyCanvas(CoordinatedLayerID) OVERRIDE; >+#endif >+ virtual void setLayerAnimations(CoordinatedLayerID, const WebCore::GraphicsLayerAnimations&); >+ >+ virtual void detachLayer(WebCore::CoordinatedGraphicsLayer*); >+ virtual void syncFixedLayers(); >+ virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, int& atlasID, WebCore::IntPoint&); >+ >+ // UpdateAtlasClient >+ virtual void createUpdateAtlas(int atlasID, const ShareableSurface::Handle&); >+ virtual void removeUpdateAtlas(int atlasID); >+ >+ void renderNextFrame(); >+ void purgeBackingStores(); >+ >+ WebCore::GraphicsLayer* rootGraphicsLayer() const { return m_rootLayer.get(); } >+ >+private: >+ CompositingCoordinator(WebCore::Page*, CompositingCoordinatorClient*, CompositingCoordinatorMessageClient*); >+ >+ // GraphicsLayerClient >+ virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time); >+ virtual void notifyFlushRequired(const WebCore::GraphicsLayer*); >+ virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect); >+ >+ // CoordinatedImageBacking::Coordinator >+ virtual void createImageBacking(CoordinatedImageBackingID) OVERRIDE; >+ virtual void updateImageBacking(CoordinatedImageBackingID, const ShareableSurface::Handle&) OVERRIDE; >+ virtual void clearImageBackingContents(CoordinatedImageBackingID) OVERRIDE; >+ virtual void removeImageBacking(CoordinatedImageBackingID) OVERRIDE; >+ >+ void flushPendingImageBackingChanges(); >+ >+ // GraphicsLayerFactory >+ virtual PassOwnPtr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayerClient*) OVERRIDE; >+ >+ // CompositingCoordinator >+ bool flushPendingLayerChanges(); >+ void cancelPendingLayerFlush(); >+ void performScheduledLayerFlush(); >+ void syncDisplayState(); >+ void lockAnimations(); >+ void unlockAnimations(); >+ >+ void layerFlushTimerFired(WebCore::Timer<CompositingCoordinator>*); >+ >+ void scheduleReleaseInactiveAtlases(); >+ >+ void releaseInactiveAtlasesTimerFired(WebCore::Timer<CompositingCoordinator>*); >+ >+ WebCore::Page* m_page; >+ CompositingCoordinatorClient* m_client; >+ CompositingCoordinatorMessageClient* m_messageClient; >+ >+ OwnPtr<WebCore::GraphicsLayer> m_rootLayer; >+ >+ // The layer which contains all non-composited content. >+ OwnPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer; >+ >+ // The page overlay layer. Will be null if there's no page overlay. >+ OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer; >+ >+ HashSet<WebCore::CoordinatedGraphicsLayer*> m_registeredLayers; >+ Vector<CoordinatedLayerID> m_detachedLayers; >+ typedef HashMap<CoordinatedImageBackingID, RefPtr<CoordinatedImageBacking> > ImageBackingMap; >+ ImageBackingMap m_imageBackings; >+ Vector<OwnPtr<UpdateAtlas> > m_updateAtlases; >+ >+ bool m_isValid; >+ // We don't send the messages related to releasing resources to renderer during purging, because renderer already had removed all resources. >+ bool m_isPurging; >+ >+ bool m_waitingForRenderer; >+ bool m_isSuspended; >+ WebCore::IntRect m_visibleContentsRect; >+ float m_contentsScale; >+ bool m_shouldSendScrollPositionUpdate; >+ >+ bool m_shouldSyncFrame; >+ bool m_shouldSyncRootLayer; >+ WebCore::Timer<CompositingCoordinator> m_layerFlushTimer; >+ WebCore::Timer<CompositingCoordinator> m_releaseInactiveAtlasesTimer; >+ bool m_layerFlushSchedulingEnabled; >+ uint64_t m_forceRepaintAsyncCallbackID; >+ bool m_animationsLocked; >+}; >+ >+} >+ >+#endif >+ >+#endif // CompositingCoordinator_h >diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinatorClient.h b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinatorClient.h >new file mode 100644 >index 0000000000000000000000000000000000000000..150b02dabcbd021bb4ea88ed9d602227dfec512c >--- /dev/null >+++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinatorClient.h >@@ -0,0 +1,100 @@ >+/* >+ * Copyright (C) 2012 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 CompositingCoordinatorClient_h >+#define CompositingCoordinatorClient_h >+ >+#if USE(COORDINATED_GRAPHICS) >+ >+#include "CoordinatedLayerInfo.h" >+#include "ShareableSurface.h" >+#include "SurfaceUpdateInfo.h" >+#include <WebCore/GraphicsLayerAnimation.h> >+#include <WebCore/IntRect.h> >+#include <WebCore/IntSize.h> >+#include <wtf/RefCounted.h> >+ >+#if USE(GRAPHICS_SURFACE) >+#include <WebCore/GraphicsSurfaceToken.h> >+#endif >+ >+#if ENABLE(CSS_FILTERS) >+#include <WebCore/FilterOperation.h> >+#endif >+ >+namespace WebKit { >+ >+class CompositingCoordinatorMessageClient { >+public: >+ virtual void setRootCompositingLayer(CoordinatedLayerID) = 0; >+ virtual void setCompositingLayerState(CoordinatedLayerID, const CoordinatedLayerInfo&) = 0; >+ virtual void setCompositingLayerChildren(CoordinatedLayerID, const Vector<CoordinatedLayerID>&) = 0; >+#if ENABLE(CSS_FILTERS) >+ virtual void setCompositingLayerFilters(CoordinatedLayerID, const WebCore::FilterOperations&) = 0; >+#endif >+ virtual void deleteCompositingLayer(CoordinatedLayerID) = 0; >+ >+ virtual void createTileForLayer(CoordinatedLayerID, uint32_t tileID, const WebCore::IntRect&, const SurfaceUpdateInfo&) = 0; >+ virtual void updateTileForLayer(CoordinatedLayerID, uint32_t tileID, const WebCore::IntRect&, const SurfaceUpdateInfo&) = 0; >+ virtual void removeTileForLayer(CoordinatedLayerID, uint32_t tileID) = 0; >+ >+ virtual void createUpdateAtlas(int atlasID, const ShareableSurface::Handle&) = 0; >+ virtual void removeUpdateAtlas(int atlasID) = 0; >+ >+ virtual void createImageBacking(CoordinatedImageBackingID) = 0; >+ virtual void updateImageBacking(CoordinatedImageBackingID, const ShareableSurface::Handle&) = 0; >+ virtual void clearImageBackingContents(CoordinatedImageBackingID) = 0; >+ virtual void removeImageBacking(CoordinatedImageBackingID) = 0; >+ >+ virtual void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect) = 0; >+ virtual void didChangeScrollPosition(const WebCore::IntPoint& position) = 0; >+ >+#if USE(GRAPHICS_SURFACE) >+ virtual void createCanvas(CoordinatedLayerID, const WebCore::IntSize&, const WebCore::GraphicsSurfaceToken&) = 0; >+ virtual void syncCanvas(CoordinatedLayerID, uint32_t frontBuffer) = 0; >+ virtual void destroyCanvas(CoordinatedLayerID) = 0; >+#endif >+ >+ virtual void setLayerAnimations(CoordinatedLayerID, const WebCore::GraphicsLayerAnimations&) = 0; >+ virtual void setAnimationsLocked(bool) = 0; >+}; >+ >+class CompositingCoordinatorClient { >+public: >+ virtual const WebCore::IntSize& viewSize() const = 0; >+ >+ virtual void didPerformScheduledLayerFlush(bool didSync) = 0; >+ virtual void layoutIfNeeded() = 0; >+ >+ virtual bool isOpaqueContents() = 0; >+ >+ virtual void paintContents(WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) = 0; >+ virtual void paintOverlayContents(WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) = 0; >+}; >+ >+} >+#endif >+ >+#endif // CompositingCoordinatorClient_h >diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp >index c985d11b3a6e006c3ff2600ad23d0bc909a70426..0efa9bbcd3fb450e4ad2fbe5ac285f54370deb0f 100644 >--- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp >+++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp >@@ -1,6 +1,7 @@ > /* > * Copyright (C) 2011 Apple Inc. All rights reserved. > * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). >+ * Copyright (C) 2012 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 >@@ -29,32 +30,10 @@ > #if USE(COORDINATED_GRAPHICS) > #include "LayerTreeCoordinator.h" > >-#include "CoordinatedGraphicsArgumentCoders.h" > #include "CoordinatedGraphicsLayer.h" > #include "DrawingAreaImpl.h" > #include "GraphicsContext.h" >-#include "LayerTreeCoordinatorProxyMessages.h" >-#include "MessageID.h" >-#include "SurfaceUpdateInfo.h" >-#include "WebCoreArgumentCoders.h" > #include "WebPage.h" >-#include "WebPageProxyMessages.h" >-#include <WebCore/Frame.h> >-#include <WebCore/FrameView.h> >-#include <WebCore/GraphicsSurface.h> >-#include <WebCore/Page.h> >-#include <WebCore/RenderLayer.h> >-#include <WebCore/RenderLayerBacking.h> >-#include <WebCore/RenderLayerCompositor.h> >-#include <WebCore/RenderView.h> >-#include <WebCore/Settings.h> >-#include <WebCore/TextureMapperPlatformLayer.h> >-#include <wtf/TemporaryChange.h> >- >-#if ENABLE(CSS_SHADERS) >-#include "CustomFilterValidatedProgram.h" >-#include "ValidatedCustomFilterOperation.h" >-#endif > > using namespace WebCore; > >@@ -67,89 +46,33 @@ PassRefPtr<LayerTreeCoordinator> LayerTreeCoordinator::create(WebPage* webPage) > > LayerTreeCoordinator::~LayerTreeCoordinator() > { >-#if ENABLE(CSS_SHADERS) >- disconnectCustomFilterPrograms(); >-#endif >- >- // Prevent setCoordinatedGraphicsLayerClient(0) -> detachLayer() from modifying the set while we iterate it. >- HashSet<WebCore::CoordinatedGraphicsLayer*> registeredLayers; >- registeredLayers.swap(m_registeredLayers); >- >- HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator end = registeredLayers.end(); >- for (HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator it = registeredLayers.begin(); it != end; ++it) >- (*it)->setCoordinator(0); > } > > LayerTreeCoordinator::LayerTreeCoordinator(WebPage* webPage) > : LayerTreeHost(webPage) > , m_notifyAfterScheduledLayerFlush(false) >- , m_isValid(true) >- , m_isPurging(false) >- , m_waitingForUIProcess(true) >- , m_isSuspended(false) >- , m_contentsScale(1) >- , m_shouldSendScrollPositionUpdate(true) >- , m_shouldSyncFrame(false) >- , m_shouldSyncRootLayer(true) >- , m_layerFlushTimer(this, &LayerTreeCoordinator::layerFlushTimerFired) >- , m_releaseInactiveAtlasesTimer(this, &LayerTreeCoordinator::releaseInactiveAtlasesTimerFired) >- , m_layerFlushSchedulingEnabled(true) > , m_forceRepaintAsyncCallbackID(0) >- , m_animationsLocked(false) >-{ >- // Create a root layer. >- m_rootLayer = GraphicsLayer::create(this, this); >- CoordinatedGraphicsLayer* coordinatedRootLayer = toCoordinatedGraphicsLayer(m_rootLayer.get()); >- coordinatedRootLayer->setRootLayer(true); >-#ifndef NDEBUG >- m_rootLayer->setName("LayerTreeCoordinator root layer"); >-#endif >- m_rootLayer->setDrawsContent(false); >- m_rootLayer->setSize(m_webPage->size()); >- m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(coordinatedRootLayer)->id(); >- >- m_nonCompositedContentLayer = GraphicsLayer::create(this, this); >-#ifndef NDEBUG >- m_nonCompositedContentLayer->setName("LayerTreeCoordinator non-composited content"); >-#endif >- m_nonCompositedContentLayer->setDrawsContent(true); >- m_nonCompositedContentLayer->setSize(m_webPage->size()); >+{ >+ m_compositingCoordinatorMessageClient = WebCompositingCoordinatorMessageClient::create(m_webPage); >+ m_compositingCoordinator = CompositingCoordinator::create(m_webPage->corePage(), this, m_compositingCoordinatorMessageClient.get()); > >- m_rootLayer->addChild(m_nonCompositedContentLayer.get()); >+ CoordinatedGraphicsLayer* rootLayer = toCoordinatedGraphicsLayer(m_compositingCoordinator->rootGraphicsLayer()); >+ m_layerTreeContext.coordinatedLayerID = rootLayer->id(); > > if (m_webPage->hasPageOverlay()) >- createPageOverlayLayer(); >+ m_compositingCoordinator->createPageOverlayLayer(); > > scheduleLayerFlush(); > } > > void LayerTreeCoordinator::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled) > { >- if (m_layerFlushSchedulingEnabled == layerFlushingEnabled) >- return; >- >- m_layerFlushSchedulingEnabled = layerFlushingEnabled; >- >- if (m_layerFlushSchedulingEnabled) { >- scheduleLayerFlush(); >- return; >- } >- >- cancelPendingLayerFlush(); >+ m_compositingCoordinator->setLayerFlushSchedulingEnabled(layerFlushingEnabled); > } > > void LayerTreeCoordinator::scheduleLayerFlush() > { >- if (!m_layerFlushSchedulingEnabled) >- return; >- >- if (!m_layerFlushTimer.isActive()) >- m_layerFlushTimer.startOneShot(0); >-} >- >-void LayerTreeCoordinator::cancelPendingLayerFlush() >-{ >- m_layerFlushTimer.stop(); >+ m_compositingCoordinator->scheduleLayerFlush(); > } > > void LayerTreeCoordinator::setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush) >@@ -159,30 +82,17 @@ void LayerTreeCoordinator::setShouldNotifyAfterNextScheduledLayerFlush(bool noti > > void LayerTreeCoordinator::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer) > { >- m_nonCompositedContentLayer->removeAllChildren(); >- m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground() && !m_webPage->drawsTransparentBackground()); >- >- // Add the accelerated layer tree hierarchy. >- if (graphicsLayer) >- m_nonCompositedContentLayer->addChild(graphicsLayer); >+ m_compositingCoordinator->setRootCompositingLayer(graphicsLayer); > } > > void LayerTreeCoordinator::invalidate() > { >- cancelPendingLayerFlush(); >- >- ASSERT(m_isValid); >- m_rootLayer = nullptr; >- m_isValid = false; >+ m_compositingCoordinator->invalidate(); > } > > void LayerTreeCoordinator::setNonCompositedContentsNeedDisplay(const WebCore::IntRect& rect) > { >- m_nonCompositedContentLayer->setNeedsDisplayInRect(rect); >- if (m_pageOverlayLayer) >- m_pageOverlayLayer->setNeedsDisplayInRect(rect); >- >- scheduleLayerFlush(); >+ m_compositingCoordinator->setNeedsDisplayInRect(rect); > } > > void LayerTreeCoordinator::scrollNonCompositedContents(const WebCore::IntRect& scrollRect, const WebCore::IntSize& /* scrollOffset */) >@@ -192,14 +102,7 @@ void LayerTreeCoordinator::scrollNonCompositedContents(const WebCore::IntRect& s > > void LayerTreeCoordinator::forceRepaint() > { >- // This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely. >- // Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed. >- syncDisplayState(); >- >- // We need to schedule another flush, otherwise the forced paint might cancel a later expected flush. >- // This is aligned with LayerTreeHostCA. >- scheduleLayerFlush(); >- flushPendingLayerChanges(); >+ m_compositingCoordinator->forceRepaint(); > } > > bool LayerTreeCoordinator::forceRepaintAsync(uint64_t callbackID) >@@ -213,425 +116,77 @@ bool LayerTreeCoordinator::forceRepaintAsync(uint64_t callbackID) > > void LayerTreeCoordinator::sizeDidChange(const WebCore::IntSize& newSize) > { >- if (m_rootLayer->size() == newSize) >- return; >- >- m_rootLayer->setSize(newSize); >- >- // If the newSize exposes new areas of the non-composited content a setNeedsDisplay is needed >- // for those newly exposed areas. >- FloatSize oldSize = m_nonCompositedContentLayer->size(); >- m_nonCompositedContentLayer->setSize(newSize); >- >- if (newSize.width() > oldSize.width()) { >- float height = std::min(static_cast<float>(newSize.height()), oldSize.height()); >- m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(oldSize.width(), 0, newSize.width() - oldSize.width(), height)); >- } >- >- if (newSize.height() > oldSize.height()) >- m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(0, oldSize.height(), newSize.width(), newSize.height() - oldSize.height())); >- >- if (m_pageOverlayLayer) >- m_pageOverlayLayer->setSize(newSize); >- >- scheduleLayerFlush(); >+ m_compositingCoordinator->sizeDidChange(newSize); > } > > void LayerTreeCoordinator::didInstallPageOverlay() > { >- createPageOverlayLayer(); >- scheduleLayerFlush(); >+ m_compositingCoordinator->createPageOverlayLayer(); > } > > void LayerTreeCoordinator::didUninstallPageOverlay() > { >- destroyPageOverlayLayer(); >- scheduleLayerFlush(); >+ m_compositingCoordinator->destroyPageOverlayLayer(); > } > > void LayerTreeCoordinator::setPageOverlayNeedsDisplay(const WebCore::IntRect& rect) > { >- ASSERT(m_pageOverlayLayer); >- m_pageOverlayLayer->setNeedsDisplayInRect(rect); >- scheduleLayerFlush(); >+ m_compositingCoordinator->setPageOverlayNeedsDisplay(rect); > } > > void LayerTreeCoordinator::setPageOverlayOpacity(float value) > { >- ASSERT(m_pageOverlayLayer); >- m_pageOverlayLayer->setOpacity(value); >- scheduleLayerFlush(); >+ m_compositingCoordinator->setPageOverlayOpacity(value); > } > >-bool LayerTreeCoordinator::flushPendingLayerChanges() >+void LayerTreeCoordinator::pauseRendering() > { >- if (m_waitingForUIProcess) >- return false; >- >- m_rootLayer->flushCompositingStateForThisLayerOnly(); >- m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly(); >- if (m_pageOverlayLayer) >- m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); >- >- bool didSync = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes(); >- >- flushPendingImageBackingChanges(); >- >- if (m_shouldSyncRootLayer) { >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetRootCompositingLayer(toCoordinatedGraphicsLayer(m_rootLayer.get())->id())); >- m_shouldSyncRootLayer = false; >- m_shouldSyncFrame = true; >- } >- >- for (size_t i = 0; i < m_detachedLayers.size(); ++i) >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::DeleteCompositingLayer(m_detachedLayers[i])); >- m_detachedLayers.clear(); >- >- if (m_shouldSyncFrame) { >- didSync = true; >- >- IntSize contentsSize = roundedIntSize(m_nonCompositedContentLayer->size()); >- IntRect coveredRect = toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->coverRect(); >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::DidRenderFrame(contentsSize, coveredRect)); >- m_waitingForUIProcess = true; >- m_shouldSyncFrame = false; >- } else >- unlockAnimations(); >- >- if (m_forceRepaintAsyncCallbackID) { >- m_webPage->send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID)); >- m_forceRepaintAsyncCallbackID = 0; >- } >- >- return didSync; >-} >- >-void LayerTreeCoordinator::syncLayerState(CoordinatedLayerID id, const CoordinatedLayerInfo& info) >-{ >- if (m_shouldSendScrollPositionUpdate) { >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::DidChangeScrollPosition(m_visibleContentsRect.location())); >- m_shouldSendScrollPositionUpdate = false; >- } >- >- m_shouldSyncFrame = true; >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetCompositingLayerState(id, info)); >+ m_compositingCoordinator->pauseRendering(); > } > >-void LayerTreeCoordinator::syncLayerChildren(CoordinatedLayerID id, const Vector<CoordinatedLayerID>& children) >+void LayerTreeCoordinator::resumeRendering() > { >- m_shouldSyncFrame = true; >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetCompositingLayerChildren(id, children)); >+ m_compositingCoordinator->resumeRendering(); > } > >-#if USE(GRAPHICS_SURFACE) >-void LayerTreeCoordinator::createCanvas(CoordinatedLayerID id, PlatformLayer* canvasPlatformLayer) >+const IntSize& LayerTreeCoordinator::viewSize() const > { >- m_shouldSyncFrame = true; >- GraphicsSurfaceToken token = canvasPlatformLayer->graphicsSurfaceToken(); >- IntSize canvasSize = canvasPlatformLayer->platformLayerSize(); >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateCanvas(id, canvasSize, token)); >+ return m_webPage->size(); > } > >-void LayerTreeCoordinator::syncCanvas(CoordinatedLayerID id, PlatformLayer* canvasPlatformLayer) >+void LayerTreeCoordinator::layoutIfNeeded() > { >- m_shouldSyncFrame = true; >- uint32_t frontBuffer = canvasPlatformLayer->copyToGraphicsSurface(); >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::SyncCanvas(id, frontBuffer)); >+ m_webPage->layoutIfNeeded(); > } > >-void LayerTreeCoordinator::destroyCanvas(CoordinatedLayerID id) >+bool LayerTreeCoordinator::isOpaqueContents() > { >- if (m_isPurging) >- return; >- >- m_shouldSyncFrame = true; >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::DestroyCanvas(id)); >+ return m_webPage->drawsBackground() && !m_webPage->drawsTransparentBackground(); > } >-#endif > >-#if ENABLE(CSS_FILTERS) >-void LayerTreeCoordinator::syncLayerFilters(CoordinatedLayerID id, const FilterOperations& filters) >+void LayerTreeCoordinator::didPerformScheduledLayerFlush(bool didSync) > { >- m_shouldSyncFrame = true; >-#if ENABLE(CSS_SHADERS) >- checkCustomFilterProgramProxies(filters); >-#endif >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetCompositingLayerFilters(id, filters)); >-} >-#endif >- >-#if ENABLE(CSS_SHADERS) >-void LayerTreeCoordinator::checkCustomFilterProgramProxies(const FilterOperations& filters) >-{ >- // We need to create the WebCustomFilterProgramProxy objects before we get to serialize the >- // custom filters to the other process. That's because WebCustomFilterProgramProxy needs >- // to link back to the coordinator, so that we can send a message to the UI process when >- // the program is not needed anymore. >- // Note that the serialization will only happen at a later time in ArgumentCoder<WebCore::FilterOperations>::encode. >- // At that point the program will only be serialized once. All the other times it will only use the ID of the program. >- for (size_t i = 0; i < filters.size(); ++i) { >- const FilterOperation* operation = filters.at(i); >- if (operation->getOperationType() != FilterOperation::VALIDATED_CUSTOM) >- continue; >- const ValidatedCustomFilterOperation* customOperation = static_cast<const ValidatedCustomFilterOperation*>(operation); >- ASSERT(customOperation->validatedProgram()->isInitialized()); >- TextureMapperPlatformCompiledProgram* program = customOperation->validatedProgram()->platformCompiledProgram(); >- >- RefPtr<WebCustomFilterProgramProxy> customFilterProgramProxy; >- if (program->client()) >- customFilterProgramProxy = static_cast<WebCustomFilterProgramProxy*>(program->client()); >- else { >- customFilterProgramProxy = WebCustomFilterProgramProxy::create(); >- program->setClient(customFilterProgramProxy); >- } >- >- if (!customFilterProgramProxy->client()) { >- customFilterProgramProxy->setClient(this); >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateCustomFilterProgram(customFilterProgramProxy->id(), customOperation->validatedProgram()->validatedProgramInfo())); >- } else { >- // If the client was not disconnected then this coordinator must be the client for it. >- ASSERT(customFilterProgramProxy->client() == this); >- } >+ if (m_forceRepaintAsyncCallbackID) { >+ m_compositingCoordinatorMessageClient->invokeForceRepaintAsyncCallback(m_forceRepaintAsyncCallbackID); >+ m_forceRepaintAsyncCallbackID = 0; > } >-} >- >-void LayerTreeCoordinator::removeCustomFilterProgramProxy(WebCustomFilterProgramProxy* customFilterProgramProxy) >-{ >- // At this time the shader is not needed anymore, so we remove it from our set and >- // send a message to the other process to delete it. >- m_customFilterPrograms.remove(customFilterProgramProxy); >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveCustomFilterProgram(customFilterProgramProxy->id())); >-} >- >-void LayerTreeCoordinator::disconnectCustomFilterPrograms() >-{ >- // Make sure that WebCore will not call into this coordinator anymore. >- HashSet<WebCustomFilterProgramProxy*>::iterator iter = m_customFilterPrograms.begin(); >- for (; iter != m_customFilterPrograms.end(); ++iter) >- (*iter)->setClient(0); >-} >-#endif >- >-void LayerTreeCoordinator::detachLayer(CoordinatedGraphicsLayer* layer) >-{ >- m_registeredLayers.remove(layer); >- m_shouldSyncFrame = true; >- m_detachedLayers.append(layer->id()); >- scheduleLayerFlush(); >-} >- >-static void updateOffsetFromViewportForSelf(RenderLayer* renderLayer) >-{ >- // These conditions must match the conditions in RenderLayerCompositor::requiresCompositingForPosition. >- RenderLayerBacking* backing = renderLayer->backing(); >- if (!backing) >- return; >- >- RenderStyle* style = renderLayer->renderer()->style(); >- if (!style) >- return; >- >- if (!renderLayer->renderer()->isOutOfFlowPositioned() || renderLayer->renderer()->style()->position() != FixedPosition) >- return; >- >- if (!renderLayer->renderer()->container()->isRenderView()) >- return; >- >- if (!renderLayer->isStackingContext()) >- return; >- >- CoordinatedGraphicsLayer* graphicsLayer = toCoordinatedGraphicsLayer(backing->graphicsLayer()); >- graphicsLayer->setFixedToViewport(true); >-} >- >-static void updateOffsetFromViewportForLayer(RenderLayer* renderLayer) >-{ >- updateOffsetFromViewportForSelf(renderLayer); >- >- if (renderLayer->firstChild()) >- updateOffsetFromViewportForLayer(renderLayer->firstChild()); >- if (renderLayer->nextSibling()) >- updateOffsetFromViewportForLayer(renderLayer->nextSibling()); >-} >- >-void LayerTreeCoordinator::syncFixedLayers() >-{ >- if (!m_webPage->corePage()->settings() || !m_webPage->corePage()->settings()->acceleratedCompositingForFixedPositionEnabled()) >- return; >- >- if (!m_webPage->mainFrame()->view()->hasViewportConstrainedObjects()) >- return; >- >- RenderLayer* rootRenderLayer = m_webPage->mainFrame()->contentRenderer()->compositor()->rootRenderLayer(); >- ASSERT(rootRenderLayer); >- if (rootRenderLayer->firstChild()) >- updateOffsetFromViewportForLayer(rootRenderLayer->firstChild()); >-} >- >-void LayerTreeCoordinator::lockAnimations() >-{ >- m_animationsLocked = true; >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetAnimationsLocked(true)); >-} >- >-void LayerTreeCoordinator::unlockAnimations() >-{ >- if (!m_animationsLocked) >- return; >- >- m_animationsLocked = false; >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetAnimationsLocked(false)); >-} >- >-void LayerTreeCoordinator::performScheduledLayerFlush() >-{ >- if (m_isSuspended || m_waitingForUIProcess) >- return; >- >- // We lock the animations while performing layout, to avoid flickers caused by animations continuing in the UI process while >- // the web process layout wants to cancel them. >- lockAnimations(); >- syncDisplayState(); >- >- // We can unlock the animations before flushing if there are no visible changes, for example if there are content updates >- // in a layer with opacity 0. >- bool canUnlockBeforeFlush = !m_isValid || !toCoordinatedGraphicsLayer(m_rootLayer.get())->hasPendingVisibleChanges(); >- if (canUnlockBeforeFlush) >- unlockAnimations(); >- >- if (!m_isValid) >- return; > >- if (flushPendingLayerChanges()) >- didPerformScheduledLayerFlush(); >-} >- >-void LayerTreeCoordinator::syncDisplayState() >-{ >-#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER) && !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) >- // Make sure that any previously registered animation callbacks are being executed before we flush the layers. >- m_webPage->corePage()->mainFrame()->view()->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(currentTime())); >-#endif >- >- m_webPage->layoutIfNeeded(); >-} >- >-void LayerTreeCoordinator::didPerformScheduledLayerFlush() >-{ >- if (m_notifyAfterScheduledLayerFlush) { >+ if (didSync && m_notifyAfterScheduledLayerFlush) { > static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers(); > m_notifyAfterScheduledLayerFlush = false; > } > } > >-void LayerTreeCoordinator::layerFlushTimerFired(Timer<LayerTreeCoordinator>*) >-{ >- performScheduledLayerFlush(); >-} >- >-void LayerTreeCoordinator::createPageOverlayLayer() >-{ >- ASSERT(!m_pageOverlayLayer); >- >- m_pageOverlayLayer = GraphicsLayer::create(this, this); >-#ifndef NDEBUG >- m_pageOverlayLayer->setName("LayerTreeCoordinator page overlay content"); >-#endif >- >- m_pageOverlayLayer->setDrawsContent(true); >- m_pageOverlayLayer->setSize(m_webPage->size()); >- >- m_rootLayer->addChild(m_pageOverlayLayer.get()); >-} >- >-void LayerTreeCoordinator::destroyPageOverlayLayer() >-{ >- ASSERT(m_pageOverlayLayer); >- m_pageOverlayLayer->removeFromParent(); >- m_pageOverlayLayer = nullptr; >-} >- >-PassRefPtr<CoordinatedImageBacking> LayerTreeCoordinator::createImageBackingIfNeeded(Image* image) >-{ >- CoordinatedImageBackingID imageID = CoordinatedImageBacking::getCoordinatedImageBackingID(image); >- ImageBackingMap::iterator it = m_imageBackings.find(imageID); >- RefPtr<CoordinatedImageBacking> imageBacking; >- if (it == m_imageBackings.end()) { >- imageBacking = CoordinatedImageBacking::create(this, image); >- m_imageBackings.add(imageID, imageBacking); >- } else >- imageBacking = it->value; >- >- return imageBacking; >-} >- >-void LayerTreeCoordinator::createImageBacking(CoordinatedImageBackingID imageID) >+void LayerTreeCoordinator::paintContents(WebCore::GraphicsContext& graphicsContext, const IntRect& clipRect) > { >- m_shouldSyncFrame = true; >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateImageBacking(imageID)); >-} >- >-void LayerTreeCoordinator::updateImageBacking(CoordinatedImageBackingID imageID, const ShareableSurface::Handle& handle) >-{ >- m_shouldSyncFrame = true; >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::UpdateImageBacking(imageID, handle)); >-} >- >-void LayerTreeCoordinator::clearImageBackingContents(CoordinatedImageBackingID imageID) >-{ >- m_shouldSyncFrame = true; >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::ClearImageBackingContents(imageID)); >-} >- >-void LayerTreeCoordinator::removeImageBacking(CoordinatedImageBackingID imageID) >-{ >- if (m_isPurging) >- return; >- >- ASSERT(m_imageBackings.contains(imageID)); >- m_shouldSyncFrame = true; >- m_imageBackings.remove(imageID); >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveImageBacking(imageID)); >-} >- >-void LayerTreeCoordinator::flushPendingImageBackingChanges() >-{ >- ImageBackingMap::iterator end = m_imageBackings.end(); >- for (ImageBackingMap::iterator iter = m_imageBackings.begin(); iter != end; ++iter) >- iter->value->update(); >-} >- >-void LayerTreeCoordinator::notifyAnimationStarted(const WebCore::GraphicsLayer*, double /* time */) >-{ >-} >- >-void LayerTreeCoordinator::notifyFlushRequired(const WebCore::GraphicsLayer*) >-{ >-} >- >-void LayerTreeCoordinator::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect) >-{ >- if (graphicsLayer == m_nonCompositedContentLayer) { >- m_webPage->drawRect(graphicsContext, clipRect); >- return; >- } >- >- if (graphicsLayer == m_pageOverlayLayer) { >- // Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here. >- graphicsContext.clearRect(clipRect); >- m_webPage->drawPageOverlay(graphicsContext, clipRect); >- return; >- } >+ m_webPage->drawRect(graphicsContext, clipRect); > } > >-PassOwnPtr<GraphicsLayer> LayerTreeCoordinator::createGraphicsLayer(GraphicsLayerClient* client) >+void LayerTreeCoordinator::paintOverlayContents(WebCore::GraphicsContext& graphicsContext, const IntRect& clipRect) > { >- CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(client); >- layer->setCoordinator(this); >- m_registeredLayers.add(layer); >- layer->setContentsScale(m_contentsScale); >- layer->adjustVisibleRect(); >- return adoptPtr(layer); >+ // Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here. >+ graphicsContext.clearRect(clipRect); >+ m_webPage->drawPageOverlay(graphicsContext, clipRect); > } > > bool LayerTreeHost::supportsAcceleratedCompositing() >@@ -639,99 +194,23 @@ bool LayerTreeHost::supportsAcceleratedCompositing() > return true; > } > >-void LayerTreeCoordinator::createTile(CoordinatedLayerID layerID, uint32_t tileID, const SurfaceUpdateInfo& updateInfo, const WebCore::IntRect& tileRect) >-{ >- m_shouldSyncFrame = true; >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateTileForLayer(layerID, tileID, tileRect, updateInfo)); >-} >- >-void LayerTreeCoordinator::updateTile(CoordinatedLayerID layerID, uint32_t tileID, const SurfaceUpdateInfo& updateInfo, const WebCore::IntRect& tileRect) >-{ >- m_shouldSyncFrame = true; >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::UpdateTileForLayer(layerID, tileID, tileRect, updateInfo)); >-} >- >-void LayerTreeCoordinator::removeTile(CoordinatedLayerID layerID, uint32_t tileID) >-{ >- if (m_isPurging) >- return; >- m_shouldSyncFrame = true; >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveTileForLayer(layerID, tileID)); >-} >- >-void LayerTreeCoordinator::createUpdateAtlas(int atlasID, const ShareableSurface::Handle& handle) >-{ >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateUpdateAtlas(atlasID, handle)); >-} >- >-void LayerTreeCoordinator::removeUpdateAtlas(int atlasID) >-{ >- if (m_isPurging) >- return; >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveUpdateAtlas(atlasID)); >-} >- >-WebCore::IntRect LayerTreeCoordinator::visibleContentsRect() const >-{ >- return m_visibleContentsRect; >-} >- >- >-void LayerTreeCoordinator::setLayerAnimations(CoordinatedLayerID layerID, const GraphicsLayerAnimations& animations) >-{ >- m_shouldSyncFrame = true; >- GraphicsLayerAnimations activeAnimations = animations.getActiveAnimations(); >-#if ENABLE(CSS_SHADERS) >- for (size_t i = 0; i < activeAnimations.animations().size(); ++i) { >- const KeyframeValueList& keyframes = animations.animations().at(i).keyframes(); >- if (keyframes.property() != AnimatedPropertyWebkitFilter) >- continue; >- for (size_t j = 0; j < keyframes.size(); ++j) { >- const FilterAnimationValue* filterValue = static_cast<const FilterAnimationValue*>(keyframes.at(i)); >- checkCustomFilterProgramProxies(*filterValue->value()); >- } >- } >-#endif >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetLayerAnimations(layerID, activeAnimations)); >-} >- > void LayerTreeCoordinator::setVisibleContentsRect(const IntRect& rect, float scale, const FloatPoint& trajectoryVector) > { >- bool contentsRectDidChange = rect != m_visibleContentsRect; >- bool contentsScaleDidChange = scale != m_contentsScale; >- >- // A zero trajectoryVector indicates that tiles all around the viewport are requested. >- toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRectTrajectoryVector(trajectoryVector); >+ m_compositingCoordinator->setVisibleContentsRect(rect, scale, trajectoryVector); > >- if (contentsRectDidChange || contentsScaleDidChange) { >- m_visibleContentsRect = rect; >- m_contentsScale = scale; >- >- HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator end = m_registeredLayers.end(); >- for (HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it) { >- if (contentsScaleDidChange) >- (*it)->setContentsScale(scale); >- if (contentsRectDidChange) >- (*it)->adjustVisibleRect(); >- } >- } >- >- scheduleLayerFlush(); > if (m_webPage->useFixedLayout()) > m_webPage->setFixedVisibleContentRect(rect); >- if (contentsRectDidChange) >- m_shouldSendScrollPositionUpdate = true; > } > > GraphicsLayerFactory* LayerTreeCoordinator::graphicsLayerFactory() > { >- return this; >+ return m_compositingCoordinator.get(); > } > > #if ENABLE(REQUEST_ANIMATION_FRAME) > void LayerTreeCoordinator::scheduleAnimation() > { >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::RequestAnimationFrame()); >+ m_compositingCoordinatorMessageClient->requestAnimationFrame(); > } > > void LayerTreeCoordinator::animationFrameReady() >@@ -742,84 +221,17 @@ void LayerTreeCoordinator::animationFrameReady() > > void LayerTreeCoordinator::renderNextFrame() > { >- m_waitingForUIProcess = false; >- scheduleLayerFlush(); >- for (unsigned i = 0; i < m_updateAtlases.size(); ++i) >- m_updateAtlases[i]->didSwapBuffers(); >-} >- >-bool LayerTreeCoordinator::layerTreeTileUpdatesAllowed() const >-{ >- return !m_isSuspended && !m_waitingForUIProcess; >+ m_compositingCoordinator->renderNextFrame(); > } > > void LayerTreeCoordinator::purgeBackingStores() > { >- TemporaryChange<bool> purgingToggle(m_isPurging, true); >- >- HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator end = m_registeredLayers.end(); >- for (HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it) >- (*it)->purgeBackingStores(); >- >- m_imageBackings.clear(); >- m_updateAtlases.clear(); >-} >- >-PassOwnPtr<WebCore::GraphicsContext> LayerTreeCoordinator::beginContentUpdate(const WebCore::IntSize& size, ShareableBitmap::Flags flags, int& atlasID, WebCore::IntPoint& offset) >-{ >- OwnPtr<WebCore::GraphicsContext> graphicsContext; >- for (unsigned i = 0; i < m_updateAtlases.size(); ++i) { >- UpdateAtlas* atlas = m_updateAtlases[i].get(); >- if (atlas->flags() == flags) { >- // This will return null if there is no available buffer space. >- graphicsContext = atlas->beginPaintingOnAvailableBuffer(atlasID, size, offset); >- if (graphicsContext) >- return graphicsContext.release(); >- } >- } >- >- static const int ScratchBufferDimension = 1024; // Should be a power of two. >- m_updateAtlases.append(adoptPtr(new UpdateAtlas(this, ScratchBufferDimension, flags))); >- scheduleReleaseInactiveAtlases(); >- return m_updateAtlases.last()->beginPaintingOnAvailableBuffer(atlasID, size, offset); >-} >- >-const double ReleaseInactiveAtlasesTimerInterval = 0.5; >- >-void LayerTreeCoordinator::scheduleReleaseInactiveAtlases() >-{ >- if (!m_releaseInactiveAtlasesTimer.isActive()) >- m_releaseInactiveAtlasesTimer.startRepeating(ReleaseInactiveAtlasesTimerInterval); >-} >- >-void LayerTreeCoordinator::releaseInactiveAtlasesTimerFired(Timer<LayerTreeCoordinator>*) >-{ >- // We always want to keep one atlas for non-composited content. >- OwnPtr<UpdateAtlas> atlasToKeepAnyway; >- bool foundActiveAtlasForNonCompositedContent = false; >- for (int i = m_updateAtlases.size() - 1; i >= 0; --i) { >- UpdateAtlas* atlas = m_updateAtlases[i].get(); >- if (!atlas->isInUse()) >- atlas->addTimeInactive(ReleaseInactiveAtlasesTimerInterval); >- bool usableForNonCompositedContent = atlas->flags() == ShareableBitmap::NoFlags; >- if (atlas->isInactive()) { >- if (!foundActiveAtlasForNonCompositedContent && !atlasToKeepAnyway && usableForNonCompositedContent) >- atlasToKeepAnyway = m_updateAtlases[i].release(); >- m_updateAtlases.remove(i); >- } else if (usableForNonCompositedContent) >- foundActiveAtlasForNonCompositedContent = true; >- } >- >- if (!foundActiveAtlasForNonCompositedContent && atlasToKeepAnyway) >- m_updateAtlases.append(atlasToKeepAnyway.release()); >- >- if (m_updateAtlases.size() <= 1) >- m_releaseInactiveAtlasesTimer.stop(); >+ m_compositingCoordinator->purgeBackingStores(); > } > > void LayerTreeCoordinator::setBackgroundColor(const WebCore::Color& color) > { >- m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetBackgroundColor(color)); >+ m_compositingCoordinatorMessageClient->setBackgroundColor(color); > } > > } // namespace WebKit >diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h >index 268a8a91c24d26f3c2e9e972d8b5e74e927f485f..e884c02795d1f16b367ea09142b5db7e9f97b7ea 100644 >--- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h >+++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h >@@ -1,5 +1,6 @@ > /* > Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) >+ Copyright (C) 2012 Company 100, Inc. All rights reserved. > > This library is free software; you can redistribute it and/or > modify it under the terms of the GNU Library General Public >@@ -22,38 +23,28 @@ > > #if USE(COORDINATED_GRAPHICS) > >-#include "CoordinatedGraphicsLayer.h" >-#include "CoordinatedImageBacking.h" >+#include "CompositingCoordinator.h" > #include "LayerTreeContext.h" > #include "LayerTreeHost.h" >-#include "Timer.h" >-#include "UpdateAtlas.h" >-#include <WebCore/GraphicsLayerClient.h> >-#include <WebCore/GraphicsLayerFactory.h> >+#include "WebCompositingCoordinatorMessageClient.h" > #include <wtf/OwnPtr.h> >+#include <wtf/RefPtr.h> > >-#if ENABLE(CSS_SHADERS) >-#include "WebCustomFilterProgramProxy.h" >-#endif >+namespace WebCore { >+class GraphicsLayerFactory; >+} > > namespace WebKit { > > class UpdateInfo; > class WebPage; > >-class LayerTreeCoordinator : public LayerTreeHost, WebCore::GraphicsLayerClient >- , public CoordinatedGraphicsLayerClient >- , public CoordinatedImageBacking::Coordinator >- , public UpdateAtlasClient >- , public WebCore::GraphicsLayerFactory >-#if ENABLE(CSS_SHADERS) >- , WebCustomFilterProgramProxyClient >-#endif >-{ >+class LayerTreeCoordinator : public LayerTreeHost, public CompositingCoordinatorClient { > public: > static PassRefPtr<LayerTreeCoordinator> create(WebPage*); > virtual ~LayerTreeCoordinator(); > >+ // Reimplementations from LayerTreeHost > virtual const LayerTreeContext& layerTreeContext() { return m_layerTreeContext; } > virtual void setLayerFlushSchedulingEnabled(bool); > virtual void scheduleLayerFlush(); >@@ -73,132 +64,43 @@ public: > virtual void setPageOverlayOpacity(float); > virtual bool pageOverlayShouldApplyFadeWhenPainting() const { return false; } > >- virtual void pauseRendering() { m_isSuspended = true; } >- virtual void resumeRendering() { m_isSuspended = false; scheduleLayerFlush(); } >+ virtual void pauseRendering(); >+ virtual void resumeRendering(); > virtual void deviceScaleFactorDidChange() { } >- virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) OVERRIDE; > >- virtual void createTile(CoordinatedLayerID, uint32_t tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&); >- virtual void updateTile(CoordinatedLayerID, uint32_t tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&); >- virtual void removeTile(CoordinatedLayerID, uint32_t tileID); >- virtual WebCore::IntRect visibleContentsRect() const; > virtual void renderNextFrame(); > virtual void purgeBackingStores(); >- virtual bool layerTreeTileUpdatesAllowed() const; > virtual void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint&); > virtual void didReceiveLayerTreeCoordinatorMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&); > virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE; >- >- virtual void syncLayerState(CoordinatedLayerID, const CoordinatedLayerInfo&); >- virtual void syncLayerChildren(CoordinatedLayerID, const Vector<CoordinatedLayerID>&); >- virtual void setLayerAnimations(CoordinatedLayerID, const WebCore::GraphicsLayerAnimations&); >-#if ENABLE(CSS_FILTERS) >- virtual void syncLayerFilters(CoordinatedLayerID, const WebCore::FilterOperations&); >-#endif >-#if USE(GRAPHICS_SURFACE) >- virtual void createCanvas(CoordinatedLayerID, WebCore::PlatformLayer*) OVERRIDE; >- virtual void syncCanvas(CoordinatedLayerID, WebCore::PlatformLayer*) OVERRIDE; >- virtual void destroyCanvas(CoordinatedLayerID) OVERRIDE; >-#endif >- virtual void detachLayer(WebCore::CoordinatedGraphicsLayer*); >- virtual void syncFixedLayers(); >- >- virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, int& atlasID, WebCore::IntPoint&); >- >- // UpdateAtlasClient >- virtual void createUpdateAtlas(int atlasID, const ShareableSurface::Handle&); >- virtual void removeUpdateAtlas(int atlasID); >- > #if ENABLE(REQUEST_ANIMATION_FRAME) > virtual void scheduleAnimation() OVERRIDE; > #endif > virtual void setBackgroundColor(const WebCore::Color&) OVERRIDE; > >+ // Reimplementations from CompositingCoordinatorClient >+ virtual const WebCore::IntSize& viewSize() const OVERRIDE; >+ virtual void didPerformScheduledLayerFlush(bool didSync) OVERRIDE; >+ virtual bool isOpaqueContents() OVERRIDE; >+ virtual void layoutIfNeeded() OVERRIDE; >+ virtual void paintContents(WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) OVERRIDE; >+ virtual void paintOverlayContents(WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) OVERRIDE; >+ > protected: > explicit LayerTreeCoordinator(WebPage*); > > private: >- // GraphicsLayerClient >- virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time); >- virtual void notifyFlushRequired(const WebCore::GraphicsLayer*); >- virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect); >- >- // CoordinatedImageBacking::Coordinator >- virtual void createImageBacking(CoordinatedImageBackingID) OVERRIDE; >- virtual void updateImageBacking(CoordinatedImageBackingID, const ShareableSurface::Handle&) OVERRIDE; >- virtual void clearImageBackingContents(CoordinatedImageBackingID) OVERRIDE; >- virtual void removeImageBacking(CoordinatedImageBackingID) OVERRIDE; >- >- void flushPendingImageBackingChanges(); >- >- // GraphicsLayerFactory >- virtual PassOwnPtr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayerClient*) OVERRIDE; >- >- // LayerTreeCoordinator >- void createPageOverlayLayer(); >- void destroyPageOverlayLayer(); >- bool flushPendingLayerChanges(); >- void cancelPendingLayerFlush(); >- void performScheduledLayerFlush(); >- void didPerformScheduledLayerFlush(); >- void syncDisplayState(); >- void lockAnimations(); >- void unlockAnimations(); >- >- void layerFlushTimerFired(WebCore::Timer<LayerTreeCoordinator>*); >- >- void scheduleReleaseInactiveAtlases(); > #if ENABLE(REQUEST_ANIMATION_FRAME) > void animationFrameReady(); > #endif > >- void releaseInactiveAtlasesTimerFired(WebCore::Timer<LayerTreeCoordinator>*); >- >-#if ENABLE(CSS_SHADERS) >- // WebCustomFilterProgramProxyClient >- void removeCustomFilterProgramProxy(WebCustomFilterProgramProxy*); >- >- void checkCustomFilterProgramProxies(const WebCore::FilterOperations&); >- void disconnectCustomFilterPrograms(); >-#endif >- >- OwnPtr<WebCore::GraphicsLayer> m_rootLayer; >- >- // The layer which contains all non-composited content. >- OwnPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer; >- >- // The page overlay layer. Will be null if there's no page overlay. >- OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer; >- >- HashSet<WebCore::CoordinatedGraphicsLayer*> m_registeredLayers; >- Vector<CoordinatedLayerID> m_detachedLayers; >- typedef HashMap<CoordinatedImageBackingID, RefPtr<CoordinatedImageBacking> > ImageBackingMap; >- ImageBackingMap m_imageBackings; >- Vector<OwnPtr<UpdateAtlas> > m_updateAtlases; >- >-#if ENABLE(CSS_SHADERS) >- HashSet<WebCustomFilterProgramProxy*> m_customFilterPrograms; >-#endif >+ RefPtr<WebCompositingCoordinatorMessageClient> m_compositingCoordinatorMessageClient; >+ OwnPtr<CompositingCoordinator> m_compositingCoordinator; > > bool m_notifyAfterScheduledLayerFlush; >- bool m_isValid; >- // We don't send the messages related to releasing resources to UI Process during purging, because UI Process already had removed all resources. >- bool m_isPurging; >- >- bool m_waitingForUIProcess; >- bool m_isSuspended; >- WebCore::IntRect m_visibleContentsRect; >- float m_contentsScale; >- bool m_shouldSendScrollPositionUpdate; > > LayerTreeContext m_layerTreeContext; >- bool m_shouldSyncFrame; >- bool m_shouldSyncRootLayer; >- WebCore::Timer<LayerTreeCoordinator> m_layerFlushTimer; >- WebCore::Timer<LayerTreeCoordinator> m_releaseInactiveAtlasesTimer; >- bool m_layerFlushSchedulingEnabled; > uint64_t m_forceRepaintAsyncCallbackID; >- bool m_animationsLocked; > }; > > } >diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/WebCompositingCoordinatorMessageClient.cpp b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/WebCompositingCoordinatorMessageClient.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..9f9ccaebaba0e5db239b1d305bd17425897b348b >--- /dev/null >+++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/WebCompositingCoordinatorMessageClient.cpp >@@ -0,0 +1,263 @@ >+/* >+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). >+ * Copyright (C) 2012 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 "config.h" >+ >+#if USE(COORDINATED_GRAPHICS) >+ >+#include "WebCompositingCoordinatorMessageClient.h" >+ >+#include "CoordinatedGraphicsArgumentCoders.h" >+#include "LayerTreeCoordinatorProxyMessages.h" >+#include "MessageID.h" >+#include "SurfaceUpdateInfo.h" >+#include "WebCoreArgumentCoders.h" >+#include "WebPage.h" >+#include "WebPageProxyMessages.h" >+ >+#if ENABLE(CSS_SHADERS) >+#include "CustomFilterValidatedProgram.h" >+#include "ValidatedCustomFilterOperation.h" >+#endif >+ >+using namespace WebCore; >+ >+namespace WebKit { >+ >+PassRefPtr<WebCompositingCoordinatorMessageClient> WebCompositingCoordinatorMessageClient::create(WebPage* webPage) >+{ >+ return adoptRef(new WebCompositingCoordinatorMessageClient(webPage)); >+} >+ >+WebCompositingCoordinatorMessageClient::~WebCompositingCoordinatorMessageClient() >+{ >+#if ENABLE(CSS_SHADERS) >+ disconnectCustomFilterPrograms(); >+#endif >+} >+ >+WebCompositingCoordinatorMessageClient::WebCompositingCoordinatorMessageClient(WebPage* webPage) >+ : m_webPage(webPage) >+{ >+ >+} >+ >+void WebCompositingCoordinatorMessageClient::setRootCompositingLayer(CoordinatedLayerID id) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetRootCompositingLayer(id)); >+} >+ >+void WebCompositingCoordinatorMessageClient::setCompositingLayerState(CoordinatedLayerID id, const CoordinatedLayerInfo& info) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetCompositingLayerState(id, info)); >+} >+ >+void WebCompositingCoordinatorMessageClient::setCompositingLayerChildren(CoordinatedLayerID id, const Vector<CoordinatedLayerID>& children) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetCompositingLayerChildren(id, children)); >+} >+ >+#if ENABLE(CSS_FILTERS) >+void WebCompositingCoordinatorMessageClient::setCompositingLayerFilters(CoordinatedLayerID id, const FilterOperations& filters) >+{ >+#if ENABLE(CSS_SHADERS) >+ checkCustomFilterProgramProxies(filters); >+#endif >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetCompositingLayerFilters(id, filters)); >+} >+#endif >+ >+void WebCompositingCoordinatorMessageClient::deleteCompositingLayer(CoordinatedLayerID id) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::DeleteCompositingLayer(id)); >+} >+ >+void WebCompositingCoordinatorMessageClient::createTileForLayer(CoordinatedLayerID layerID, uint32_t tileID, const IntRect& tileRect, const SurfaceUpdateInfo& updateInfo) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateTileForLayer(layerID, tileID, tileRect, updateInfo)); >+} >+ >+void WebCompositingCoordinatorMessageClient::updateTileForLayer(CoordinatedLayerID layerID, uint32_t tileID, const IntRect& tileRect, const SurfaceUpdateInfo& updateInfo) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::UpdateTileForLayer(layerID, tileID, tileRect, updateInfo)); >+} >+ >+void WebCompositingCoordinatorMessageClient::removeTileForLayer(CoordinatedLayerID layerID, uint32_t tileID) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveTileForLayer(layerID, tileID)); >+} >+ >+void WebCompositingCoordinatorMessageClient::createUpdateAtlas(int atlasID, const ShareableSurface::Handle& handle) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateUpdateAtlas(atlasID, handle)); >+} >+ >+void WebCompositingCoordinatorMessageClient::removeUpdateAtlas(int atlasID) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveUpdateAtlas(atlasID)); >+} >+ >+void WebCompositingCoordinatorMessageClient::createImageBacking(CoordinatedImageBackingID imageID) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateImageBacking(imageID)); >+} >+ >+void WebCompositingCoordinatorMessageClient::updateImageBacking(CoordinatedImageBackingID imageID, const ShareableSurface::Handle& handle) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::UpdateImageBacking(imageID, handle)); >+} >+ >+void WebCompositingCoordinatorMessageClient::clearImageBackingContents(CoordinatedImageBackingID imageID) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::ClearImageBackingContents(imageID)); >+} >+ >+void WebCompositingCoordinatorMessageClient::removeImageBacking(CoordinatedImageBackingID imageID) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveImageBacking(imageID)); >+} >+ >+void WebCompositingCoordinatorMessageClient::didRenderFrame(const IntSize& contentsSize, const IntRect& coveredRect) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::DidRenderFrame(contentsSize, coveredRect)); >+} >+ >+void WebCompositingCoordinatorMessageClient::didChangeScrollPosition(const IntPoint& position) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::DidChangeScrollPosition(position)); >+} >+ >+#if USE(GRAPHICS_SURFACE) >+void WebCompositingCoordinatorMessageClient::createCanvas(CoordinatedLayerID id, const IntSize& canvasSize, const GraphicsSurfaceToken& token) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateCanvas(id, canvasSize, token)); >+} >+ >+void WebCompositingCoordinatorMessageClient::syncCanvas(CoordinatedLayerID id, uint32_t frontBuffer) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::SyncCanvas(id, frontBuffer)); >+} >+ >+void WebCompositingCoordinatorMessageClient::destroyCanvas(CoordinatedLayerID id) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::DestroyCanvas(id)); >+} >+#endif >+ >+void WebCompositingCoordinatorMessageClient::setLayerAnimations(CoordinatedLayerID layerID, const GraphicsLayerAnimations& activeAnimations) >+{ >+#if ENABLE(CSS_SHADERS) >+ for (size_t i = 0; i < activeAnimations.animations().size(); ++i) { >+ const KeyframeValueList& keyframes = activeAnimations.animations().at(i).keyframes(); >+ if (keyframes.property() != AnimatedPropertyWebkitFilter) >+ continue; >+ for (size_t j = 0; j < keyframes.size(); ++j) { >+ const FilterAnimationValue* filterValue = static_cast<const FilterAnimationValue*>(keyframes.at(i)); >+ checkCustomFilterProgramProxies(*filterValue->value()); >+ } >+ } >+#endif >+ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetLayerAnimations(layerID, activeAnimations)); >+} >+ >+void WebCompositingCoordinatorMessageClient::setAnimationsLocked(bool isLocked) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetAnimationsLocked(isLocked)); >+} >+ >+void WebCompositingCoordinatorMessageClient::setBackgroundColor(const WebCore::Color& color) >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetBackgroundColor(color)); >+} >+ >+#if ENABLE(REQUEST_ANIMATION_FRAME) >+void WebCompositingCoordinatorMessageClient::requestAnimationFrame() >+{ >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::RequestAnimationFrame()); >+} >+#endif >+ >+void WebCompositingCoordinatorMessageClient::invokeForceRepaintAsyncCallback(uint64_t callbackID) >+{ >+ m_webPage->send(Messages::WebPageProxy::VoidCallback(callbackID)); >+} >+ >+#if ENABLE(CSS_SHADERS) >+void WebCompositingCoordinatorMessageClient::checkCustomFilterProgramProxies(const FilterOperations& filters) >+{ >+ // We need to create the WebCustomFilterProgramProxy objects before we get to serialize the >+ // custom filters to the other process. That's because WebCustomFilterProgramProxy needs >+ // to link back to the coordinator, so that we can send a message to the UI process when >+ // the program is not needed anymore. >+ // Note that the serialization will only happen at a later time in ArgumentCoder<WebCore::FilterOperations>::encode. >+ // At that point the program will only be serialized once. All the other times it will only use the ID of the program. >+ for (size_t i = 0; i < filters.size(); ++i) { >+ const FilterOperation* operation = filters.at(i); >+ if (operation->getOperationType() != FilterOperation::VALIDATED_CUSTOM) >+ continue; >+ const ValidatedCustomFilterOperation* customOperation = static_cast<const ValidatedCustomFilterOperation*>(operation); >+ ASSERT(customOperation->validatedProgram()->isInitialized()); >+ TextureMapperPlatformCompiledProgram* program = customOperation->validatedProgram()->platformCompiledProgram(); >+ >+ RefPtr<WebCustomFilterProgramProxy> customFilterProgramProxy; >+ if (program->client()) >+ customFilterProgramProxy = static_cast<WebCustomFilterProgramProxy*>(program->client()); >+ else { >+ customFilterProgramProxy = WebCustomFilterProgramProxy::create(); >+ program->setClient(customFilterProgramProxy); >+ } >+ >+ if (!customFilterProgramProxy->client()) { >+ customFilterProgramProxy->setClient(this); >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateCustomFilterProgram(customFilterProgramProxy->id(), customOperation->validatedProgram()->validatedProgramInfo())); >+ } else { >+ // If the client was not disconnected then this coordinator must be the client for it. >+ ASSERT(customFilterProgramProxy->client() == this); >+ } >+ } >+} >+ >+void WebCompositingCoordinatorMessageClient::removeCustomFilterProgramProxy(WebCustomFilterProgramProxy* customFilterProgramProxy) >+{ >+ // At this time the shader is not needed anymore, so we remove it from our set and >+ // send a message to the other process to delete it. >+ m_customFilterPrograms.remove(customFilterProgramProxy); >+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveCustomFilterProgram(customFilterProgramProxy->id())); >+} >+ >+void WebCompositingCoordinatorMessageClient::disconnectCustomFilterPrograms() >+{ >+ // Make sure that WebCore will not call into this coordinator anymore. >+ HashSet<WebCustomFilterProgramProxy*>::iterator iter = m_customFilterPrograms.begin(); >+ for (; iter != m_customFilterPrograms.end(); ++iter) >+ (*iter)->setClient(0); >+} >+#endif >+ >+} // namespace WebKit >+ >+#endif // USE(COORDINATED_GRAPHICS) >diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/WebCompositingCoordinatorMessageClient.h b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/WebCompositingCoordinatorMessageClient.h >new file mode 100644 >index 0000000000000000000000000000000000000000..be21533cf141e82493516fa25b3ac8baa22ccc90 >--- /dev/null >+++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/WebCompositingCoordinatorMessageClient.h >@@ -0,0 +1,116 @@ >+/* >+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). >+ * Copyright (C) 2012 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 WebCompositingCoordinatorMessageClient_h >+#define WebCompositingCoordinatorMessageClient_h >+ >+#if USE(COORDINATED_GRAPHICS) >+ >+#include "CompositingCoordinatorClient.h" >+ >+#if ENABLE(CSS_SHADERS) >+#include "WebCustomFilterProgramProxy.h" >+#endif >+ >+namespace WebKit { >+ >+class WebPage; >+ >+class WebCompositingCoordinatorMessageClient : public RefCounted<WebCompositingCoordinatorMessageClient> >+ , public CompositingCoordinatorMessageClient >+#if ENABLE(CSS_SHADERS) >+ , WebCustomFilterProgramProxyClient >+#endif >+{ >+ WTF_MAKE_NONCOPYABLE(WebCompositingCoordinatorMessageClient); WTF_MAKE_FAST_ALLOCATED; >+public: >+ static PassRefPtr<WebCompositingCoordinatorMessageClient> create(WebPage*); >+ >+ ~WebCompositingCoordinatorMessageClient(); >+ >+ // CompositingCoordinatorMessageClient >+ virtual void setRootCompositingLayer(CoordinatedLayerID) OVERRIDE; >+ virtual void setCompositingLayerState(CoordinatedLayerID, const CoordinatedLayerInfo&) OVERRIDE; >+ virtual void setCompositingLayerChildren(CoordinatedLayerID, const Vector<CoordinatedLayerID>&) OVERRIDE; >+#if ENABLE(CSS_FILTERS) >+ virtual void setCompositingLayerFilters(CoordinatedLayerID, const WebCore::FilterOperations&) OVERRIDE; >+#endif >+ virtual void deleteCompositingLayer(CoordinatedLayerID) OVERRIDE; >+ >+ virtual void createTileForLayer(CoordinatedLayerID, uint32_t tileID, const WebCore::IntRect&, const SurfaceUpdateInfo&) OVERRIDE; >+ virtual void updateTileForLayer(CoordinatedLayerID, uint32_t tileID, const WebCore::IntRect&, const SurfaceUpdateInfo&) OVERRIDE; >+ virtual void removeTileForLayer(CoordinatedLayerID, uint32_t tileID) OVERRIDE; >+ >+ virtual void createUpdateAtlas(int atlasID, const ShareableSurface::Handle&) OVERRIDE; >+ virtual void removeUpdateAtlas(int atlasID) OVERRIDE; >+ >+ virtual void createImageBacking(CoordinatedImageBackingID) OVERRIDE; >+ virtual void updateImageBacking(CoordinatedImageBackingID, const ShareableSurface::Handle&) OVERRIDE; >+ virtual void clearImageBackingContents(CoordinatedImageBackingID) OVERRIDE; >+ virtual void removeImageBacking(CoordinatedImageBackingID) OVERRIDE; >+ >+ virtual void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect) OVERRIDE; >+ virtual void didChangeScrollPosition(const WebCore::IntPoint& position) OVERRIDE; >+ >+#if USE(GRAPHICS_SURFACE) >+ virtual void createCanvas(CoordinatedLayerID, const WebCore::IntSize&, const WebCore::GraphicsSurfaceToken&) OVERRIDE; >+ virtual void syncCanvas(CoordinatedLayerID, uint32_t frontBuffer) OVERRIDE; >+ virtual void destroyCanvas(CoordinatedLayerID) OVERRIDE; >+#endif >+ >+ virtual void setLayerAnimations(CoordinatedLayerID, const WebCore::GraphicsLayerAnimations&) OVERRIDE; >+ virtual void setAnimationsLocked(bool) OVERRIDE; >+ >+ void setBackgroundColor(const WebCore::Color&); >+ >+#if ENABLE(REQUEST_ANIMATION_FRAME) >+ void requestAnimationFrame(); >+#endif >+ void invokeForceRepaintAsyncCallback(uint64_t callbackID); >+ >+private: >+ explicit WebCompositingCoordinatorMessageClient(WebPage*); >+ >+#if ENABLE(CSS_SHADERS) >+ // WebCustomFilterProgramProxyClient >+ void removeCustomFilterProgramProxy(WebCustomFilterProgramProxy*); >+ >+ void checkCustomFilterProgramProxies(const WebCore::FilterOperations& filters) OVERRIDE; >+ void disconnectCustomFilterPrograms(); >+#endif >+ >+ WebPage* m_webPage; >+ >+#if ENABLE(CSS_SHADERS) >+ HashSet<WebCustomFilterProgramProxy*> m_customFilterPrograms; >+#endif >+}; >+ >+} // namespace WebKit >+ >+#endif >+ >+#endif // WebCompositingCoordinatorMessageClient_h
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 104360
:
178194
|
178339
|
178512
|
178863
|
182305
|
192909
|
193083
|
203804
|
203920
|
204012
|
204024
|
204029
|
205472
|
205548
|
205715