| 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 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 layer_tree_host()->SetRootLayer(layer_); | 1258 layer_tree_host()->SetRootLayer(layer_); |
| 1259 LayerTreeHostTest::SetupTree(); | 1259 LayerTreeHostTest::SetupTree(); |
| 1260 } | 1260 } |
| 1261 | 1261 |
| 1262 virtual void BeginTest() OVERRIDE { | 1262 virtual void BeginTest() OVERRIDE { |
| 1263 drew_frame_ = -1; | 1263 drew_frame_ = -1; |
| 1264 PostSetNeedsCommitToMainThread(); | 1264 PostSetNeedsCommitToMainThread(); |
| 1265 } | 1265 } |
| 1266 | 1266 |
| 1267 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1267 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 1268 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates); | 1268 ASSERT_EQ(0u, layer_tree_host()->MaxPartialTextureUpdates()); |
| 1269 | 1269 |
| 1270 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( | 1270 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( |
| 1271 impl->output_surface()->context_provider()->Context3d()); | 1271 impl->output_surface()->context_provider()->Context3d()); |
| 1272 | 1272 |
| 1273 switch (impl->active_tree()->source_frame_number()) { | 1273 switch (impl->active_tree()->source_frame_number()) { |
| 1274 case 0: | 1274 case 0: |
| 1275 // Number of textures should be one for each layer | 1275 // Number of textures should be one for each layer |
| 1276 ASSERT_EQ(2u, context->NumTextures()); | 1276 ASSERT_EQ(2u, context->NumTextures()); |
| 1277 // Number of textures used for commit should be one for each layer. | 1277 // Number of textures used for commit should be one for each layer. |
| 1278 EXPECT_EQ(2u, context->NumUsedTextures()); | 1278 EXPECT_EQ(2u, context->NumUsedTextures()); |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2082 scoped_ptr<FakeProxy> proxy(new FakeProxy); | 2082 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
| 2083 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; | 2083 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; |
| 2084 proxy->SetMaxPartialTextureUpdates(5); | 2084 proxy->SetMaxPartialTextureUpdates(5); |
| 2085 | 2085 |
| 2086 LayerTreeSettings settings; | 2086 LayerTreeSettings settings; |
| 2087 settings.max_partial_texture_updates = 10; | 2087 settings.max_partial_texture_updates = 10; |
| 2088 | 2088 |
| 2089 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 2089 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
| 2090 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); | 2090 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); |
| 2091 | 2091 |
| 2092 EXPECT_EQ(0u, host.settings().max_partial_texture_updates); | 2092 EXPECT_EQ(0u, host.MaxPartialTextureUpdates()); |
| 2093 } | 2093 } |
| 2094 | 2094 |
| 2095 // When partial updates are allowed, | 2095 // When partial updates are allowed, |
| 2096 // max updates should be limited by the proxy. | 2096 // max updates should be limited by the proxy. |
| 2097 { | 2097 { |
| 2098 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2098 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 2099 | 2099 |
| 2100 scoped_ptr<FakeProxy> proxy(new FakeProxy); | 2100 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
| 2101 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; | 2101 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; |
| 2102 proxy->SetMaxPartialTextureUpdates(5); | 2102 proxy->SetMaxPartialTextureUpdates(5); |
| 2103 | 2103 |
| 2104 LayerTreeSettings settings; | 2104 LayerTreeSettings settings; |
| 2105 settings.max_partial_texture_updates = 10; | 2105 settings.max_partial_texture_updates = 10; |
| 2106 | 2106 |
| 2107 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 2107 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
| 2108 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); | 2108 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); |
| 2109 | 2109 |
| 2110 EXPECT_EQ(5u, host.settings().max_partial_texture_updates); | 2110 EXPECT_EQ(5u, host.MaxPartialTextureUpdates()); |
| 2111 } | 2111 } |
| 2112 | 2112 |
| 2113 // When partial updates are allowed, | 2113 // When partial updates are allowed, |
| 2114 // max updates should also be limited by the settings. | 2114 // max updates should also be limited by the settings. |
| 2115 { | 2115 { |
| 2116 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2116 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 2117 | 2117 |
| 2118 scoped_ptr<FakeProxy> proxy(new FakeProxy); | 2118 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
| 2119 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; | 2119 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; |
| 2120 proxy->SetMaxPartialTextureUpdates(20); | 2120 proxy->SetMaxPartialTextureUpdates(20); |
| 2121 | 2121 |
| 2122 LayerTreeSettings settings; | 2122 LayerTreeSettings settings; |
| 2123 settings.max_partial_texture_updates = 10; | 2123 settings.max_partial_texture_updates = 10; |
| 2124 | 2124 |
| 2125 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 2125 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
| 2126 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); | 2126 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); |
| 2127 | 2127 |
| 2128 EXPECT_EQ(10u, host.settings().max_partial_texture_updates); | 2128 EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); |
| 2129 } | 2129 } |
| 2130 } | 2130 } |
| 2131 | 2131 |
| 2132 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { | 2132 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { |
| 2133 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2133 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 2134 | 2134 |
| 2135 LayerTreeSettings settings; | 2135 LayerTreeSettings settings; |
| 2136 settings.max_partial_texture_updates = 4; | 2136 settings.max_partial_texture_updates = 4; |
| 2137 | 2137 |
| 2138 scoped_ptr<LayerTreeHost> host = | 2138 scoped_ptr<LayerTreeHost> host = |
| 2139 LayerTreeHost::Create(&client, settings, NULL); | 2139 LayerTreeHost::Create(&client, settings, NULL); |
| 2140 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 2140 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
| 2141 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 2141 EXPECT_EQ(4u, host->MaxPartialTextureUpdates()); |
| 2142 } | 2142 } |
| 2143 | 2143 |
| 2144 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { | 2144 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { |
| 2145 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); | 2145 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); |
| 2146 | 2146 |
| 2147 LayerTreeSettings settings; | 2147 LayerTreeSettings settings; |
| 2148 settings.max_partial_texture_updates = 4; | 2148 settings.max_partial_texture_updates = 4; |
| 2149 | 2149 |
| 2150 scoped_ptr<LayerTreeHost> host = | 2150 scoped_ptr<LayerTreeHost> host = |
| 2151 LayerTreeHost::Create(&client, settings, NULL); | 2151 LayerTreeHost::Create(&client, settings, NULL); |
| 2152 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 2152 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
| 2153 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 2153 EXPECT_EQ(4u, host->MaxPartialTextureUpdates()); |
| 2154 } | 2154 } |
| 2155 | 2155 |
| 2156 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { | 2156 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { |
| 2157 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); | 2157 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); |
| 2158 | 2158 |
| 2159 LayerTreeSettings settings; | 2159 LayerTreeSettings settings; |
| 2160 settings.max_partial_texture_updates = 4; | 2160 settings.max_partial_texture_updates = 4; |
| 2161 | 2161 |
| 2162 scoped_ptr<LayerTreeHost> host = | 2162 scoped_ptr<LayerTreeHost> host = |
| 2163 LayerTreeHost::Create(&client, settings, NULL); | 2163 LayerTreeHost::Create(&client, settings, NULL); |
| 2164 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 2164 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
| 2165 EXPECT_EQ(0u, host->settings().max_partial_texture_updates); | 2165 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); |
| 2166 } | 2166 } |
| 2167 | 2167 |
| 2168 TEST(LayerTreeHostTest, | 2168 TEST(LayerTreeHostTest, |
| 2169 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { | 2169 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { |
| 2170 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); | 2170 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); |
| 2171 | 2171 |
| 2172 LayerTreeSettings settings; | 2172 LayerTreeSettings settings; |
| 2173 settings.max_partial_texture_updates = 4; | 2173 settings.max_partial_texture_updates = 4; |
| 2174 | 2174 |
| 2175 scoped_ptr<LayerTreeHost> host = | 2175 scoped_ptr<LayerTreeHost> host = |
| 2176 LayerTreeHost::Create(&client, settings, NULL); | 2176 LayerTreeHost::Create(&client, settings, NULL); |
| 2177 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 2177 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
| 2178 EXPECT_EQ(0u, host->settings().max_partial_texture_updates); | 2178 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); |
| 2179 } | 2179 } |
| 2180 | 2180 |
| 2181 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted | 2181 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted |
| 2182 : public LayerTreeHostTest { | 2182 : public LayerTreeHostTest { |
| 2183 public: | 2183 public: |
| 2184 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() | 2184 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() |
| 2185 : root_layer_(FakeContentLayer::Create(&client_)), | 2185 : root_layer_(FakeContentLayer::Create(&client_)), |
| 2186 child_layer1_(FakeContentLayer::Create(&client_)), | 2186 child_layer1_(FakeContentLayer::Create(&client_)), |
| 2187 child_layer2_(FakeContentLayer::Create(&client_)), | 2187 child_layer2_(FakeContentLayer::Create(&client_)), |
| 2188 num_commits_(0) {} | 2188 num_commits_(0) {} |
| (...skipping 2647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4836 : public LayerTreeHostTestOffscreenContext { | 4836 : public LayerTreeHostTestOffscreenContext { |
| 4837 protected: | 4837 protected: |
| 4838 LayerTreeHostTestOffscreenContext_WithContext() { with_context_ = true; } | 4838 LayerTreeHostTestOffscreenContext_WithContext() { with_context_ = true; } |
| 4839 }; | 4839 }; |
| 4840 | 4840 |
| 4841 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestOffscreenContext_WithContext); | 4841 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestOffscreenContext_WithContext); |
| 4842 | 4842 |
| 4843 } // namespace | 4843 } // namespace |
| 4844 | 4844 |
| 4845 } // namespace cc | 4845 } // namespace cc |
| OLD | NEW |