Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 738983002: Move output surface fallback from cc to embedders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_client.h ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 2085 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
2086 2086
2087 scoped_ptr<FakeProxy> proxy(new FakeProxy); 2087 scoped_ptr<FakeProxy> proxy(new FakeProxy);
2088 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; 2088 proxy->GetRendererCapabilities().allow_partial_texture_updates = false;
2089 proxy->SetMaxPartialTextureUpdates(5); 2089 proxy->SetMaxPartialTextureUpdates(5);
2090 2090
2091 LayerTreeSettings settings; 2091 LayerTreeSettings settings;
2092 settings.max_partial_texture_updates = 10; 2092 settings.max_partial_texture_updates = 10;
2093 2093
2094 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); 2094 LayerTreeHostWithProxy host(&client, settings, proxy.Pass());
2095 host.OnCreateAndInitializeOutputSurfaceAttempted(true);
2096 2095
2097 EXPECT_EQ(0u, host.MaxPartialTextureUpdates()); 2096 EXPECT_EQ(0u, host.MaxPartialTextureUpdates());
2098 } 2097 }
2099 2098
2100 // When partial updates are allowed, 2099 // When partial updates are allowed,
2101 // max updates should be limited by the proxy. 2100 // max updates should be limited by the proxy.
2102 { 2101 {
2103 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 2102 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
2104 2103
2105 scoped_ptr<FakeProxy> proxy(new FakeProxy); 2104 scoped_ptr<FakeProxy> proxy(new FakeProxy);
2106 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; 2105 proxy->GetRendererCapabilities().allow_partial_texture_updates = true;
2107 proxy->SetMaxPartialTextureUpdates(5); 2106 proxy->SetMaxPartialTextureUpdates(5);
2108 2107
2109 LayerTreeSettings settings; 2108 LayerTreeSettings settings;
2110 settings.max_partial_texture_updates = 10; 2109 settings.max_partial_texture_updates = 10;
2111 2110
2112 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); 2111 LayerTreeHostWithProxy host(&client, settings, proxy.Pass());
2113 host.OnCreateAndInitializeOutputSurfaceAttempted(true);
2114 2112
2115 EXPECT_EQ(5u, host.MaxPartialTextureUpdates()); 2113 EXPECT_EQ(5u, host.MaxPartialTextureUpdates());
2116 } 2114 }
2117 2115
2118 // When partial updates are allowed, 2116 // When partial updates are allowed,
2119 // max updates should also be limited by the settings. 2117 // max updates should also be limited by the settings.
2120 { 2118 {
2121 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 2119 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
2122 2120
2123 scoped_ptr<FakeProxy> proxy(new FakeProxy); 2121 scoped_ptr<FakeProxy> proxy(new FakeProxy);
2124 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; 2122 proxy->GetRendererCapabilities().allow_partial_texture_updates = true;
2125 proxy->SetMaxPartialTextureUpdates(20); 2123 proxy->SetMaxPartialTextureUpdates(20);
2126 2124
2127 LayerTreeSettings settings; 2125 LayerTreeSettings settings;
2128 settings.max_partial_texture_updates = 10; 2126 settings.max_partial_texture_updates = 10;
2129 2127
2130 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); 2128 LayerTreeHostWithProxy host(&client, settings, proxy.Pass());
2131 host.OnCreateAndInitializeOutputSurfaceAttempted(true);
2132 2129
2133 EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); 2130 EXPECT_EQ(10u, host.MaxPartialTextureUpdates());
2134 } 2131 }
2135 } 2132 }
2136 2133
2137 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { 2134 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) {
2138 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 2135 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
2139 2136
2140 LayerTreeSettings settings; 2137 LayerTreeSettings settings;
2141 settings.max_partial_texture_updates = 4; 2138 settings.max_partial_texture_updates = 4;
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
2683 GLsizei count, 2680 GLsizei count,
2684 GLenum type, 2681 GLenum type,
2685 GLintptr offset)); 2682 GLintptr offset));
2686 MOCK_METHOD1(deleteTexture, void(GLenum texture)); 2683 MOCK_METHOD1(deleteTexture, void(GLenum texture));
2687 MOCK_METHOD2(produceTextureCHROMIUM, 2684 MOCK_METHOD2(produceTextureCHROMIUM,
2688 void(GLenum target, const GLbyte* mailbox)); 2685 void(GLenum target, const GLbyte* mailbox));
2689 }; 2686 };
2690 2687
2691 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest { 2688 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest {
2692 protected: 2689 protected:
2693 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( 2690 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
2694 bool fallback) override {
2695 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned( 2691 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned(
2696 new MockIOSurfaceWebGraphicsContext3D); 2692 new MockIOSurfaceWebGraphicsContext3D);
2697 mock_context_ = mock_context_owned.get(); 2693 mock_context_ = mock_context_owned.get();
2698 2694
2699 if (delegating_renderer()) 2695 if (delegating_renderer())
2700 return FakeOutputSurface::CreateDelegating3d(mock_context_owned.Pass()); 2696 return FakeOutputSurface::CreateDelegating3d(mock_context_owned.Pass());
2701 else 2697 else
2702 return FakeOutputSurface::Create3d(mock_context_owned.Pass()); 2698 return FakeOutputSurface::Create3d(mock_context_owned.Pass());
2703 } 2699 }
2704 2700
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 LayerTreeHostTest::SetupTree(); 2874 LayerTreeHostTest::SetupTree();
2879 } 2875 }
2880 2876
2881 void BeginTest() override { 2877 void BeginTest() override {
2882 did_initialize_gl_ = false; 2878 did_initialize_gl_ = false;
2883 did_release_gl_ = false; 2879 did_release_gl_ = false;
2884 last_source_frame_number_drawn_ = -1; // Never drawn. 2880 last_source_frame_number_drawn_ = -1; // Never drawn.
2885 PostSetNeedsCommitToMainThread(); 2881 PostSetNeedsCommitToMainThread();
2886 } 2882 }
2887 2883
2888 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( 2884 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
2889 bool fallback) override {
2890 scoped_ptr<TestWebGraphicsContext3D> context3d( 2885 scoped_ptr<TestWebGraphicsContext3D> context3d(
2891 TestWebGraphicsContext3D::Create()); 2886 TestWebGraphicsContext3D::Create());
2892 2887
2893 return FakeOutputSurface::CreateDeferredGL( 2888 return FakeOutputSurface::CreateDeferredGL(
2894 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), 2889 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice),
2895 delegating_renderer()); 2890 delegating_renderer());
2896 } 2891 }
2897 2892
2898 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 2893 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
2899 ASSERT_TRUE(host_impl->RootLayer()); 2894 ASSERT_TRUE(host_impl->RootLayer());
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after
4397 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); 4392 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures);
4398 4393
4399 class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest { 4394 class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest {
4400 protected: 4395 protected:
4401 void InitializeSettings(LayerTreeSettings* settings) override { 4396 void InitializeSettings(LayerTreeSettings* settings) override {
4402 settings->impl_side_painting = true; 4397 settings->impl_side_painting = true;
4403 settings->use_zero_copy = false; 4398 settings->use_zero_copy = false;
4404 settings->use_one_copy = false; 4399 settings->use_one_copy = false;
4405 } 4400 }
4406 4401
4407 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( 4402 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
4408 bool fallback) override {
4409 scoped_refptr<TestContextProvider> context_provider = 4403 scoped_refptr<TestContextProvider> context_provider =
4410 TestContextProvider::Create(); 4404 TestContextProvider::Create();
4411 context_provider->SetMaxTransferBufferUsageBytes(512 * 512); 4405 context_provider->SetMaxTransferBufferUsageBytes(512 * 512);
4412 if (delegating_renderer()) 4406 if (delegating_renderer())
4413 return FakeOutputSurface::CreateDelegating3d(context_provider); 4407 return FakeOutputSurface::CreateDelegating3d(context_provider);
4414 else 4408 else
4415 return FakeOutputSurface::Create3d(context_provider); 4409 return FakeOutputSurface::Create3d(context_provider);
4416 } 4410 }
4417 4411
4418 void SetupTree() override { 4412 void SetupTree() override {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
4539 4533
4540 } // namespace 4534 } // namespace
4541 4535
4542 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface 4536 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface
4543 : public LayerTreeHostTest { 4537 : public LayerTreeHostTest {
4544 protected: 4538 protected:
4545 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() 4539 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface()
4546 : first_output_surface_memory_limit_(4321234), 4540 : first_output_surface_memory_limit_(4321234),
4547 second_output_surface_memory_limit_(1234321) {} 4541 second_output_surface_memory_limit_(1234321) {}
4548 4542
4549 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( 4543 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
4550 bool fallback) override {
4551 if (!first_context_provider_.get()) { 4544 if (!first_context_provider_.get()) {
4552 first_context_provider_ = TestContextProvider::Create(); 4545 first_context_provider_ = TestContextProvider::Create();
4553 } else { 4546 } else {
4554 EXPECT_FALSE(second_context_provider_.get()); 4547 EXPECT_FALSE(second_context_provider_.get());
4555 second_context_provider_ = TestContextProvider::Create(); 4548 second_context_provider_ = TestContextProvider::Create();
4556 } 4549 }
4557 4550
4558 scoped_refptr<TestContextProvider> provider(second_context_provider_.get() 4551 scoped_refptr<TestContextProvider> provider(second_context_provider_.get()
4559 ? second_context_provider_ 4552 ? second_context_provider_
4560 : first_context_provider_); 4553 : first_context_provider_);
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
5731 5724
5732 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); 5725 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds);
5733 5726
5734 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy 5727 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy
5735 : public LayerTreeHostTestCrispUpAfterPinchEnds { 5728 : public LayerTreeHostTestCrispUpAfterPinchEnds {
5736 protected: 5729 protected:
5737 void InitializeSettings(LayerTreeSettings* settings) override { 5730 void InitializeSettings(LayerTreeSettings* settings) override {
5738 settings->use_one_copy = true; 5731 settings->use_one_copy = true;
5739 } 5732 }
5740 5733
5741 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( 5734 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
5742 bool fallback) override {
5743 scoped_ptr<TestWebGraphicsContext3D> context3d = 5735 scoped_ptr<TestWebGraphicsContext3D> context3d =
5744 TestWebGraphicsContext3D::Create(); 5736 TestWebGraphicsContext3D::Create();
5745 context3d->set_support_image(true); 5737 context3d->set_support_image(true);
5746 context3d->set_support_sync_query(true); 5738 context3d->set_support_sync_query(true);
5747 #if defined(OS_MACOSX) 5739 #if defined(OS_MACOSX)
5748 context3d->set_support_texture_rectangle(true); 5740 context3d->set_support_texture_rectangle(true);
5749 #endif 5741 #endif
5750 5742
5751 if (delegating_renderer()) 5743 if (delegating_renderer())
5752 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); 5744 return FakeOutputSurface::CreateDelegating3d(context3d.Pass());
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
5984 5976
5985 protected: 5977 protected:
5986 FakeContentLayerClient client_; 5978 FakeContentLayerClient client_;
5987 size_t notify_ready_to_activate_count_; 5979 size_t notify_ready_to_activate_count_;
5988 size_t scheduled_prepare_tiles_count_; 5980 size_t scheduled_prepare_tiles_count_;
5989 }; 5981 };
5990 5982
5991 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); 5983 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles);
5992 5984
5993 } // namespace cc 5985 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_client.h ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698