diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-19 09:48:09 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-19 09:48:09 +0000 |
commit | 408b5e2ed7d842a073911265fcdfe88d0d98e5b1 (patch) | |
tree | f0558c6a7182dfd138e0d73cf970815fe52eebde | |
parent | de82be2276d21bbe59a4ae9b25f7c7b738fafab4 (diff) | |
download | chromium_src-408b5e2ed7d842a073911265fcdfe88d0d98e5b1.zip chromium_src-408b5e2ed7d842a073911265fcdfe88d0d98e5b1.tar.gz chromium_src-408b5e2ed7d842a073911265fcdfe88d0d98e5b1.tar.bz2 |
cc: Chromify LayerTreeHostClient.
Style-only change. Fix LayerTreeHostClient and
FakeLayer(Impl)TreeHostClient to use chromium style. And rename
LayerImplTreeHostClient to LayerTreeHostClient like it should be.
R=enne
Review URL: https://chromiumcodereview.appspot.com/12494030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188968 0039d316-1c4b-4281-b951-d872f2087c98
21 files changed, 309 insertions, 352 deletions
diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc index 4106484..c0eb8cc 100644 --- a/cc/layers/layer_unittest.cc +++ b/cc/layers/layer_unittest.cc @@ -44,16 +44,13 @@ namespace { class MockLayerTreeHost : public LayerTreeHost { public: - MockLayerTreeHost() - : LayerTreeHost(&fake_client_, LayerTreeSettings()) { + MockLayerTreeHost(LayerTreeHostClient* client) + : LayerTreeHost(client, LayerTreeSettings()) { Initialize(scoped_ptr<Thread>(NULL)); } MOCK_METHOD0(SetNeedsCommit, void()); MOCK_METHOD0(SetNeedsFullTreeSync, void()); - - private: - FakeLayerImplTreeHostClient fake_client_; }; class MockLayerPainter : public LayerPainter { @@ -67,11 +64,12 @@ class MockLayerPainter : public LayerPainter { class LayerTest : public testing::Test { public: LayerTest() - : host_impl_(&proxy_) {} + : host_impl_(&proxy_), + fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} protected: virtual void SetUp() OVERRIDE { - layer_tree_host_.reset(new StrictMock<MockLayerTreeHost>); + layer_tree_host_.reset(new StrictMock<MockLayerTreeHost>(&fake_client_)); } virtual void TearDown() OVERRIDE { @@ -138,6 +136,7 @@ class LayerTest : public testing::Test { FakeImplProxy proxy_; FakeLayerTreeHostImpl host_impl_; + FakeLayerTreeHostClient fake_client_; scoped_ptr<StrictMock<MockLayerTreeHost> > layer_tree_host_; scoped_refptr<Layer> parent_; scoped_refptr<Layer> child1_; @@ -760,29 +759,25 @@ TEST_F(LayerTest, MaskAndReplicaHasParent) { EXPECT_EQ(replica, replica->mask_layer()->parent()); } -class FakeLayerImplTreeHost : public LayerTreeHost { +class LayerTreeHostFactory { public: - static scoped_ptr<FakeLayerImplTreeHost> Create() { - scoped_ptr<FakeLayerImplTreeHost> host = - make_scoped_ptr(new FakeLayerImplTreeHost(LayerTreeSettings())); - // The initialize call will fail, since our client doesn't provide a valid - // GraphicsContext3D, but it doesn't matter in the tests that use this fake - // so ignore the return value. - host->Initialize(scoped_ptr<Thread>(NULL)); - return host.Pass(); + LayerTreeHostFactory() + : client_(FakeLayerTreeHostClient::DIRECT_3D) {} + + scoped_ptr<LayerTreeHost> Create() { + return LayerTreeHost::Create(&client_, + LayerTreeSettings(), + scoped_ptr<Thread>(NULL)).Pass(); } - static scoped_ptr<FakeLayerImplTreeHost> Create(LayerTreeSettings settings) { - scoped_ptr<FakeLayerImplTreeHost> host(new FakeLayerImplTreeHost(settings)); - host->Initialize(scoped_ptr<Thread>(NULL)); - return host.Pass(); + scoped_ptr<LayerTreeHost> Create(LayerTreeSettings settings) { + return LayerTreeHost::Create(&client_, + settings, + scoped_ptr<Thread>(NULL)).Pass(); } private: - FakeLayerImplTreeHost(const LayerTreeSettings& settings) - : LayerTreeHost(&client_, settings) {} - - FakeLayerImplTreeHostClient client_; + FakeLayerTreeHostClient client_; }; void AssertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) { @@ -814,8 +809,8 @@ TEST(LayerLayerTreeHostTest, EnteringTree) { AssertLayerTreeHostMatchesForSubtree(parent.get(), NULL); - scoped_ptr<FakeLayerImplTreeHost> layer_tree_host = - FakeLayerImplTreeHost::Create(); + LayerTreeHostFactory factory; + scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); // Setting the root layer should set the host pointer for all layers in the // tree. layer_tree_host->SetRootLayer(parent.get()); @@ -831,8 +826,8 @@ TEST(LayerLayerTreeHostTest, EnteringTree) { TEST(LayerLayerTreeHostTest, AddingLayerSubtree) { scoped_refptr<Layer> parent = Layer::Create(); - scoped_ptr<FakeLayerImplTreeHost> layer_tree_host = - FakeLayerImplTreeHost::Create(); + LayerTreeHostFactory factory; + scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); layer_tree_host->SetRootLayer(parent.get()); @@ -871,8 +866,8 @@ TEST(LayerLayerTreeHostTest, ChangeHost) { child->SetReplicaLayer(replica.get()); replica->SetMaskLayer(replica_mask.get()); - scoped_ptr<FakeLayerImplTreeHost> first_layer_tree_host = - FakeLayerImplTreeHost::Create(); + LayerTreeHostFactory factory; + scoped_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); first_layer_tree_host->SetRootLayer(parent.get()); AssertLayerTreeHostMatchesForSubtree(parent.get(), @@ -880,8 +875,7 @@ TEST(LayerLayerTreeHostTest, ChangeHost) { // Now re-root the tree to a new host (simulating what we do on a context lost // event). This should update the host pointers for all layers in the tree. - scoped_ptr<FakeLayerImplTreeHost> second_layer_tree_host = - FakeLayerImplTreeHost::Create(); + scoped_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); second_layer_tree_host->SetRootLayer(parent.get()); AssertLayerTreeHostMatchesForSubtree(parent.get(), @@ -902,8 +896,8 @@ TEST(LayerLayerTreeHostTest, ChangeHostInSubtree) { second_child->AddChild(second_grand_child); first_parent->AddChild(second_child); - scoped_ptr<FakeLayerImplTreeHost> first_layer_tree_host = - FakeLayerImplTreeHost::Create(); + LayerTreeHostFactory factory; + scoped_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); first_layer_tree_host->SetRootLayer(first_parent.get()); AssertLayerTreeHostMatchesForSubtree(first_parent.get(), @@ -911,8 +905,7 @@ TEST(LayerLayerTreeHostTest, ChangeHostInSubtree) { // Now reparent the subtree starting at second_child to a layer in a different // tree. - scoped_ptr<FakeLayerImplTreeHost> second_layer_tree_host = - FakeLayerImplTreeHost::Create(); + scoped_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); second_layer_tree_host->SetRootLayer(second_parent.get()); second_parent->AddChild(second_child); @@ -941,8 +934,8 @@ TEST(LayerLayerTreeHostTest, ReplaceMaskAndReplicaLayer) { mask->AddChild(mask_child); replica->AddChild(replica_child); - scoped_ptr<FakeLayerImplTreeHost> layer_tree_host = - FakeLayerImplTreeHost::Create(); + LayerTreeHostFactory factory; + scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); layer_tree_host->SetRootLayer(parent.get()); AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); @@ -965,8 +958,8 @@ TEST(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) { scoped_refptr<Layer> root = Layer::Create(); scoped_refptr<Layer> child = Layer::Create(); root->AddChild(child); - scoped_ptr<FakeLayerImplTreeHost> layer_tree_host = - FakeLayerImplTreeHost::Create(); + LayerTreeHostFactory factory; + scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); layer_tree_host->SetRootLayer(root); } @@ -1003,8 +996,8 @@ TEST(LayerLayerTreeHostTest, ShouldNotAddAnimationWithoutAnimationRegistrar) { LayerTreeSettings settings; settings.acceleratedAnimationEnabled = false; - scoped_ptr<FakeLayerImplTreeHost> layer_tree_host = - FakeLayerImplTreeHost::Create(settings); + LayerTreeHostFactory factory; + scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(settings); layer_tree_host->SetRootLayer(layer); layer->SetLayerTreeHost(layer_tree_host.get()); AssertLayerTreeHostMatchesForSubtree(layer.get(), layer_tree_host.get()); diff --git a/cc/layers/nine_patch_layer_unittest.cc b/cc/layers/nine_patch_layer_unittest.cc index f9c00aa..b8a6047 100644 --- a/cc/layers/nine_patch_layer_unittest.cc +++ b/cc/layers/nine_patch_layer_unittest.cc @@ -30,20 +30,20 @@ namespace { class MockLayerTreeHost : public LayerTreeHost { public: - MockLayerTreeHost() - : LayerTreeHost(&m_fakeClient, LayerTreeSettings()) + MockLayerTreeHost(LayerTreeHostClient* client) + : LayerTreeHost(client, LayerTreeSettings()) { Initialize(scoped_ptr<Thread>(NULL)); } private: - FakeLayerImplTreeHostClient m_fakeClient; }; class NinePatchLayerTest : public testing::Test { public: NinePatchLayerTest() + : m_fakeClient(FakeLayerTreeHostClient::DIRECT_3D) { } @@ -52,7 +52,7 @@ public: protected: virtual void SetUp() { - layer_tree_host_.reset(new MockLayerTreeHost); + layer_tree_host_.reset(new MockLayerTreeHost(&m_fakeClient)); } virtual void TearDown() @@ -61,6 +61,7 @@ protected: } scoped_ptr<MockLayerTreeHost> layer_tree_host_; + FakeLayerTreeHostClient m_fakeClient; }; TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap) diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc index 8c424a9..ad140b4 100644 --- a/cc/layers/scrollbar_layer_unittest.cc +++ b/cc/layers/scrollbar_layer_unittest.cc @@ -267,26 +267,24 @@ TEST_F(ScrollbarLayerTestMaxTextureSize, runTest) { class MockLayerTreeHost : public LayerTreeHost { public: - MockLayerTreeHost(const LayerTreeSettings& settings) - : LayerTreeHost(&m_fakeClient, settings) + MockLayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings) + : LayerTreeHost(client, settings) { Initialize(scoped_ptr<Thread>(NULL)); } - -private: - FakeLayerImplTreeHostClient m_fakeClient; }; class ScrollbarLayerTestResourceCreation : public testing::Test { public: ScrollbarLayerTestResourceCreation() + : m_fakeClient(FakeLayerTreeHostClient::DIRECT_3D) { } void testResourceUpload(int expectedResources) { - m_layerTreeHost.reset(new MockLayerTreeHost(m_layerTreeSettings)); + m_layerTreeHost.reset(new MockLayerTreeHost(&m_fakeClient, m_layerTreeSettings)); scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); scoped_refptr<Layer> layerTreeRoot = Layer::Create(); @@ -327,8 +325,9 @@ public: } protected: - scoped_ptr<MockLayerTreeHost> m_layerTreeHost; + FakeLayerTreeHostClient m_fakeClient; LayerTreeSettings m_layerTreeSettings; + scoped_ptr<MockLayerTreeHost> m_layerTreeHost; }; TEST_F(ScrollbarLayerTestResourceCreation, resourceUpload) diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc index 0e48b1b..d7c0a2e 100644 --- a/cc/layers/texture_layer_unittest.cc +++ b/cc/layers/texture_layer_unittest.cc @@ -27,26 +27,27 @@ using ::testing::AnyNumber; namespace cc { namespace { -class MockLayerImplTreeHost : public LayerTreeHost { +class MockLayerTreeHost : public LayerTreeHost { public: - MockLayerImplTreeHost() : LayerTreeHost(&fake_client_, LayerTreeSettings()) { + MockLayerTreeHost(LayerTreeHostClient* client) + : LayerTreeHost(client, LayerTreeSettings()) { Initialize(scoped_ptr<Thread>(NULL)); } MOCK_METHOD0(AcquireLayerTextures, void()); MOCK_METHOD0(SetNeedsCommit, void()); - - private: - FakeLayerImplTreeHostClient fake_client_; }; class TextureLayerTest : public testing::Test { public: - TextureLayerTest() : host_impl_(&proxy_) {} + TextureLayerTest() + : fake_client_( + FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)), + host_impl_(&proxy_) {} protected: virtual void SetUp() { - layer_tree_host_.reset(new MockLayerImplTreeHost); + layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_)); } virtual void TearDown() { @@ -58,8 +59,9 @@ class TextureLayerTest : public testing::Test { layer_tree_host_.reset(); } - scoped_ptr<MockLayerImplTreeHost> layer_tree_host_; + scoped_ptr<MockLayerTreeHost> layer_tree_host_; FakeImplProxy proxy_; + FakeLayerTreeHostClient fake_client_; FakeLayerTreeHostImpl host_impl_; }; @@ -376,13 +378,18 @@ SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerImplWithMailboxThreadedCallback); class TextureLayerImplWithMailboxTest : public TextureLayerTest { protected: + TextureLayerImplWithMailboxTest() + : fake_client_( + FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)) {} + virtual void SetUp() { TextureLayerTest::SetUp(); - layer_tree_host_.reset(new MockLayerImplTreeHost); + layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_)); EXPECT_TRUE(host_impl_.InitializeRenderer(createFakeOutputSurface())); } CommonMailboxObjects test_data_; + FakeLayerTreeHostClient fake_client_; }; TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { diff --git a/cc/layers/tiled_layer_unittest.cc b/cc/layers/tiled_layer_unittest.cc index 671fd0d..cfc8b51 100644 --- a/cc/layers/tiled_layer_unittest.cc +++ b/cc/layers/tiled_layer_unittest.cc @@ -49,6 +49,7 @@ public: : m_proxy(NULL) , m_outputSurface(createFakeOutputSurface()) , m_queue(make_scoped_ptr(new ResourceUpdateQueue)) + , m_fakeLayerImplTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D) , m_occlusion(0) { m_settings.maxPartialTextureUpdates = std::numeric_limits<size_t>::max(); @@ -186,7 +187,7 @@ public: scoped_ptr<ResourceProvider> m_resourceProvider; scoped_ptr<ResourceUpdateQueue> m_queue; PriorityCalculator m_priorityCalculator; - FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient; + FakeLayerTreeHostClient m_fakeLayerImplTreeHostClient; scoped_ptr<LayerTreeHost> layer_tree_host_; scoped_ptr<FakeLayerTreeHostImpl> m_hostImpl; scoped_ptr<PrioritizedResourceManager> m_resourceManager; @@ -540,8 +541,6 @@ TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately) { // Create a LayerTreeHost that has the right viewportsize, // so the layer is considered small enough. - FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient; - bool runOutOfMemory[2] = {false, true}; for (int i = 0; i < 2; i++) { // Create a layer with 5x5 tiles, with 4x4 size viewport. diff --git a/cc/test/fake_layer_tree_host_client.cc b/cc/test/fake_layer_tree_host_client.cc index 83ca327..a9baa8b 100644 --- a/cc/test/fake_layer_tree_host_client.cc +++ b/cc/test/fake_layer_tree_host_client.cc @@ -9,48 +9,60 @@ namespace cc { -FakeLayerImplTreeHostClient::FakeLayerImplTreeHostClient(bool useSoftwareRendering, bool useDelegatingRenderer) - : m_useSoftwareRendering(useSoftwareRendering) - , m_useDelegatingRenderer(useDelegatingRenderer) -{ -} - -FakeLayerImplTreeHostClient::~FakeLayerImplTreeHostClient() { } +FakeLayerTreeHostClient::FakeLayerTreeHostClient(RendererOptions options) + : use_software_rendering_(options == DIRECT_SOFTWARE || + options == DELEGATED_SOFTWARE), + use_delegating_renderer_(options == DELEGATED_3D || + options == DELEGATED_SOFTWARE) {} -scoped_ptr<OutputSurface> FakeLayerImplTreeHostClient::createOutputSurface() -{ - if (m_useSoftwareRendering) { - if (m_useDelegatingRenderer) - return FakeOutputSurface::CreateDelegatingSoftware(make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>(); +FakeLayerTreeHostClient::~FakeLayerTreeHostClient() {} - return FakeOutputSurface::CreateSoftware(make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>(); +scoped_ptr<OutputSurface> FakeLayerTreeHostClient::CreateOutputSurface() { + if (use_software_rendering_) { + if (use_delegating_renderer_) { + return FakeOutputSurface::CreateDelegatingSoftware( + make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>(); } - WebKit::WebGraphicsContext3D::Attributes attrs; - if (m_useDelegatingRenderer) - return FakeOutputSurface::CreateDelegating3d(TestWebGraphicsContext3D::Create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); + return FakeOutputSurface::CreateSoftware( + make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>(); + } - return FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); + WebKit::WebGraphicsContext3D::Attributes attrs; + if (use_delegating_renderer_) { + return FakeOutputSurface::CreateDelegating3d( + TestWebGraphicsContext3D::Create(attrs) + .PassAs<WebKit::WebGraphicsContext3D>()) + .PassAs<OutputSurface>(); + } + + return FakeOutputSurface::Create3d( + TestWebGraphicsContext3D::Create(attrs) + .PassAs<WebKit::WebGraphicsContext3D>()) + .PassAs<OutputSurface>(); } -scoped_ptr<InputHandler> FakeLayerImplTreeHostClient::createInputHandler() -{ - return scoped_ptr<InputHandler>(); +scoped_ptr<InputHandler> FakeLayerTreeHostClient::CreateInputHandler() { + return scoped_ptr<InputHandler>(); } -scoped_refptr<cc::ContextProvider> FakeLayerImplTreeHostClient::OffscreenContextProviderForMainThread() { - if (!m_mainThreadContexts || m_mainThreadContexts->DestroyedOnMainThread()) { - m_mainThreadContexts = FakeContextProvider::Create(); - if (!m_mainThreadContexts->BindToCurrentThread()) - m_mainThreadContexts = NULL; - } - return m_mainThreadContexts; +scoped_refptr<cc::ContextProvider> FakeLayerTreeHostClient:: + OffscreenContextProviderForMainThread() { + if (!main_thread_contexts_ || + main_thread_contexts_->DestroyedOnMainThread()) { + main_thread_contexts_ = FakeContextProvider::Create(); + if (!main_thread_contexts_->BindToCurrentThread()) + main_thread_contexts_ = NULL; + } + return main_thread_contexts_; } -scoped_refptr<cc::ContextProvider> FakeLayerImplTreeHostClient::OffscreenContextProviderForCompositorThread() { - if (!m_compositorThreadContexts || m_compositorThreadContexts->DestroyedOnMainThread()) - m_compositorThreadContexts = FakeContextProvider::Create(); - return m_compositorThreadContexts; +scoped_refptr<cc::ContextProvider> FakeLayerTreeHostClient:: + OffscreenContextProviderForCompositorThread() { + if (!compositor_thread_contexts_ || + compositor_thread_contexts_->DestroyedOnMainThread()) + compositor_thread_contexts_ = FakeContextProvider::Create(); + return compositor_thread_contexts_; } } // namespace cc diff --git a/cc/test/fake_layer_tree_host_client.h b/cc/test/fake_layer_tree_host_client.h index a7899a2..240b450 100644 --- a/cc/test/fake_layer_tree_host_client.h +++ b/cc/test/fake_layer_tree_host_client.h @@ -13,37 +13,46 @@ namespace cc { -class FakeLayerImplTreeHostClient : public LayerTreeHostClient { -public: - FakeLayerImplTreeHostClient(bool useSoftwareRendering = false, bool useDelegatingRenderer = false); - virtual ~FakeLayerImplTreeHostClient(); - - virtual void willBeginFrame() OVERRIDE { } - virtual void didBeginFrame() OVERRIDE { } - virtual void animate(double monotonicFrameBeginTime) OVERRIDE { } - virtual void layout() OVERRIDE { } - virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale) OVERRIDE { } - - virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE; - virtual void didRecreateOutputSurface(bool success) OVERRIDE { } - virtual scoped_ptr<InputHandler> createInputHandler() OVERRIDE; - virtual void willCommit() OVERRIDE { } - virtual void didCommit() OVERRIDE { } - virtual void didCommitAndDrawFrame() OVERRIDE { } - virtual void didCompleteSwapBuffers() OVERRIDE { } - - // Used only in the single-threaded path. - virtual void scheduleComposite() OVERRIDE { } - - virtual scoped_refptr<cc::ContextProvider> OffscreenContextProviderForMainThread() OVERRIDE; - virtual scoped_refptr<cc::ContextProvider> OffscreenContextProviderForCompositorThread() OVERRIDE; - -private: - bool m_useSoftwareRendering; - bool m_useDelegatingRenderer; - - scoped_refptr<FakeContextProvider> m_mainThreadContexts; - scoped_refptr<FakeContextProvider> m_compositorThreadContexts; +class FakeLayerTreeHostClient : public LayerTreeHostClient { + public: + enum RendererOptions { + DIRECT_3D, + DIRECT_SOFTWARE, + DELEGATED_3D, + DELEGATED_SOFTWARE + }; + FakeLayerTreeHostClient(RendererOptions options); + virtual ~FakeLayerTreeHostClient(); + + virtual void WillBeginFrame() OVERRIDE {} + virtual void DidBeginFrame() OVERRIDE {} + virtual void Animate(double frame_begin_time) OVERRIDE {} + virtual void Layout() OVERRIDE {} + virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, + float page_scale) OVERRIDE {} + + virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE; + virtual void DidRecreateOutputSurface(bool success) OVERRIDE {} + virtual scoped_ptr<InputHandler> CreateInputHandler() OVERRIDE; + virtual void WillCommit() OVERRIDE {} + virtual void DidCommit() OVERRIDE {} + virtual void DidCommitAndDrawFrame() OVERRIDE {} + virtual void DidCompleteSwapBuffers() OVERRIDE {} + + // Used only in the single-threaded path. + virtual void ScheduleComposite() OVERRIDE {} + + virtual scoped_refptr<cc::ContextProvider> + OffscreenContextProviderForMainThread() OVERRIDE; + virtual scoped_refptr<cc::ContextProvider> + OffscreenContextProviderForCompositorThread() OVERRIDE; + + private: + bool use_software_rendering_; + bool use_delegating_renderer_; + + scoped_refptr<FakeContextProvider> main_thread_contexts_; + scoped_refptr<FakeContextProvider> compositor_thread_contexts_; }; } // namespace cc diff --git a/cc/test/layer_tree_test_common.cc b/cc/test/layer_tree_test_common.cc index 4f30730..e9be315 100644 --- a/cc/test/layer_tree_test_common.cc +++ b/cc/test/layer_tree_test_common.cc @@ -31,9 +31,7 @@ namespace cc { TestHooks::TestHooks() { - bool useSoftwareRendering = false; - bool useDelegatingRenderer = false; - m_fakeClient.reset(new FakeLayerImplTreeHostClient(useSoftwareRendering, useDelegatingRenderer)); + m_fakeClient.reset(new FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)); } TestHooks::~TestHooks() { } @@ -214,68 +212,68 @@ public: return make_scoped_ptr(new ThreadedMockLayerTreeHostClient(testHooks)); } - virtual void willBeginFrame() OVERRIDE + virtual void WillBeginFrame() OVERRIDE { } - virtual void didBeginFrame() OVERRIDE + virtual void DidBeginFrame() OVERRIDE { } - virtual void animate(double monotonicTime) OVERRIDE + virtual void Animate(double monotonicTime) OVERRIDE { m_testHooks->animate(base::TimeTicks::FromInternalValue(monotonicTime * base::Time::kMicrosecondsPerSecond)); } - virtual void layout() OVERRIDE + virtual void Layout() OVERRIDE { m_testHooks->layout(); } - virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE + virtual void ApplyScrollAndScale(gfx::Vector2d scrollDelta, float scale) OVERRIDE { m_testHooks->applyScrollAndScale(scrollDelta, scale); } - virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE + virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { return m_testHooks->createOutputSurface(); } - virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE + virtual void DidRecreateOutputSurface(bool succeeded) OVERRIDE { m_testHooks->didRecreateOutputSurface(succeeded); } - virtual void willRetryRecreateOutputSurface() OVERRIDE + virtual void WillRetryRecreateOutputSurface() OVERRIDE { m_testHooks->willRetryRecreateOutputSurface(); } - virtual scoped_ptr<InputHandler> createInputHandler() OVERRIDE + virtual scoped_ptr<InputHandler> CreateInputHandler() OVERRIDE { return scoped_ptr<InputHandler>(); } - virtual void willCommit() OVERRIDE + virtual void WillCommit() OVERRIDE { } - virtual void didCommit() OVERRIDE + virtual void DidCommit() OVERRIDE { m_testHooks->didCommit(); } - virtual void didCommitAndDrawFrame() OVERRIDE + virtual void DidCommitAndDrawFrame() OVERRIDE { m_testHooks->didCommitAndDrawFrame(); } - virtual void didCompleteSwapBuffers() OVERRIDE + virtual void DidCompleteSwapBuffers() OVERRIDE { } - virtual void scheduleComposite() OVERRIDE + virtual void ScheduleComposite() OVERRIDE { m_testHooks->scheduleComposite(); } diff --git a/cc/test/layer_tree_test_common.h b/cc/test/layer_tree_test_common.h index cc3e855..cfb5341 100644 --- a/cc/test/layer_tree_test_common.h +++ b/cc/test/layer_tree_test_common.h @@ -18,7 +18,7 @@ class WebGraphicsContext3D; } namespace cc { -class FakeLayerImplTreeHostClient; +class FakeLayerTreeHostClient; class LayerImpl; class LayerTreeHost; class LayerTreeHostClient; @@ -64,7 +64,7 @@ public: virtual scoped_refptr<cc::ContextProvider> OffscreenContextProviderForCompositorThread(); private: - scoped_ptr<FakeLayerImplTreeHostClient> m_fakeClient; + scoped_ptr<FakeLayerTreeHostClient> m_fakeClient; }; class TimeoutTask; diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 383e7e1..ce8e6fc 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -146,7 +146,7 @@ void LayerTreeHost::InitializeRenderer() { if (!proxy_->InitializeRenderer()) { // Uh oh, better tell the client that we can't do anything with this output // surface. - client_->didRecreateOutputSurface(false); + client_->DidRecreateOutputSurface(false); return; } @@ -184,12 +184,12 @@ LayerTreeHost::RecreateResult LayerTreeHost::RecreateOutputSurface() { DCHECK(output_surface_lost_); if (proxy_->RecreateOutputSurface()) { - client_->didRecreateOutputSurface(true); + client_->DidRecreateOutputSurface(true); output_surface_lost_ = false; return RecreateSucceeded; } - client_->willRetryRecreateOutputSurface(); + client_->WillRetryRecreateOutputSurface(); // Tolerate a certain number of recreation failures to work around races // in the output-surface-lost machinery. @@ -205,7 +205,7 @@ LayerTreeHost::RecreateResult LayerTreeHost::RecreateOutputSurface() { // We have tried too many times to recreate the output surface. Tell the // host to fall back to software rendering. - client_->didRecreateOutputSurface(false); + client_->DidRecreateOutputSurface(false); return RecreateFailedAndGaveUp; } @@ -222,12 +222,12 @@ void LayerTreeHost::AcquireLayerTextures() { } void LayerTreeHost::DidBeginFrame() { - client_->didBeginFrame(); + client_->DidBeginFrame(); } void LayerTreeHost::UpdateAnimations(base::TimeTicks frame_begin_time) { animating_ = true; - client_->animate((frame_begin_time - base::TimeTicks()).InSecondsF()); + client_->Animate((frame_begin_time - base::TimeTicks()).InSecondsF()); AnimateLayers(frame_begin_time); animating_ = false; @@ -239,7 +239,7 @@ void LayerTreeHost::DidStopFlinging() { } void LayerTreeHost::Layout() { - client_->layout(); + client_->Layout(); } void LayerTreeHost::BeginCommitOnImplThread(LayerTreeHostImpl* host_impl) { @@ -409,7 +409,7 @@ void LayerTreeHost::CreateAndAddPinchZoomScrollbars() { } void LayerTreeHost::WillCommit() { - client_->willCommit(); + client_->WillCommit(); if (settings().usePinchZoomScrollbars) CreateAndAddPinchZoomScrollbars(); @@ -429,15 +429,15 @@ void LayerTreeHost::UpdateHudLayer() { } void LayerTreeHost::CommitComplete() { - client_->didCommit(); + client_->DidCommit(); } scoped_ptr<OutputSurface> LayerTreeHost::CreateOutputSurface() { - return client_->createOutputSurface(); + return client_->CreateOutputSurface(); } scoped_ptr<InputHandler> LayerTreeHost::CreateInputHandler() { - return client_->createInputHandler(); + return client_->CreateInputHandler(); } scoped_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( @@ -513,7 +513,7 @@ void LayerTreeHost::SetNeedsFullTreeSync() { void LayerTreeHost::SetNeedsRedraw() { proxy_->SetNeedsRedraw(); if (!proxy_->ImplThread()) - client_->scheduleComposite(); + client_->ScheduleComposite(); } bool LayerTreeHost::CommitRequested() const { @@ -611,7 +611,7 @@ void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) { } void LayerTreeHost::ScheduleComposite() { - client_->scheduleComposite(); + client_->ScheduleComposite(); } bool LayerTreeHost::InitializeRendererIfNeeded() { @@ -893,7 +893,7 @@ void LayerTreeHost::ApplyScrollAndScale(const ScrollAndScaleSet& info) { info.scrolls[i].scrollDelta); } if (!root_scroll_delta.IsZero() || info.pageScaleDelta != 1.f) - client_->applyScrollAndScale(root_scroll_delta, info.pageScaleDelta); + client_->ApplyScrollAndScale(root_scroll_delta, info.pageScaleDelta); } void LayerTreeHost::SetImplTransform(const gfx::Transform& transform) { diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 0b0d58d..2b815de 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -94,7 +94,7 @@ class CC_EXPORT LayerTreeHost : public RateLimiterClient { } // LayerTreeHost interface to Proxy. - void WillBeginFrame() { client_->willBeginFrame(); } + void WillBeginFrame() { client_->WillBeginFrame(); } void DidBeginFrame(); void UpdateAnimations(base::TimeTicks monotonic_frame_begin_time); void DidStopFlinging(); @@ -116,8 +116,8 @@ class CC_EXPORT LayerTreeHost : public RateLimiterClient { RecreateFailedAndGaveUp, }; RecreateResult RecreateOutputSurface(); - void DidCommitAndDrawFrame() { client_->didCommitAndDrawFrame(); } - void DidCompleteSwapBuffers() { client_->didCompleteSwapBuffers(); } + void DidCommitAndDrawFrame() { client_->DidCommitAndDrawFrame(); } + void DidCompleteSwapBuffers() { client_->DidCompleteSwapBuffers(); } void DeleteContentsTexturesOnImplThread(ResourceProvider* resource_provider); virtual void AcquireLayerTextures(); // Returns false if we should abort this frame due to initialization failure. diff --git a/cc/trees/layer_tree_host_client.h b/cc/trees/layer_tree_host_client.h index 81635a0..547c442 100644 --- a/cc/trees/layer_tree_host_client.h +++ b/cc/trees/layer_tree_host_client.h @@ -18,33 +18,38 @@ class InputHandler; class OutputSurface; class LayerTreeHostClient { -public: - virtual void willBeginFrame() = 0; - // Marks finishing compositing-related tasks on the main thread. In threaded mode, this corresponds to didCommit(). - virtual void didBeginFrame() = 0; - virtual void animate(double frameBeginTime) = 0; - virtual void layout() = 0; - virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale) = 0; - virtual scoped_ptr<OutputSurface> createOutputSurface() = 0; - virtual void didRecreateOutputSurface(bool success) = 0; - virtual scoped_ptr<InputHandler> createInputHandler() = 0; - virtual void willCommit() = 0; - virtual void didCommit() = 0; - virtual void didCommitAndDrawFrame() = 0; - virtual void didCompleteSwapBuffers() = 0; - - // Used only in the single-threaded path. - virtual void scheduleComposite() = 0; - - // These must always return a valid ContextProvider. But the provider does not need to be capable of creating contexts. - virtual scoped_refptr<cc::ContextProvider> OffscreenContextProviderForMainThread() = 0; - virtual scoped_refptr<cc::ContextProvider> OffscreenContextProviderForCompositorThread() = 0; - - // This hook is for testing. - virtual void willRetryRecreateOutputSurface() {} - -protected: - virtual ~LayerTreeHostClient() { } + public: + virtual void WillBeginFrame() = 0; + // Marks finishing compositing-related tasks on the main thread. In threaded + // mode, this corresponds to DidCommit(). + virtual void DidBeginFrame() = 0; + virtual void Animate(double frame_begin_time) = 0; + virtual void Layout() = 0; + virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, + float page_scale) = 0; + virtual scoped_ptr<OutputSurface> CreateOutputSurface() = 0; + virtual void DidRecreateOutputSurface(bool success) = 0; + virtual scoped_ptr<InputHandler> CreateInputHandler() = 0; + virtual void WillCommit() = 0; + virtual void DidCommit() = 0; + virtual void DidCommitAndDrawFrame() = 0; + virtual void DidCompleteSwapBuffers() = 0; + + // Used only in the single-threaded path. + virtual void ScheduleComposite() = 0; + + // These must always return a valid ContextProvider. But the provider does not + // need to be capable of creating contexts. + virtual scoped_refptr<cc::ContextProvider> + OffscreenContextProviderForMainThread() = 0; + virtual scoped_refptr<cc::ContextProvider> + OffscreenContextProviderForCompositorThread() = 0; + + // This hook is for testing. + virtual void WillRetryRecreateOutputSurface() {} + + protected: + virtual ~LayerTreeHostClient() {} }; } diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index c035581..a99f2a9 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -1876,21 +1876,18 @@ TEST_F(LayerTreeHostTestDeferCommits, runMultiThread) class LayerTreeHostWithProxy : public LayerTreeHost { public: - LayerTreeHostWithProxy(FakeLayerImplTreeHostClient* client, const LayerTreeSettings& settings, scoped_ptr<Proxy> proxy) + LayerTreeHostWithProxy(FakeLayerTreeHostClient* client, const LayerTreeSettings& settings, scoped_ptr<Proxy> proxy) : LayerTreeHost(client, settings) { EXPECT_TRUE(InitializeForTesting(proxy.Pass())); } - -private: - FakeLayerImplTreeHostClient m_client; }; TEST(LayerTreeHostTest, LimitPartialUpdates) { // When partial updates are not allowed, max updates should be 0. { - FakeLayerImplTreeHostClient client; + FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); scoped_ptr<FakeProxy> proxy = make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>())); proxy->GetRendererCapabilities().allow_partial_texture_updates = false; @@ -1907,7 +1904,7 @@ TEST(LayerTreeHostTest, LimitPartialUpdates) // When partial updates are allowed, max updates should be limited by the proxy. { - FakeLayerImplTreeHostClient client; + FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); scoped_ptr<FakeProxy> proxy = make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>())); proxy->GetRendererCapabilities().allow_partial_texture_updates = true; @@ -1924,7 +1921,7 @@ TEST(LayerTreeHostTest, LimitPartialUpdates) // When partial updates are allowed, max updates should also be limited by the settings. { - FakeLayerImplTreeHostClient client; + FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); scoped_ptr<FakeProxy> proxy = make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>())); proxy->GetRendererCapabilities().allow_partial_texture_updates = true; @@ -1942,9 +1939,7 @@ TEST(LayerTreeHostTest, LimitPartialUpdates) TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { - bool useSoftwareRendering = false; - bool useDelegatingRenderer = false; - FakeLayerImplTreeHostClient client(useSoftwareRendering, useDelegatingRenderer); + FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); LayerTreeSettings settings; settings.maxPartialTextureUpdates = 4; @@ -1956,9 +1951,7 @@ TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { - bool useSoftwareRendering = true; - bool useDelegatingRenderer = false; - FakeLayerImplTreeHostClient client(useSoftwareRendering, useDelegatingRenderer); + FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); LayerTreeSettings settings; settings.maxPartialTextureUpdates = 4; @@ -1970,9 +1963,7 @@ TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { - bool useSoftwareRendering = false; - bool useDelegatingRenderer = true; - FakeLayerImplTreeHostClient client(useSoftwareRendering, useDelegatingRenderer); + FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); LayerTreeSettings settings; settings.maxPartialTextureUpdates = 4; @@ -1984,9 +1975,7 @@ TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndSoftwareContent) { - bool useSoftwareRendering = true; - bool useDelegatingRenderer = true; - FakeLayerImplTreeHostClient client(useSoftwareRendering, useDelegatingRenderer); + FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); LayerTreeSettings settings; settings.maxPartialTextureUpdates = 4; diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc index ee4e0f4..005fe23 100644 --- a/content/browser/renderer_host/compositor_impl_android.cc +++ b/content/browser/renderer_host/compositor_impl_android.cc @@ -313,17 +313,7 @@ bool CompositorImpl::CopyTextureToBitmap(WebKit::WebGLId texture_id, return true; } -void CompositorImpl::animate(double monotonicFrameBeginTime) { -} - -void CompositorImpl::layout() { -} - -void CompositorImpl::applyScrollAndScale(gfx::Vector2d scrollDelta, - float pageScale) { -} - -scoped_ptr<cc::OutputSurface> CompositorImpl::createOutputSurface() { +scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface() { if (g_use_direct_gl) { WebKit::WebGraphicsContext3D::Attributes attrs; attrs.shareResources = false; @@ -364,24 +354,15 @@ scoped_ptr<cc::OutputSurface> CompositorImpl::createOutputSurface() { } } -scoped_ptr<cc::InputHandler> CompositorImpl::createInputHandler() { +scoped_ptr<cc::InputHandler> CompositorImpl::CreateInputHandler() { return scoped_ptr<cc::InputHandler>(); } -void CompositorImpl::didRecreateOutputSurface(bool success) { -} - -void CompositorImpl::didCommit() { -} - -void CompositorImpl::didCommitAndDrawFrame() { -} - -void CompositorImpl::didCompleteSwapBuffers() { +void CompositorImpl::DidCompleteSwapBuffers() { client_->OnSwapBuffersCompleted(); } -void CompositorImpl::scheduleComposite() { +void CompositorImpl::ScheduleComposite() { client_->ScheduleComposite(); } diff --git a/content/browser/renderer_host/compositor_impl_android.h b/content/browser/renderer_host/compositor_impl_android.h index 8e14dd6..d984547 100644 --- a/content/browser/renderer_host/compositor_impl_android.h +++ b/content/browser/renderer_host/compositor_impl_android.h @@ -67,20 +67,20 @@ class CONTENT_EXPORT CompositorImpl gfx::JavaBitmap& bitmap) OVERRIDE; // LayerTreeHostClient implementation. - virtual void willBeginFrame() OVERRIDE {} - virtual void didBeginFrame() OVERRIDE {} - virtual void animate(double monotonicFrameBeginTime) OVERRIDE; - virtual void layout() OVERRIDE; - virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, - float pageScale) OVERRIDE; - virtual scoped_ptr<cc::OutputSurface> createOutputSurface() OVERRIDE; - virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; - virtual void didRecreateOutputSurface(bool success) OVERRIDE; - virtual void willCommit() OVERRIDE {} - virtual void didCommit() OVERRIDE; - virtual void didCommitAndDrawFrame() OVERRIDE; - virtual void didCompleteSwapBuffers() OVERRIDE; - virtual void scheduleComposite() OVERRIDE; + virtual void WillBeginFrame() OVERRIDE {} + virtual void DidBeginFrame() OVERRIDE {} + virtual void Animate(double frame_begin_time) OVERRIDE {} + virtual void Layout() OVERRIDE {} + virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, + float page_scale) OVERRIDE {} + virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface() OVERRIDE; + virtual scoped_ptr<cc::InputHandler> CreateInputHandler() OVERRIDE; + virtual void DidRecreateOutputSurface(bool success) OVERRIDE {} + virtual void WillCommit() OVERRIDE {} + virtual void DidCommit() OVERRIDE {} + virtual void DidCommitAndDrawFrame() OVERRIDE {} + virtual void DidCompleteSwapBuffers() OVERRIDE; + virtual void ScheduleComposite() OVERRIDE; virtual scoped_refptr<cc::ContextProvider> OffscreenContextProviderForMainThread() OVERRIDE; virtual scoped_refptr<cc::ContextProvider> diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc index 7ead8d4..3696c2b 100644 --- a/content/renderer/gpu/render_widget_compositor.cc +++ b/content/renderer/gpu/render_widget_compositor.cc @@ -440,38 +440,38 @@ void RenderWidgetCompositor::setContinuousPaintingEnabled(bool enabled) { layer_tree_host_->SetDebugState(debug_state); } -void RenderWidgetCompositor::willBeginFrame() { +void RenderWidgetCompositor::WillBeginFrame() { widget_->InstrumentWillBeginFrame(); widget_->willBeginCompositorFrame(); } -void RenderWidgetCompositor::didBeginFrame() { +void RenderWidgetCompositor::DidBeginFrame() { widget_->InstrumentDidBeginFrame(); } -void RenderWidgetCompositor::animate(double monotonic_frame_begin_time) { - widget_->webwidget()->animate(monotonic_frame_begin_time); +void RenderWidgetCompositor::Animate(double frame_begin_time) { + widget_->webwidget()->animate(frame_begin_time); } -void RenderWidgetCompositor::layout() { +void RenderWidgetCompositor::Layout() { widget_->webwidget()->layout(); } -void RenderWidgetCompositor::applyScrollAndScale(gfx::Vector2d scroll_delta, +void RenderWidgetCompositor::ApplyScrollAndScale(gfx::Vector2d scroll_delta, float page_scale) { widget_->webwidget()->applyScrollAndScale(scroll_delta, page_scale); } -scoped_ptr<cc::OutputSurface> RenderWidgetCompositor::createOutputSurface() { +scoped_ptr<cc::OutputSurface> RenderWidgetCompositor::CreateOutputSurface() { return widget_->CreateOutputSurface(); } -void RenderWidgetCompositor::didRecreateOutputSurface(bool success) { +void RenderWidgetCompositor::DidRecreateOutputSurface(bool success) { if (!success) widget_->webwidget()->didExitCompositingMode(); } -scoped_ptr<cc::InputHandler> RenderWidgetCompositor::createInputHandler() { +scoped_ptr<cc::InputHandler> RenderWidgetCompositor::CreateInputHandler() { scoped_ptr<cc::InputHandler> ret; scoped_ptr<WebKit::WebInputHandler> web_handler( widget_->webwidget()->createInputHandler()); @@ -480,24 +480,24 @@ scoped_ptr<cc::InputHandler> RenderWidgetCompositor::createInputHandler() { return ret.Pass(); } -void RenderWidgetCompositor::willCommit() { +void RenderWidgetCompositor::WillCommit() { widget_->InstrumentWillComposite(); } -void RenderWidgetCompositor::didCommit() { +void RenderWidgetCompositor::DidCommit() { widget_->DidCommitCompositorFrame(); widget_->didBecomeReadyForAdditionalInput(); } -void RenderWidgetCompositor::didCommitAndDrawFrame() { +void RenderWidgetCompositor::DidCommitAndDrawFrame() { widget_->didCommitAndDrawCompositorFrame(); } -void RenderWidgetCompositor::didCompleteSwapBuffers() { +void RenderWidgetCompositor::DidCompleteSwapBuffers() { widget_->didCompleteSwapBuffers(); } -void RenderWidgetCompositor::scheduleComposite() { +void RenderWidgetCompositor::ScheduleComposite() { if (!suppress_schedule_composite_) widget_->scheduleComposite(); } diff --git a/content/renderer/gpu/render_widget_compositor.h b/content/renderer/gpu/render_widget_compositor.h index 11ca391..3976ddd 100644 --- a/content/renderer/gpu/render_widget_compositor.h +++ b/content/renderer/gpu/render_widget_compositor.h @@ -75,20 +75,20 @@ class RenderWidgetCompositor : public WebKit::WebLayerTreeView, virtual void setContinuousPaintingEnabled(bool enabled); // cc::LayerTreeHostClient implementation. - virtual void willBeginFrame() OVERRIDE; - virtual void didBeginFrame() OVERRIDE; - virtual void animate(double monotonic_frame_begin_time) OVERRIDE; - virtual void layout() OVERRIDE; - virtual void applyScrollAndScale(gfx::Vector2d scroll_delta, + virtual void WillBeginFrame() OVERRIDE; + virtual void DidBeginFrame() OVERRIDE; + virtual void Animate(double frame_begin_time) OVERRIDE; + virtual void Layout() OVERRIDE; + virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float page_scale) OVERRIDE; - virtual scoped_ptr<cc::OutputSurface> createOutputSurface() OVERRIDE; - virtual void didRecreateOutputSurface(bool success) OVERRIDE; - virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; - virtual void willCommit() OVERRIDE; - virtual void didCommit() OVERRIDE; - virtual void didCommitAndDrawFrame() OVERRIDE; - virtual void didCompleteSwapBuffers() OVERRIDE; - virtual void scheduleComposite() OVERRIDE; + virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface() OVERRIDE; + virtual void DidRecreateOutputSurface(bool success) OVERRIDE; + virtual scoped_ptr<cc::InputHandler> CreateInputHandler() OVERRIDE; + virtual void WillCommit() OVERRIDE; + virtual void DidCommit() OVERRIDE; + virtual void DidCommitAndDrawFrame() OVERRIDE; + virtual void DidCompleteSwapBuffers() OVERRIDE; + virtual void ScheduleComposite() OVERRIDE; virtual scoped_refptr<cc::ContextProvider> OffscreenContextProviderForMainThread() OVERRIDE; virtual scoped_refptr<cc::ContextProvider> diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index d056ca1..954e11e 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc @@ -507,7 +507,7 @@ void Compositor::Draw(bool force_clear) { if (!IsLocked()) { // TODO(nduca): Temporary while compositor calls // compositeImmediately() directly. - layout(); + Layout(); host_->Composite(base::TimeTicks::Now()); } if (!pending_swap.posted()) @@ -596,16 +596,7 @@ void Compositor::OnUpdateVSyncParameters(base::TimeTicks timebase, OnUpdateVSyncParameters(this, timebase, interval)); } -void Compositor::willBeginFrame() { -} - -void Compositor::didBeginFrame() { -} - -void Compositor::animate(double frameBeginTime) { -} - -void Compositor::layout() { +void Compositor::Layout() { // We're sending damage that will be addressed during this composite // cycle, so we don't need to schedule another composite to address it. disable_schedule_composite_ = true; @@ -614,45 +605,35 @@ void Compositor::layout() { disable_schedule_composite_ = false; } -void Compositor::applyScrollAndScale(gfx::Vector2d scrollDelta, - float pageScale) { -} - -scoped_ptr<cc::OutputSurface> Compositor::createOutputSurface() { +scoped_ptr<cc::OutputSurface> Compositor::CreateOutputSurface() { return make_scoped_ptr( ContextFactory::GetInstance()->CreateOutputSurface(this)); } -void Compositor::didRecreateOutputSurface(bool success) { -} - -scoped_ptr<cc::InputHandler> Compositor::createInputHandler() { +scoped_ptr<cc::InputHandler> Compositor::CreateInputHandler() { return scoped_ptr<cc::InputHandler>(); } -void Compositor::willCommit() { -} - -void Compositor::didCommit() { +void Compositor::DidCommit() { DCHECK(!IsLocked()); FOR_EACH_OBSERVER(CompositorObserver, observer_list_, OnCompositingDidCommit(this)); } -void Compositor::didCommitAndDrawFrame() { +void Compositor::DidCommitAndDrawFrame() { base::TimeTicks start_time = base::TimeTicks::Now(); FOR_EACH_OBSERVER(CompositorObserver, observer_list_, OnCompositingStarted(this, start_time)); } -void Compositor::didCompleteSwapBuffers() { +void Compositor::DidCompleteSwapBuffers() { DCHECK(g_compositor_thread); NotifyEnd(); } -void Compositor::scheduleComposite() { +void Compositor::ScheduleComposite() { if (!disable_schedule_composite_) ScheduleDraw(); } diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h index d7347c5..0b78e72 100644 --- a/ui/compositor/compositor.h +++ b/ui/compositor/compositor.h @@ -17,6 +17,7 @@ #include "ui/gfx/native_widget_types.h" #include "ui/gfx/size.h" #include "ui/gfx/transform.h" +#include "ui/gfx/vector2d.h" #include "ui/gl/gl_share_group.h" class SkBitmap; @@ -293,21 +294,21 @@ class COMPOSITOR_EXPORT Compositor base::TimeDelta interval); // LayerTreeHostClient implementation. - virtual void willBeginFrame() OVERRIDE; - virtual void didBeginFrame() OVERRIDE; - virtual void animate(double frameBeginTime) OVERRIDE; - virtual void layout() OVERRIDE; - virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, - float pageScale) OVERRIDE; + virtual void WillBeginFrame() OVERRIDE {} + virtual void DidBeginFrame() OVERRIDE {} + virtual void Animate(double frame_begin_time) OVERRIDE {} + virtual void Layout() OVERRIDE; + virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, + float page_scale) OVERRIDE {} virtual scoped_ptr<cc::OutputSurface> - createOutputSurface() OVERRIDE; - virtual void didRecreateOutputSurface(bool success) OVERRIDE; - virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; - virtual void willCommit() OVERRIDE; - virtual void didCommit() OVERRIDE; - virtual void didCommitAndDrawFrame() OVERRIDE; - virtual void didCompleteSwapBuffers() OVERRIDE; - virtual void scheduleComposite() OVERRIDE; + CreateOutputSurface() OVERRIDE; + virtual void DidRecreateOutputSurface(bool success) OVERRIDE {} + virtual scoped_ptr<cc::InputHandler> CreateInputHandler() OVERRIDE; + virtual void WillCommit() OVERRIDE {} + virtual void DidCommit() OVERRIDE; + virtual void DidCommitAndDrawFrame() OVERRIDE; + virtual void DidCompleteSwapBuffers() OVERRIDE; + virtual void ScheduleComposite() OVERRIDE; virtual scoped_refptr<cc::ContextProvider> OffscreenContextProviderForMainThread() OVERRIDE; virtual scoped_refptr<cc::ContextProvider> diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc b/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc index 9d618c9..a0b26cb 100644 --- a/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc +++ b/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc @@ -165,25 +165,17 @@ void WebLayerTreeViewImplForTesting::setDeferCommits(bool defer_commits) { void WebLayerTreeViewImplForTesting::renderingStats(WebRenderingStats&) const {} -void WebLayerTreeViewImplForTesting::willBeginFrame() {} - -void WebLayerTreeViewImplForTesting::didBeginFrame() {} - -void WebLayerTreeViewImplForTesting::animate( - double monotonic_frame_begin_time) { -} - -void WebLayerTreeViewImplForTesting::layout() { +void WebLayerTreeViewImplForTesting::Layout() { if (client_) client_->Layout(); } -void WebLayerTreeViewImplForTesting::applyScrollAndScale( +void WebLayerTreeViewImplForTesting::ApplyScrollAndScale( gfx::Vector2d scroll_delta, float page_scale) {} scoped_ptr<cc::OutputSurface> -WebLayerTreeViewImplForTesting::createOutputSurface() { +WebLayerTreeViewImplForTesting::CreateOutputSurface() { scoped_ptr<cc::OutputSurface> surface; switch (type_) { case webkit_support::FAKE_CONTEXT: { @@ -209,22 +201,12 @@ WebLayerTreeViewImplForTesting::createOutputSurface() { return surface.Pass(); } -void WebLayerTreeViewImplForTesting::didRecreateOutputSurface(bool success) {} - scoped_ptr<cc::InputHandler> -WebLayerTreeViewImplForTesting::createInputHandler() { +WebLayerTreeViewImplForTesting::CreateInputHandler() { return scoped_ptr<cc::InputHandler>(); } -void WebLayerTreeViewImplForTesting::willCommit() {} - -void WebLayerTreeViewImplForTesting::didCommit() {} - -void WebLayerTreeViewImplForTesting::didCommitAndDrawFrame() {} - -void WebLayerTreeViewImplForTesting::didCompleteSwapBuffers() {} - -void WebLayerTreeViewImplForTesting::scheduleComposite() { +void WebLayerTreeViewImplForTesting::ScheduleComposite() { if (client_) client_->ScheduleComposite(); } diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h b/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h index ffd3b8f..719c649 100644 --- a/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h +++ b/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h @@ -63,24 +63,24 @@ class WebLayerTreeViewImplForTesting : public WebKit::WebLayerTreeView, virtual void renderingStats(WebKit::WebRenderingStats& stats) const; // cc::LayerTreeHostClient implementation. - virtual void willBeginFrame() OVERRIDE; - virtual void didBeginFrame() OVERRIDE; - virtual void animate(double monotonic_frame_begin_time) OVERRIDE; - virtual void layout() OVERRIDE; - virtual void applyScrollAndScale(gfx::Vector2d scroll_delta, float page_scale) + virtual void WillBeginFrame() OVERRIDE {} + virtual void DidBeginFrame() OVERRIDE {} + virtual void Animate(double frame_begin_time) OVERRIDE {} + virtual void Layout() OVERRIDE; + virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float page_scale) OVERRIDE; - virtual scoped_ptr<cc::OutputSurface> createOutputSurface() OVERRIDE; - virtual void didRecreateOutputSurface(bool success) OVERRIDE; - virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; - virtual void willCommit() OVERRIDE; - virtual void didCommit() OVERRIDE; - virtual void didCommitAndDrawFrame() OVERRIDE; - virtual void didCompleteSwapBuffers() OVERRIDE; - virtual void scheduleComposite() OVERRIDE; + virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface() OVERRIDE; + virtual void DidRecreateOutputSurface(bool success) OVERRIDE {} + virtual scoped_ptr<cc::InputHandler> CreateInputHandler() OVERRIDE; + virtual void WillCommit() OVERRIDE {} + virtual void DidCommit() OVERRIDE {} + virtual void DidCommitAndDrawFrame() OVERRIDE {} + virtual void DidCompleteSwapBuffers() OVERRIDE {} + virtual void ScheduleComposite() OVERRIDE; virtual scoped_refptr<cc::ContextProvider> - OffscreenContextProviderForMainThread() OVERRIDE; + OffscreenContextProviderForMainThread() OVERRIDE; virtual scoped_refptr<cc::ContextProvider> - OffscreenContextProviderForCompositorThread() OVERRIDE; + OffscreenContextProviderForCompositorThread() OVERRIDE; private: webkit_support::LayerTreeViewType type_; |