| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2086 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2086 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 2087 | 2087 |
| 2088 scoped_ptr<FakeProxy> proxy(new FakeProxy); | 2088 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
| 2089 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; | 2089 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; |
| 2090 proxy->SetMaxPartialTextureUpdates(5); | 2090 proxy->SetMaxPartialTextureUpdates(5); |
| 2091 | 2091 |
| 2092 LayerTreeSettings settings; | 2092 LayerTreeSettings settings; |
| 2093 settings.max_partial_texture_updates = 10; | 2093 settings.max_partial_texture_updates = 10; |
| 2094 | 2094 |
| 2095 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 2095 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
| 2096 host.OnCreateAndInitializeOutputSurfaceAttempted(true); | |
| 2097 | 2096 |
| 2098 EXPECT_EQ(0u, host.MaxPartialTextureUpdates()); | 2097 EXPECT_EQ(0u, host.MaxPartialTextureUpdates()); |
| 2099 } | 2098 } |
| 2100 | 2099 |
| 2101 // When partial updates are allowed, | 2100 // When partial updates are allowed, |
| 2102 // max updates should be limited by the proxy. | 2101 // max updates should be limited by the proxy. |
| 2103 { | 2102 { |
| 2104 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2103 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 2105 | 2104 |
| 2106 scoped_ptr<FakeProxy> proxy(new FakeProxy); | 2105 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
| 2107 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; | 2106 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; |
| 2108 proxy->SetMaxPartialTextureUpdates(5); | 2107 proxy->SetMaxPartialTextureUpdates(5); |
| 2109 | 2108 |
| 2110 LayerTreeSettings settings; | 2109 LayerTreeSettings settings; |
| 2111 settings.max_partial_texture_updates = 10; | 2110 settings.max_partial_texture_updates = 10; |
| 2112 | 2111 |
| 2113 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 2112 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
| 2114 host.OnCreateAndInitializeOutputSurfaceAttempted(true); | |
| 2115 | 2113 |
| 2116 EXPECT_EQ(5u, host.MaxPartialTextureUpdates()); | 2114 EXPECT_EQ(5u, host.MaxPartialTextureUpdates()); |
| 2117 } | 2115 } |
| 2118 | 2116 |
| 2119 // When partial updates are allowed, | 2117 // When partial updates are allowed, |
| 2120 // max updates should also be limited by the settings. | 2118 // max updates should also be limited by the settings. |
| 2121 { | 2119 { |
| 2122 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2120 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 2123 | 2121 |
| 2124 scoped_ptr<FakeProxy> proxy(new FakeProxy); | 2122 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
| 2125 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; | 2123 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; |
| 2126 proxy->SetMaxPartialTextureUpdates(20); | 2124 proxy->SetMaxPartialTextureUpdates(20); |
| 2127 | 2125 |
| 2128 LayerTreeSettings settings; | 2126 LayerTreeSettings settings; |
| 2129 settings.max_partial_texture_updates = 10; | 2127 settings.max_partial_texture_updates = 10; |
| 2130 | 2128 |
| 2131 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 2129 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
| 2132 host.OnCreateAndInitializeOutputSurfaceAttempted(true); | |
| 2133 | 2130 |
| 2134 EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); | 2131 EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); |
| 2135 } | 2132 } |
| 2136 } | 2133 } |
| 2137 | 2134 |
| 2138 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { | 2135 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { |
| 2139 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2136 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 2140 | 2137 |
| 2141 LayerTreeSettings settings; | 2138 LayerTreeSettings settings; |
| 2142 settings.max_partial_texture_updates = 4; | 2139 settings.max_partial_texture_updates = 4; |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2684 GLsizei count, | 2681 GLsizei count, |
| 2685 GLenum type, | 2682 GLenum type, |
| 2686 GLintptr offset)); | 2683 GLintptr offset)); |
| 2687 MOCK_METHOD1(deleteTexture, void(GLenum texture)); | 2684 MOCK_METHOD1(deleteTexture, void(GLenum texture)); |
| 2688 MOCK_METHOD2(produceTextureCHROMIUM, | 2685 MOCK_METHOD2(produceTextureCHROMIUM, |
| 2689 void(GLenum target, const GLbyte* mailbox)); | 2686 void(GLenum target, const GLbyte* mailbox)); |
| 2690 }; | 2687 }; |
| 2691 | 2688 |
| 2692 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest { | 2689 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest { |
| 2693 protected: | 2690 protected: |
| 2694 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( | 2691 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 2695 bool fallback) override { | |
| 2696 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned( | 2692 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned( |
| 2697 new MockIOSurfaceWebGraphicsContext3D); | 2693 new MockIOSurfaceWebGraphicsContext3D); |
| 2698 mock_context_ = mock_context_owned.get(); | 2694 mock_context_ = mock_context_owned.get(); |
| 2699 | 2695 |
| 2700 if (delegating_renderer()) | 2696 if (delegating_renderer()) |
| 2701 return FakeOutputSurface::CreateDelegating3d(mock_context_owned.Pass()); | 2697 return FakeOutputSurface::CreateDelegating3d(mock_context_owned.Pass()); |
| 2702 else | 2698 else |
| 2703 return FakeOutputSurface::Create3d(mock_context_owned.Pass()); | 2699 return FakeOutputSurface::Create3d(mock_context_owned.Pass()); |
| 2704 } | 2700 } |
| 2705 | 2701 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2879 LayerTreeHostTest::SetupTree(); | 2875 LayerTreeHostTest::SetupTree(); |
| 2880 } | 2876 } |
| 2881 | 2877 |
| 2882 void BeginTest() override { | 2878 void BeginTest() override { |
| 2883 did_initialize_gl_ = false; | 2879 did_initialize_gl_ = false; |
| 2884 did_release_gl_ = false; | 2880 did_release_gl_ = false; |
| 2885 last_source_frame_number_drawn_ = -1; // Never drawn. | 2881 last_source_frame_number_drawn_ = -1; // Never drawn. |
| 2886 PostSetNeedsCommitToMainThread(); | 2882 PostSetNeedsCommitToMainThread(); |
| 2887 } | 2883 } |
| 2888 | 2884 |
| 2889 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( | 2885 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 2890 bool fallback) override { | |
| 2891 scoped_ptr<TestWebGraphicsContext3D> context3d( | 2886 scoped_ptr<TestWebGraphicsContext3D> context3d( |
| 2892 TestWebGraphicsContext3D::Create()); | 2887 TestWebGraphicsContext3D::Create()); |
| 2893 | 2888 |
| 2894 return FakeOutputSurface::CreateDeferredGL( | 2889 return FakeOutputSurface::CreateDeferredGL( |
| 2895 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), | 2890 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), |
| 2896 delegating_renderer()); | 2891 delegating_renderer()); |
| 2897 } | 2892 } |
| 2898 | 2893 |
| 2899 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 2894 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 2900 ASSERT_TRUE(host_impl->RootLayer()); | 2895 ASSERT_TRUE(host_impl->RootLayer()); |
| (...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4398 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); | 4393 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); |
| 4399 | 4394 |
| 4400 class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest { | 4395 class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest { |
| 4401 protected: | 4396 protected: |
| 4402 void InitializeSettings(LayerTreeSettings* settings) override { | 4397 void InitializeSettings(LayerTreeSettings* settings) override { |
| 4403 settings->impl_side_painting = true; | 4398 settings->impl_side_painting = true; |
| 4404 settings->use_zero_copy = false; | 4399 settings->use_zero_copy = false; |
| 4405 settings->use_one_copy = false; | 4400 settings->use_one_copy = false; |
| 4406 } | 4401 } |
| 4407 | 4402 |
| 4408 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( | 4403 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 4409 bool fallback) override { | |
| 4410 scoped_refptr<TestContextProvider> context_provider = | 4404 scoped_refptr<TestContextProvider> context_provider = |
| 4411 TestContextProvider::Create(); | 4405 TestContextProvider::Create(); |
| 4412 context_provider->SetMaxTransferBufferUsageBytes(512 * 512); | 4406 context_provider->SetMaxTransferBufferUsageBytes(512 * 512); |
| 4413 if (delegating_renderer()) | 4407 if (delegating_renderer()) |
| 4414 return FakeOutputSurface::CreateDelegating3d(context_provider); | 4408 return FakeOutputSurface::CreateDelegating3d(context_provider); |
| 4415 else | 4409 else |
| 4416 return FakeOutputSurface::Create3d(context_provider); | 4410 return FakeOutputSurface::Create3d(context_provider); |
| 4417 } | 4411 } |
| 4418 | 4412 |
| 4419 void SetupTree() override { | 4413 void SetupTree() override { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4540 | 4534 |
| 4541 } // namespace | 4535 } // namespace |
| 4542 | 4536 |
| 4543 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface | 4537 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface |
| 4544 : public LayerTreeHostTest { | 4538 : public LayerTreeHostTest { |
| 4545 protected: | 4539 protected: |
| 4546 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() | 4540 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() |
| 4547 : first_output_surface_memory_limit_(4321234), | 4541 : first_output_surface_memory_limit_(4321234), |
| 4548 second_output_surface_memory_limit_(1234321) {} | 4542 second_output_surface_memory_limit_(1234321) {} |
| 4549 | 4543 |
| 4550 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( | 4544 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 4551 bool fallback) override { | |
| 4552 if (!first_context_provider_.get()) { | 4545 if (!first_context_provider_.get()) { |
| 4553 first_context_provider_ = TestContextProvider::Create(); | 4546 first_context_provider_ = TestContextProvider::Create(); |
| 4554 } else { | 4547 } else { |
| 4555 EXPECT_FALSE(second_context_provider_.get()); | 4548 EXPECT_FALSE(second_context_provider_.get()); |
| 4556 second_context_provider_ = TestContextProvider::Create(); | 4549 second_context_provider_ = TestContextProvider::Create(); |
| 4557 } | 4550 } |
| 4558 | 4551 |
| 4559 scoped_refptr<TestContextProvider> provider(second_context_provider_.get() | 4552 scoped_refptr<TestContextProvider> provider(second_context_provider_.get() |
| 4560 ? second_context_provider_ | 4553 ? second_context_provider_ |
| 4561 : first_context_provider_); | 4554 : first_context_provider_); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4806 bool did_handle) override { | 4799 bool did_handle) override { |
| 4807 EndTest(); | 4800 EndTest(); |
| 4808 // This lets the test finally commit and exit. | 4801 // This lets the test finally commit and exit. |
| 4809 MainThreadTaskRunner()->PostTask( | 4802 MainThreadTaskRunner()->PostTask( |
| 4810 FROM_HERE, | 4803 FROM_HERE, |
| 4811 base::Bind(&LayerTreeHostTestBreakSwapPromiseForContextAbortedCommit:: | 4804 base::Bind(&LayerTreeHostTestBreakSwapPromiseForContextAbortedCommit:: |
| 4812 FindOutputSurface, | 4805 FindOutputSurface, |
| 4813 base::Unretained(this))); | 4806 base::Unretained(this))); |
| 4814 } | 4807 } |
| 4815 | 4808 |
| 4816 void FindOutputSurface() { | 4809 void FindOutputSurface() { layer_tree_host()->DidInitializeOutputSurface(); } |
| 4817 layer_tree_host()->OnCreateAndInitializeOutputSurfaceAttempted(true); | |
| 4818 } | |
| 4819 | 4810 |
| 4820 void AfterTest() override { | 4811 void AfterTest() override { |
| 4821 { | 4812 { |
| 4822 base::AutoLock lock(swap_promise_result_.lock); | 4813 base::AutoLock lock(swap_promise_result_.lock); |
| 4823 EXPECT_FALSE(swap_promise_result_.did_swap_called); | 4814 EXPECT_FALSE(swap_promise_result_.did_swap_called); |
| 4824 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); | 4815 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); |
| 4825 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); | 4816 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); |
| 4826 EXPECT_TRUE(swap_promise_result_.dtor_called); | 4817 EXPECT_TRUE(swap_promise_result_.dtor_called); |
| 4827 } | 4818 } |
| 4828 } | 4819 } |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5684 | 5675 |
| 5685 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); | 5676 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); |
| 5686 | 5677 |
| 5687 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy | 5678 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy |
| 5688 : public LayerTreeHostTestCrispUpAfterPinchEnds { | 5679 : public LayerTreeHostTestCrispUpAfterPinchEnds { |
| 5689 protected: | 5680 protected: |
| 5690 void InitializeSettings(LayerTreeSettings* settings) override { | 5681 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5691 settings->use_one_copy = true; | 5682 settings->use_one_copy = true; |
| 5692 } | 5683 } |
| 5693 | 5684 |
| 5694 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( | 5685 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 5695 bool fallback) override { | |
| 5696 scoped_ptr<TestWebGraphicsContext3D> context3d = | 5686 scoped_ptr<TestWebGraphicsContext3D> context3d = |
| 5697 TestWebGraphicsContext3D::Create(); | 5687 TestWebGraphicsContext3D::Create(); |
| 5698 context3d->set_support_image(true); | 5688 context3d->set_support_image(true); |
| 5699 context3d->set_support_sync_query(true); | 5689 context3d->set_support_sync_query(true); |
| 5700 #if defined(OS_MACOSX) | 5690 #if defined(OS_MACOSX) |
| 5701 context3d->set_support_texture_rectangle(true); | 5691 context3d->set_support_texture_rectangle(true); |
| 5702 #endif | 5692 #endif |
| 5703 | 5693 |
| 5704 if (delegating_renderer()) | 5694 if (delegating_renderer()) |
| 5705 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); | 5695 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5881 | 5871 |
| 5882 FakeContentLayerClient client_; | 5872 FakeContentLayerClient client_; |
| 5883 int step_; | 5873 int step_; |
| 5884 int continuous_draws_; | 5874 int continuous_draws_; |
| 5885 base::WaitableEvent playback_allowed_event_; | 5875 base::WaitableEvent playback_allowed_event_; |
| 5886 }; | 5876 }; |
| 5887 | 5877 |
| 5888 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); | 5878 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); |
| 5889 | 5879 |
| 5890 } // namespace cc | 5880 } // namespace cc |
| OLD | NEW |