Changeset 163972 in webkit
- Timestamp:
- Feb 12, 2014 12:32:46 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r163971 r163972 1 2014-02-12 Zan Dobersek <zdobersek@igalia.com> 2 3 [CoordinatedGraphics] Move CoordinatedGraphicsScene, CoordinatedLayerTreeHostProxy to std::function 4 https://bugs.webkit.org/show_bug.cgi?id=128473 5 6 Reviewed by Anders Carlsson. 7 8 9 Move the CoordinatedGraphicsScene class to using std::function instead of WTF::Functional and std::bind 10 instead of WTF::bind. The function wrapper is now moved through function calls and not passed by reference, 11 and lambda functions are inlined into the dispatchOnMainThread() calls, with the CoordinatedGraphicsScene 12 refcount-protected. 13 14 * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp: 15 (WebCore::CoordinatedGraphicsScene::dispatchOnMainThread): 16 (WebCore::CoordinatedGraphicsScene::paintToCurrentGLContext): 17 (WebCore::CoordinatedGraphicsScene::commitSceneState): 18 (WebCore::CoordinatedGraphicsScene::syncRemoteContent): 19 (WebCore::CoordinatedGraphicsScene::purgeGLResources): 20 (WebCore::CoordinatedGraphicsScene::commitScrollOffset): 21 (WebCore::CoordinatedGraphicsScene::appendUpdate): 22 (WebCore::CoordinatedGraphicsScene::setActive): 23 * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h: 24 1 25 2014-02-12 Eric Carlson <eric.carlson@apple.com> 2 26 -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
r162644 r163972 35 35 namespace WebCore { 36 36 37 void CoordinatedGraphicsScene::dispatchOnMainThread( const Function<void()>&function)37 void CoordinatedGraphicsScene::dispatchOnMainThread(std::function<void()> function) 38 38 { 39 39 if (isMainThread()) 40 40 function(); 41 41 else 42 callOnMainThread( function);42 callOnMainThread(std::move(function)); 43 43 } 44 44 … … 99 99 m_textureMapper->endPainting(); 100 100 101 if (currentRootLayer->descendantsOrSelfHaveRunningAnimations()) 102 dispatchOnMainThread(bind(&CoordinatedGraphicsScene::updateViewport, this)); 101 if (currentRootLayer->descendantsOrSelfHaveRunningAnimations()) { 102 RefPtr<CoordinatedGraphicsScene> protector(this); 103 dispatchOnMainThread([=] { 104 protector->updateViewport(); 105 }); 106 } 103 107 } 104 108 … … 577 581 578 582 // The pending tiles state is on its way for the screen, tell the web process to render the next one. 579 dispatchOnMainThread(bind(&CoordinatedGraphicsScene::renderNextFrame, this)); 583 RefPtr<CoordinatedGraphicsScene> protector(this); 584 dispatchOnMainThread([=] { 585 protector->renderNextFrame(); 586 }); 580 587 } 581 588 … … 608 615 ensureRootLayer(); 609 616 610 Vector< Function<void()>> renderQueue;617 Vector<std::function<void()>> renderQueue; 611 618 bool calledOnMainThread = WTF::isMainThread(); 612 619 if (!calledOnMainThread) 613 620 m_renderQueueMutex.lock(); 614 renderQueue .swap(m_renderQueue);621 renderQueue = std::move(m_renderQueue); 615 622 if (!calledOnMainThread) 616 623 m_renderQueueMutex.unlock(); 617 624 618 for ( size_t i = 0; i < renderQueue.size(); ++i)619 renderQueue[i]();625 for (auto& function : renderQueue) 626 function(); 620 627 } 621 628 … … 638 645 639 646 setActive(false); 640 dispatchOnMainThread(bind(&CoordinatedGraphicsScene::purgeBackingStores, this)); 647 648 RefPtr<CoordinatedGraphicsScene> protector(this); 649 dispatchOnMainThread([=] { 650 protector->purgeBackingStores(); 651 }); 641 652 } 642 653 … … 648 659 void CoordinatedGraphicsScene::commitScrollOffset(uint32_t layerID, const IntSize& offset) 649 660 { 650 dispatchOnMainThread(bind(&CoordinatedGraphicsScene::dispatchCommitScrollOffset, this, layerID, offset)); 661 RefPtr<CoordinatedGraphicsScene> protector(this); 662 dispatchOnMainThread([=] { 663 protector->dispatchCommitScrollOffset(layerID, offset); 664 }); 651 665 } 652 666 … … 672 686 } 673 687 674 void CoordinatedGraphicsScene::appendUpdate( const Function<void()>&function)688 void CoordinatedGraphicsScene::appendUpdate(std::function<void()> function) 675 689 { 676 690 if (!m_isActive) … … 679 693 ASSERT(isMainThread()); 680 694 MutexLocker locker(m_renderQueueMutex); 681 m_renderQueue.append( function);695 m_renderQueue.append(std::move(function)); 682 696 } 683 697 … … 692 706 m_renderQueue.clear(); 693 707 m_isActive = active; 694 if (m_isActive) 695 dispatchOnMainThread(bind(&CoordinatedGraphicsScene::renderNextFrame, this)); 708 if (m_isActive) { 709 RefPtr<CoordinatedGraphicsScene> protector(this); 710 dispatchOnMainThread([=] { 711 protector->renderNextFrame(); 712 }); 713 } 696 714 } 697 715 -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h
r162644 r163972 36 36 #include "TextureMapperLayer.h" 37 37 #include "Timer.h" 38 #include < wtf/Functional.h>38 #include <functional> 39 39 #include <wtf/HashSet.h> 40 40 #include <wtf/ThreadingPrimitives.h> … … 66 66 void setScrollPosition(const FloatPoint&); 67 67 void detach(); 68 void appendUpdate( const Function<void()>&);68 void appendUpdate(std::function<void()>); 69 69 70 70 WebCore::TextureMapperLayer* findScrollableContentsLayerAt(const WebCore::FloatPoint&); … … 126 126 void adjustPositionForFixedLayers(); 127 127 128 void dispatchOnMainThread( const Function<void()>&);128 void dispatchOnMainThread(std::function<void()>); 129 129 void updateViewport(); 130 130 void renderNextFrame(); … … 147 147 148 148 // Render queue can be accessed ony from main thread or updatePaintNode call stack! 149 Vector< Function<void()>> m_renderQueue;149 Vector<std::function<void()>> m_renderQueue; 150 150 Mutex m_renderQueueMutex; 151 151 -
trunk/Source/WebKit2/ChangeLog
r163961 r163972 1 2014-02-12 Zan Dobersek <zdobersek@igalia.com> 2 3 [CoordinatedGraphics] Move CoordinatedGraphicsScene, CoordinatedLayerTreeHostProxy to std::function 4 https://bugs.webkit.org/show_bug.cgi?id=128473 5 6 Reviewed by Anders Carlsson. 7 8 Move the CoordinatedLayerTreeHostProxy class to using std::function instead of WTF::Functional. C++11 9 lambdas are used to construct the update functions, with the CoordinatedGraphicsScene refcount-protected 10 throughout the lifetime of the function wrapper. 11 12 * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp: 13 (WebKit::CoordinatedLayerTreeHostProxy::dispatchUpdate): 14 (WebKit::CoordinatedLayerTreeHostProxy::commitCoordinatedGraphicsState): 15 (WebKit::CoordinatedLayerTreeHostProxy::setVisibleContentsRect): 16 (WebKit::CoordinatedLayerTreeHostProxy::setBackgroundColor): 17 * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h: 18 1 19 2014-02-12 Dan Bernstein <mitz@apple.com> 2 20 -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp
r160476 r163972 53 53 } 54 54 55 void CoordinatedLayerTreeHostProxy::dispatchUpdate( const Function<void()>&function)55 void CoordinatedLayerTreeHostProxy::dispatchUpdate(std::function<void()> function) 56 56 { 57 m_scene->appendUpdate( function);57 m_scene->appendUpdate(std::move(function)); 58 58 } 59 59 60 60 void CoordinatedLayerTreeHostProxy::commitCoordinatedGraphicsState(const CoordinatedGraphicsState& graphicsState) 61 61 { 62 dispatchUpdate(bind(&CoordinatedGraphicsScene::commitSceneState, m_scene.get(), graphicsState)); 62 RefPtr<CoordinatedGraphicsScene> sceneProtector(m_scene); 63 dispatchUpdate([=] { 64 sceneProtector->commitSceneState(graphicsState); 65 }); 66 63 67 updateViewport(); 64 68 #if USE(TILED_BACKING_STORE) … … 70 74 { 71 75 // Inform the renderer to adjust viewport-fixed layers. 72 dispatchUpdate(bind(&CoordinatedGraphicsScene::setScrollPosition, m_scene.get(), rect.location())); 76 RefPtr<CoordinatedGraphicsScene> sceneProtector(m_scene); 77 const FloatPoint& scrollPosition = rect.location(); 78 dispatchUpdate([=] { 79 sceneProtector->setScrollPosition(scrollPosition); 80 }); 73 81 74 82 if (rect == m_lastSentVisibleRect && trajectoryVector == m_lastSentTrajectoryVector) … … 92 100 void CoordinatedLayerTreeHostProxy::setBackgroundColor(const Color& color) 93 101 { 94 dispatchUpdate(bind(&CoordinatedGraphicsScene::setBackgroundColor, m_scene.get(), color)); 102 RefPtr<CoordinatedGraphicsScene> sceneProtector(m_scene); 103 dispatchUpdate([=] { 104 sceneProtector->setBackgroundColor(color); 105 }); 95 106 } 96 107 -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h
r162139 r163972 27 27 #include "MessageReceiver.h" 28 28 #include <WebCore/CoordinatedGraphicsScene.h> 29 #include < wtf/Functional.h>29 #include <functional> 30 30 31 31 namespace WebCore { … … 58 58 59 59 protected: 60 void dispatchUpdate( const Function<void()>&);60 void dispatchUpdate(std::function<void()>); 61 61 62 62 // IPC::MessageReceiver
Note: See TracChangeset
for help on using the changeset viewer.