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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 using testing::_; | 60 using testing::_; |
61 using testing::AnyNumber; | 61 using testing::AnyNumber; |
62 using testing::AtLeast; | 62 using testing::AtLeast; |
63 using testing::Mock; | 63 using testing::Mock; |
64 | 64 |
65 namespace cc { | 65 namespace cc { |
66 namespace { | 66 namespace { |
67 | 67 |
68 class LayerTreeHostTest : public LayerTreeTest {}; | 68 class LayerTreeHostTest : public LayerTreeTest {}; |
69 | 69 |
| 70 // Test if the LTHI receives ReadyToActivate notifications from the TileManager |
| 71 // when no raster tasks get scheduled. |
| 72 class LayerTreeHostTestReadyToActivateEmpty : public LayerTreeHostTest { |
| 73 public: |
| 74 LayerTreeHostTestReadyToActivateEmpty() |
| 75 : did_notify_ready_to_activate_(false), |
| 76 all_tiles_required_for_activation_are_ready_to_draw_(false), |
| 77 required_for_activation_count_(0) {} |
| 78 |
| 79 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 80 |
| 81 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 82 const std::vector<PictureLayerImpl*>& layers = impl->GetPictureLayers(); |
| 83 required_for_activation_count_ = 0; |
| 84 for (const auto& layer : layers) { |
| 85 FakePictureLayerImpl* fake_layer = |
| 86 static_cast<FakePictureLayerImpl*>(layer); |
| 87 required_for_activation_count_ += |
| 88 fake_layer->CountTilesRequiredForActivation(); |
| 89 } |
| 90 } |
| 91 |
| 92 void NotifyReadyToActivateOnThread(LayerTreeHostImpl* impl) override { |
| 93 did_notify_ready_to_activate_ = true; |
| 94 const std::vector<PictureLayerImpl*>& layers = impl->GetPictureLayers(); |
| 95 all_tiles_required_for_activation_are_ready_to_draw_ = true; |
| 96 for (const auto& layer : layers) { |
| 97 if (!layer->AllTilesRequiredForActivationAreReadyToDraw()) |
| 98 all_tiles_required_for_activation_are_ready_to_draw_ = false; |
| 99 } |
| 100 EndTest(); |
| 101 } |
| 102 |
| 103 void AfterTest() override { |
| 104 EXPECT_TRUE(did_notify_ready_to_activate_); |
| 105 EXPECT_TRUE(all_tiles_required_for_activation_are_ready_to_draw_); |
| 106 EXPECT_EQ(size_t(0), required_for_activation_count_); |
| 107 } |
| 108 |
| 109 protected: |
| 110 bool did_notify_ready_to_activate_; |
| 111 bool all_tiles_required_for_activation_are_ready_to_draw_; |
| 112 size_t required_for_activation_count_; |
| 113 }; |
| 114 |
| 115 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestReadyToActivateEmpty); |
| 116 |
| 117 // Test if the LTHI receives ReadyToActivate notifications from the TileManager |
| 118 // when some raster tasks flagged as REQUIRED_FOR_ACTIVATION got scheduled. |
| 119 class LayerTreeHostTestReadyToActivateNonEmpty |
| 120 : public LayerTreeHostTestReadyToActivateEmpty { |
| 121 public: |
| 122 void SetupTree() override { |
| 123 client_.set_fill_with_nonsolid_color(true); |
| 124 scoped_refptr<FakePictureLayer> root_layer = |
| 125 FakePictureLayer::Create(&client_); |
| 126 root_layer->SetBounds(gfx::Size(1024, 1024)); |
| 127 root_layer->SetIsDrawable(true); |
| 128 |
| 129 layer_tree_host()->SetRootLayer(root_layer); |
| 130 LayerTreeHostTest::SetupTree(); |
| 131 } |
| 132 |
| 133 void AfterTest() override { |
| 134 EXPECT_TRUE(did_notify_ready_to_activate_); |
| 135 EXPECT_TRUE(all_tiles_required_for_activation_are_ready_to_draw_); |
| 136 EXPECT_LE(size_t(1), required_for_activation_count_); |
| 137 } |
| 138 |
| 139 private: |
| 140 FakeContentLayerClient client_; |
| 141 }; |
| 142 |
| 143 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestReadyToActivateNonEmpty); |
| 144 |
| 145 // Test if the LTHI receives ReadyToDraw notifications from the TileManager when |
| 146 // no raster tasks get scheduled. |
| 147 class LayerTreeHostTestReadyToDrawEmpty : public LayerTreeHostTest { |
| 148 public: |
| 149 LayerTreeHostTestReadyToDrawEmpty() |
| 150 : did_notify_ready_to_draw_(false), |
| 151 all_tiles_required_for_draw_are_ready_to_draw_(false), |
| 152 required_for_draw_count_(0) {} |
| 153 |
| 154 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 155 |
| 156 void NotifyReadyToDrawOnThread(LayerTreeHostImpl* impl) override { |
| 157 did_notify_ready_to_draw_ = true; |
| 158 const std::vector<PictureLayerImpl*>& layers = impl->GetPictureLayers(); |
| 159 all_tiles_required_for_draw_are_ready_to_draw_ = true; |
| 160 for (const auto& layer : layers) { |
| 161 if (!layer->AllTilesRequiredForDrawAreReadyToDraw()) |
| 162 all_tiles_required_for_draw_are_ready_to_draw_ = false; |
| 163 FakePictureLayerImpl* fake_layer = |
| 164 static_cast<FakePictureLayerImpl*>(layer); |
| 165 required_for_draw_count_ += fake_layer->CountTilesRequiredForDraw(); |
| 166 } |
| 167 |
| 168 EndTest(); |
| 169 } |
| 170 |
| 171 void AfterTest() override { |
| 172 EXPECT_TRUE(did_notify_ready_to_draw_); |
| 173 EXPECT_TRUE(all_tiles_required_for_draw_are_ready_to_draw_); |
| 174 EXPECT_EQ(size_t(0), required_for_draw_count_); |
| 175 } |
| 176 |
| 177 protected: |
| 178 bool did_notify_ready_to_draw_; |
| 179 bool all_tiles_required_for_draw_are_ready_to_draw_; |
| 180 size_t required_for_draw_count_; |
| 181 }; |
| 182 |
| 183 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestReadyToDrawEmpty); |
| 184 |
| 185 // Test if the LTHI receives ReadyToDraw notifications from the TileManager when |
| 186 // some raster tasks flagged as REQUIRED_FOR_DRAW got scheduled. |
| 187 class LayerTreeHostTestReadyToDrawNonEmpty |
| 188 : public LayerTreeHostTestReadyToDrawEmpty { |
| 189 public: |
| 190 void SetupTree() override { |
| 191 client_.set_fill_with_nonsolid_color(true); |
| 192 scoped_refptr<FakePictureLayer> root_layer = |
| 193 FakePictureLayer::Create(&client_); |
| 194 root_layer->SetBounds(gfx::Size(1024, 1024)); |
| 195 root_layer->SetIsDrawable(true); |
| 196 |
| 197 layer_tree_host()->SetRootLayer(root_layer); |
| 198 LayerTreeHostTest::SetupTree(); |
| 199 } |
| 200 |
| 201 void AfterTest() override { |
| 202 EXPECT_TRUE(did_notify_ready_to_draw_); |
| 203 EXPECT_TRUE(all_tiles_required_for_draw_are_ready_to_draw_); |
| 204 EXPECT_LE(size_t(1), required_for_draw_count_); |
| 205 } |
| 206 |
| 207 private: |
| 208 FakeContentLayerClient client_; |
| 209 }; |
| 210 |
| 211 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in |
| 212 // single threaded mode. |
| 213 SINGLE_THREAD_IMPL_TEST_F(LayerTreeHostTestReadyToDrawNonEmpty); |
| 214 |
70 // Two setNeedsCommits in a row should lead to at least 1 commit and at least 1 | 215 // Two setNeedsCommits in a row should lead to at least 1 commit and at least 1 |
71 // draw with frame 0. | 216 // draw with frame 0. |
72 class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest { | 217 class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest { |
73 public: | 218 public: |
74 LayerTreeHostTestSetNeedsCommit1() : num_commits_(0), num_draws_(0) {} | 219 LayerTreeHostTestSetNeedsCommit1() : num_commits_(0), num_draws_(0) {} |
75 | 220 |
76 void BeginTest() override { | 221 void BeginTest() override { |
77 PostSetNeedsCommitToMainThread(); | 222 PostSetNeedsCommitToMainThread(); |
78 PostSetNeedsCommitToMainThread(); | 223 PostSetNeedsCommitToMainThread(); |
79 } | 224 } |
(...skipping 1882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 settings.single_thread_proxy_scheduler = false; | 2107 settings.single_thread_proxy_scheduler = false; |
1963 | 2108 |
1964 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 2109 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
1965 new TestSharedBitmapManager()); | 2110 new TestSharedBitmapManager()); |
1966 scoped_ptr<LayerTreeHost> host = | 2111 scoped_ptr<LayerTreeHost> host = |
1967 LayerTreeHost::CreateSingleThreaded(&client, | 2112 LayerTreeHost::CreateSingleThreaded(&client, |
1968 &client, | 2113 &client, |
1969 shared_bitmap_manager.get(), | 2114 shared_bitmap_manager.get(), |
1970 NULL, | 2115 NULL, |
1971 settings, | 2116 settings, |
1972 base::MessageLoopProxy::current()); | 2117 base::MessageLoopProxy::current(), |
| 2118 nullptr); |
1973 client.SetLayerTreeHost(host.get()); | 2119 client.SetLayerTreeHost(host.get()); |
1974 host->Composite(base::TimeTicks::Now()); | 2120 host->Composite(base::TimeTicks::Now()); |
1975 | 2121 |
1976 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 2122 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); |
1977 } | 2123 } |
1978 | 2124 |
1979 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { | 2125 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { |
1980 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); | 2126 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); |
1981 | 2127 |
1982 LayerTreeSettings settings; | 2128 LayerTreeSettings settings; |
1983 settings.max_partial_texture_updates = 4; | 2129 settings.max_partial_texture_updates = 4; |
1984 settings.single_thread_proxy_scheduler = false; | 2130 settings.single_thread_proxy_scheduler = false; |
1985 | 2131 |
1986 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 2132 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
1987 new TestSharedBitmapManager()); | 2133 new TestSharedBitmapManager()); |
1988 scoped_ptr<LayerTreeHost> host = | 2134 scoped_ptr<LayerTreeHost> host = |
1989 LayerTreeHost::CreateSingleThreaded(&client, | 2135 LayerTreeHost::CreateSingleThreaded(&client, |
1990 &client, | 2136 &client, |
1991 shared_bitmap_manager.get(), | 2137 shared_bitmap_manager.get(), |
1992 NULL, | 2138 NULL, |
1993 settings, | 2139 settings, |
1994 base::MessageLoopProxy::current()); | 2140 base::MessageLoopProxy::current(), |
| 2141 nullptr); |
1995 client.SetLayerTreeHost(host.get()); | 2142 client.SetLayerTreeHost(host.get()); |
1996 host->Composite(base::TimeTicks::Now()); | 2143 host->Composite(base::TimeTicks::Now()); |
1997 | 2144 |
1998 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 2145 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); |
1999 } | 2146 } |
2000 | 2147 |
2001 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { | 2148 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { |
2002 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); | 2149 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); |
2003 | 2150 |
2004 LayerTreeSettings settings; | 2151 LayerTreeSettings settings; |
2005 settings.max_partial_texture_updates = 4; | 2152 settings.max_partial_texture_updates = 4; |
2006 settings.single_thread_proxy_scheduler = false; | 2153 settings.single_thread_proxy_scheduler = false; |
2007 | 2154 |
2008 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 2155 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
2009 new TestSharedBitmapManager()); | 2156 new TestSharedBitmapManager()); |
2010 scoped_ptr<LayerTreeHost> host = | 2157 scoped_ptr<LayerTreeHost> host = |
2011 LayerTreeHost::CreateSingleThreaded(&client, | 2158 LayerTreeHost::CreateSingleThreaded(&client, |
2012 &client, | 2159 &client, |
2013 shared_bitmap_manager.get(), | 2160 shared_bitmap_manager.get(), |
2014 NULL, | 2161 NULL, |
2015 settings, | 2162 settings, |
2016 base::MessageLoopProxy::current()); | 2163 base::MessageLoopProxy::current(), |
| 2164 nullptr); |
2017 client.SetLayerTreeHost(host.get()); | 2165 client.SetLayerTreeHost(host.get()); |
2018 host->Composite(base::TimeTicks::Now()); | 2166 host->Composite(base::TimeTicks::Now()); |
2019 | 2167 |
2020 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); | 2168 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); |
2021 } | 2169 } |
2022 | 2170 |
2023 TEST(LayerTreeHostTest, | 2171 TEST(LayerTreeHostTest, |
2024 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { | 2172 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { |
2025 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); | 2173 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); |
2026 | 2174 |
2027 LayerTreeSettings settings; | 2175 LayerTreeSettings settings; |
2028 settings.max_partial_texture_updates = 4; | 2176 settings.max_partial_texture_updates = 4; |
2029 settings.single_thread_proxy_scheduler = false; | 2177 settings.single_thread_proxy_scheduler = false; |
2030 | 2178 |
2031 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 2179 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
2032 new TestSharedBitmapManager()); | 2180 new TestSharedBitmapManager()); |
2033 scoped_ptr<LayerTreeHost> host = | 2181 scoped_ptr<LayerTreeHost> host = |
2034 LayerTreeHost::CreateSingleThreaded(&client, | 2182 LayerTreeHost::CreateSingleThreaded(&client, |
2035 &client, | 2183 &client, |
2036 shared_bitmap_manager.get(), | 2184 shared_bitmap_manager.get(), |
2037 NULL, | 2185 NULL, |
2038 settings, | 2186 settings, |
2039 base::MessageLoopProxy::current()); | 2187 base::MessageLoopProxy::current(), |
| 2188 nullptr); |
2040 client.SetLayerTreeHost(host.get()); | 2189 client.SetLayerTreeHost(host.get()); |
2041 host->Composite(base::TimeTicks::Now()); | 2190 host->Composite(base::TimeTicks::Now()); |
2042 | 2191 |
2043 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); | 2192 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); |
2044 } | 2193 } |
2045 | 2194 |
2046 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted | 2195 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted |
2047 : public LayerTreeHostTest { | 2196 : public LayerTreeHostTest { |
2048 public: | 2197 public: |
2049 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() | 2198 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2218 private: | 2367 private: |
2219 NotificationClient client_; | 2368 NotificationClient client_; |
2220 }; | 2369 }; |
2221 | 2370 |
2222 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDNotification); | 2371 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDNotification); |
2223 | 2372 |
2224 // Verify that the BeginFrame notification is used to initiate rendering. | 2373 // Verify that the BeginFrame notification is used to initiate rendering. |
2225 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { | 2374 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { |
2226 public: | 2375 public: |
2227 void InitializeSettings(LayerTreeSettings* settings) override { | 2376 void InitializeSettings(LayerTreeSettings* settings) override { |
2228 settings->begin_frame_scheduling_enabled = true; | 2377 settings->use_external_begin_frame_source = true; |
2229 } | 2378 } |
2230 | 2379 |
2231 void BeginTest() override { | 2380 void BeginTest() override { |
2232 // This will trigger a SetNeedsBeginFrame which will trigger a | 2381 // This will trigger a SetNeedsBeginFrame which will trigger a |
2233 // BeginFrame. | 2382 // BeginFrame. |
2234 PostSetNeedsCommitToMainThread(); | 2383 PostSetNeedsCommitToMainThread(); |
2235 } | 2384 } |
2236 | 2385 |
2237 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 2386 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
2238 LayerTreeHostImpl::FrameData* frame, | 2387 LayerTreeHostImpl::FrameData* frame, |
2239 DrawResult draw_result) override { | 2388 DrawResult draw_result) override { |
2240 EndTest(); | 2389 EndTest(); |
2241 return DRAW_SUCCESS; | 2390 return DRAW_SUCCESS; |
2242 } | 2391 } |
2243 | 2392 |
2244 void AfterTest() override {} | 2393 void AfterTest() override {} |
2245 | 2394 |
2246 private: | 2395 private: |
2247 base::TimeTicks frame_time_; | 2396 base::TimeTicks frame_time_; |
2248 }; | 2397 }; |
2249 | 2398 |
2250 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification); | 2399 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification); |
2251 | 2400 |
2252 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled | 2401 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled |
2253 : public LayerTreeHostTest { | 2402 : public LayerTreeHostTest { |
2254 public: | 2403 public: |
2255 void InitializeSettings(LayerTreeSettings* settings) override { | 2404 void InitializeSettings(LayerTreeSettings* settings) override { |
2256 settings->begin_frame_scheduling_enabled = true; | 2405 settings->use_external_begin_frame_source = true; |
2257 settings->using_synchronous_renderer_compositor = true; | 2406 settings->using_synchronous_renderer_compositor = true; |
2258 } | 2407 } |
2259 | 2408 |
2260 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 2409 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
2261 | 2410 |
2262 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 2411 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
2263 // The BeginFrame notification is turned off now but will get enabled | 2412 // The BeginFrame notification is turned off now but will get enabled |
2264 // once we return. End test while it's enabled. | 2413 // once we return. End test while it's enabled. |
2265 ImplThreadTaskRunner()->PostTask( | 2414 ImplThreadTaskRunner()->PostTask( |
2266 FROM_HERE, | 2415 FROM_HERE, |
2267 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, | 2416 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, |
2268 base::Unretained(this))); | 2417 base::Unretained(this))); |
2269 } | 2418 } |
2270 | 2419 |
2271 void AfterTest() override {} | 2420 void AfterTest() override {} |
2272 }; | 2421 }; |
2273 | 2422 |
2274 MULTI_THREAD_TEST_F( | 2423 MULTI_THREAD_TEST_F( |
2275 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); | 2424 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); |
2276 | 2425 |
2277 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { | 2426 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { |
2278 protected: | 2427 protected: |
2279 LayerTreeHostTestAbortedCommitDoesntStall() | 2428 LayerTreeHostTestAbortedCommitDoesntStall() |
2280 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} | 2429 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} |
2281 | 2430 |
2282 void InitializeSettings(LayerTreeSettings* settings) override { | 2431 void InitializeSettings(LayerTreeSettings* settings) override { |
2283 settings->begin_frame_scheduling_enabled = true; | 2432 settings->use_external_begin_frame_source = true; |
2284 } | 2433 } |
2285 | 2434 |
2286 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 2435 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
2287 | 2436 |
2288 void DidCommit() override { | 2437 void DidCommit() override { |
2289 commit_count_++; | 2438 commit_count_++; |
2290 if (commit_count_ == 4) { | 2439 if (commit_count_ == 4) { |
2291 // After two aborted commits, request a real commit now to make sure a | 2440 // After two aborted commits, request a real commit now to make sure a |
2292 // real commit following an aborted commit will still complete and | 2441 // real commit following an aborted commit will still complete and |
2293 // end the test even when the Impl thread is idle. | 2442 // end the test even when the Impl thread is idle. |
(...skipping 2438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4732 | 4881 |
4733 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_); | 4882 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_); |
4734 layer->SetBounds(gfx::Size(10, 10)); | 4883 layer->SetBounds(gfx::Size(10, 10)); |
4735 layer->SetIsDrawable(true); | 4884 layer->SetIsDrawable(true); |
4736 layer_tree_host()->root_layer()->AddChild(layer); | 4885 layer_tree_host()->root_layer()->AddChild(layer); |
4737 } | 4886 } |
4738 | 4887 |
4739 void BeginTest() override { | 4888 void BeginTest() override { |
4740 Layer* root = layer_tree_host()->root_layer(); | 4889 Layer* root = layer_tree_host()->root_layer(); |
4741 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); | 4890 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); |
4742 PicturePile* pile = layer->GetPicturePileForTesting(); | 4891 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
4743 | 4892 |
4744 // Verify default values. | 4893 // Verify default values. |
4745 EXPECT_TRUE(root->IsSuitableForGpuRasterization()); | 4894 EXPECT_TRUE(root->IsSuitableForGpuRasterization()); |
4746 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); | 4895 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); |
4747 EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization()); | 4896 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); |
4748 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4897 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
4749 EXPECT_FALSE(layer_tree_host()->UseGpuRasterization()); | 4898 EXPECT_FALSE(layer_tree_host()->UseGpuRasterization()); |
4750 | 4899 |
4751 // Setting gpu rasterization trigger does not enable gpu rasterization. | 4900 // Setting gpu rasterization trigger does not enable gpu rasterization. |
4752 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 4901 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
4753 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4902 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
4754 EXPECT_FALSE(layer_tree_host()->UseGpuRasterization()); | 4903 EXPECT_FALSE(layer_tree_host()->UseGpuRasterization()); |
4755 | 4904 |
4756 PostSetNeedsCommitToMainThread(); | 4905 PostSetNeedsCommitToMainThread(); |
4757 } | 4906 } |
(...skipping 30 matching lines...) Expand all Loading... |
4788 | 4937 |
4789 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_); | 4938 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_); |
4790 layer->SetBounds(gfx::Size(10, 10)); | 4939 layer->SetBounds(gfx::Size(10, 10)); |
4791 layer->SetIsDrawable(true); | 4940 layer->SetIsDrawable(true); |
4792 layer_tree_host()->root_layer()->AddChild(layer); | 4941 layer_tree_host()->root_layer()->AddChild(layer); |
4793 } | 4942 } |
4794 | 4943 |
4795 void BeginTest() override { | 4944 void BeginTest() override { |
4796 Layer* root = layer_tree_host()->root_layer(); | 4945 Layer* root = layer_tree_host()->root_layer(); |
4797 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); | 4946 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); |
4798 PicturePile* pile = layer->GetPicturePileForTesting(); | 4947 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
4799 | 4948 |
4800 // Verify default values. | 4949 // Verify default values. |
4801 EXPECT_TRUE(root->IsSuitableForGpuRasterization()); | 4950 EXPECT_TRUE(root->IsSuitableForGpuRasterization()); |
4802 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); | 4951 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); |
4803 EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization()); | 4952 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); |
4804 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4953 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
4805 EXPECT_FALSE(layer_tree_host()->UseGpuRasterization()); | 4954 EXPECT_FALSE(layer_tree_host()->UseGpuRasterization()); |
4806 | 4955 |
4807 // Gpu rasterization trigger is relevant. | 4956 // Gpu rasterization trigger is relevant. |
4808 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 4957 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
4809 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4958 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
4810 EXPECT_TRUE(layer_tree_host()->UseGpuRasterization()); | 4959 EXPECT_TRUE(layer_tree_host()->UseGpuRasterization()); |
4811 | 4960 |
4812 // Content-based veto is relevant as well. | 4961 // Content-based veto is relevant as well. |
4813 pile->SetUnsuitableForGpuRasterizationForTesting(); | 4962 recording_source->SetUnsuitableForGpuRasterizationForTesting(); |
4814 EXPECT_FALSE(pile->is_suitable_for_gpu_rasterization()); | 4963 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); |
4815 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); | 4964 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); |
4816 // Veto will take effect when layers are updated. | 4965 // Veto will take effect when layers are updated. |
4817 // The results will be verified after commit is completed below. | 4966 // The results will be verified after commit is completed below. |
4818 // Since we are manually marking picture pile as unsuitable, | 4967 // Since we are manually marking picture pile as unsuitable, |
4819 // make sure that the layer gets a chance to update. | 4968 // make sure that the layer gets a chance to update. |
4820 layer->SetNeedsDisplay(); | 4969 layer->SetNeedsDisplay(); |
4821 PostSetNeedsCommitToMainThread(); | 4970 PostSetNeedsCommitToMainThread(); |
4822 } | 4971 } |
4823 | 4972 |
4824 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 4973 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
(...skipping 28 matching lines...) Expand all Loading... |
4853 | 5002 |
4854 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_); | 5003 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_); |
4855 layer->SetBounds(gfx::Size(10, 10)); | 5004 layer->SetBounds(gfx::Size(10, 10)); |
4856 layer->SetIsDrawable(true); | 5005 layer->SetIsDrawable(true); |
4857 layer_tree_host()->root_layer()->AddChild(layer); | 5006 layer_tree_host()->root_layer()->AddChild(layer); |
4858 } | 5007 } |
4859 | 5008 |
4860 void BeginTest() override { | 5009 void BeginTest() override { |
4861 Layer* root = layer_tree_host()->root_layer(); | 5010 Layer* root = layer_tree_host()->root_layer(); |
4862 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); | 5011 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); |
4863 PicturePile* pile = layer->GetPicturePileForTesting(); | 5012 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
4864 | 5013 |
4865 // Verify default values. | 5014 // Verify default values. |
4866 EXPECT_TRUE(root->IsSuitableForGpuRasterization()); | 5015 EXPECT_TRUE(root->IsSuitableForGpuRasterization()); |
4867 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); | 5016 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); |
4868 EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization()); | 5017 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); |
4869 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5018 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
4870 | 5019 |
4871 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. | 5020 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. |
4872 EXPECT_TRUE(layer_tree_host()->UseGpuRasterization()); | 5021 EXPECT_TRUE(layer_tree_host()->UseGpuRasterization()); |
4873 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 5022 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
4874 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5023 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
4875 EXPECT_TRUE(layer_tree_host()->UseGpuRasterization()); | 5024 EXPECT_TRUE(layer_tree_host()->UseGpuRasterization()); |
4876 | 5025 |
4877 // Content-based veto is irrelevant as well. | 5026 // Content-based veto is irrelevant as well. |
4878 pile->SetUnsuitableForGpuRasterizationForTesting(); | 5027 recording_source->SetUnsuitableForGpuRasterizationForTesting(); |
4879 EXPECT_FALSE(pile->is_suitable_for_gpu_rasterization()); | 5028 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); |
4880 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); | 5029 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); |
4881 // Veto will take effect when layers are updated. | 5030 // Veto will take effect when layers are updated. |
4882 // The results will be verified after commit is completed below. | 5031 // The results will be verified after commit is completed below. |
4883 // Since we are manually marking picture pile as unsuitable, | 5032 // Since we are manually marking picture pile as unsuitable, |
4884 // make sure that the layer gets a chance to update. | 5033 // make sure that the layer gets a chance to update. |
4885 layer->SetNeedsDisplay(); | 5034 layer->SetNeedsDisplay(); |
4886 PostSetNeedsCommitToMainThread(); | 5035 PostSetNeedsCommitToMainThread(); |
4887 } | 5036 } |
4888 | 5037 |
4889 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5038 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5175 void AfterTest() override { | 5324 void AfterTest() override { |
5176 EXPECT_TRUE(deltas_sent_to_client_); | 5325 EXPECT_TRUE(deltas_sent_to_client_); |
5177 } | 5326 } |
5178 | 5327 |
5179 ScrollAndScaleSet info_; | 5328 ScrollAndScaleSet info_; |
5180 bool deltas_sent_to_client_; | 5329 bool deltas_sent_to_client_; |
5181 }; | 5330 }; |
5182 | 5331 |
5183 MULTI_THREAD_TEST_F(LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer); | 5332 MULTI_THREAD_TEST_F(LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer); |
5184 } // namespace cc | 5333 } // namespace cc |
OLD | NEW |