Changeset 220792 in webkit
- Timestamp:
- Aug 16, 2017 4:21:41 AM (7 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r220787 r220792 1 2017-08-16 Zan Dobersek <zdobersek@igalia.com> 2 3 [CoordGraphics] Simplify CoordinatedGraphicsScene state updates 4 https://bugs.webkit.org/show_bug.cgi?id=175528 5 <rdar://problem/33876795> 6 7 Reviewed by Carlos Garcia Campos. 8 9 Hold the information about state updates in ThreadedCompositor, in the 10 m_attributes struct. This way we don't need to store the updates in 11 functors and accumulate them in the CoordinatedGraphicsScene class, but 12 instead just apply any pending state update or atlas removal before the 13 scene is rendered. 14 15 This removes the need to update the CoordinatedGraphicsScene object from 16 the main thread with data that ultimately has to be handled on the 17 composition thread. Similarly, when updating CoordinatedGraphicsScene, we 18 only need to synchronize on the m_attributes lock object once in order to 19 retrieve the scene update information, instead of having each functor do 20 that repeatedly. 21 22 Outside of CoordinatedGraphicsScene and ThreadedCompositor classes, the 23 CompositingCoordinator class now passes the atlases-to-remove Vector by 24 a const lvalue reference down to ThreadedCompositor, and then manually 25 clears the Vector. Before the Vector was passed as an rvalue reference, 26 depending on the ThreadedCompositor code to clear out the original Vector 27 object by moving its resources into the functor object. This doesn't occur 28 anymore because the Vector object is now appended to another Vector. 29 30 * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp: 31 (WebKit::CoordinatedGraphicsScene::applyStateChanges): 32 (WebKit::CoordinatedGraphicsScene::paintToCurrentGLContext): 33 (WebKit::CoordinatedGraphicsScene::detach): 34 (WebKit::CoordinatedGraphicsScene::setActive): 35 (WebKit::CoordinatedGraphicsScene::syncRemoteContent): Deleted. 36 (WebKit::CoordinatedGraphicsScene::appendUpdate): Deleted. 37 * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h: 38 * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp: 39 (WebKit::ThreadedCompositor::renderLayerTree): 40 (WebKit::ThreadedCompositor::updateSceneState): 41 (WebKit::ThreadedCompositor::releaseUpdateAtlases): 42 * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h: 43 * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp: 44 (WebKit::CompositingCoordinator::flushPendingLayerChanges): 45 (WebKit::CompositingCoordinator::releaseAtlases): 46 (WebKit::CompositingCoordinator::clearUpdateAtlases): 47 * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h: 48 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h: 49 * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp: 50 (WebKit::ThreadedCoordinatedLayerTreeHost::releaseUpdateAtlases): 51 * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h: 52 1 53 2017-08-16 Andy Estes <aestes@apple.com> 2 54 -
trunk/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
r220742 r220792 78 78 } 79 79 80 void CoordinatedGraphicsScene:: paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, const Color& backgroundColor, bool drawsBackground, const FloatPoint& contentPosition, TextureMapper::PaintFlags PaintFlags)80 void CoordinatedGraphicsScene::applyStateChanges(const Vector<CoordinatedGraphicsState>& states) 81 81 { 82 82 if (!m_textureMapper) { … … 85 85 } 86 86 87 syncRemoteContent(); 88 87 ensureRootLayer(); 88 89 for (auto& state : states) 90 commitSceneState(state); 91 } 92 93 void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, const Color& backgroundColor, bool drawsBackground, const FloatPoint& contentPosition, TextureMapper::PaintFlags PaintFlags) 94 { 89 95 adjustPositionForFixedLayers(contentPosition); 90 96 TextureMapperLayer* currentRootLayer = rootLayer(); … … 581 587 } 582 588 583 void CoordinatedGraphicsScene::syncRemoteContent()584 {585 // We enqueue messages and execute them during paint, as they require an active GL context.586 ensureRootLayer();587 588 Vector<Function<void()>> renderQueue;589 bool calledOnMainThread = RunLoop::isMain();590 if (!calledOnMainThread)591 m_renderQueueMutex.lock();592 renderQueue = WTFMove(m_renderQueue);593 if (!calledOnMainThread)594 m_renderQueueMutex.unlock();595 596 for (auto& function : renderQueue)597 function();598 }599 600 589 void CoordinatedGraphicsScene::purgeGLResources() 601 590 { … … 643 632 m_isActive = false; 644 633 m_client = nullptr; 645 LockHolder locker(m_renderQueueMutex);646 m_renderQueue.clear();647 }648 649 void CoordinatedGraphicsScene::appendUpdate(Function<void()>&& function)650 {651 if (!m_isActive)652 return;653 654 ASSERT(RunLoop::isMain());655 LockHolder locker(m_renderQueueMutex);656 m_renderQueue.append(WTFMove(function));657 634 } 658 635 659 636 void CoordinatedGraphicsScene::setActive(bool active) 660 637 { 661 if (!m_client) 662 return; 663 664 if (m_isActive == active) 665 return; 666 667 // Have to clear render queue in both cases. 668 // If there are some updates in queue during activation then those updates are from previous instance of paint node 669 // and cannot be applied to the newly created instance. 670 m_renderQueue.clear(); 638 if (!m_client || m_isActive == active) 639 return; 640 671 641 m_isActive = active; 672 642 if (m_isActive) -
trunk/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h
r220742 r220792 69 69 explicit CoordinatedGraphicsScene(CoordinatedGraphicsSceneClient*); 70 70 virtual ~CoordinatedGraphicsScene(); 71 72 void applyStateChanges(const Vector<WebCore::CoordinatedGraphicsState>&); 71 73 void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float, const WebCore::FloatRect&, const WebCore::Color& backgroundColor, bool drawsBackground, const WebCore::FloatPoint&, WebCore::TextureMapper::PaintFlags = 0); 72 74 void detach(); 73 void appendUpdate(Function<void()>&&);74 75 75 76 WebCore::TextureMapperLayer* findScrollableContentsLayerAt(const WebCore::FloatPoint&); … … 125 126 WebCore::TextureMapperLayer* rootLayer() { return m_rootLayer.get(); } 126 127 127 void syncRemoteContent();128 128 void adjustPositionForFixedLayers(const WebCore::FloatPoint& contentPosition); 129 129 … … 149 149 WebCore::TextureMapperGL* texmapGL() override; 150 150 #endif 151 152 // Render queue can be accessed ony from main thread or updatePaintNode call stack!153 Vector<Function<void()>> m_renderQueue;154 Lock m_renderQueueMutex;155 151 156 152 std::unique_ptr<WebCore::TextureMapper> m_textureMapper; -
trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
r220742 r220792 209 209 bool drawsBackground; 210 210 bool needsResize; 211 Vector<WebCore::CoordinatedGraphicsState> states; 212 Vector<uint32_t> atlasesToRemove; 213 211 214 { 212 215 LockHolder locker(m_attributes.lock); … … 217 220 needsResize = m_attributes.needsResize; 218 221 222 states = WTFMove(m_attributes.states); 223 atlasesToRemove = WTFMove(m_attributes.atlasesToRemove); 224 225 if (!states.isEmpty()) { 226 // Client has to be notified upon finishing this scene update. 227 m_attributes.clientRendersNextFrame = true; 228 229 // Coordinate scene update completion with the client in case of changed or updated platform layers. 230 // But do not change coordinateUpdateCompletionWithClient while in force repaint because that 231 // demands immediate scene update completion regardless of platform layers. 232 if (!m_inForceRepaint) { 233 bool coordinateUpdate = false; 234 for (auto& state : states) 235 coordinateUpdate |= std::any_of(state.layersToUpdate.begin(), state.layersToUpdate.end(), 236 [](auto& it) { return it.second.platformLayerChanged || it.second.platformLayerUpdated; }); 237 m_attributes.coordinateUpdateCompletionWithClient = coordinateUpdate; 238 } 239 } 240 219 241 // Reset the needsResize attribute to false. 220 242 m_attributes.needsResize = false; … … 233 255 } 234 256 257 m_scene->applyStateChanges(states); 258 m_scene->releaseUpdateAtlases(atlasesToRemove); 235 259 m_scene->paintToCurrentGLContext(viewportTransform, 1, FloatRect { FloatPoint { }, viewportSize }, 236 260 Color::transparent, !drawsBackground, scrollPosition, m_paintFlags); … … 279 303 void ThreadedCompositor::updateSceneState(const CoordinatedGraphicsState& state) 280 304 { 281 ASSERT(RunLoop::isMain()); 282 m_scene->appendUpdate([this, scene = makeRef(*m_scene), state] { 283 scene->commitSceneState(state); 284 285 LockHolder locker(m_attributes.lock); 286 287 // Client has to be notified upon finishing this scene update. 288 m_attributes.clientRendersNextFrame = true; 289 290 // Coordinate scene update completion with the client in case of changed or updated platform layers. 291 // Do not change m_coordinateUpdateCompletionWithClient while in force repaint. 292 bool coordinateUpdate = !m_inForceRepaint && std::any_of(state.layersToUpdate.begin(), state.layersToUpdate.end(), 293 [](const std::pair<CoordinatedLayerID, CoordinatedGraphicsLayerState>& it) { 294 return it.second.platformLayerChanged || it.second.platformLayerUpdated; 295 }); 296 297 m_attributes.coordinateUpdateCompletionWithClient |= coordinateUpdate; 298 }); 299 300 m_compositingRunLoop->scheduleUpdate(); 301 } 302 303 void ThreadedCompositor::releaseUpdateAtlases(Vector<uint32_t>&& atlasesToRemove) 304 { 305 ASSERT(RunLoop::isMain()); 306 m_scene->appendUpdate([scene = makeRef(*m_scene), atlasesToRemove = WTFMove(atlasesToRemove)] { 307 scene->releaseUpdateAtlases(atlasesToRemove); 308 }); 305 LockHolder locker(m_attributes.lock); 306 m_attributes.states.append(state); 307 m_compositingRunLoop->scheduleUpdate(); 308 } 309 310 void ThreadedCompositor::releaseUpdateAtlases(const Vector<uint32_t>& atlasesToRemove) 311 { 312 LockHolder locker(m_attributes.lock); 313 m_attributes.atlasesToRemove.appendVector(atlasesToRemove); 309 314 m_compositingRunLoop->scheduleUpdate(); 310 315 } -
trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h
r220742 r220792 30 30 #include "CompositingRunLoop.h" 31 31 #include "CoordinatedGraphicsScene.h" 32 #include <WebCore/CoordinatedGraphicsState.h> 32 33 #include <WebCore/GLContext.h> 33 34 #include <WebCore/IntSize.h> … … 41 42 #include <WebCore/DisplayRefreshMonitor.h> 42 43 #endif 43 44 namespace WebCore {45 struct CoordinatedGraphicsState;46 }47 44 48 45 namespace WebKit { … … 81 78 82 79 void updateSceneState(const WebCore::CoordinatedGraphicsState&); 83 void releaseUpdateAtlases( Vector<uint32_t>&&);80 void releaseUpdateAtlases(const Vector<uint32_t>&); 84 81 85 82 void invalidate(); … … 127 124 bool needsResize { false }; 128 125 126 Vector<WebCore::CoordinatedGraphicsState> states; 127 Vector<uint32_t> atlasesToRemove; 128 129 129 bool clientRendersNextFrame { false }; 130 130 bool coordinateUpdateCompletionWithClient { false }; -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp
r219876 r220792 139 139 140 140 if (!m_atlasesToRemove.isEmpty()) 141 m_client.releaseUpdateAtlases(WTFMove(m_atlasesToRemove)); 141 m_client.releaseUpdateAtlases(m_atlasesToRemove); 142 m_atlasesToRemove.clear(); 142 143 143 144 clearPendingStateChanges(); … … 443 444 444 445 if (!m_atlasesToRemove.isEmpty()) 445 m_client.releaseUpdateAtlases(WTFMove(m_atlasesToRemove)); 446 m_client.releaseUpdateAtlases(m_atlasesToRemove); 447 m_atlasesToRemove.clear(); 446 448 } 447 449 … … 455 457 456 458 if (!m_atlasesToRemove.isEmpty()) 457 m_client.releaseUpdateAtlases(WTFMove(m_atlasesToRemove)); 459 m_client.releaseUpdateAtlases(m_atlasesToRemove); 460 m_atlasesToRemove.clear(); 458 461 } 459 462 -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h
r219876 r220792 61 61 virtual void commitSceneState(const WebCore::CoordinatedGraphicsState&) = 0; 62 62 virtual void paintLayerContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) = 0; 63 virtual void releaseUpdateAtlases( Vector<uint32_t>&&) = 0;63 virtual void releaseUpdateAtlases(const Vector<uint32_t>&) = 0; 64 64 }; 65 65 -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h
r218985 r220792 76 76 void commitSceneState(const WebCore::CoordinatedGraphicsState&) override; 77 77 void paintLayerContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) override; 78 void releaseUpdateAtlases( Vector<uint32_t>&&) override { };78 void releaseUpdateAtlases(const Vector<uint32_t>&) override { }; 79 79 80 80 private: -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp
r217123 r220792 250 250 } 251 251 252 void ThreadedCoordinatedLayerTreeHost::releaseUpdateAtlases( Vector<uint32_t>&& atlasesToRemove)253 { 254 m_compositor->releaseUpdateAtlases( WTFMove(atlasesToRemove));252 void ThreadedCoordinatedLayerTreeHost::releaseUpdateAtlases(const Vector<uint32_t>& atlasesToRemove) 253 { 254 m_compositor->releaseUpdateAtlases(atlasesToRemove); 255 255 } 256 256 -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h
r217595 r220792 119 119 void didFlushRootLayer(const WebCore::FloatRect&) override { } 120 120 void commitSceneState(const WebCore::CoordinatedGraphicsState&) override; 121 void releaseUpdateAtlases( Vector<uint32_t>&&) override;121 void releaseUpdateAtlases(const Vector<uint32_t>&) override; 122 122 123 123 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
Note: See TracChangeset
for help on using the changeset viewer.