| 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 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2083 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2083 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 2084 | 2084 |
| 2085 scoped_ptr<FakeProxy> proxy(new FakeProxy); | 2085 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
| 2086 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; | 2086 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; |
| 2087 proxy->SetMaxPartialTextureUpdates(5); | 2087 proxy->SetMaxPartialTextureUpdates(5); |
| 2088 | 2088 |
| 2089 LayerTreeSettings settings; | 2089 LayerTreeSettings settings; |
| 2090 settings.max_partial_texture_updates = 10; | 2090 settings.max_partial_texture_updates = 10; |
| 2091 | 2091 |
| 2092 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 2092 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
| 2093 host.OnCreateAndInitializeOutputSurfaceAttempted(true); | |
| 2094 | 2093 |
| 2095 EXPECT_EQ(0u, host.MaxPartialTextureUpdates()); | 2094 EXPECT_EQ(0u, host.MaxPartialTextureUpdates()); |
| 2096 } | 2095 } |
| 2097 | 2096 |
| 2098 // When partial updates are allowed, | 2097 // When partial updates are allowed, |
| 2099 // max updates should be limited by the proxy. | 2098 // max updates should be limited by the proxy. |
| 2100 { | 2099 { |
| 2101 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2100 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 2102 | 2101 |
| 2103 scoped_ptr<FakeProxy> proxy(new FakeProxy); | 2102 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
| 2104 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; | 2103 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; |
| 2105 proxy->SetMaxPartialTextureUpdates(5); | 2104 proxy->SetMaxPartialTextureUpdates(5); |
| 2106 | 2105 |
| 2107 LayerTreeSettings settings; | 2106 LayerTreeSettings settings; |
| 2108 settings.max_partial_texture_updates = 10; | 2107 settings.max_partial_texture_updates = 10; |
| 2109 | 2108 |
| 2110 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 2109 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
| 2111 host.OnCreateAndInitializeOutputSurfaceAttempted(true); | |
| 2112 | 2110 |
| 2113 EXPECT_EQ(5u, host.MaxPartialTextureUpdates()); | 2111 EXPECT_EQ(5u, host.MaxPartialTextureUpdates()); |
| 2114 } | 2112 } |
| 2115 | 2113 |
| 2116 // When partial updates are allowed, | 2114 // When partial updates are allowed, |
| 2117 // max updates should also be limited by the settings. | 2115 // max updates should also be limited by the settings. |
| 2118 { | 2116 { |
| 2119 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2117 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 2120 | 2118 |
| 2121 scoped_ptr<FakeProxy> proxy(new FakeProxy); | 2119 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
| 2122 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; | 2120 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; |
| 2123 proxy->SetMaxPartialTextureUpdates(20); | 2121 proxy->SetMaxPartialTextureUpdates(20); |
| 2124 | 2122 |
| 2125 LayerTreeSettings settings; | 2123 LayerTreeSettings settings; |
| 2126 settings.max_partial_texture_updates = 10; | 2124 settings.max_partial_texture_updates = 10; |
| 2127 | 2125 |
| 2128 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 2126 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
| 2129 host.OnCreateAndInitializeOutputSurfaceAttempted(true); | |
| 2130 | 2127 |
| 2131 EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); | 2128 EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); |
| 2132 } | 2129 } |
| 2133 } | 2130 } |
| 2134 | 2131 |
| 2135 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { | 2132 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { |
| 2136 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2133 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 2137 | 2134 |
| 2138 LayerTreeSettings settings; | 2135 LayerTreeSettings settings; |
| 2139 settings.max_partial_texture_updates = 4; | 2136 settings.max_partial_texture_updates = 4; |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2681 GLsizei count, | 2678 GLsizei count, |
| 2682 GLenum type, | 2679 GLenum type, |
| 2683 GLintptr offset)); | 2680 GLintptr offset)); |
| 2684 MOCK_METHOD1(deleteTexture, void(GLenum texture)); | 2681 MOCK_METHOD1(deleteTexture, void(GLenum texture)); |
| 2685 MOCK_METHOD2(produceTextureCHROMIUM, | 2682 MOCK_METHOD2(produceTextureCHROMIUM, |
| 2686 void(GLenum target, const GLbyte* mailbox)); | 2683 void(GLenum target, const GLbyte* mailbox)); |
| 2687 }; | 2684 }; |
| 2688 | 2685 |
| 2689 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest { | 2686 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest { |
| 2690 protected: | 2687 protected: |
| 2691 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( | 2688 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 2692 bool fallback) override { | |
| 2693 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned( | 2689 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned( |
| 2694 new MockIOSurfaceWebGraphicsContext3D); | 2690 new MockIOSurfaceWebGraphicsContext3D); |
| 2695 mock_context_ = mock_context_owned.get(); | 2691 mock_context_ = mock_context_owned.get(); |
| 2696 | 2692 |
| 2697 if (delegating_renderer()) | 2693 if (delegating_renderer()) |
| 2698 return FakeOutputSurface::CreateDelegating3d(mock_context_owned.Pass()); | 2694 return FakeOutputSurface::CreateDelegating3d(mock_context_owned.Pass()); |
| 2699 else | 2695 else |
| 2700 return FakeOutputSurface::Create3d(mock_context_owned.Pass()); | 2696 return FakeOutputSurface::Create3d(mock_context_owned.Pass()); |
| 2701 } | 2697 } |
| 2702 | 2698 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2876 LayerTreeHostTest::SetupTree(); | 2872 LayerTreeHostTest::SetupTree(); |
| 2877 } | 2873 } |
| 2878 | 2874 |
| 2879 void BeginTest() override { | 2875 void BeginTest() override { |
| 2880 did_initialize_gl_ = false; | 2876 did_initialize_gl_ = false; |
| 2881 did_release_gl_ = false; | 2877 did_release_gl_ = false; |
| 2882 last_source_frame_number_drawn_ = -1; // Never drawn. | 2878 last_source_frame_number_drawn_ = -1; // Never drawn. |
| 2883 PostSetNeedsCommitToMainThread(); | 2879 PostSetNeedsCommitToMainThread(); |
| 2884 } | 2880 } |
| 2885 | 2881 |
| 2886 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( | 2882 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 2887 bool fallback) override { | |
| 2888 scoped_ptr<TestWebGraphicsContext3D> context3d( | 2883 scoped_ptr<TestWebGraphicsContext3D> context3d( |
| 2889 TestWebGraphicsContext3D::Create()); | 2884 TestWebGraphicsContext3D::Create()); |
| 2890 | 2885 |
| 2891 return FakeOutputSurface::CreateDeferredGL( | 2886 return FakeOutputSurface::CreateDeferredGL( |
| 2892 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), | 2887 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), |
| 2893 delegating_renderer()); | 2888 delegating_renderer()); |
| 2894 } | 2889 } |
| 2895 | 2890 |
| 2896 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 2891 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 2897 ASSERT_TRUE(host_impl->RootLayer()); | 2892 ASSERT_TRUE(host_impl->RootLayer()); |
| (...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4373 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); | 4368 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); |
| 4374 | 4369 |
| 4375 class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest { | 4370 class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest { |
| 4376 protected: | 4371 protected: |
| 4377 void InitializeSettings(LayerTreeSettings* settings) override { | 4372 void InitializeSettings(LayerTreeSettings* settings) override { |
| 4378 settings->impl_side_painting = true; | 4373 settings->impl_side_painting = true; |
| 4379 settings->use_zero_copy = false; | 4374 settings->use_zero_copy = false; |
| 4380 settings->use_one_copy = false; | 4375 settings->use_one_copy = false; |
| 4381 } | 4376 } |
| 4382 | 4377 |
| 4383 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( | 4378 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 4384 bool fallback) override { | |
| 4385 scoped_refptr<TestContextProvider> context_provider = | 4379 scoped_refptr<TestContextProvider> context_provider = |
| 4386 TestContextProvider::Create(); | 4380 TestContextProvider::Create(); |
| 4387 context_provider->SetMaxTransferBufferUsageBytes(512 * 512); | 4381 context_provider->SetMaxTransferBufferUsageBytes(512 * 512); |
| 4388 if (delegating_renderer()) | 4382 if (delegating_renderer()) |
| 4389 return FakeOutputSurface::CreateDelegating3d(context_provider); | 4383 return FakeOutputSurface::CreateDelegating3d(context_provider); |
| 4390 else | 4384 else |
| 4391 return FakeOutputSurface::Create3d(context_provider); | 4385 return FakeOutputSurface::Create3d(context_provider); |
| 4392 } | 4386 } |
| 4393 | 4387 |
| 4394 void SetupTree() override { | 4388 void SetupTree() override { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4515 | 4509 |
| 4516 } // namespace | 4510 } // namespace |
| 4517 | 4511 |
| 4518 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface | 4512 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface |
| 4519 : public LayerTreeHostTest { | 4513 : public LayerTreeHostTest { |
| 4520 protected: | 4514 protected: |
| 4521 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() | 4515 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() |
| 4522 : first_output_surface_memory_limit_(4321234), | 4516 : first_output_surface_memory_limit_(4321234), |
| 4523 second_output_surface_memory_limit_(1234321) {} | 4517 second_output_surface_memory_limit_(1234321) {} |
| 4524 | 4518 |
| 4525 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( | 4519 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 4526 bool fallback) override { | |
| 4527 if (!first_context_provider_.get()) { | 4520 if (!first_context_provider_.get()) { |
| 4528 first_context_provider_ = TestContextProvider::Create(); | 4521 first_context_provider_ = TestContextProvider::Create(); |
| 4529 } else { | 4522 } else { |
| 4530 EXPECT_FALSE(second_context_provider_.get()); | 4523 EXPECT_FALSE(second_context_provider_.get()); |
| 4531 second_context_provider_ = TestContextProvider::Create(); | 4524 second_context_provider_ = TestContextProvider::Create(); |
| 4532 } | 4525 } |
| 4533 | 4526 |
| 4534 scoped_refptr<TestContextProvider> provider(second_context_provider_.get() | 4527 scoped_refptr<TestContextProvider> provider(second_context_provider_.get() |
| 4535 ? second_context_provider_ | 4528 ? second_context_provider_ |
| 4536 : first_context_provider_); | 4529 : first_context_provider_); |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5101 void AfterTest() override {} | 5094 void AfterTest() override {} |
| 5102 | 5095 |
| 5103 FakeContentLayerClient layer_client_; | 5096 FakeContentLayerClient layer_client_; |
| 5104 }; | 5097 }; |
| 5105 | 5098 |
| 5106 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled); | 5099 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled); |
| 5107 | 5100 |
| 5108 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { | 5101 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { |
| 5109 protected: | 5102 protected: |
| 5110 void InitializeSettings(LayerTreeSettings* settings) override { | 5103 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5111 settings->impl_side_painting = true; | 5104 ASSERT_TRUE(settings->impl_side_painting); |
| 5112 | 5105 |
| 5113 EXPECT_FALSE(settings->gpu_rasterization_forced); | 5106 EXPECT_FALSE(settings->gpu_rasterization_forced); |
| 5114 settings->gpu_rasterization_forced = true; | 5107 settings->gpu_rasterization_forced = true; |
| 5115 } | 5108 } |
| 5116 | 5109 |
| 5117 void SetupTree() override { | 5110 void SetupTree() override { |
| 5118 LayerTreeHostTest::SetupTree(); | 5111 LayerTreeHostTest::SetupTree(); |
| 5119 | 5112 |
| 5120 scoped_refptr<FakePictureLayer> layer = | 5113 scoped_refptr<FakePictureLayer> layer = |
| 5121 FakePictureLayer::Create(&layer_client_); | 5114 FakePictureLayer::Create(&layer_client_); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5162 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization()); | 5155 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization()); |
| 5163 EXPECT_TRUE(host_impl->use_gpu_rasterization()); | 5156 EXPECT_TRUE(host_impl->use_gpu_rasterization()); |
| 5164 EndTest(); | 5157 EndTest(); |
| 5165 } | 5158 } |
| 5166 | 5159 |
| 5167 void AfterTest() override {} | 5160 void AfterTest() override {} |
| 5168 | 5161 |
| 5169 FakeContentLayerClient layer_client_; | 5162 FakeContentLayerClient layer_client_; |
| 5170 }; | 5163 }; |
| 5171 | 5164 |
| 5172 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); | 5165 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestGpuRasterizationForced); |
| 5173 | 5166 |
| 5174 class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { | 5167 class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { |
| 5175 public: | 5168 public: |
| 5176 LayerTreeHostTestContinuousPainting() | 5169 LayerTreeHostTestContinuousPainting() |
| 5177 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} | 5170 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} |
| 5178 | 5171 |
| 5179 protected: | 5172 protected: |
| 5180 enum { kExpectedNumCommits = 10 }; | 5173 enum { kExpectedNumCommits = 10 }; |
| 5181 | 5174 |
| 5182 void SetupTree() override { | 5175 void SetupTree() override { |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5707 | 5700 |
| 5708 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); | 5701 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); |
| 5709 | 5702 |
| 5710 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy | 5703 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy |
| 5711 : public LayerTreeHostTestCrispUpAfterPinchEnds { | 5704 : public LayerTreeHostTestCrispUpAfterPinchEnds { |
| 5712 protected: | 5705 protected: |
| 5713 void InitializeSettings(LayerTreeSettings* settings) override { | 5706 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5714 settings->use_one_copy = true; | 5707 settings->use_one_copy = true; |
| 5715 } | 5708 } |
| 5716 | 5709 |
| 5717 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( | 5710 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 5718 bool fallback) override { | |
| 5719 scoped_ptr<TestWebGraphicsContext3D> context3d = | 5711 scoped_ptr<TestWebGraphicsContext3D> context3d = |
| 5720 TestWebGraphicsContext3D::Create(); | 5712 TestWebGraphicsContext3D::Create(); |
| 5721 context3d->set_support_image(true); | 5713 context3d->set_support_image(true); |
| 5722 context3d->set_support_sync_query(true); | 5714 context3d->set_support_sync_query(true); |
| 5723 #if defined(OS_MACOSX) | 5715 #if defined(OS_MACOSX) |
| 5724 context3d->set_support_texture_rectangle(true); | 5716 context3d->set_support_texture_rectangle(true); |
| 5725 #endif | 5717 #endif |
| 5726 | 5718 |
| 5727 if (delegating_renderer()) | 5719 if (delegating_renderer()) |
| 5728 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); | 5720 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5960 | 5952 |
| 5961 protected: | 5953 protected: |
| 5962 FakeContentLayerClient client_; | 5954 FakeContentLayerClient client_; |
| 5963 size_t notify_ready_to_activate_count_; | 5955 size_t notify_ready_to_activate_count_; |
| 5964 size_t scheduled_prepare_tiles_count_; | 5956 size_t scheduled_prepare_tiles_count_; |
| 5965 }; | 5957 }; |
| 5966 | 5958 |
| 5967 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); | 5959 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); |
| 5968 | 5960 |
| 5969 } // namespace cc | 5961 } // namespace cc |
| OLD | NEW |