Changeset 103293 in webkit
- Timestamp:
- Dec 19, 2011 6:54:49 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 28 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r103291 r103293 1 2011-12-19 James Robinson <jamesr@chromium.org> 2 3 [chromium] CCLayerDelegate and WebLayerClient do not need notifySyncRequired 4 https://bugs.webkit.org/show_bug.cgi?id=74376 5 6 Reviewed by Kenneth Russell. 7 8 CCLayerDelegate::notifySyncRequired is an odd bit of interface that we originally cargo-culted from the 9 CoreAnimation compositor implementation. It is a mechanism by which a LayerChromium instance may request a new 10 frame via its CCLayerDelegate, which in WebCore is always a GraphicsLayerClient. In practice, all 11 implementations eventually ended up routing to CCLayerTreeHost::setNeedsCommit which then made the proper 12 scheduling decision. 13 14 This patch routes all changes that would have gone through CCLayerDelegate::notifySyncRequired directly to 15 CCLayerTreeHost::setNeedsCommit, which greatly simplifies the scheduling logic. 16 17 There is a large amount of unit test coverage for this change, largely in LayerChromiumTest 18 19 * platform/graphics/chromium/GraphicsLayerChromium.cpp: 20 * platform/graphics/chromium/GraphicsLayerChromium.h: 21 * platform/graphics/chromium/LayerChromium.cpp: 22 (WebCore::LayerChromium::setNeedsCommit): 23 (WebCore::LayerChromium::insertChild): 24 * platform/graphics/chromium/LayerChromium.h: 25 * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: 26 (WebCore::CCLayerTreeHost::~CCLayerTreeHost): 27 (WebCore::CCLayerTreeHost::setRootLayer): 28 * platform/graphics/chromium/cc/CCLayerTreeHost.h: 29 * platform/graphics/chromium/cc/CCScopedThreadProxy.h: 30 (WebCore::CCScopedThreadProxy::runTaskIfNotShutdown): 31 1 32 2011-12-19 Sailesh Agrawal <sail@chromium.org> 2 33 -
trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
r103150 r103293 666 666 } 667 667 668 void GraphicsLayerChromium::notifySyncRequired()669 {670 if (m_client)671 m_client->notifySyncRequired(this);672 }673 674 668 } // namespace WebCore 675 669 -
trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h
r103150 r103293 100 100 virtual bool drawsContent() const; 101 101 virtual void paintContents(GraphicsContext&, const IntRect& clip); 102 virtual void notifySyncRequired();103 102 104 103 // Exposed for tests. -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
r103290 r103293 130 130 void LayerChromium::setNeedsCommit() 131 131 { 132 if (m_ delegate)133 m_ delegate->notifySyncRequired();132 if (m_layerTreeHost) 133 m_layerTreeHost->setNeedsCommit(); 134 134 } 135 135 -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h
r103290 r103293 62 62 virtual bool drawsContent() const = 0; 63 63 virtual void paintContents(GraphicsContext&, const IntRect& clip) = 0; 64 virtual void notifySyncRequired() = 0;65 64 }; 66 65 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
r103290 r103293 105 105 ASSERT(CCProxy::isMainThread()); 106 106 TRACE_EVENT("CCLayerTreeHost::~CCLayerTreeHost", this, 0); 107 ASSERT(m_proxy); 107 108 m_proxy->stop(); 108 109 m_proxy.clear(); … … 249 250 if (m_rootLayer) 250 251 m_rootLayer->setLayerTreeHost(this); 252 setNeedsCommit(); 251 253 } 252 254 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
r103290 r103293 164 164 165 165 void setNeedsAnimate(); 166 void setNeedsCommit(); 166 // virtual for testing 167 virtual void setNeedsCommit(); 167 168 void setNeedsRedraw(); 168 169 -
trunk/Source/WebKit/chromium/ChangeLog
r103290 r103293 1 2011-12-19 James Robinson <jamesr@chromium.org> 2 3 [chromium] CCLayerDelegate and WebLayerClient do not need notifySyncRequired 4 https://bugs.webkit.org/show_bug.cgi?id=74376 5 6 Reviewed by Kenneth Russell. 7 8 WebLayerClient::notifyNeedsComposite() is an odd interface for the same reason that 9 CCLayerDelegate::notifySyncRequired() is - all scheduling decisions should route through the WebLayerTreeView, 10 not individual layers. In practice, all implementations of WebLayerClient::notifySyncRequired() do the exact 11 same thing as WebLayerTreeView::scheduleComposite(). This removes that callback, making WebLayerClient an empty 12 interface, and routes all calls that would go to that interface to WebLayerTreeView::scheduleComposite(). 13 14 Once downstream implementations of WebLayerClient are removed, WebLayerClient.h and the constructors associated 15 with it can be deleted. 16 17 The bulk of the changes here are to the test harness. Many tests that were designed around notifySyncRequired() 18 are rewritten to check for CCLayerTreeHost::setNeedsCommit() or WebLayerTreeView::scheduleComposite() instead. 19 In a few instances, this required changing the setup logic around somewhat so that the layers being manipulated 20 were in a tree that initialized without errors. 21 22 * WebKit.gypi: 23 * public/platform/WebContentLayer.h: 24 * public/platform/WebExternalTextureLayer.h: 25 * public/platform/WebLayer.h: 26 * public/platform/WebLayerClient.h: 27 * src/WebContentLayer.cpp: 28 (WebKit::WebContentLayer::create): 29 * src/WebContentLayerImpl.cpp: 30 (WebKit::WebContentLayerImpl::create): 31 (WebKit::WebContentLayerImpl::WebContentLayerImpl): 32 * src/WebContentLayerImpl.h: 33 * src/WebExternalTextureLayer.cpp: 34 (WebKit::WebExternalTextureLayer::create): 35 * src/WebExternalTextureLayerImpl.cpp: 36 (WebKit::WebExternalTextureLayerImpl::create): 37 (WebKit::WebExternalTextureLayerImpl::WebExternalTextureLayerImpl): 38 * src/WebExternalTextureLayerImpl.h: 39 * src/WebLayer.cpp: 40 (WebKit::WebLayer::create): 41 * src/WebLayerImpl.cpp: 42 (WebKit::WebLayerImpl::create): 43 (WebKit::WebLayerImpl::WebLayerImpl): 44 * src/WebLayerImpl.h: 45 * src/WebLayerTreeViewImpl.cpp: 46 (WebKit::WebLayerTreeViewImpl::create): 47 (WebKit::WebLayerTreeViewImpl::WebLayerTreeViewImpl): 48 * src/WebLayerTreeViewImpl.h: 49 * tests/CCLayerTreeHostTest.cpp: 50 (WTF::MockLayerTreeHost::create): 51 (WTF::MockLayerTreeHost::MockLayerTreeHost): 52 (WTF::MockLayerTreeHostClient::createLayerTreeHostContext3D): 53 (WTF::CCLayerTreeHostTestScrollSimple::animateAndLayout): 54 * tests/CompositorMockGraphicsContext3D.h: Added. 55 (WebCore::createCompositorMockGraphicsContext3D): 56 * tests/CompositorMockWebGraphicsContext3D.h: Added. 57 (WebKit::CompositorMockWebGraphicsContext3D::create): 58 (WebKit::CompositorMockWebGraphicsContext3D::makeContextCurrent): 59 (WebKit::CompositorMockWebGraphicsContext3D::createProgram): 60 (WebKit::CompositorMockWebGraphicsContext3D::createShader): 61 (WebKit::CompositorMockWebGraphicsContext3D::getShaderiv): 62 (WebKit::CompositorMockWebGraphicsContext3D::getProgramiv): 63 (WebKit::CompositorMockWebGraphicsContext3D::CompositorMockWebGraphicsContext3D): 64 * tests/LayerChromiumTest.cpp: 65 * tests/MockWebGraphicsContext3D.h: 66 (WebKit::MockWebGraphicsContext3D::getContextAttributes): 67 * tests/WebGLLayerChromiumTest.cpp: 68 (WebKit::TEST): 69 * tests/WebLayerTest.cpp: 70 (testing::MockWebLayerTreeViewClient::animateAndLayout): 71 (testing::MockWebLayerTreeViewClient::applyScrollAndScale): 72 (testing::MockWebLayerTreeViewClient::createContext3D): 73 (testing::MockWebLayerTreeViewClient::didRebindGraphicsContext): 74 (testing::WebLayerTest::SetUp): 75 (testing::WebLayerTest::TearDown): 76 (testing::TEST_F): 77 1 78 2011-12-19 James Robinson <jamesr@chromium.org> 2 79 -
trunk/Source/WebKit/chromium/WebKit.gypi
r103264 r103293 67 67 'tests/CCLayerTreeTestCommon.h', 68 68 'tests/CCRenderSurfaceTest.cpp', 69 'tests/CCSchedulerTest.cpp',70 69 'tests/CCSchedulerStateMachineTest.cpp', 71 70 'tests/CCSchedulerTestCommon.h', 71 'tests/CCSchedulerTest.cpp', 72 72 'tests/CCThreadTaskTest.cpp', 73 'tests/CompositorFakeGraphicsContext3D.h', 74 'tests/CompositorFakeWebGraphicsContext3D.h', 75 'tests/FakeGraphicsContext3DTest.cpp', 76 'tests/FakeWebGraphicsContext3D.h', 73 77 'tests/FloatQuadTest.cpp', 74 78 'tests/FrameTestHelpers.cpp', … … 81 85 'tests/KURLTest.cpp', 82 86 'tests/LayerChromiumTest.cpp', 83 'tests/MockGraphicsContext3DTest.cpp',84 'tests/MockWebGraphicsContext3D.h',85 87 'tests/PODArenaTest.cpp', 86 88 'tests/PODIntervalTreeTest.cpp', -
trunk/Source/WebKit/chromium/public/platform/WebContentLayer.h
r103150 r103293 38 38 class WebContentLayer : public WebLayer { 39 39 public: 40 WEBKIT_EXPORT static WebContentLayer create(WebContentLayerClient*); 41 // FIXME: Remove this as soon as downstream clients are updated. 40 42 WEBKIT_EXPORT static WebContentLayer create(WebLayerClient*, WebContentLayerClient*); 41 43 -
trunk/Source/WebKit/chromium/public/platform/WebExternalTextureLayer.h
r103150 r103293 43 43 class WebExternalTextureLayer : public WebLayer { 44 44 public: 45 WEBKIT_EXPORT static WebExternalTextureLayer create(); 46 // FIXME: Remove as soon as downstream clients are updated. 45 47 WEBKIT_EXPORT static WebExternalTextureLayer create(WebLayerClient*); 46 48 -
trunk/Source/WebKit/chromium/public/platform/WebLayer.h
r103150 r103293 41 41 class WebLayer { 42 42 public: 43 WEBKIT_EXPORT static WebLayer create(); 44 // FIXME: Remove this constructor once downstream clients are updated. 43 45 WEBKIT_EXPORT static WebLayer create(WebLayerClient*); 44 46 -
trunk/Source/WebKit/chromium/public/platform/WebLayerClient.h
r103150 r103293 31 31 class WebLayerClient { 32 32 public: 33 // Notifies the client that the layer has changed in a way that needs a 34 // compositing pass to visually update. The client should eventually call 35 // WebLayerTreeView::composite. 36 // Note: some complex operations (e.g layer reparenting) can cause this to 37 // be called while the layer tree is in an inconsistent state, so to get 38 // correct results, WebLayerTreeView::composite should be called after the 39 // operation has finished (e.g. by posting a task). 40 virtual void notifyNeedsComposite() = 0; 33 // This empty interface exists only for legacy reasons - it will be deleted as soon 34 // as downstream consumers stop depending on this interface existing. 41 35 42 36 protected: -
trunk/Source/WebKit/chromium/src/WebContentLayer.cpp
r103150 r103293 32 32 namespace WebKit { 33 33 34 WebContentLayer WebContentLayer::create(Web LayerClient* client, WebContentLayerClient* contentClient)34 WebContentLayer WebContentLayer::create(WebContentLayerClient* contentClient) 35 35 { 36 return WebContentLayer(WebContentLayerImpl::create(client, contentClient)); 36 return WebContentLayer(WebContentLayerImpl::create(contentClient)); 37 } 38 39 WebContentLayer WebContentLayer::create(WebLayerClient*, WebContentLayerClient* contentClient) 40 { 41 return WebContentLayer::create(contentClient); 37 42 } 38 43 -
trunk/Source/WebKit/chromium/src/WebContentLayerImpl.cpp
r103150 r103293 28 28 29 29 #include "platform/WebContentLayerClient.h" 30 #include "platform/WebLayerClient.h"31 30 #include "platform/WebRect.h" 32 31 #include "GraphicsContext.h" … … 40 39 namespace WebKit { 41 40 42 PassRefPtr<WebContentLayerImpl> WebContentLayerImpl::create(Web LayerClient* client, WebContentLayerClient* contentClient)41 PassRefPtr<WebContentLayerImpl> WebContentLayerImpl::create(WebContentLayerClient* contentClient) 43 42 { 44 return adoptRef(new WebContentLayerImpl(c lient, contentClient));43 return adoptRef(new WebContentLayerImpl(contentClient)); 45 44 } 46 45 47 WebContentLayerImpl::WebContentLayerImpl(Web LayerClient* client, WebContentLayerClient* contentClient)46 WebContentLayerImpl::WebContentLayerImpl(WebContentLayerClient* contentClient) 48 47 : ContentLayerChromium(this) 49 , m_client(client)50 48 , m_contentClient(contentClient) 51 49 , m_drawsContent(true) … … 81 79 } 82 80 83 void WebContentLayerImpl::notifySyncRequired()84 {85 if (m_client)86 m_client->notifyNeedsComposite();87 }88 89 81 } // namespace WebKit -
trunk/Source/WebKit/chromium/src/WebContentLayerImpl.h
r103150 r103293 31 31 32 32 namespace WebKit { 33 class WebLayerClient;34 33 class WebContentLayerClient; 35 34 36 35 class WebContentLayerImpl : public WebCore::ContentLayerChromium, public WebCore::CCLayerDelegate { 37 36 public: 38 static PassRefPtr<WebContentLayerImpl> create(Web LayerClient*, WebContentLayerClient* contentClient);37 static PassRefPtr<WebContentLayerImpl> create(WebContentLayerClient* contentClient); 39 38 40 39 void setDrawsContent(bool); … … 42 41 43 42 protected: 44 WebContentLayerImpl(WebLayerClient*,WebContentLayerClient* contentClient);43 explicit WebContentLayerImpl(WebContentLayerClient* contentClient); 45 44 virtual ~WebContentLayerImpl(); 46 45 virtual void paintContents(WebCore::GraphicsContext&, const WebCore::IntRect& clip); 47 virtual void notifySyncRequired();48 46 49 WebLayerClient* m_client;50 47 WebContentLayerClient* m_contentClient; 51 48 bool m_drawsContent; -
trunk/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp
r103150 r103293 32 32 namespace WebKit { 33 33 34 WebExternalTextureLayer WebExternalTextureLayer::create(WebLayerClient* client)34 WebExternalTextureLayer WebExternalTextureLayer::create(WebLayerClient*) 35 35 { 36 return WebExternalTextureLayer(WebExternalTextureLayerImpl::create(client)); 36 return WebExternalTextureLayer::create(); 37 } 38 39 WebExternalTextureLayer WebExternalTextureLayer::create() 40 { 41 return WebExternalTextureLayer(WebExternalTextureLayerImpl::create()); 37 42 } 38 43 -
trunk/Source/WebKit/chromium/src/WebExternalTextureLayerImpl.cpp
r103150 r103293 27 27 #include "WebExternalTextureLayerImpl.h" 28 28 29 #include "platform/WebLayerClient.h"30 29 #include "GraphicsContext.h" 31 30 #include "platform/WebCanvas.h" … … 35 34 namespace WebKit { 36 35 37 PassRefPtr<WebExternalTextureLayerImpl> WebExternalTextureLayerImpl::create( WebLayerClient* client)36 PassRefPtr<WebExternalTextureLayerImpl> WebExternalTextureLayerImpl::create() 38 37 { 39 return adoptRef(new WebExternalTextureLayerImpl( client));38 return adoptRef(new WebExternalTextureLayerImpl()); 40 39 } 41 40 42 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl( WebLayerClient* client)41 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl() 43 42 : PluginLayerChromium(this) 44 , m_client(client)45 43 { 46 44 setFlipped(false); … … 61 59 } 62 60 63 void WebExternalTextureLayerImpl::notifySyncRequired()64 {65 if (m_client)66 m_client->notifyNeedsComposite();67 }68 69 61 } // namespace WebKit -
trunk/Source/WebKit/chromium/src/WebExternalTextureLayerImpl.h
r103150 r103293 31 31 32 32 namespace WebKit { 33 class WebLayerClient;34 33 35 34 class WebExternalTextureLayerImpl : public WebCore::PluginLayerChromium, public WebCore::CCLayerDelegate { 36 35 public: 37 static PassRefPtr<WebExternalTextureLayerImpl> create( WebLayerClient*);36 static PassRefPtr<WebExternalTextureLayerImpl> create(); 38 37 39 38 protected: 40 WebExternalTextureLayerImpl( WebLayerClient*);39 WebExternalTextureLayerImpl(); 41 40 virtual ~WebExternalTextureLayerImpl(); 42 41 virtual void paintContents(WebCore::GraphicsContext&, const WebCore::IntRect& clip); 43 virtual void notifySyncRequired();44 42 virtual bool drawsContent() const; 45 46 WebLayerClient* m_client;47 43 }; 48 44 -
trunk/Source/WebKit/chromium/src/WebLayer.cpp
r103150 r103293 75 75 namespace WebKit { 76 76 77 WebLayer WebLayer::create(WebLayerClient* client) 78 { 79 return WebLayer(WebLayerImpl::create(client)); 77 WebLayer WebLayer::create(WebLayerClient*) 78 { 79 return WebLayer::create(); 80 } 81 82 WebLayer WebLayer::create() 83 { 84 return WebLayer(WebLayerImpl::create()); 80 85 } 81 86 -
trunk/Source/WebKit/chromium/src/WebLayerImpl.cpp
r103150 r103293 27 27 #include "WebLayerImpl.h" 28 28 29 #include "platform/WebLayerClient.h"30 31 29 using namespace WebCore; 32 30 33 31 namespace WebKit { 34 32 35 PassRefPtr<WebLayerImpl> WebLayerImpl::create( WebLayerClient* client)33 PassRefPtr<WebLayerImpl> WebLayerImpl::create() 36 34 { 37 return adoptRef(new WebLayerImpl( client));35 return adoptRef(new WebLayerImpl()); 38 36 } 39 37 40 WebLayerImpl::WebLayerImpl(WebLayerClient* client) : LayerChromium(this), m_client(client) 38 WebLayerImpl::WebLayerImpl() 39 : LayerChromium(this) 41 40 { 42 41 } … … 56 55 } 57 56 58 void WebLayerImpl::notifySyncRequired()59 {60 if (m_client)61 m_client->notifyNeedsComposite();62 }63 64 57 } // namespace WebKit -
trunk/Source/WebKit/chromium/src/WebLayerImpl.h
r103150 r103293 31 31 32 32 namespace WebKit { 33 class WebLayerClient;34 33 35 34 class WebLayerImpl : public WebCore::LayerChromium, public WebCore::CCLayerDelegate { 36 35 public: 37 static PassRefPtr<WebLayerImpl> create( WebLayerClient*);36 static PassRefPtr<WebLayerImpl> create(); 38 37 39 38 protected: 40 WebLayerImpl( WebLayerClient*);39 WebLayerImpl(); 41 40 virtual ~WebLayerImpl(); 42 41 virtual bool drawsContent() const; 43 42 virtual void paintContents(WebCore::GraphicsContext&, const WebCore::IntRect& clip); 44 virtual void notifySyncRequired();45 46 WebLayerClient* m_client;47 43 }; 48 44 -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
r103150 r103293 27 27 #include "cc/CCLayerTreeHostImpl.h" 28 28 29 #include "FakeWebGraphicsContext3D.h" 29 30 #include "GraphicsContext3DPrivate.h" 30 31 #include "LayerRendererChromium.h" 31 #include "MockWebGraphicsContext3D.h"32 32 #include "cc/CCLayerImpl.h" 33 33 #include "cc/CCSingleThreadProxy.h" … … 156 156 } 157 157 158 class BlendStateTrackerContext: public MockWebGraphicsContext3D {158 class BlendStateTrackerContext: public FakeWebGraphicsContext3D { 159 159 public: 160 160 BlendStateTrackerContext() : m_blend(false) { } … … 290 290 } 291 291 292 class ReshapeTrackerContext: public MockWebGraphicsContext3D {292 class ReshapeTrackerContext: public FakeWebGraphicsContext3D { 293 293 public: 294 294 ReshapeTrackerContext() : m_reshapeCalled(false) { } -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
r103290 r103293 27 27 #include "cc/CCLayerTreeHost.h" 28 28 29 #include "CompositorFakeGraphicsContext3D.h" 29 30 #include "ContentLayerChromium.h" 30 #include " GraphicsContext3DPrivate.h"31 #include "FakeWebGraphicsContext3D.h" 31 32 #include "LayerChromium.h" 32 #include "MockWebGraphicsContext3D.h"33 33 #include "TextureManager.h" 34 34 #include "WebCompositor.h" … … 105 105 { 106 106 RefPtr<MockLayerTreeHost> layerTreeHost = adoptRef(new MockLayerTreeHost(testHooks, client, settings)); 107 layerTreeHost->setRootLayer(rootLayer);108 107 bool success = layerTreeHost->initialize(); 109 108 EXPECT_TRUE(success); 109 layerTreeHost->setRootLayer(rootLayer); 110 110 111 111 // LayerTreeHostImpl won't draw if it has 1x1 viewport. … … 130 130 }; 131 131 132 // Test stub for WebGraphicsContext3D. Returns canned values needed for compositor initialization.133 class CompositorMockWebGraphicsContext3D : public MockWebGraphicsContext3D {134 public:135 static PassOwnPtr<CompositorMockWebGraphicsContext3D> create()136 {137 return adoptPtr(new CompositorMockWebGraphicsContext3D());138 }139 140 virtual bool makeContextCurrent() { return true; }141 virtual WebGLId createProgram() { return 1; }142 virtual WebGLId createShader(WGC3Denum) { return 1; }143 virtual void getShaderiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }144 virtual void getProgramiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }145 146 private:147 CompositorMockWebGraphicsContext3D() { }148 };149 150 132 // Implementation of CCLayerTreeHost callback interface. 151 133 class MockLayerTreeHostClient : public CCLayerTreeHostClient { … … 168 150 virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() 169 151 { 170 OwnPtr<WebGraphicsContext3D> mock = CompositorMockWebGraphicsContext3D::create(); 171 GraphicsContext3D::Attributes attrs; 172 RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(mock.release(), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnAnotherThread); 173 return context; 152 return createCompositorMockGraphicsContext3D(GraphicsContext3D::Attributes()); 174 153 } 175 154 … … 758 737 } 759 738 760 virtual void beginCommitOnCCThread(CCLayerTreeHostImpl* impl)739 virtual void animateAndLayout(double frameBeginTime) 761 740 { 762 741 LayerChromium* root = m_layerTreeHost->rootLayer(); … … 943 922 virtual bool drawsContent() const { return true; } 944 923 virtual bool preserves3D() { return false; } 945 virtual void notifySyncRequired() { }946 924 947 925 private: -
trunk/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp
r103273 r103293 27 27 #include "Canvas2DLayerChromium.h" 28 28 29 #include "FakeWebGraphicsContext3D.h" 29 30 #include "GraphicsContext3DPrivate.h" 30 #include "MockWebGraphicsContext3D.h"31 31 #include "TextureManager.h" 32 32 #include "cc/CCCanvasLayerImpl.h" … … 59 59 namespace { 60 60 61 class MockCanvasContext : public MockWebGraphicsContext3D {61 class MockCanvasContext : public FakeWebGraphicsContext3D { 62 62 public: 63 63 MOCK_METHOD0(createFramebuffer, WebGLId()); -
trunk/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp
r103292 r103293 28 28 #include "GraphicsContext3D.h" 29 29 30 #include "FakeWebGraphicsContext3D.h" 30 31 #include "GraphicsContext3DPrivate.h" 31 #include "MockWebGraphicsContext3D.h"32 32 33 33 #include <gmock/gmock.h> … … 36 36 using namespace WebCore; 37 37 using namespace WebKit; 38 using testing::Return;39 38 40 class FrameCountingContext : public MockWebGraphicsContext3D {39 class FrameCountingContext : public FakeWebGraphicsContext3D { 41 40 public: 42 41 FrameCountingContext() : m_frame(0) { } … … 51 50 }; 52 51 53 TEST( MockGraphicsContext3DTest, CanOverrideManually)52 TEST(FakeGraphicsContext3DTest, CanOverrideManually) 54 53 { 55 54 GraphicsContext3D::Attributes attrs; … … 67 66 68 67 69 class GMockContext : public MockWebGraphicsContext3D {68 class GMockContext : public FakeWebGraphicsContext3D { 70 69 public: 71 70 MOCK_METHOD0(getError, WGC3Denum()); 72 71 }; 73 72 74 TEST( MockGraphicsContext3DTest, CanUseGMock)73 TEST(FakeGraphicsContext3DTest, CanUseGMock) 75 74 { 76 75 GraphicsContext3D::Attributes attrs; … … 79 78 80 79 EXPECT_CALL(mockContext, getError()) 81 .WillRepeatedly( Return(314));80 .WillRepeatedly(testing::Return(314)); 82 81 83 82 // It's OK to call methods GMock doesn't know about. … … 89 88 } 90 89 91 class ContextThatCountsMakeCurrents : public MockWebGraphicsContext3D {90 class ContextThatCountsMakeCurrents : public FakeWebGraphicsContext3D { 92 91 public: 93 92 ContextThatCountsMakeCurrents() : m_makeCurrentCount(0) { } … … 103 102 104 103 105 TEST( MockGraphicsContext3DTest, ContextForThisThreadShouldMakeCurrent)104 TEST(FakeGraphicsContext3DTest, ContextForThisThreadShouldMakeCurrent) 106 105 { 107 106 GraphicsContext3D::Attributes attrs; … … 112 111 } 113 112 114 TEST( MockGraphicsContext3DTest, ContextForAnotherThreadShouldNotMakeCurrent)113 TEST(FakeGraphicsContext3DTest, ContextForAnotherThreadShouldNotMakeCurrent) 115 114 { 116 115 GraphicsContext3D::Attributes attrs; … … 121 120 } 122 121 123 class ContextWithMakeCurrentThatFails : public MockWebGraphicsContext3D {122 class ContextWithMakeCurrentThatFails : public FakeWebGraphicsContext3D { 124 123 public: 125 124 ContextWithMakeCurrentThatFails() { } … … 127 126 }; 128 127 129 TEST( MockGraphicsContext3DTest, ContextForThisThreadFailsWhenMakeCurrentFails)128 TEST(FakeGraphicsContext3DTest, ContextForThisThreadFailsWhenMakeCurrentFails) 130 129 { 131 130 GraphicsContext3D::Attributes attrs; -
trunk/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h
r103292 r103293 24 24 */ 25 25 26 #ifndef MockWebGraphicsContext3D_h27 #define MockWebGraphicsContext3D_h26 #ifndef FakeWebGraphicsContext3D_h 27 #define FakeWebGraphicsContext3D_h 28 28 29 29 #include "GraphicsContext3D.h" … … 34 34 // WebGraphicsContext3D base class for use in WebKit unit tests. 35 35 // All operations are no-ops (returning 0 if necessary). 36 class MockWebGraphicsContext3D : public WebGraphicsContext3D {36 class FakeWebGraphicsContext3D : public WebGraphicsContext3D { 37 37 public: 38 38 virtual bool initialize(Attributes, WebView*, bool renderDirectlyToWebView) { return false; } … … 129 129 virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value) { } 130 130 virtual void getBufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Dint* value) { } 131 virtual Attributes getContextAttributes() { return Attributes(); }131 virtual Attributes getContextAttributes() { return m_attrs; } 132 132 virtual WGC3Denum getError() { return 0; } 133 133 virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value) { } … … 255 255 virtual void texStorage2DEXT(WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat, 256 256 WGC3Dint width, WGC3Dint height) { } 257 258 protected: 259 Attributes m_attrs; 257 260 }; 258 261 259 262 } // namespace WebKit 260 263 261 #endif // MockWebGraphicsContext3D_h264 #endif // FakeWebGraphicsContext3D_h -
trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp
r103290 r103293 27 27 #include "LayerChromium.h" 28 28 29 #include "cc/CCLayerTreeHost.h" 29 30 #include "CCLayerTreeTestCommon.h" 30 31 #include "LayerPainterChromium.h" … … 36 37 37 38 using namespace WebCore; 38 using namespace WebKit;39 39 using namespace WebKitTests; 40 40 using ::testing::Mock; … … 43 43 using ::testing::AnyNumber; 44 44 45 #define EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(delegate, numTimesExpectedNotifySync, codeToTest) \ 46 EXPECT_CALL((delegate), notifySyncRequired()).Times((numTimesExpectedNotifySync)); \ 47 codeToTest; \ 48 Mock::VerifyAndClearExpectations(&(delegate)) 45 #define EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(numTimesExpectedSetNeedsCommit, codeToTest) do { \ 46 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times((numTimesExpectedSetNeedsCommit)); \ 47 codeToTest; \ 48 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); \ 49 } while (0) 49 50 50 51 namespace { 51 52 52 class MockLayerDelegate : public CCLayerDelegate{53 class FakeCCLayerTreeHostClient : public CCLayerTreeHostClient { 53 54 public: 54 MOCK_CONST_METHOD0(drawsContent, bool()); 55 MOCK_CONST_METHOD0(preserves3D, bool()); 56 MOCK_METHOD2(paintContents, void(GraphicsContext&, const IntRect&)); 57 MOCK_METHOD0(notifySyncRequired, void()); 55 virtual void animateAndLayout(double frameBeginTime) { } 56 virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) { } 57 virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() { return 0; } 58 virtual void didRecreateGraphicsContext(bool success) { } 59 virtual void didCommitAndDrawFrame() { } 60 virtual void didCompleteSwapBuffers() { } 61 62 // Used only in the single-threaded path. 63 virtual void scheduleComposite() { } 64 }; 65 66 class MockCCLayerTreeHost : public CCLayerTreeHost { 67 public: 68 MockCCLayerTreeHost() 69 : CCLayerTreeHost(&m_fakeClient, CCSettings()) 70 { 71 initialize(); 72 } 73 74 MOCK_METHOD0(setNeedsCommit, void()); 75 76 private: 77 FakeCCLayerTreeHostClient m_fakeClient; 58 78 }; 59 79 … … 63 83 }; 64 84 65 class MockNonCompositedContentHost : public NonCompositedContentHost {66 public:67 static PassOwnPtr<MockNonCompositedContentHost> create()68 {69 return adoptPtr(new MockNonCompositedContentHost);70 }71 72 MOCK_METHOD1(notifySyncRequired, void(const GraphicsLayer*));73 74 private:75 MockNonCompositedContentHost()76 : NonCompositedContentHost(adoptPtr(new MockLayerPainterChromium()))77 {78 m_scrollLayer = GraphicsLayer::create(0);79 setScrollLayer(m_scrollLayer.get());80 }81 OwnPtr<GraphicsLayer> m_scrollLayer;82 };83 84 class LayerChromiumWithInstrumentedDestructor : public LayerChromium {85 public:86 explicit LayerChromiumWithInstrumentedDestructor(CCLayerDelegate* delegate)87 : LayerChromium(delegate)88 {89 }90 91 virtual ~LayerChromiumWithInstrumentedDestructor()92 {93 s_numInstancesDestroyed++;94 }95 96 static int getNumInstancesDestroyed() { return s_numInstancesDestroyed; }97 static void resetNumInstancesDestroyed() { s_numInstancesDestroyed = 0; }98 99 private:100 static int s_numInstancesDestroyed;101 };102 103 int LayerChromiumWithInstrumentedDestructor::s_numInstancesDestroyed = 0;104 85 105 86 class LayerChromiumTest : public testing::Test { … … 107 88 virtual void SetUp() 108 89 { 109 // m_silentDelegate is initialized to be just a stub and will 110 // not print any warnings. It is used when we are not worried 111 // about testing how the delegate is called. 112 EXPECT_CALL(m_silentDelegate, drawsContent()).Times(AnyNumber()); 113 EXPECT_CALL(m_silentDelegate, preserves3D()).Times(AnyNumber()); 114 EXPECT_CALL(m_silentDelegate, paintContents(_, _)).Times(AnyNumber()); 115 EXPECT_CALL(m_silentDelegate, notifySyncRequired()).Times(AnyNumber()); 116 117 // Static variables need to be reset for every new test case 118 LayerChromiumWithInstrumentedDestructor::resetNumInstancesDestroyed(); 90 // Initialize without threading support. 91 WebKit::WebCompositor::initialize(0); 92 m_layerTreeHost = adoptRef(new MockCCLayerTreeHost); 93 } 94 95 virtual void TearDown() 96 { 97 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 98 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); 99 m_parent.clear(); 100 m_child1.clear(); 101 m_child2.clear(); 102 m_child3.clear(); 103 m_grandChild1.clear(); 104 m_grandChild2.clear(); 105 m_grandChild3.clear(); 106 107 m_layerTreeHost->setRootLayer(0); 108 m_layerTreeHost.clear(); 109 WebKit::WebCompositor::shutdown(); 119 110 } 120 111 … … 144 135 void createSimpleTestTree() 145 136 { 146 m_parent = LayerChromium::create(&m_parentDelegate); 147 m_child1 = LayerChromium::create(&m_silentDelegate); 148 m_child2 = LayerChromium::create(&m_silentDelegate); 149 m_child3 = LayerChromium::create(&m_silentDelegate); 150 m_grandChild1 = LayerChromium::create(&m_silentDelegate); 151 m_grandChild2 = LayerChromium::create(&m_silentDelegate); 152 m_grandChild3 = LayerChromium::create(&m_silentDelegate); 153 154 EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(3); 137 m_parent = LayerChromium::create(0); 138 m_child1 = LayerChromium::create(0); 139 m_child2 = LayerChromium::create(0); 140 m_child3 = LayerChromium::create(0); 141 m_grandChild1 = LayerChromium::create(0); 142 m_grandChild2 = LayerChromium::create(0); 143 m_grandChild3 = LayerChromium::create(0); 144 145 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); 146 m_layerTreeHost->setRootLayer(m_parent); 147 155 148 m_parent->addChild(m_child1); 156 149 m_parent->addChild(m_child2); 157 150 m_parent->addChild(m_child3); 158 Mock::VerifyAndClearExpectations(&m_parentDelegate);159 151 m_child1->addChild(m_grandChild1); 160 152 m_child1->addChild(m_grandChild2); 161 153 m_child2->addChild(m_grandChild3); 162 154 155 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 156 163 157 verifyTestTreeInitialState(); 164 158 } 165 159 166 MockLayerDelegate m_silentDelegate, m_parentDelegate;160 RefPtr<MockCCLayerTreeHost> m_layerTreeHost; 167 161 RefPtr<LayerChromium> m_parent, m_child1, m_child2, m_child3, m_grandChild1, m_grandChild2, m_grandChild3; 168 162 }; … … 170 164 TEST_F(LayerChromiumTest, basicCreateAndDestroy) 171 165 { 172 MockLayerDelegate mockDelegate; 173 174 // notifySyncRequired should not be called just because the layer is created or destroyed. 175 EXPECT_CALL(mockDelegate, notifySyncRequired()).Times(0); 176 177 RefPtr<LayerChromiumWithInstrumentedDestructor> testLayer = adoptRef(new LayerChromiumWithInstrumentedDestructor(&mockDelegate)); 178 ASSERT_TRUE(testLayer.get()); 179 180 // notifySyncRequired should also not be called on the destructor when the layer has no children. 181 // so we need to make sure the layer is destroyed before the mock delegate. 182 ASSERT_EQ(0, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed()); 183 testLayer.release(); 184 ASSERT_EQ(1, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed()); 166 RefPtr<LayerChromium> testLayer = LayerChromium::create(0); 167 ASSERT_TRUE(testLayer); 168 169 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0); 170 testLayer->setLayerTreeHost(m_layerTreeHost.get()); 185 171 } 186 172 187 173 TEST_F(LayerChromiumTest, addAndRemoveChild) 188 174 { 189 MockLayerDelegate parentDelegate; 190 MockLayerDelegate childDelegate; 191 RefPtr<LayerChromium> parent = LayerChromium::create(&parentDelegate); 192 RefPtr<LayerChromium> child = LayerChromium::create(&childDelegate); 175 RefPtr<LayerChromium> parent = LayerChromium::create(0); 176 RefPtr<LayerChromium> child = LayerChromium::create(0); 193 177 194 178 // Upon creation, layers should not have children or parent. … … 196 180 EXPECT_FALSE(child->parent()); 197 181 198 // Parent calls notifySyncRequired exactly once when adding child. 199 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->addChild(child)); 182 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, m_layerTreeHost->setRootLayer(parent)); 183 184 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->addChild(child)); 200 185 201 186 ASSERT_EQ(static_cast<size_t>(1), parent->children().size()); … … 204 189 EXPECT_EQ(parent.get(), child->rootLayer()); 205 190 206 // removeFromParent should cause the parent's notifySyncRequired to be called exactly once. 207 // The childDelegate notifySyncRequired should remain un-used. 208 EXPECT_CALL(childDelegate, notifySyncRequired()).Times(0); 209 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, child->removeFromParent()); 210 } 211 212 TEST_F(LayerChromiumTest, verifyDestructorSemantics) 213 { 214 MockLayerDelegate parentDelegate; 215 MockLayerDelegate childDelegate; 216 RefPtr<LayerChromiumWithInstrumentedDestructor> parent = adoptRef(new LayerChromiumWithInstrumentedDestructor(&parentDelegate)); 217 RefPtr<LayerChromium> child = LayerChromium::create(&childDelegate); 218 219 // Set up initial test conditions 220 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->addChild(child)); 221 EXPECT_TRUE(child->parent()); 222 223 // When being destroyed, notifySyncRequired is called once for the parent, because it has one child, 224 // but should not be called for the child which has no children. 225 EXPECT_CALL(parentDelegate, notifySyncRequired()).Times(1); 226 EXPECT_CALL(childDelegate, notifySyncRequired()).Times(0); 227 228 ASSERT_EQ(0, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed()); 229 parent.release(); 230 ASSERT_EQ(1, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed()); 231 232 // Child should have been un-parented correctly, but not yet destroyed since we have a reference to it. 233 EXPECT_FALSE(child->parent()); 234 } 235 236 TEST_F(LayerChromiumTest, verifyDestructorDoesNotLeak) 237 { 238 // In this test we explicitly instantiate a special subclass of 239 // LayerChromium so we can track the number of destructors called. 240 241 RefPtr<LayerChromiumWithInstrumentedDestructor> parent, child1, child2, child3, grandChild1, grandChild2, grandChild3; 242 parent = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate)); 243 child1 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate)); 244 child2 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate)); 245 child3 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate)); 246 grandChild1 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate)); 247 grandChild2 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate)); 248 grandChild3 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate)); 249 250 // set up a simple tree. 251 parent->addChild(child1); 252 parent->addChild(child2); 253 parent->addChild(child3); 254 child1->addChild(grandChild1); 255 child1->addChild(grandChild2); 256 child2->addChild(grandChild3); 257 258 // Clear all the children RefPtrs here. But since they are attached to the tree, no destructors should be called yet. 259 child1.clear(); 260 child2.clear(); 261 child3.clear(); 262 grandChild1.clear(); 263 grandChild2.clear(); 264 grandChild3.clear(); 265 266 // releasing the parent should cause all destructors to be invoked. 267 ASSERT_EQ(0, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed()); 268 parent.release(); 269 ASSERT_EQ(7, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed()); 191 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), child->removeFromParent()); 270 192 } 271 193 272 194 TEST_F(LayerChromiumTest, insertChild) 273 195 { 274 MockLayerDelegate parentDelegate;275 MockLayerDelegate childDelegate;276 RefPtr<LayerChromium> parent = LayerChromium::create(&parentDelegate);277 RefPtr<LayerChromium> child1 = LayerChromium::create(&childDelegate);278 RefPtr<LayerChromium> child2 = LayerChromium::create(&childDelegate);279 RefPtr<LayerChromium>child3 = LayerChromium::create(&childDelegate); 280 RefPtr<LayerChromium>child4 = LayerChromium::create(&childDelegate);196 RefPtr<LayerChromium> parent = LayerChromium::create(0); 197 RefPtr<LayerChromium> child1 = LayerChromium::create(0); 198 RefPtr<LayerChromium> child2 = LayerChromium::create(0); 199 RefPtr<LayerChromium> child3 = LayerChromium::create(0); 200 RefPtr<LayerChromium> child4 = LayerChromium::create(0); 201 202 parent->setLayerTreeHost(m_layerTreeHost.get()); 281 203 282 204 ASSERT_EQ(static_cast<size_t>(0), parent->children().size()); 283 205 284 // The child delegate notifySyncRequired should not be called when inserting.285 EXPECT_CALL(childDelegate, notifySyncRequired()).Times(0);286 287 206 // Case 1: inserting to empty list. 288 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(parentDelegate,1, parent->insertChild(child3, 0));207 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child3, 0)); 289 208 ASSERT_EQ(static_cast<size_t>(1), parent->children().size()); 290 209 EXPECT_EQ(child3, parent->children()[0]); … … 292 211 293 212 // Case 2: inserting to beginning of list 294 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(parentDelegate,1, parent->insertChild(child1, 0));213 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child1, 0)); 295 214 ASSERT_EQ(static_cast<size_t>(2), parent->children().size()); 296 215 EXPECT_EQ(child1, parent->children()[0]); … … 299 218 300 219 // Case 3: inserting to middle of list 301 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(parentDelegate,1, parent->insertChild(child2, 1));220 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child2, 1)); 302 221 ASSERT_EQ(static_cast<size_t>(3), parent->children().size()); 303 222 EXPECT_EQ(child1, parent->children()[0]); … … 307 226 308 227 // Case 4: inserting to end of list 309 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(parentDelegate,1, parent->insertChild(child4, 3));228 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child4, 3)); 310 229 311 230 ASSERT_EQ(static_cast<size_t>(4), parent->children().size()); … … 316 235 EXPECT_EQ(parent.get(), child4->parent()); 317 236 318 // parent's destructor will invoke notifySyncRequired as it removes its children. 319 EXPECT_CALL(parentDelegate, notifySyncRequired()).Times(AtLeast(1)); 237 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); 320 238 } 321 239 322 240 TEST_F(LayerChromiumTest, insertChildPastEndOfList) 323 241 { 324 RefPtr<LayerChromium> parent = LayerChromium::create( &m_silentDelegate);325 RefPtr<LayerChromium> child1 = LayerChromium::create( &m_silentDelegate);326 RefPtr<LayerChromium> child2 = LayerChromium::create( &m_silentDelegate);242 RefPtr<LayerChromium> parent = LayerChromium::create(0); 243 RefPtr<LayerChromium> child1 = LayerChromium::create(0); 244 RefPtr<LayerChromium> child2 = LayerChromium::create(0); 327 245 328 246 ASSERT_EQ(static_cast<size_t>(0), parent->children().size()); … … 344 262 TEST_F(LayerChromiumTest, insertSameChildTwice) 345 263 { 346 MockLayerDelegate parentDelegate; 347 RefPtr<LayerChromium> parent = LayerChromium::create(&parentDelegate); 348 RefPtr<LayerChromium> child1 = LayerChromium::create(&m_silentDelegate); 349 RefPtr<LayerChromium> child2 = LayerChromium::create(&m_silentDelegate); 264 RefPtr<LayerChromium> parent = LayerChromium::create(0); 265 RefPtr<LayerChromium> child1 = LayerChromium::create(0); 266 RefPtr<LayerChromium> child2 = LayerChromium::create(0); 267 268 parent->setLayerTreeHost(m_layerTreeHost.get()); 350 269 351 270 ASSERT_EQ(static_cast<size_t>(0), parent->children().size()); 352 271 353 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(parentDelegate,1, parent->insertChild(child1, 0));354 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(parentDelegate,1, parent->insertChild(child2, 1));272 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child1, 0)); 273 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child2, 1)); 355 274 356 275 ASSERT_EQ(static_cast<size_t>(2), parent->children().size()); … … 359 278 360 279 // Inserting the same child again should cause the child to be removed and re-inserted at the new location. 361 // So the parent's notifySyncRequired would be called one or more times. 362 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, AtLeast(1), parent->insertChild(child1, 1)); 280 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), parent->insertChild(child1, 1)); 363 281 364 282 // child1 should now be at the end of the list. … … 367 285 EXPECT_EQ(child1, parent->children()[1]); 368 286 369 // parent's destructor will invoke notifySyncRequired as it removes leftover children 370 EXPECT_CALL(parentDelegate, notifySyncRequired()).Times(AtLeast(1)); 371 } 372 373 TEST_F(LayerChromiumTest, insertChildThatAlreadyHadParent) 374 { 375 MockLayerDelegate oldParentDelegate; 376 RefPtr<LayerChromium> oldParent = LayerChromium::create(&oldParentDelegate); 377 RefPtr<LayerChromium> parent = LayerChromium::create(&m_silentDelegate); 378 RefPtr<LayerChromium> child = LayerChromium::create(&m_silentDelegate); 379 380 // set up and sanity-check initial test conditions 381 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(oldParentDelegate, 1, oldParent->addChild(child)); 382 ASSERT_EQ(static_cast<size_t>(1), oldParent->children().size()); 383 ASSERT_EQ(static_cast<size_t>(0), parent->children().size()); 384 EXPECT_EQ(child, oldParent->children()[0]); 385 EXPECT_EQ(oldParent.get(), child->parent()); 386 387 // Inserting to new parent causes old parent's notifySyncRequired to be called. 388 // Note that it also causes parent's notifySyncRequired to be called, but that is tested elsewhere. 389 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(oldParentDelegate, 1, parent->insertChild(child, 0)); 390 391 ASSERT_EQ(static_cast<size_t>(0), oldParent->children().size()); 392 ASSERT_EQ(static_cast<size_t>(1), parent->children().size()); 393 EXPECT_EQ(child, parent->children()[0]); 394 EXPECT_EQ(parent.get(), child->parent()); 287 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); 395 288 } 396 289 … … 398 291 { 399 292 createSimpleTestTree(); 400 RefPtr<LayerChromium> child4 = LayerChromium::create( &m_silentDelegate);293 RefPtr<LayerChromium> child4 = LayerChromium::create(0); 401 294 402 295 EXPECT_FALSE(child4->parent()); 403 296 404 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(m_parentDelegate,AtLeast(1), m_parent->replaceChild(m_child2.get(), child4));297 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), m_parent->replaceChild(m_child2.get(), child4)); 405 298 406 299 ASSERT_EQ(static_cast<size_t>(3), m_parent->children().size()); … … 411 304 412 305 EXPECT_FALSE(m_child2->parent()); 413 414 // parent's destructor will invoke notifySyncRequired as it removes leftover children415 EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(AtLeast(1));416 306 } 417 307 … … 421 311 422 312 // create another simple tree with testLayer and child4. 423 RefPtr<LayerChromium> testLayer = LayerChromium::create( &m_silentDelegate);424 RefPtr<LayerChromium> child4 = LayerChromium::create( &m_silentDelegate);313 RefPtr<LayerChromium> testLayer = LayerChromium::create(0); 314 RefPtr<LayerChromium> child4 = LayerChromium::create(0); 425 315 testLayer->addChild(child4); 426 316 ASSERT_EQ(static_cast<size_t>(1), testLayer->children().size()); … … 428 318 EXPECT_EQ(testLayer.get(), child4->parent()); 429 319 430 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(m_parentDelegate,AtLeast(1), m_parent->replaceChild(m_child2.get(), child4));320 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), m_parent->replaceChild(m_child2.get(), child4)); 431 321 432 322 ASSERT_EQ(static_cast<size_t>(3), m_parent->children().size()); … … 440 330 ASSERT_EQ(static_cast<size_t>(0), testLayer->children().size()); 441 331 EXPECT_FALSE(m_child2->parent()); 442 443 // parent's destructor will invoke notifySyncRequired as it removes leftover children444 EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(AtLeast(1));445 332 } 446 333 … … 449 336 createSimpleTestTree(); 450 337 451 // notifySyncRequiredshould not be called because its the same child452 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(m_parentDelegate,0, m_parent->replaceChild(m_child2.get(), m_child2));338 // setNeedsCommit should not be called because its the same child 339 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, m_parent->replaceChild(m_child2.get(), m_child2)); 453 340 454 341 verifyTestTreeInitialState(); 455 456 // parent's destructor will invoke notifySyncRequired as it removes leftover children457 EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(AtLeast(1));458 342 } 459 343 … … 462 346 createSimpleTestTree(); 463 347 464 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(m_parentDelegate, AtLeast(1), m_parent->removeAllChildren());348 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(3), m_parent->removeAllChildren()); 465 349 466 350 ASSERT_EQ(static_cast<size_t>(0), m_parent->children().size()); … … 468 352 EXPECT_FALSE(m_child2->parent()); 469 353 EXPECT_FALSE(m_child3->parent()); 470 471 // notifySyncRequired should not be called if trying to removeAllChildren when there are no children.472 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(m_parentDelegate, 0, m_parent->removeAllChildren());473 354 } 474 355 475 356 TEST_F(LayerChromiumTest, setChildren) 476 357 { 477 MockLayerDelegate newParentDelegate; 478 RefPtr<LayerChromium> oldParent = LayerChromium::create(&m_silentDelegate); 479 RefPtr<LayerChromium> newParent = LayerChromium::create(&newParentDelegate); 480 481 RefPtr<LayerChromium> child1 = LayerChromium::create(&m_silentDelegate); 482 RefPtr<LayerChromium> child2 = LayerChromium::create(&m_silentDelegate); 358 RefPtr<LayerChromium> oldParent = LayerChromium::create(0); 359 RefPtr<LayerChromium> newParent = LayerChromium::create(0); 360 361 RefPtr<LayerChromium> child1 = LayerChromium::create(0); 362 RefPtr<LayerChromium> child2 = LayerChromium::create(0); 483 363 484 364 Vector<RefPtr<LayerChromium> > newChildren; … … 492 372 EXPECT_FALSE(child2->parent()); 493 373 494 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(newParentDelegate, AtLeast(1), newParent->setChildren(newChildren)); 374 newParent->setLayerTreeHost(m_layerTreeHost.get()); 375 376 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), newParent->setChildren(newChildren)); 495 377 496 378 ASSERT_EQ(static_cast<size_t>(2), newParent->children().size()); … … 498 380 EXPECT_EQ(newParent.get(), child2->parent()); 499 381 500 // parent's destructor will invoke notifySyncRequired as it removes its children. 501 EXPECT_CALL(newParentDelegate, notifySyncRequired()).Times(AtLeast(1)); 382 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); 502 383 } 503 384 … … 505 386 { 506 387 createSimpleTestTree(); 507 RefPtr<LayerChromium> child4 = LayerChromium::create(&m_silentDelegate); 508 509 // In this test case, we don't care about how the parent's notifySyncRequired is called. 510 EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(AnyNumber()); 388 389 // For this test we don't care about setNeedsCommit calls. 390 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); 391 392 RefPtr<LayerChromium> child4 = LayerChromium::create(0); 511 393 512 394 EXPECT_EQ(m_parent.get(), m_parent->rootLayer()); … … 563 445 // The semantics for setNeedsDisplay which are tested here: 564 446 // 1. sets needsDisplay flag appropriately. 565 // 2. indirectly calls notifySyncRequired, exactly once for each call to setNeedsDisplay. 566 567 MockLayerDelegate mockDelegate; 568 RefPtr<LayerChromium> testLayer = LayerChromium::create(&mockDelegate); 447 // 2. indirectly calls setNeedsCommit, exactly once for each call to setNeedsDisplay. 448 449 RefPtr<LayerChromium> testLayer = LayerChromium::create(0); 450 testLayer->setLayerTreeHost(m_layerTreeHost.get()); 451 569 452 IntSize testBounds = IntSize(501, 508); 570 453 … … 577 460 EXPECT_FALSE(testLayer->needsDisplay()); 578 461 579 // This is just initialization, but notifySyncRequired behavior is verified anyway to avoid warnings. 580 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds)); 581 testLayer = LayerChromium::create(&mockDelegate); 462 // This is just initialization, but setNeedsCommit behavior is verified anyway to avoid warnings. 463 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds)); 464 testLayer = LayerChromium::create(0); 465 testLayer->setLayerTreeHost(m_layerTreeHost.get()); 582 466 EXPECT_FALSE(testLayer->needsDisplay()); 583 467 … … 585 469 586 470 // Case 1: needsDisplay flag should not change because of an empty dirty rect. 587 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(mockDelegate,1, testLayer->setNeedsDisplayRect(emptyDirtyRect));471 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRect(emptyDirtyRect)); 588 472 EXPECT_FALSE(testLayer->needsDisplay()); 589 473 590 474 // Case 2: basic. 591 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(mockDelegate,1, testLayer->setNeedsDisplayRect(dirty1));475 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRect(dirty1)); 592 476 EXPECT_TRUE(testLayer->needsDisplay()); 593 477 594 478 // Case 3: a second dirty rect. 595 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(mockDelegate,1, testLayer->setNeedsDisplayRect(dirty2));479 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRect(dirty2)); 596 480 EXPECT_TRUE(testLayer->needsDisplay()); 597 481 598 482 // Case 4: LayerChromium should accept dirty rects that go beyond its bounds. 599 testLayer = LayerChromium::create(&mockDelegate); 600 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds)); 601 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplayRect(outOfBoundsDirtyRect)); 483 testLayer = LayerChromium::create(0); 484 testLayer->setLayerTreeHost(m_layerTreeHost.get()); 485 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds)); 486 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRect(outOfBoundsDirtyRect)); 602 487 EXPECT_TRUE(testLayer->needsDisplay()); 603 488 604 489 // Case 5: setNeedsDisplay() without the dirty rect arg. 605 testLayer = LayerChromium::create(&mockDelegate); 606 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds)); 607 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplay()); 490 testLayer = LayerChromium::create(0); 491 testLayer->setLayerTreeHost(m_layerTreeHost.get()); 492 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds)); 493 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplay()); 608 494 EXPECT_TRUE(testLayer->needsDisplay()); 609 610 // Case 6: setNeedsDisplay() without the dirty rect arg should not cause611 // needsDisplay flag to change for LayerChromium with empty bounds.612 testLayer = LayerChromium::create(&mockDelegate);613 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplay());614 EXPECT_FALSE(testLayer->needsDisplay());615 495 } 616 496 617 497 TEST_F(LayerChromiumTest, checkSetNeedsDisplayWithNullDelegate) 618 498 { 619 // Without a delegate, the layer should still mark itself dirty as appropriate,620 // and it should not crash trying to use a non-existing delegate.621 499 RefPtr<LayerChromium> testLayer = LayerChromium::create(0); 622 500 IntSize testBounds = IntSize(501, 508); … … 636 514 TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior) 637 515 { 638 MockLayerDelegate initialDelegate;639 MockLayerDelegate mockDelegate;640 RefPtr<LayerChromium> testLayer = LayerChromium::create(&initialDelegate); 641 RefPtr<LayerChromium> dummyLayer = LayerChromium::create( &m_silentDelegate); // just a dummy layer for this test case.516 RefPtr<LayerChromium> testLayer = LayerChromium::create(0); 517 testLayer->setLayerTreeHost(m_layerTreeHost.get()); 518 519 RefPtr<LayerChromium> dummyLayer = LayerChromium::create(0); // just a dummy layer for this test case. 642 520 643 521 // sanity check of initial test condition … … 645 523 646 524 // Test properties that should not call needsDisplay and needsCommit when changed. 647 // notifySyncRequired should not be called, and the needsDisplay flag should remain false. 648 EXPECT_CALL(initialDelegate, notifySyncRequired()).Times(0); // old delegate should not be used when setDelegate gives a new delegate. 649 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDelegate(&mockDelegate)); 650 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setName("Test Layer")); 651 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setVisibleLayerRect(IntRect(0, 0, 40, 50))); 652 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setUsesLayerClipping(true)); 653 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setIsNonCompositedContent(true)); 654 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDrawOpacity(0.5f)); 655 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setClipRect(IntRect(3, 3, 8, 8))); 656 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setTargetRenderSurface(0)); 657 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDrawTransform(TransformationMatrix())); 658 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setScreenSpaceTransform(TransformationMatrix())); 659 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDrawableContentRect(IntRect(4, 5, 6, 7))); 525 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setName("Test Layer")); 526 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setVisibleLayerRect(IntRect(0, 0, 40, 50))); 527 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setUsesLayerClipping(true)); 528 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setIsNonCompositedContent(true)); 529 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0.5f)); 530 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setClipRect(IntRect(3, 3, 8, 8))); 531 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setTargetRenderSurface(0)); 532 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(TransformationMatrix())); 533 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setScreenSpaceTransform(TransformationMatrix())); 534 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawableContentRect(IntRect(4, 5, 6, 7))); 660 535 EXPECT_FALSE(testLayer->needsDisplay()); 661 536 662 537 // Next, test properties that should call setNeedsCommit (but not setNeedsDisplay) 663 // These properties should indirectly call notifySyncRequired, but the needsDisplay flag should not change. 664 // All properties need to be set to new values in order for setNeedsCommit 665 // to be called. 666 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setAnchorPoint(FloatPoint(1.23f, 4.56f))); 667 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setAnchorPointZ(0.7f)); 668 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBackgroundColor(Color(0.4f, 0.4f, 0.4f))); 669 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setMasksToBounds(true)); 670 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setMaskLayer(dummyLayer.get())); 671 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setOpacity(0.5f)); 672 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setOpaque(true)); 673 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setPosition(FloatPoint(4.0f, 9.0f))); 674 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setReplicaLayer(dummyLayer.get())); 675 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setSublayerTransform(TransformationMatrix(0, 0, 0, 0, 0, 0))); 676 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setScrollable(true)); 677 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setScrollPosition(IntPoint(10, 10))); 678 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setTransform(TransformationMatrix(0, 0, 0, 0, 0, 0))); 679 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setDoubleSided(false)); 538 // All properties need to be set to new values in order for setNeedsCommit to be called. 539 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setAnchorPoint(FloatPoint(1.23f, 4.56f))); 540 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setAnchorPointZ(0.7f)); 541 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBackgroundColor(Color(0.4f, 0.4f, 0.4f))); 542 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMasksToBounds(true)); 543 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMaskLayer(dummyLayer.get())); 544 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setOpacity(0.5f)); 545 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setOpaque(true)); 546 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setPosition(FloatPoint(4.0f, 9.0f))); 547 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setReplicaLayer(dummyLayer.get())); 548 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransform(TransformationMatrix(0, 0, 0, 0, 0, 0))); 549 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollable(true)); 550 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollPosition(IntPoint(10, 10))); 551 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(TransformationMatrix(0, 0, 0, 0, 0, 0))); 552 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(false)); 680 553 681 554 // The above tests should not have caused a change to the needsDisplay flag. 682 555 EXPECT_FALSE(testLayer->needsDisplay()); 683 556 684 // Test properties that should call setNeedsDisplay 685 // These properties will call notifySyncRequired and change the needsDisplay flag. 686 EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(IntSize(5, 10))); 557 // Test properties that should call setNeedsDisplay and setNeedsCommit 558 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(IntSize(5, 10))); 687 559 EXPECT_TRUE(testLayer->needsDisplay()); 688 689 // FIXME: need to add a test for setLayerTreeHost with a non-null stubbed CCLayerTreeHost.690 }691 692 TEST_F(LayerChromiumTest, checkNonCompositedContentPropertyChangeCausesCommit)693 {694 OwnPtr<MockNonCompositedContentHost> nonCompositedContentHost(MockNonCompositedContentHost::create());695 696 GraphicsLayer* rootLayer = nonCompositedContentHost->topLevelRootLayer();697 698 EXPECT_CALL(*nonCompositedContentHost, notifySyncRequired(_)).Times(1);699 rootLayer->platformLayer()->setScrollPosition(IntPoint(1, 1));700 Mock::VerifyAndClearExpectations(nonCompositedContentHost.get());701 702 EXPECT_CALL(*nonCompositedContentHost, notifySyncRequired(_)).Times(AtLeast(1));703 nonCompositedContentHost->setViewport(IntSize(30, 30), IntSize(20, 20), IntPoint(10, 10), 1);704 560 } 705 561 … … 724 580 TEST_F(LayerChromiumTest, checkContentsScaleChangeTriggersNeedsDisplay) 725 581 { 726 MockLayerDelegate mockDelegate;727 RefPtr<LayerChromiumWithContentScaling> testLayer = adoptRef(new LayerChromiumWithContentScaling(&mockDelegate));582 RefPtr<LayerChromiumWithContentScaling> testLayer = adoptRef(new LayerChromiumWithContentScaling(0)); 583 testLayer->setLayerTreeHost(m_layerTreeHost.get()); 728 584 729 585 IntSize testBounds = IntSize(320, 240); 730 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(mockDelegate,1, testLayer->setBounds(testBounds));586 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds)); 731 587 732 588 testLayer->resetNeedsDisplay(); 733 589 EXPECT_FALSE(testLayer->needsDisplay()); 734 590 735 EXECUTE_AND_VERIFY_ NOTIFY_SYNC_BEHAVIOR(mockDelegate,1, testLayer->setContentsScale(testLayer->contentsScale() + 1.f));591 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setContentsScale(testLayer->contentsScale() + 1.f)); 736 592 EXPECT_TRUE(testLayer->needsDisplay()); 737 593 } 738 739 class FakeCCLayerTreeHostClient : public CCLayerTreeHostClient {740 public:741 virtual void animateAndLayout(double frameBeginTime) { }742 virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) { }743 virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() { return 0; }744 virtual void didRecreateGraphicsContext(bool success) { }745 virtual void didCommitAndDrawFrame() { }746 virtual void didCompleteSwapBuffers() { }747 virtual void scheduleComposite() { }748 };749 594 750 595 class FakeCCLayerTreeHost : public CCLayerTreeHost { … … 784 629 TEST(LayerChromiumLayerTreeHostTest, enteringTree) 785 630 { 786 Web Compositor::initialize(0);631 WebKit::WebCompositor::initialize(0); 787 632 RefPtr<LayerChromium> parent = LayerChromium::create(0); 788 633 RefPtr<LayerChromium> child = LayerChromium::create(0); … … 811 656 812 657 layerTreeHost.clear(); 813 Web Compositor::shutdown();658 WebKit::WebCompositor::shutdown(); 814 659 } 815 660 816 661 TEST(LayerChromiumLayerTreeHostTest, addingLayerSubtree) 817 662 { 818 Web Compositor::initialize(0);663 WebKit::WebCompositor::initialize(0); 819 664 RefPtr<LayerChromium> parent = LayerChromium::create(0); 820 665 RefPtr<FakeCCLayerTreeHost> layerTreeHost = FakeCCLayerTreeHost::create(); … … 842 687 layerTreeHost->setRootLayer(0); 843 688 layerTreeHost.clear(); 844 Web Compositor::shutdown();689 WebKit::WebCompositor::shutdown(); 845 690 } 846 691 847 692 TEST(LayerChromiumLayerTreeHostTest, changeHost) 848 693 { 849 Web Compositor::initialize(0);694 WebKit::WebCompositor::initialize(0); 850 695 RefPtr<LayerChromium> parent = LayerChromium::create(0); 851 696 RefPtr<LayerChromium> child = LayerChromium::create(0); … … 875 720 firstLayerTreeHost.clear(); 876 721 secondLayerTreeHost.clear(); 877 Web Compositor::shutdown();722 WebKit::WebCompositor::shutdown(); 878 723 } 879 724 880 725 TEST(LayerChromiumLayerTreeHostTest, changeHostInSubtree) 881 726 { 882 Web Compositor::initialize(0);727 WebKit::WebCompositor::initialize(0); 883 728 RefPtr<LayerChromium> firstParent = LayerChromium::create(0); 884 729 RefPtr<LayerChromium> firstChild = LayerChromium::create(0); … … 912 757 firstLayerTreeHost.clear(); 913 758 secondLayerTreeHost.clear(); 914 Web Compositor::shutdown();759 WebKit::WebCompositor::shutdown(); 915 760 } 916 761 917 762 TEST(LayerChromiumLayerTreeHostTest, replaceMaskAndReplicaLayer) 918 763 { 919 Web Compositor::initialize(0);764 WebKit::WebCompositor::initialize(0); 920 765 RefPtr<LayerChromium> parent = LayerChromium::create(0); 921 766 RefPtr<LayerChromium> mask = LayerChromium::create(0); … … 949 794 layerTreeHost->setRootLayer(0); 950 795 layerTreeHost.clear(); 951 Web Compositor::shutdown();796 WebKit::WebCompositor::shutdown(); 952 797 } 953 798 -
trunk/Source/WebKit/chromium/tests/WebGLLayerChromiumTest.cpp
r103150 r103293 27 27 #include "WebGLLayerChromium.h" 28 28 29 #include "CompositorFakeGraphicsContext3D.h" 29 30 #include "DrawingBuffer.h" 30 #include "GraphicsContext3DPrivate.h"31 #include "MockWebGraphicsContext3D.h"32 31 #include <gmock/gmock.h> 33 32 #include <gtest/gtest.h> … … 37 36 38 37 namespace { 39 40 // Test stub for WebGraphicsContext3D. Returns canned values needed for compositor initialization.41 class CompositorMockWebGraphicsContext3D : public MockWebGraphicsContext3D {42 public:43 static PassOwnPtr<CompositorMockWebGraphicsContext3D> create(GraphicsContext3D::Attributes attrs) { return adoptPtr(new CompositorMockWebGraphicsContext3D(attrs)); }44 virtual bool makeContextCurrent() { return true; }45 virtual WebGLId createProgram() { return 1; }46 virtual WebGLId createShader(WGC3Denum) { return 1; }47 virtual void getShaderiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }48 virtual void getProgramiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }49 virtual WebGraphicsContext3D::Attributes getContextAttributes() { return m_attrs; }50 51 private:52 CompositorMockWebGraphicsContext3D(GraphicsContext3D::Attributes attrs) { m_attrs.alpha = attrs.alpha; }53 54 WebGraphicsContext3D::Attributes m_attrs;55 };56 57 static PassRefPtr<GraphicsContext3D> createGraphicsContext(GraphicsContext3D::Attributes attrs)58 {59 OwnPtr<WebGraphicsContext3D> webContext = CompositorMockWebGraphicsContext3D::create(attrs);60 return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(61 webContext.release(), attrs, 0,62 GraphicsContext3D::RenderDirectlyToHostWindow,63 GraphicsContext3DPrivate::ForUseOnAnotherThread);64 }65 38 66 39 TEST(WebGLLayerChromiumTest, opaqueFormats) … … 73 46 opaqueAttrs.alpha = false; 74 47 75 RefPtr<GraphicsContext3D> alphaContext = create GraphicsContext(alphaAttrs);48 RefPtr<GraphicsContext3D> alphaContext = createCompositorMockGraphicsContext3D(alphaAttrs); 76 49 EXPECT_TRUE(alphaContext); 77 RefPtr<GraphicsContext3D> opaqueContext = create GraphicsContext(opaqueAttrs);50 RefPtr<GraphicsContext3D> opaqueContext = createCompositorMockGraphicsContext3D(opaqueAttrs); 78 51 EXPECT_TRUE(opaqueContext); 79 52 -
trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp
r103150 r103293 26 26 #include "platform/WebLayer.h" 27 27 28 #include "platform/WebFloatPoint.h" 29 #include "platform/WebFloatRect.h" 30 #include "platform/WebRect.h" 31 #include "platform/WebSize.h" 28 #include "CompositorFakeWebGraphicsContext3D.h" 29 #include "WebCompositor.h" 32 30 #include "platform/WebContentLayer.h" 33 31 #include "platform/WebContentLayerClient.h" 34 32 #include "platform/WebExternalTextureLayer.h" 35 #include "platform/WebLayerClient.h" 33 #include "platform/WebFloatPoint.h" 34 #include "platform/WebFloatRect.h" 35 #include "platform/WebLayerTreeView.h" 36 #include "platform/WebLayerTreeViewClient.h" 37 #include "platform/WebRect.h" 38 #include "platform/WebSize.h" 36 39 37 40 #include <gmock/gmock.h> … … 42 45 namespace { 43 46 44 class MockWebLayer Client : public WebLayerClient {47 class MockWebLayerTreeViewClient : public WebLayerTreeViewClient { 45 48 public: 46 MOCK_METHOD0(notifyNeedsComposite, void()); 49 MOCK_METHOD0(scheduleComposite, void()); 50 51 virtual void animateAndLayout(double frameBeginTime) { } 52 virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) { } 53 virtual WebGraphicsContext3D* createContext3D() { return CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).leakPtr(); } 54 virtual void didRebindGraphicsContext(bool success) { } 47 55 }; 48 56 … … 54 62 class WebLayerTest : public Test { 55 63 public: 56 WebLayerTest() { } 64 virtual void SetUp() 65 { 66 // Initialize without threading support. 67 WebKit::WebCompositor::initialize(0); 68 m_rootLayer = WebLayer::create(); 69 EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); 70 m_view = WebLayerTreeView::create(&m_client, m_rootLayer, WebLayerTreeView::Settings()); 71 Mock::VerifyAndClearExpectations(&m_client); 72 } 73 74 virtual void TearDown() 75 { 76 // We may get any number of scheduleComposite calls during shutdown. 77 EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); 78 m_view.setRootLayer(0); 79 m_rootLayer.reset(); 80 m_view.reset(); 81 WebKit::WebCompositor::shutdown(); 82 } 83 84 protected: 85 MockWebLayerTreeViewClient m_client; 86 WebLayer m_rootLayer; 87 WebLayerTreeView m_view; 57 88 }; 58 89 … … 62 93 { 63 94 // Base layer. 64 MockWebLayerClient client;65 EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber());66 WebLayer layer = WebLayer::create(&client);67 Mock::VerifyAndClearExpectations(& client);95 EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); 96 WebLayer layer = WebLayer::create(); 97 m_rootLayer.addChild(layer); 98 Mock::VerifyAndClearExpectations(&m_client); 68 99 69 100 WebFloatPoint point(3, 4); 70 EXPECT_CALL( client, notifyNeedsComposite()).Times(AtLeast(1));101 EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); 71 102 layer.setAnchorPoint(point); 72 Mock::VerifyAndClearExpectations(& client);103 Mock::VerifyAndClearExpectations(&m_client); 73 104 EXPECT_EQ(point, layer.anchorPoint()); 74 105 75 EXPECT_CALL( client, notifyNeedsComposite()).Times(AtLeast(1));106 EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); 76 107 float anchorZ = 5; 77 108 layer.setAnchorPointZ(anchorZ); 78 Mock::VerifyAndClearExpectations(& client);109 Mock::VerifyAndClearExpectations(&m_client); 79 110 EXPECT_EQ(anchorZ, layer.anchorPointZ()); 80 111 81 112 WebSize size(7, 8); 82 EXPECT_CALL( client, notifyNeedsComposite()).Times(AtLeast(1));113 EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); 83 114 layer.setBounds(size); 84 Mock::VerifyAndClearExpectations(& client);115 Mock::VerifyAndClearExpectations(&m_client); 85 116 EXPECT_EQ(size, layer.bounds()); 86 117 87 EXPECT_CALL( client, notifyNeedsComposite()).Times(AtLeast(1));118 EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); 88 119 layer.setMasksToBounds(true); 89 Mock::VerifyAndClearExpectations(& client);120 Mock::VerifyAndClearExpectations(&m_client); 90 121 EXPECT_TRUE(layer.masksToBounds()); 91 122 92 MockWebLayerClient otherClient;93 EXPECT_CALL(otherClient, notifyNeedsComposite()).Times(AnyNumber());94 WebLayer otherLayer = WebLayer::create(&otherClient);95 EXPECT_CALL( client, notifyNeedsComposite()).Times(AtLeast(1));123 EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); 124 WebLayer otherLayer = WebLayer::create(); 125 m_rootLayer.addChild(otherLayer); 126 EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); 96 127 layer.setMaskLayer(otherLayer); 97 Mock::VerifyAndClearExpectations(& client);128 Mock::VerifyAndClearExpectations(&m_client); 98 129 EXPECT_EQ(otherLayer, layer.maskLayer()); 99 130 100 EXPECT_CALL( client, notifyNeedsComposite()).Times(AtLeast(1));131 EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); 101 132 float opacity = 0.123; 102 133 layer.setOpacity(opacity); 103 Mock::VerifyAndClearExpectations(& client);134 Mock::VerifyAndClearExpectations(&m_client); 104 135 EXPECT_EQ(opacity, layer.opacity()); 105 136 106 EXPECT_CALL( client, notifyNeedsComposite()).Times(AtLeast(1));137 EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); 107 138 layer.setOpaque(true); 108 Mock::VerifyAndClearExpectations(& client);139 Mock::VerifyAndClearExpectations(&m_client); 109 140 EXPECT_TRUE(layer.opaque()); 110 141 111 EXPECT_CALL( client, notifyNeedsComposite()).Times(AtLeast(1));142 EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); 112 143 layer.setPosition(point); 113 Mock::VerifyAndClearExpectations(& client);144 Mock::VerifyAndClearExpectations(&m_client); 114 145 EXPECT_EQ(point, layer.position()); 115 146 116 147 // Texture layer. 117 EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber()); 118 WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create(&client); 119 Mock::VerifyAndClearExpectations(&client); 120 121 EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1)); 148 EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); 149 WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create(); 150 m_rootLayer.addChild(textureLayer); 151 Mock::VerifyAndClearExpectations(&m_client); 152 153 EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); 122 154 textureLayer.setTextureId(3); 123 Mock::VerifyAndClearExpectations(& client);155 Mock::VerifyAndClearExpectations(&m_client); 124 156 EXPECT_EQ(3u, textureLayer.textureId()); 125 157 126 EXPECT_CALL( client, notifyNeedsComposite()).Times(AtLeast(1));158 EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); 127 159 textureLayer.setFlipped(true); 128 Mock::VerifyAndClearExpectations(& client);160 Mock::VerifyAndClearExpectations(&m_client); 129 161 EXPECT_TRUE(textureLayer.flipped()); 130 162 131 EXPECT_CALL( client, notifyNeedsComposite()).Times(AtLeast(1));163 EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); 132 164 WebFloatRect uvRect(0.1, 0.1, 0.9, 0.9); 133 165 textureLayer.setUVRect(uvRect); 134 Mock::VerifyAndClearExpectations(& client);166 Mock::VerifyAndClearExpectations(&m_client); 135 167 EXPECT_TRUE(textureLayer.flipped()); 136 168 … … 139 171 MockWebContentLayerClient contentClient; 140 172 EXPECT_CALL(contentClient, paintContents(_, _)).Times(AnyNumber()); 141 EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber()); 142 WebContentLayer contentLayer = WebContentLayer::create(&client, &contentClient); 143 Mock::VerifyAndClearExpectations(&client); 144 145 EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1)); 173 EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); 174 WebContentLayer contentLayer = WebContentLayer::create(&contentClient); 175 m_rootLayer.addChild(contentLayer); 176 Mock::VerifyAndClearExpectations(&m_client); 177 178 EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); 146 179 contentLayer.setDrawsContent(false); 147 Mock::VerifyAndClearExpectations(& client);180 Mock::VerifyAndClearExpectations(&m_client); 148 181 EXPECT_FALSE(contentLayer.drawsContent()); 149 182 } … … 151 184 TEST_F(WebLayerTest, Hierarchy) 152 185 { 153 MockWebLayerClient client; 154 EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber()); 155 WebLayer layer1 = WebLayer::create(&client); 156 WebLayer layer2 = WebLayer::create(&client); 186 EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); 187 WebLayer layer1 = WebLayer::create(); 188 WebLayer layer2 = WebLayer::create(); 157 189 158 190 EXPECT_TRUE(layer1.parent().isNull()); … … 173 205 MockWebContentLayerClient contentClient; 174 206 EXPECT_CALL(contentClient, paintContents(_, _)).Times(AnyNumber()); 175 WebContentLayer contentLayer = WebContentLayer::create(&c lient, &contentClient);176 WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create( &client);207 WebContentLayer contentLayer = WebContentLayer::create(&contentClient); 208 WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create(); 177 209 178 210 textureLayer.addChild(contentLayer);
Note: See TracChangeset
for help on using the changeset viewer.