Changeset 96529 in webkit
- Timestamp:
- Oct 3, 2011 12:52:01 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h
r96454 r96529 84 84 { 85 85 #if !ASSERT_DISABLED 86 ASSERT(CCProxy::isMainThread());87 86 CCProxy::setImplThread(true); 88 87 #endif -
trunk/Source/WebKit/chromium/ChangeLog
r96490 r96529 1 2011-10-03 James Robinson <jamesr@chromium.org> 2 3 [chromium] Add WebWidget API for accessing the current WebCompositor 4 https://bugs.webkit.org/show_bug.cgi?id=69181 5 6 Reviewed by Darin Fisher. 7 8 Add new WebWidgetClient::did(Activate|Deactivate)Compositor calls intended to replace 9 didActivateAccleratedCompositing(bool) so that the enable call can be parameterized. 10 11 Add a WebCompositor identifier parameter to didEnableAcceleratedCompositing that can be used on the compositor 12 thread to get access to a WebCompositor pointer. 13 14 * public/WebWidget.h: 15 (WebKit::WebWidget::compositor): 16 * src/WebViewImpl.cpp: 17 (WebKit::WebViewImpl::compositor): 18 (WebKit::WebViewImpl::setIsAcceleratedCompositingActive): 19 * src/WebViewImpl.h: 20 1 21 2011-10-03 Sheriff Bot <webkit.review.bot@gmail.com> 2 22 -
trunk/Source/WebKit/chromium/WebKit.gypi
r96490 r96529 77 77 'tests/TreeTestHelpers.cpp', 78 78 'tests/TreeTestHelpers.h', 79 'tests/WebCompositorImplTest.cpp', 79 80 'tests/WebFrameTest.cpp', 80 81 'tests/WebURLRequestTest.cpp', -
trunk/Source/WebKit/chromium/public/WebCompositor.h
r96490 r96529 41 41 // This must be called once with a non-null WebThread before any compositors attempt to initialize. 42 42 WEBKIT_EXPORT static void setThread(WebThread*); 43 WEBKIT_EXPORT static WebCompositor* fromIdentifier(int); 43 44 44 45 virtual void setClient(WebCompositorClient*) = 0; -
trunk/Source/WebKit/chromium/public/WebWidgetClient.h
r96490 r96529 53 53 54 54 // Called when the compositor enables or disables. 55 // FIXME: Remove when all implementations switch over to didEnable.../didDisable... 55 56 virtual void didActivateAcceleratedCompositing(bool active) { } 57 58 // Called when the compositor is enabled or disabled. 59 // The WebCompositor identifier can be used on the compositor thread to get access 60 // to the WebCompositor instance associated with this WebWidget. 61 virtual void didActivateCompositor(int compositorIdentifier) { } 62 virtual void didDeactivateCompositor() { } 56 63 57 64 // Called when a call to WebWidget::composite is required -
trunk/Source/WebKit/chromium/src/WebCompositorImpl.cpp
r96490 r96529 32 32 #include "WebInputEvent.h" 33 33 #include "cc/CCThreadProxy.h" 34 #include <wtf/ThreadingPrimitives.h> 34 35 35 36 using namespace WebCore; … … 43 44 } 44 45 46 int WebCompositorImpl::s_nextAvailableIdentifier = 1; 47 48 // These data structures are always allocated from the main thread, but may 49 // be accessed and mutated on the main or compositor thread. 50 // s_compositors is deleted when it has no elements. s_compositorsLock is never 51 // deleted. 52 HashSet<WebCompositorImpl*>* WebCompositorImpl::s_compositors = 0; 53 Mutex* WebCompositorImpl::s_compositorsLock = 0; 54 55 WebCompositor* WebCompositor::fromIdentifier(int identifier) 56 { 57 return WebCompositorImpl::fromIdentifier(identifier); 58 } 59 60 WebCompositor* WebCompositorImpl::fromIdentifier(int identifier) 61 { 62 ASSERT(CCProxy::isImplThread()); 63 if (!s_compositorsLock) 64 return 0; 65 66 MutexLocker lock(*s_compositorsLock); 67 if (!s_compositors) 68 return 0; 69 70 for (HashSet<WebCompositorImpl*>::iterator it = s_compositors->begin(); it != s_compositors->end(); ++it) { 71 if ((*it)->identifier() == identifier) 72 return *it; 73 } 74 return 0; 75 } 76 45 77 WebCompositorImpl::WebCompositorImpl() 46 78 : m_client(0) 79 , m_identifier(s_nextAvailableIdentifier++) 47 80 { 81 ASSERT(CCProxy::isMainThread()); 82 if (!s_compositorsLock) 83 s_compositorsLock = new Mutex; 84 MutexLocker lock(*s_compositorsLock); 85 if (!s_compositors) 86 s_compositors = new HashSet<WebCompositorImpl*>; 87 s_compositors->add(this); 48 88 } 49 89 50 90 WebCompositorImpl::~WebCompositorImpl() 51 91 { 92 ASSERT(s_compositorsLock); 93 MutexLocker lock(*s_compositorsLock); 94 ASSERT(s_compositors); 95 s_compositors->remove(this); 96 if (!s_compositors->size()) { 97 delete s_compositors; 98 s_compositors = 0; 99 } 52 100 } 53 101 54 102 void WebCompositorImpl::setClient(WebCompositorClient* client) 55 103 { 104 ASSERT(CCProxy::isImplThread()); 56 105 ASSERT(client); 57 106 m_client = client; … … 60 109 void WebCompositorImpl::handleInputEvent(const WebInputEvent& event) 61 110 { 111 ASSERT(CCProxy::isImplThread()); 62 112 // FIXME: Do something interesting with the event here. 63 113 m_client->didHandleInputEvent(false); -
trunk/Source/WebKit/chromium/src/WebCompositorImpl.h
r96490 r96529 28 28 29 29 #include "WebCompositor.h" 30 31 #include <wtf/HashSet.h> 30 32 #include <wtf/Noncopyable.h> 31 33 #include <wtf/PassOwnPtr.h> 34 35 namespace WTF { 36 class Mutex; 37 } 32 38 33 39 namespace WebKit { … … 38 44 WTF_MAKE_NONCOPYABLE(WebCompositorImpl); 39 45 public: 46 static WebCompositor* fromIdentifier(int identifier); 47 40 48 static PassOwnPtr<WebCompositorImpl> create() 41 49 { … … 48 56 virtual void handleInputEvent(const WebInputEvent&); 49 57 58 int identifier() const { return m_identifier; } 59 50 60 private: 51 61 WebCompositorImpl(); 52 62 53 63 WebCompositorClient* m_client; 64 int m_identifier; 65 66 static HashSet<WebCompositorImpl*>* s_compositors; 67 static Mutex* s_compositorsLock; 68 69 static int s_nextAvailableIdentifier; 54 70 }; 55 71 -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r96490 r96529 104 104 #include "WebAccessibilityObject.h" 105 105 #include "WebAutofillClient.h" 106 #include "WebCompositorImpl.h" 106 107 #include "WebDevToolsAgentImpl.h" 107 108 #include "WebDevToolsAgentPrivate.h" … … 2646 2647 m_layerTreeHost->finishAllRendering(); 2647 2648 m_client->didActivateAcceleratedCompositing(false); 2649 m_client->didDeactivateCompositor(); 2648 2650 } else if (m_layerTreeHost) { 2649 2651 m_isAcceleratedCompositingActive = true; … … 2651 2653 2652 2654 m_client->didActivateAcceleratedCompositing(true); 2655 m_client->didActivateCompositor(m_webCompositorImpl->identifier()); 2653 2656 } else { 2654 2657 TRACE_EVENT("WebViewImpl::setIsAcceleratedCompositingActive(true)", this, 0); … … 2668 2671 m_layerTreeHost = CCLayerTreeHost::create(this, m_nonCompositedContentHost->topLevelRootLayer()->platformLayer(), ccSettings); 2669 2672 if (m_layerTreeHost) { 2673 m_webCompositorImpl = WebCompositorImpl::create(); 2674 // FIXME: Hook the m_webCompositorImpl up with the CCLayerTreeHost somehow. 2670 2675 updateLayerTreeViewport(); 2671 2676 m_client->didActivateAcceleratedCompositing(true); 2677 m_client->didActivateCompositor(m_webCompositorImpl->identifier()); 2672 2678 m_isAcceleratedCompositingActive = true; 2673 2679 m_compositorCreationFailed = false; … … 2677 2683 m_isAcceleratedCompositingActive = false; 2678 2684 m_client->didActivateAcceleratedCompositing(false); 2685 m_client->didDeactivateCompositor(); 2679 2686 m_compositorCreationFailed = true; 2680 2687 } -
trunk/Source/WebKit/chromium/src/WebViewImpl.h
r96490 r96529 83 83 class SpeechInputClientImpl; 84 84 class WebAccessibilityObject; 85 class WebCompositorImpl; 85 86 class WebDevToolsAgentClient; 86 87 class WebDevToolsAgentPrivate; … … 576 577 OwnPtr<WebCore::NonCompositedContentHost> m_nonCompositedContentHost; 577 578 RefPtr<WebCore::CCLayerTreeHost> m_layerTreeHost; 579 OwnPtr<WebCompositorImpl> m_webCompositorImpl; 578 580 WebCore::GraphicsLayer* m_rootGraphicsLayer; 579 581 bool m_isAcceleratedCompositingActive; -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
r96490 r96529 118 118 bool success = initialize(); 119 119 ASSERT(success); 120 UNUSED_PARAM(success); 120 121 } 121 122 -
trunk/Source/WebKit/chromium/tests/WebCompositorImplTest.cpp
r96527 r96529 28 28 #include "WebCompositorImpl.h" 29 29 30 #include "CCThreadImpl.h" 31 #include "WebCompositorClient.h" 32 #include "WebInputEvent.h" 33 #include "cc/CCThreadProxy.h" 30 #include "cc/CCProxy.h" 34 31 35 using namespace WebCore; 32 #include <gtest/gtest.h> 33 #include <wtf/OwnPtr.h> 36 34 37 namespace WebKit { 35 using WebKit::WebCompositor; 36 using WebKit::WebCompositorImpl; 38 37 39 void WebCompositor::setThread(WebThread* compositorThread) 38 namespace { 39 40 TEST(WebCompositorImpl, fromIdentifier) 40 41 { 41 ASSERT(compositorThread); 42 CCThreadProxy::setThread(CCThreadImpl::create(compositorThread).leakPtr()); 43 } 42 #ifndef NDEBUG 43 // WebCompositor APIs can only be called from the compositor thread. 44 WebCore::CCProxy::setImplThread(true); 45 #endif 44 46 45 WebCompositorImpl::WebCompositorImpl() 46 : m_client(0)47 { 48 } 47 // Before creating any WebCompositors, lookups for any value should fail and not crash. 48 EXPECT_EQ(0, WebCompositor::fromIdentifier(2)); 49 EXPECT_EQ(0, WebCompositor::fromIdentifier(0)); 50 EXPECT_EQ(0, WebCompositor::fromIdentifier(-1)); 49 51 50 WebCompositorImpl::~WebCompositorImpl() 51 { 52 } 52 int compositorIdentifier = -1; 53 { 54 #ifndef NDEBUG 55 WebCore::CCProxy::setImplThread(false); 56 #endif 57 OwnPtr<WebCompositorImpl> comp = WebCompositorImpl::create(); 58 #ifndef NDEBUG 59 WebCore::CCProxy::setImplThread(true); 60 #endif 61 compositorIdentifier = comp->identifier(); 62 // The compositor we just created should be locatable. 63 EXPECT_EQ(comp.get(), WebCompositor::fromIdentifier(compositorIdentifier)); 53 64 54 void WebCompositorImpl::setClient(WebCompositorClient* client) 55 { 56 ASSERT(client); 57 m_client = client; 58 } 65 // But nothing else. 66 EXPECT_EQ(0, WebCompositor::fromIdentifier(comp->identifier() + 10)); 67 } 59 68 60 void WebCompositorImpl::handleInputEvent(const WebInputEvent& event) 61 { 62 // FIXME: Do something interesting with the event here. 63 m_client->didHandleInputEvent(false); 69 // After the compositor is destroyed, its entry should be removed from the map. 70 EXPECT_EQ(0, WebCompositor::fromIdentifier(compositorIdentifier)); 64 71 } 65 72 66 73 } 67
Note: See TracChangeset
for help on using the changeset viewer.