Changeset 202621 in webkit
- Timestamp:
- Jun 29, 2016 5:16:41 AM (8 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r202612 r202621 1 2016-06-29 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Too much duplicated code in LayerTreeHosts implementations 4 https://bugs.webkit.org/show_bug.cgi?id=159144 5 6 Reviewed by Žan Doberšek. 7 8 There's some code common and duplicated in all current LayerTreeHosts implementations (Gtk, Coordinated, and 9 ThreadedCoordinated). The thing is even worse in the case of ThreadedCoordinated and Coordinated, where the 10 former is actually a special case of the later, and it seems like code was copy pasted and then modified to add 11 ThreadedCoordinated specific code. The problem of that approach, apart from the code duplication, is that common 12 parts end up diverging too. This patch moves the common parts to the base class LayerTreeHost and makes 13 ThreadedCoordinatedLayerTreeHost inherit from CoordinatedLayerTreeHost, to share the common code and simply add 14 the specific one. 15 16 * PlatformGTK.cmake: 17 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.h: 18 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp: 19 (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost): 20 (WebKit::CoordinatedLayerTreeHost::scheduleLayerFlush): 21 (WebKit::CoordinatedLayerTreeHost::setViewOverlayRootLayer): 22 (WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer): 23 (WebKit::CoordinatedLayerTreeHost::invalidate): 24 (WebKit::CoordinatedLayerTreeHost::sizeDidChange): 25 (WebKit::CoordinatedLayerTreeHost::layerFlushTimerFired): 26 (WebKit::CoordinatedLayerTreeHost::commitSceneState): 27 (WebKit::CoordinatedLayerTreeHost::createCoordinatedSurface): 28 (WebKit::CoordinatedLayerTreeHost::cancelPendingLayerFlush): Deleted. 29 (WebKit::CoordinatedLayerTreeHost::forceRepaint): Deleted. 30 (WebKit::CoordinatedLayerTreeHost::forceRepaintAsync): Deleted. 31 (WebKit::CoordinatedLayerTreeHost::didFlushRootLayer): Deleted. 32 (WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): Deleted. 33 (WebKit::CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged): Deleted. 34 (WebKit::CoordinatedLayerTreeHost::graphicsLayerFactory): Deleted. 35 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h: 36 * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp: 37 (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): 38 (WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): 39 (WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange): 40 (WebKit::ThreadedCoordinatedLayerTreeHost::setVisibleContentsRect): 41 (WebKit::ThreadedCoordinatedLayerTreeHost::commitSceneState): 42 (WebKit::ThreadedCoordinatedLayerTreeHost::create): Deleted. 43 (WebKit::ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents): Deleted. 44 (WebKit::ThreadedCoordinatedLayerTreeHost::contentsSizeChanged): Deleted. 45 (WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewportProperties): Deleted. 46 (WebKit::ThreadedCoordinatedLayerTreeHost::didScaleFactorChanged): Deleted. 47 (WebKit::ThreadedCoordinatedLayerTreeHost::setNativeSurfaceHandleForCompositing): Deleted. 48 * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h: 49 * WebProcess/WebPage/DrawingArea.h: 50 (WebKit::DrawingArea::layerHostDidFlushLayers): 51 * WebProcess/WebPage/DrawingAreaImpl.h: 52 * WebProcess/WebPage/LayerTreeHost.cpp: 53 (WebKit::LayerTreeHost::~LayerTreeHost): 54 (WebKit::LayerTreeHost::setLayerFlushSchedulingEnabled): 55 (WebKit::LayerTreeHost::pauseRendering): 56 (WebKit::LayerTreeHost::resumeRendering): 57 (WebKit::LayerTreeHost::invalidate): 58 * WebProcess/WebPage/LayerTreeHost.h: 59 (WebKit::LayerTreeHost::layerTreeContext): 60 (WebKit::LayerTreeHost::setShouldNotifyAfterNextScheduledLayerFlush): 61 (WebKit::LayerTreeHost::setNonCompositedContentsNeedDisplay): 62 (WebKit::LayerTreeHost::setNonCompositedContentsNeedDisplayInRect): 63 (WebKit::LayerTreeHost::scrollNonCompositedContents): 64 (WebKit::LayerTreeHost::graphicsLayerFactory): 65 (WebKit::LayerTreeHost::contentsSizeChanged): 66 (WebKit::LayerTreeHost::didChangeViewportProperties): 67 (WebKit::LayerTreeHost::setNativeSurfaceHandleForCompositing): 68 (WebKit::LayerTreeHost::setViewOverlayRootLayer): 69 (WebKit::LayerTreeHost::forceRepaintAsync): Deleted. 70 * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp: 71 (WebKit::LayerTreeHostGtk::invalidate): 72 (WebKit::LayerTreeHostGtk::setViewOverlayRootLayer): 73 (WebKit::LayerTreeHostGtk::LayerTreeHostGtk): Deleted. 74 (WebKit::LayerTreeHostGtk::setRootCompositingLayer): Deleted. 75 (WebKit::LayerTreeHostGtk::setNonCompositedContentsNeedDisplay): Deleted. 76 (WebKit::LayerTreeHostGtk::scrollNonCompositedContents): Deleted. 77 (WebKit::LayerTreeHostGtk::setNativeSurfaceHandleForCompositing): Deleted. 78 * WebProcess/WebPage/gtk/LayerTreeHostGtk.h: 79 1 80 2016-06-28 Commit Queue <commit-queue@webkit.org> 2 81 -
trunk/Source/WebKit2/PlatformGTK.cmake
r200621 r202621 827 827 Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 828 828 829 WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp 829 830 WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp 830 831 ) -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp
r202611 r202621 349 349 return; 350 350 351 CoordinatedLayerTreeHost* coordinatedLayerTreeHost = static_cast<CoordinatedLayerTreeHost*>(m_layerTreeHost.get()); 352 coordinatedLayerTreeHost->setViewOverlayRootLayer(viewOverlayRootLayer); 351 m_layerTreeHost->setViewOverlayRootLayer(viewOverlayRootLayer); 353 352 } 354 353 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.h
r202611 r202621 42 42 virtual ~CoordinatedDrawingArea(); 43 43 44 void layerHostDidFlushLayers();45 46 44 private: 47 45 // DrawingArea … … 69 67 void viewStateDidChange(WebCore::ViewState::Flags, bool /* wantsDidUpdateViewState */, const Vector<uint64_t>& /* callbackIDs */) override; 70 68 void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override; 69 70 void layerHostDidFlushLayers() override; 71 71 72 72 // IPC message handlers. -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
r201802 r202621 31 31 #include "CoordinatedLayerTreeHost.h" 32 32 33 #include "CoordinatedDrawingArea.h" 34 #include "CoordinatedGraphicsArgumentCoders.h" 35 #include "CoordinatedLayerTreeHostProxyMessages.h" 36 #include "GraphicsContext.h" 33 #include "DrawingArea.h" 37 34 #include "WebCoordinatedSurface.h" 38 #include "WebCoreArgumentCoders.h"39 35 #include "WebPage.h" 40 36 #include "WebPageProxyMessages.h" 41 #include <WebCore/Frame.h>42 37 #include <WebCore/FrameView.h> 43 38 #include <WebCore/MainFrame.h> 44 39 #include <WebCore/PageOverlayController.h> 45 #include <WebCore/Settings.h> 46 #include <wtf/CurrentTime.h> 40 41 #if USE(COORDINATED_GRAPHICS_THREADED) 42 #include "ThreadSafeCoordinatedSurface.h" 43 #elif USE(COORDINATED_GRAPHICS_MULTIPROCESS) 44 #include "CoordinatedGraphicsArgumentCoders.h" 45 #include "CoordinatedLayerTreeHostProxyMessages.h" 46 #include "WebCoreArgumentCoders.h" 47 #endif 47 48 48 49 using namespace WebCore; … … 61 62 CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage& webPage) 62 63 : LayerTreeHost(webPage) 63 , m_notifyAfterScheduledLayerFlush(false) 64 , m_isValid(true) 65 , m_isSuspended(false) 66 , m_isWaitingForRenderer(true) 67 , m_layerFlushTimer(*this, &CoordinatedLayerTreeHost::layerFlushTimerFired) 68 , m_layerFlushSchedulingEnabled(true) 69 , m_forceRepaintAsyncCallbackID(0) 70 , m_viewOverlayRootLayer(nullptr) 71 { 72 m_coordinator = std::make_unique<CompositingCoordinator>(m_webPage.corePage(), this); 73 64 , m_coordinator(std::make_unique<CompositingCoordinator>(webPage.corePage(), this)) 65 , m_layerFlushTimer(RunLoop::main(), this, &CoordinatedLayerTreeHost::layerFlushTimerFired) 66 { 74 67 m_coordinator->createRootLayer(m_webPage.size()); 68 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS) 75 69 m_layerTreeContext.contextID = toCoordinatedGraphicsLayer(m_coordinator->rootLayer())->id(); 70 #endif 76 71 77 72 CoordinatedSurface::setFactory(createCoordinatedSurface); 78 79 scheduleLayerFlush(); 80 } 81 82 void CoordinatedLayerTreeHost::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled) 83 { 84 if (m_layerFlushSchedulingEnabled == layerFlushingEnabled) 85 return; 86 87 m_layerFlushSchedulingEnabled = layerFlushingEnabled; 88 89 if (m_layerFlushSchedulingEnabled) { 90 scheduleLayerFlush(); 91 return; 92 } 93 73 scheduleLayerFlush(); 74 } 75 76 void CoordinatedLayerTreeHost::scheduleLayerFlush() 77 { 78 if (!m_layerFlushSchedulingEnabled) 79 return; 80 81 if (!m_layerFlushTimer.isActive()) 82 m_layerFlushTimer.startOneShot(0); 83 } 84 85 void CoordinatedLayerTreeHost::cancelPendingLayerFlush() 86 { 87 m_layerFlushTimer.stop(); 88 } 89 90 void CoordinatedLayerTreeHost::setViewOverlayRootLayer(GraphicsLayer* viewOverlayRootLayer) 91 { 92 LayerTreeHost::setViewOverlayRootLayer(viewOverlayRootLayer); 93 m_coordinator->setViewOverlayRootLayer(viewOverlayRootLayer); 94 } 95 96 void CoordinatedLayerTreeHost::setRootCompositingLayer(GraphicsLayer* graphicsLayer) 97 { 98 m_coordinator->setRootCompositingLayer(graphicsLayer); 99 } 100 101 void CoordinatedLayerTreeHost::invalidate() 102 { 94 103 cancelPendingLayerFlush(); 95 } 96 97 void CoordinatedLayerTreeHost::scheduleLayerFlush() 98 { 99 if (!m_layerFlushSchedulingEnabled) 100 return; 101 102 if (!m_layerFlushTimer.isActive() || m_layerFlushTimer.nextFireInterval() > 0) 103 m_layerFlushTimer.startOneShot(0); 104 } 105 106 void CoordinatedLayerTreeHost::cancelPendingLayerFlush() 107 { 108 m_layerFlushTimer.stop(); 109 } 110 111 void CoordinatedLayerTreeHost::setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush) 112 { 113 m_notifyAfterScheduledLayerFlush = notifyAfterScheduledLayerFlush; 114 } 115 116 void CoordinatedLayerTreeHost::setViewOverlayRootLayer(WebCore::GraphicsLayer* viewOverlayRootLayer) 117 { 118 m_viewOverlayRootLayer = viewOverlayRootLayer; 119 m_coordinator->setViewOverlayRootLayer(viewOverlayRootLayer); 120 } 121 122 void CoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer) 123 { 124 m_coordinator->setRootCompositingLayer(graphicsLayer); 125 } 126 127 void CoordinatedLayerTreeHost::invalidate() 128 { 129 cancelPendingLayerFlush(); 130 131 ASSERT(m_isValid); 104 132 105 m_coordinator->clearRootLayer(); 133 m_isValid = false;106 LayerTreeHost::invalidate(); 134 107 } 135 108 … … 159 132 } 160 133 161 void CoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize)134 void CoordinatedLayerTreeHost::sizeDidChange(const IntSize& newSize) 162 135 { 163 136 m_coordinator->sizeDidChange(newSize); … … 190 163 } 191 164 192 void CoordinatedLayerTreeHost:: performScheduledLayerFlush()165 void CoordinatedLayerTreeHost::layerFlushTimerFired() 193 166 { 194 167 if (m_isSuspended || m_isWaitingForRenderer) … … 208 181 209 182 if (m_notifyAfterScheduledLayerFlush && didSync) { 210 static_cast<CoordinatedDrawingArea*>(m_webPage.drawingArea())->layerHostDidFlushLayers();183 m_webPage.drawingArea()->layerHostDidFlushLayers(); 211 184 m_notifyAfterScheduledLayerFlush = false; 212 185 } 213 186 } 214 187 215 void CoordinatedLayerTreeHost::layerFlushTimerFired()216 {217 performScheduledLayerFlush();218 }219 220 188 void CoordinatedLayerTreeHost::paintLayerContents(const GraphicsLayer*, GraphicsContext&, const IntRect&) 221 189 { 222 190 } 223 191 224 void CoordinatedLayerTreeHost::commitSceneState(const WebCore::CoordinatedGraphicsState& state) 225 { 192 void CoordinatedLayerTreeHost::commitSceneState(const CoordinatedGraphicsState& state) 193 { 194 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS) 226 195 m_webPage.send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(state)); 196 #endif 227 197 m_isWaitingForRenderer = true; 228 198 } … … 230 200 RefPtr<CoordinatedSurface> CoordinatedLayerTreeHost::createCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags) 231 201 { 202 #if USE(COORDINATED_GRAPHICS_THREADED) 203 return ThreadSafeCoordinatedSurface::create(size, flags); 204 #elif USE(COORDINATED_GRAPHICS_MULTIPROCESS) 232 205 return WebCoordinatedSurface::create(size, flags); 206 #else 207 UNUSED_PARAM(size); 208 UNUSED_PARAM(flags); 209 return nullptr; 210 #endif 233 211 } 234 212 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h
r201802 r202621 24 24 #if USE(COORDINATED_GRAPHICS) 25 25 26 #include "LayerTreeContext.h"27 26 #include "LayerTreeHost.h" 28 27 #include <WebCore/CompositingCoordinator.h> 29 #include <WebCore/GraphicsLayerFactory.h> 30 #include <wtf/HashSet.h> 28 #include <wtf/RunLoop.h> 31 29 32 30 namespace WebCore { 33 31 class CoordinatedSurface; 32 class GraphicsLayerFactory; 34 33 } 35 34 … … 44 43 virtual ~CoordinatedLayerTreeHost(); 45 44 46 const LayerTreeContext& layerTreeContext() override { return m_layerTreeContext; } 47 void setLayerFlushSchedulingEnabled(bool) override; 45 protected: 46 explicit CoordinatedLayerTreeHost(WebPage&); 47 48 48 void scheduleLayerFlush() override; 49 void setShouldNotifyAfterNextScheduledLayerFlush(bool) override;49 void cancelPendingLayerFlush() override; 50 50 void setRootCompositingLayer(WebCore::GraphicsLayer*) override; 51 51 void invalidate() override; 52 52 53 void setNonCompositedContentsNeedDisplay() override { }54 void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) override { }55 void scrollNonCompositedContents(const WebCore::IntRect&) override { }56 53 void forceRepaint() override; 57 54 bool forceRepaintAsync(uint64_t callbackID) override; 58 55 void sizeDidChange(const WebCore::IntSize& newSize) override; 59 56 60 void pauseRendering() override { m_isSuspended = true; }61 void resumeRendering() override { m_isSuspended = false; scheduleLayerFlush(); }62 57 void deviceOrPageScaleFactorChanged() override; 63 58 void pageBackgroundTransparencyChanged() override; 64 59 65 void didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection&, IPC::MessageDecoder&) override; 60 void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&); 61 void renderNextFrame(); 62 void purgeBackingStores(); 63 void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset); 64 66 65 WebCore::GraphicsLayerFactory* graphicsLayerFactory() override; 67 WebCore::CoordinatedGraphicsLayer* mainContentsLayer();68 66 69 67 #if ENABLE(REQUEST_ANIMATION_FRAME) … … 73 71 void setViewOverlayRootLayer(WebCore::GraphicsLayer*) override; 74 72 75 static RefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);76 77 protected:78 explicit CoordinatedLayerTreeHost(WebPage&);79 80 private:81 // CoordinatedLayerTreeHost82 void cancelPendingLayerFlush();83 void performScheduledLayerFlush();84 void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&);85 void renderNextFrame();86 void purgeBackingStores();87 void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset);88 89 void layerFlushTimerFired();90 91 73 // CompositingCoordinator::Client 92 74 void didFlushRootLayer(const WebCore::FloatRect& visibleContentRect) override; … … 95 77 void paintLayerContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) override; 96 78 79 private: 80 void layerFlushTimerFired(); 81 82 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS) 83 void didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection&, IPC::MessageDecoder&) override; 84 #endif 85 86 static RefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags); 87 97 88 std::unique_ptr<WebCore::CompositingCoordinator> m_coordinator; 98 99 bool m_notifyAfterScheduledLayerFlush; 100 bool m_isValid; 101 bool m_isSuspended; 102 bool m_isWaitingForRenderer; 103 104 LayerTreeContext m_layerTreeContext; 105 106 WebCore::Timer m_layerFlushTimer; 107 bool m_layerFlushSchedulingEnabled; 108 uint64_t m_forceRepaintAsyncCallbackID; 109 110 WebCore::GraphicsLayer* m_viewOverlayRootLayer; 89 bool m_isWaitingForRenderer { true }; 90 uint64_t m_forceRepaintAsyncCallbackID { 0 }; 91 RunLoop::Timer<CoordinatedLayerTreeHost> m_layerFlushTimer; 111 92 }; 112 93 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp
r202611 r202621 31 31 32 32 #if USE(COORDINATED_GRAPHICS_THREADED) 33 34 #include "DrawingAreaImpl.h"35 #include "NotImplemented.h"36 #include "ThreadSafeCoordinatedSurface.h"37 33 #include "WebPage.h" 38 #include <WebCore/CoordinatedGraphicsLayer.h>39 #include <WebCore/CoordinatedGraphicsState.h>40 #include <WebCore/Frame.h>41 34 #include <WebCore/FrameView.h> 42 #include <WebCore/GraphicsContext.h>43 35 #include <WebCore/MainFrame.h> 44 #include <WebCore/Page.h>45 #include <wtf/CurrentTime.h>46 36 47 37 using namespace WebCore; … … 59 49 60 50 ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage& webPage) 61 : LayerTreeHost(webPage) 62 , m_forceRepaintAsyncCallbackID(0) 63 , m_notifyAfterScheduledLayerFlush(false) 64 , m_isSuspended(false) 65 , m_isWaitingForRenderer(false) 66 , m_layerFlushTimer(RunLoop::main(), this, &ThreadedCoordinatedLayerTreeHost::performScheduledLayerFlush) 67 , m_layerFlushSchedulingEnabled(true) 51 : CoordinatedLayerTreeHost(webPage) 52 , m_compositorClient(*this) 53 , m_compositor(ThreadedCompositor::create(&m_compositorClient)) 68 54 { 69 m_coordinator = std::make_unique<CompositingCoordinator>(m_webPage.corePage(), this);70 71 m_coordinator->createRootLayer(m_webPage.size());72 73 CoordinatedSurface::setFactory(createCoordinatedSurface);74 75 m_compositor = ThreadedCompositor::create(this);76 scheduleLayerFlush();77 }78 79 RefPtr<CoordinatedSurface> ThreadedCoordinatedLayerTreeHost::createCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags)80 {81 return ThreadSafeCoordinatedSurface::create(size, flags);82 }83 84 void ThreadedCoordinatedLayerTreeHost::scheduleLayerFlush()85 {86 if (!m_layerFlushSchedulingEnabled)87 return;88 89 if (!m_layerFlushTimer.isActive())90 m_layerFlushTimer.startOneShot(0);91 }92 93 void ThreadedCoordinatedLayerTreeHost::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled)94 {95 if (m_layerFlushSchedulingEnabled == layerFlushingEnabled)96 return;97 98 m_layerFlushSchedulingEnabled = layerFlushingEnabled;99 100 if (m_layerFlushSchedulingEnabled) {101 scheduleLayerFlush();102 return;103 }104 105 cancelPendingLayerFlush();106 }107 108 void ThreadedCoordinatedLayerTreeHost::setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush)109 {110 m_notifyAfterScheduledLayerFlush = notifyAfterScheduledLayerFlush;111 }112 113 void ThreadedCoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer)114 {115 m_coordinator->setRootCompositingLayer(graphicsLayer);116 }117 118 void ThreadedCoordinatedLayerTreeHost::invalidate()119 {120 notImplemented();121 55 } 122 56 … … 125 59 m_compositor->scrollTo(rect.location()); 126 60 scheduleLayerFlush(); 127 }128 129 void ThreadedCoordinatedLayerTreeHost::forceRepaint()130 {131 notImplemented();132 }133 134 bool ThreadedCoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID)135 {136 // We expect the UI process to not require a new repaint until the previous one has finished.137 ASSERT(!m_forceRepaintAsyncCallbackID);138 m_forceRepaintAsyncCallbackID = callbackID;139 scheduleLayerFlush();140 return true;141 61 } 142 62 … … 148 68 void ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged() 149 69 { 150 m_coordinator->deviceOrPageScaleFactorChanged();70 CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged(); 151 71 m_compositor->setDeviceScaleFactor(m_webPage.deviceScaleFactor()); 152 72 } 153 73 154 void ThreadedCoordinatedLayerTreeHost:: pauseRendering()74 void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize& size) 155 75 { 156 m_isSuspended = true; 157 } 158 159 void ThreadedCoordinatedLayerTreeHost::resumeRendering() 160 { 161 m_isSuspended = false; 162 scheduleLayerFlush(); 163 } 164 165 GraphicsLayerFactory* ThreadedCoordinatedLayerTreeHost::graphicsLayerFactory() 166 { 167 return m_coordinator.get(); 168 } 169 170 void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& size) 171 { 172 m_coordinator->sizeDidChange(size); 76 CoordinatedLayerTreeHost::sizeDidChange(size); 173 77 m_compositor->didChangeViewportSize(size); 174 78 } … … 179 83 } 180 84 181 void ThreadedCoordinatedLayerTreeHost::compositorDidFlushLayers()182 {183 static_cast<DrawingAreaImpl*>(m_webPage.drawingArea())->layerHostDidFlushLayers();184 }185 186 85 void ThreadedCoordinatedLayerTreeHost::didScaleFactorChanged(float scale, const IntPoint& origin) 187 86 { 188 87 m_webPage.scalePage(scale, origin); 189 }190 191 void ThreadedCoordinatedLayerTreeHost::setViewOverlayRootLayer(GraphicsLayer* graphicsLayer)192 {193 m_coordinator->setViewOverlayRootLayer(graphicsLayer);194 88 } 195 89 … … 203 97 #endif 204 98 205 #if ENABLE(REQUEST_ANIMATION_FRAME)206 void ThreadedCoordinatedLayerTreeHost::scheduleAnimation()207 {208 if (m_isWaitingForRenderer)209 return;210 211 if (m_layerFlushTimer.isActive())212 return;213 214 m_layerFlushTimer.startOneShot(m_coordinator->nextAnimationServiceTime());215 scheduleLayerFlush();216 }217 #endif218 219 99 void ThreadedCoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector, float scale) 220 100 { 221 m_coordinator->setVisibleContentsRect(rect, trajectoryVector);101 CoordinatedLayerTreeHost::setVisibleContentsRect(rect, trajectoryVector); 222 102 if (m_lastScrollPosition != roundedIntPoint(rect.location())) { 223 103 m_lastScrollPosition = roundedIntPoint(rect.location()); … … 231 111 didScaleFactorChanged(m_lastScaleFactor, m_lastScrollPosition); 232 112 } 233 234 scheduleLayerFlush();235 }236 237 void ThreadedCoordinatedLayerTreeHost::cancelPendingLayerFlush()238 {239 m_layerFlushTimer.stop();240 }241 242 void ThreadedCoordinatedLayerTreeHost::performScheduledLayerFlush()243 {244 if (m_isSuspended || m_isWaitingForRenderer)245 return;246 247 m_coordinator->syncDisplayState();248 bool didSync = m_coordinator->flushPendingLayerChanges();249 250 if (m_notifyAfterScheduledLayerFlush && didSync) {251 compositorDidFlushLayers();252 m_notifyAfterScheduledLayerFlush = false;253 }254 }255 256 void ThreadedCoordinatedLayerTreeHost::purgeBackingStores()257 {258 m_coordinator->purgeBackingStores();259 }260 261 void ThreadedCoordinatedLayerTreeHost::renderNextFrame()262 {263 m_isWaitingForRenderer = false;264 m_coordinator->renderNextFrame();265 scheduleLayerFlush();266 }267 268 void ThreadedCoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, const IntSize& offset)269 {270 m_coordinator->commitScrollOffset(layerID, offset);271 }272 273 void ThreadedCoordinatedLayerTreeHost::notifyFlushRequired()274 {275 scheduleLayerFlush();276 113 } 277 114 278 115 void ThreadedCoordinatedLayerTreeHost::commitSceneState(const CoordinatedGraphicsState& state) 279 116 { 280 m_isWaitingForRenderer = true;117 CoordinatedLayerTreeHost::commitSceneState(state); 281 118 m_compositor->updateSceneState(state); 282 }283 284 void ThreadedCoordinatedLayerTreeHost::paintLayerContents(const GraphicsLayer*, GraphicsContext&, const IntRect&)285 {286 119 } 287 120 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h
r202611 r202621 31 31 #if USE(COORDINATED_GRAPHICS_THREADED) 32 32 33 #include "LayerTreeContext.h" 34 #include "LayerTreeHost.h" 33 #include "CoordinatedLayerTreeHost.h" 35 34 #include "ThreadedCompositor.h" 36 #include <WebCore/CompositingCoordinator.h>37 #include <WebCore/FloatPoint.h>38 #include <WebCore/FloatRect.h>39 #include <WebCore/IntPoint.h>40 #include <WebCore/IntRect.h>41 #include <WebCore/IntSize.h>42 #include <WebCore/PageOverlay.h>43 #include <WebCore/Timer.h>44 #include <wtf/RunLoop.h>45 #include <wtf/Threading.h>46 35 47 36 namespace WebCore { 48 class CoordinatedSurface;49 37 class GraphicsContext; 50 38 class GraphicsLayer; 51 class GraphicsLayerFactory;52 class GraphicsLayerFactory;53 struct CoordinatedGraphicsLayerState;54 39 struct CoordinatedGraphicsState; 55 40 } … … 59 44 class WebPage; 60 45 61 class ThreadedCoordinatedLayerTreeHost : public LayerTreeHost, public WebCore::CompositingCoordinator::Client, public ThreadedCompositor::Client { 62 WTF_MAKE_NONCOPYABLE(ThreadedCoordinatedLayerTreeHost); WTF_MAKE_FAST_ALLOCATED; 46 class ThreadedCoordinatedLayerTreeHost final : public CoordinatedLayerTreeHost { 63 47 public: 64 48 static Ref<ThreadedCoordinatedLayerTreeHost> create(WebPage&); 65 49 virtual ~ThreadedCoordinatedLayerTreeHost(); 66 50 67 const LayerTreeContext& layerTreeContext() override { return m_layerTreeContext; }; 51 private: 52 explicit ThreadedCoordinatedLayerTreeHost(WebPage&); 68 53 69 void scheduleLayerFlush() override;70 void setLayerFlushSchedulingEnabled(bool) override;71 void setShouldNotifyAfterNextScheduledLayerFlush(bool) override;72 void setRootCompositingLayer(WebCore::GraphicsLayer*) override;73 void invalidate() override;74 75 void setNonCompositedContentsNeedDisplay() override { };76 void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) override { };77 54 void scrollNonCompositedContents(const WebCore::IntRect& scrollRect) override; 78 void forceRepaint() override;79 bool forceRepaintAsync(uint64_t /*callbackID*/) override;80 55 void sizeDidChange(const WebCore::IntSize&) override; 81 56 void deviceOrPageScaleFactorChanged() override; 82 83 void pauseRendering() override;84 void resumeRendering() override;85 86 WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;87 void pageBackgroundTransparencyChanged() override { };88 57 89 58 void contentsSizeChanged(const WebCore::IntSize&) override; … … 94 63 #endif 95 64 96 #if ENABLE(REQUEST_ANIMATION_FRAME) 97 void scheduleAnimation() override; 98 #endif 65 class CompositorClient final : public ThreadedCompositor::Client { 66 WTF_MAKE_NONCOPYABLE(CompositorClient); 67 public: 68 CompositorClient(ThreadedCoordinatedLayerTreeHost& layerTreeHost) 69 : m_layerTreeHost(layerTreeHost) 70 { 71 } 99 72 100 void setViewOverlayRootLayer(WebCore::GraphicsLayer*) override; 101 static RefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags); 73 private: 74 void setVisibleContentsRect(const WebCore::FloatRect& rect, const WebCore::FloatPoint& trajectoryVector, float scale) override 75 { 76 m_layerTreeHost.setVisibleContentsRect(rect, trajectoryVector, scale); 77 } 102 78 103 protected: 104 explicit ThreadedCoordinatedLayerTreeHost(WebPage&); 79 void purgeBackingStores() override 80 { 81 m_layerTreeHost.purgeBackingStores(); 82 } 105 83 106 private: 84 void renderNextFrame() override 85 { 86 m_layerTreeHost.renderNextFrame(); 87 } 107 88 108 void compositorDidFlushLayers(); 89 void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) override 90 { 91 m_layerTreeHost.commitScrollOffset(layerID, offset); 92 } 93 94 ThreadedCoordinatedLayerTreeHost& m_layerTreeHost; 95 }; 96 109 97 void didScaleFactorChanged(float scale, const WebCore::IntPoint& origin); 110 98 111 void cancelPendingLayerFlush(); 112 void performScheduledLayerFlush(); 113 114 WebCore::GraphicsLayer* rootLayer() { return m_coordinator->rootLayer(); } 115 116 // ThreadedCompositor::Client 117 void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&, float) override; 118 void purgeBackingStores() override; 119 void renderNextFrame() override; 120 void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) override; 99 void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&, float); 121 100 122 101 // CompositingCoordinator::Client 123 102 void didFlushRootLayer(const WebCore::FloatRect&) override { } 124 void notifyFlushRequired() override;125 103 void commitSceneState(const WebCore::CoordinatedGraphicsState&) override; 126 void paintLayerContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) override;127 128 LayerTreeContext m_layerTreeContext;129 uint64_t m_forceRepaintAsyncCallbackID;130 104 131 105 WebCore::IntPoint m_prevScrollPosition; 132 133 std::unique_ptr<WebCore::CompositingCoordinator> m_coordinator; 106 CompositorClient m_compositorClient; 134 107 RefPtr<ThreadedCompositor> m_compositor; 135 136 bool m_notifyAfterScheduledLayerFlush; 137 bool m_isSuspended; 138 bool m_isWaitingForRenderer; 139 140 float m_lastScaleFactor; 108 float m_lastScaleFactor { 1 }; 141 109 WebCore::IntPoint m_lastScrollPosition; 142 143 RunLoop::Timer<ThreadedCoordinatedLayerTreeHost> m_layerFlushTimer;144 bool m_layerFlushSchedulingEnabled;145 110 }; 146 111 -
trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h
r201441 r202621 139 139 #endif 140 140 141 virtual void layerHostDidFlushLayers() { }; 142 141 143 protected: 142 144 DrawingArea(DrawingAreaType, WebPage&); -
trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h
r202611 r202621 46 46 virtual ~DrawingAreaImpl(); 47 47 48 void layerHostDidFlushLayers();49 50 48 private: 51 49 // DrawingArea … … 75 73 void destroyNativeSurfaceHandleForCompositing(bool&) override; 76 74 #endif 75 76 void layerHostDidFlushLayers() override; 77 77 78 78 // IPC message handlers. -
trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp
r201802 r202621 63 63 LayerTreeHost::~LayerTreeHost() 64 64 { 65 ASSERT(!m_isValid); 66 } 67 68 void LayerTreeHost::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled) 69 { 70 if (m_layerFlushSchedulingEnabled == layerFlushingEnabled) 71 return; 72 73 m_layerFlushSchedulingEnabled = layerFlushingEnabled; 74 75 if (m_layerFlushSchedulingEnabled) { 76 scheduleLayerFlush(); 77 return; 78 } 79 80 cancelPendingLayerFlush(); 81 } 82 83 void LayerTreeHost::pauseRendering() 84 { 85 m_isSuspended = true; 86 } 87 88 void LayerTreeHost::resumeRendering() 89 { 90 m_isSuspended = false; 91 scheduleLayerFlush(); 92 } 93 94 void LayerTreeHost::invalidate() 95 { 96 ASSERT(m_isValid); 97 m_isValid = false; 65 98 } 66 99 -
trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
r201923 r202621 30 30 31 31 #include "LayerTreeContext.h" 32 #include <WebCore/Color.h> 33 #include <wtf/PassRefPtr.h> 32 #include <wtf/Forward.h> 34 33 #include <wtf/RefCounted.h> 35 34 … … 40 39 41 40 namespace WebCore { 42 class FloatPoint;43 class FloatRect;44 41 class IntRect; 45 42 class IntSize; … … 53 50 namespace WebKit { 54 51 55 class UpdateInfo;56 52 class WebPage; 57 53 … … 61 57 virtual ~LayerTreeHost(); 62 58 63 virtual const LayerTreeContext& layerTreeContext() = 0; 59 const LayerTreeContext& layerTreeContext() const { return m_layerTreeContext; } 60 void setLayerFlushSchedulingEnabled(bool); 61 void setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush) { m_notifyAfterScheduledLayerFlush = notifyAfterScheduledLayerFlush; } 62 64 63 virtual void scheduleLayerFlush() = 0; 65 virtual void setLayerFlushSchedulingEnabled(bool) = 0; 66 virtual void setShouldNotifyAfterNextScheduledLayerFlush(bool) = 0; 64 virtual void cancelPendingLayerFlush() = 0; 67 65 virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) = 0; 68 virtual void invalidate() = 0;66 virtual void invalidate(); 69 67 70 virtual void setNonCompositedContentsNeedDisplay() = 0;71 virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) = 0;72 virtual void scrollNonCompositedContents(const WebCore::IntRect& scrollRect) = 0;68 virtual void setNonCompositedContentsNeedDisplay() { }; 69 virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) { }; 70 virtual void scrollNonCompositedContents(const WebCore::IntRect&) { }; 73 71 virtual void forceRepaint() = 0; 74 72 virtual bool forceRepaintAsync(uint64_t /*callbackID*/) { return false; } … … 77 75 virtual void pageBackgroundTransparencyChanged() = 0; 78 76 79 virtual void pauseRendering() { }80 virtual void resumeRendering() { }77 virtual void pauseRendering(); 78 virtual void resumeRendering(); 81 79 82 virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() { return 0; }80 virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() { return nullptr; } 83 81 84 82 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS) … … 87 85 88 86 #if USE(COORDINATED_GRAPHICS_THREADED) 89 virtual void contentsSizeChanged(const WebCore::IntSize&) = 0;90 virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&) = 0;87 virtual void contentsSizeChanged(const WebCore::IntSize&) { }; 88 virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&) { }; 91 89 #endif 92 90 … … 96 94 97 95 #if USE(TEXTURE_MAPPER) && PLATFORM(GTK) 98 virtual void setNativeSurfaceHandleForCompositing(uint64_t) = 0;96 virtual void setNativeSurfaceHandleForCompositing(uint64_t) { }; 99 97 #endif 100 98 101 virtual void setViewOverlayRootLayer(WebCore::GraphicsLayer* ) = 0;99 virtual void setViewOverlayRootLayer(WebCore::GraphicsLayer* viewOverlayRootLayer) { m_viewOverlayRootLayer = viewOverlayRootLayer; } 102 100 103 101 protected: … … 105 103 106 104 WebPage& m_webPage; 105 LayerTreeContext m_layerTreeContext; 106 bool m_layerFlushSchedulingEnabled { true }; 107 bool m_notifyAfterScheduledLayerFlush { false }; 108 bool m_isSuspended { false }; 109 bool m_isValid { true }; 110 WebCore::GraphicsLayer* m_viewOverlayRootLayer { nullptr }; 107 111 }; 108 112 -
trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp
r202611 r202621 134 134 LayerTreeHostGtk::LayerTreeHostGtk(WebPage& webPage) 135 135 : LayerTreeHost(webPage) 136 , m_isValid(true)137 , m_notifyAfterScheduledLayerFlush(false)138 , m_layerFlushSchedulingEnabled(true)139 , m_viewOverlayRootLayer(nullptr)140 136 , m_renderFrameScheduler(std::bind(&LayerTreeHostGtk::renderFrame, this)) 141 137 { … … 184 180 LayerTreeHostGtk::~LayerTreeHostGtk() 185 181 { 186 ASSERT(!m_isValid);187 182 ASSERT(!m_rootLayer); 188 183 cancelPendingLayerFlush(); 189 }190 191 const LayerTreeContext& LayerTreeHostGtk::layerTreeContext()192 {193 return m_layerTreeContext;194 }195 196 void LayerTreeHostGtk::setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush)197 {198 m_notifyAfterScheduledLayerFlush = notifyAfterScheduledLayerFlush;199 184 } 200 185 … … 212 197 void LayerTreeHostGtk::invalidate() 213 198 { 214 ASSERT(m_isValid);215 216 199 // This can trigger destruction of GL objects so let's make sure that 217 200 // we have the right active context … … 225 208 226 209 m_context = nullptr; 227 m_isValid = false;210 LayerTreeHost::invalidate(); 228 211 } 229 212 … … 366 349 if (m_notifyAfterScheduledLayerFlush) { 367 350 // Let the drawing area know that we've done a flush of the layer changes. 368 static_cast<DrawingAreaImpl*>(m_webPage.drawingArea())->layerHostDidFlushLayers();351 m_webPage.drawingArea()->layerHostDidFlushLayers(); 369 352 m_notifyAfterScheduledLayerFlush = false; 370 353 } … … 379 362 } 380 363 381 void LayerTreeHostGtk::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled)382 {383 if (m_layerFlushSchedulingEnabled == layerFlushingEnabled)384 return;385 386 m_layerFlushSchedulingEnabled = layerFlushingEnabled;387 388 if (m_layerFlushSchedulingEnabled) {389 scheduleLayerFlush();390 return;391 }392 393 cancelPendingLayerFlush();394 }395 396 364 void LayerTreeHostGtk::pageBackgroundTransparencyChanged() 397 365 { … … 404 372 } 405 373 406 void LayerTreeHostGtk::setViewOverlayRootLayer( WebCore::GraphicsLayer* viewOverlayRootLayer)407 { 408 m_viewOverlayRootLayer = viewOverlayRootLayer;374 void LayerTreeHostGtk::setViewOverlayRootLayer(GraphicsLayer* viewOverlayRootLayer) 375 { 376 LayerTreeHost::setViewOverlayRootLayer(viewOverlayRootLayer); 409 377 if (m_viewOverlayRootLayer) 410 378 m_rootLayer->addChild(m_viewOverlayRootLayer); -
trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h
r202611 r202621 52 52 // LayerTreeHost 53 53 void scheduleLayerFlush() override; 54 void setLayerFlushSchedulingEnabled(bool layerFlushingEnabled) override;54 void cancelPendingLayerFlush() override; 55 55 void setRootCompositingLayer(WebCore::GraphicsLayer*) override; 56 56 void invalidate() override; … … 60 60 void deviceOrPageScaleFactorChanged() override; 61 61 void pageBackgroundTransparencyChanged() override; 62 63 void setNonCompositedContentsNeedDisplay() override; 64 void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) override; 65 void scrollNonCompositedContents(const WebCore::IntRect& scrollRect) override; 66 void setViewOverlayRootLayer(WebCore::GraphicsLayer*) override; 62 67 63 68 void setNativeSurfaceHandleForCompositing(uint64_t) override; … … 81 86 }; 82 87 83 // LayerTreeHost84 const LayerTreeContext& layerTreeContext() override;85 void setShouldNotifyAfterNextScheduledLayerFlush(bool) override;86 87 void setNonCompositedContentsNeedDisplay() override;88 void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) override;89 void scrollNonCompositedContents(const WebCore::IntRect& scrollRect) override;90 void setViewOverlayRootLayer(WebCore::GraphicsLayer*) override;91 92 88 // GraphicsLayerClient 93 89 void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::FloatRect& clipRect) override; … … 101 97 102 98 void flushAndRenderLayers(); 103 void cancelPendingLayerFlush();104 105 99 bool renderFrame(); 106 107 100 bool makeContextCurrent(); 108 101 109 LayerTreeContext m_layerTreeContext;110 bool m_isValid;111 bool m_notifyAfterScheduledLayerFlush;112 102 std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer; 113 103 std::unique_ptr<WebCore::GraphicsLayer> m_nonCompositedContentLayer; 114 104 std::unique_ptr<WebCore::TextureMapper> m_textureMapper; 115 105 std::unique_ptr<WebCore::GLContext> m_context; 116 bool m_layerFlushSchedulingEnabled;117 WebCore::GraphicsLayer* m_viewOverlayRootLayer;118 106 WebCore::TransformationMatrix m_scaleMatrix; 119 107 RenderFrameScheduler m_renderFrameScheduler;
Note: See TracChangeset
for help on using the changeset viewer.