Changeset 220700 in webkit
- Timestamp:
- Aug 14, 2017 9:41:18 AM (7 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r220694 r220700 1 2017-08-14 Zan Dobersek <zdobersek@igalia.com> 2 3 [CoordGraphics] Simplify CoordinatedGraphicsScene state updates 4 https://bugs.webkit.org/show_bug.cgi?id=175528 5 6 Reviewed by Carlos Garcia Campos. 7 8 Hold the information about state updates in ThreadedCompositor, in the 9 m_attributes struct. This way we don't need to store the updates in 10 functors and accumulate them in the CoordinatedGraphicsScene class, but 11 instead just apply any pending state update or atlas removal before the 12 scene is rendered. 13 14 This removes the need to update the CoordinatedGraphicsScene object from 15 the main thread with data that ultimately has to be handled on the 16 composition thread. Similarly, when updating CoordinatedGraphicsScene, we 17 only need to synchronize on the m_attributes lock object once in order to 18 retrieve the scene update information, instead of having each functor do 19 that repeatedly. 20 21 * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp: 22 (WebKit::CoordinatedGraphicsScene::applyStateChanges): 23 (WebKit::CoordinatedGraphicsScene::paintToCurrentGLContext): 24 (WebKit::CoordinatedGraphicsScene::detach): 25 (WebKit::CoordinatedGraphicsScene::setActive): 26 (WebKit::CoordinatedGraphicsScene::syncRemoteContent): Deleted. 27 (WebKit::CoordinatedGraphicsScene::appendUpdate): Deleted. 28 * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h: 29 * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp: 30 (WebKit::ThreadedCompositor::renderLayerTree): 31 (WebKit::ThreadedCompositor::updateSceneState): 32 (WebKit::ThreadedCompositor::releaseUpdateAtlases): 33 * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h: 34 1 35 2017-08-14 Carlos Garcia Campos <cgarcia@igalia.com> 2 36 -
trunk/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
r220391 r220700 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
r218745 r220700 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
r220672 r220700 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 305 LockHolder locker(m_attributes.lock); 306 m_attributes.states.append(state); 300 307 m_compositingRunLoop->scheduleUpdate(); 301 308 } … … 303 310 void ThreadedCompositor::releaseUpdateAtlases(Vector<uint32_t>&& atlasesToRemove) 304 311 { 305 ASSERT(RunLoop::isMain()); 306 m_scene->appendUpdate([scene = makeRef(*m_scene), atlasesToRemove = WTFMove(atlasesToRemove)] { 307 scene->releaseUpdateAtlases(atlasesToRemove); 308 }); 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
r220672 r220700 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 { … … 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 };
Note: See TracChangeset
for help on using the changeset viewer.