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/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "cc/animation/timing_function.h" | 10 #include "cc/animation/timing_function.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 : root_layer_(ContentLayer::Create(&client_)) {} | 247 : root_layer_(ContentLayer::Create(&client_)) {} |
248 | 248 |
249 virtual void BeginTest() OVERRIDE { | 249 virtual void BeginTest() OVERRIDE { |
250 root_layer_->SetAutomaticallyComputeRasterScale(false); | 250 root_layer_->SetAutomaticallyComputeRasterScale(false); |
251 root_layer_->SetIsDrawable(true); | 251 root_layer_->SetIsDrawable(true); |
252 root_layer_->SetBounds(gfx::Size(1, 1)); | 252 root_layer_->SetBounds(gfx::Size(1, 1)); |
253 layer_tree_host()->SetRootLayer(root_layer_); | 253 layer_tree_host()->SetRootLayer(root_layer_); |
254 PostSetNeedsCommitToMainThread(); | 254 PostSetNeedsCommitToMainThread(); |
255 } | 255 } |
256 | 256 |
| 257 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 258 if (host_impl->active_tree()->source_frame_number() == 1) |
| 259 EndTest(); |
| 260 } |
| 261 |
257 virtual void DidCommit() OVERRIDE { | 262 virtual void DidCommit() OVERRIDE { |
258 switch (layer_tree_host()->commit_number()) { | 263 switch (layer_tree_host()->commit_number()) { |
259 case 1: | 264 case 1: |
260 // Changing the content bounds will cause a single commit! | 265 // Changing the content bounds will cause a single commit! |
261 root_layer_->SetRasterScale(4.f); | 266 root_layer_->SetRasterScale(4.f); |
262 break; | 267 break; |
263 default: | 268 default: |
264 // No extra commits. | 269 // No extra commits. |
265 EXPECT_EQ(2, layer_tree_host()->commit_number()); | 270 EXPECT_EQ(2, layer_tree_host()->commit_number()); |
266 EndTest(); | |
267 } | 271 } |
268 } | 272 } |
269 | 273 |
270 virtual void AfterTest() OVERRIDE {} | 274 virtual void AfterTest() OVERRIDE {} |
271 | 275 |
272 private: | 276 private: |
273 FakeContentLayerClient client_; | 277 FakeContentLayerClient client_; |
274 scoped_refptr<ContentLayer> root_layer_; | 278 scoped_refptr<ContentLayer> root_layer_; |
275 }; | 279 }; |
276 | 280 |
277 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoExtraCommitFromInvalidate); | 281 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoExtraCommitFromInvalidate); |
278 | 282 |
| 283 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate |
| 284 : public LayerTreeHostTest { |
| 285 public: |
| 286 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate() |
| 287 : root_layer_(FakeContentLayer::Create(&client_)) {} |
| 288 |
| 289 virtual void SetupTree() OVERRIDE { |
| 290 root_layer_->SetBounds(gfx::Size(10, 20)); |
| 291 |
| 292 bool paint_scrollbar = true; |
| 293 bool has_thumb = false; |
| 294 scrollbar_ = FakeScrollbarLayer::Create(paint_scrollbar, |
| 295 has_thumb, |
| 296 root_layer_->id()); |
| 297 scrollbar_->SetPosition(gfx::Point(0, 10)); |
| 298 scrollbar_->SetBounds(gfx::Size(10, 10)); |
| 299 |
| 300 root_layer_->AddChild(scrollbar_); |
| 301 |
| 302 layer_tree_host()->SetRootLayer(root_layer_); |
| 303 LayerTreeHostTest::SetupTree(); |
| 304 } |
| 305 |
| 306 virtual void BeginTest() OVERRIDE { |
| 307 PostSetNeedsCommitToMainThread(); |
| 308 } |
| 309 |
| 310 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 311 if (host_impl->active_tree()->source_frame_number() == 1) |
| 312 EndTest(); |
| 313 } |
| 314 |
| 315 virtual void DidCommit() OVERRIDE { |
| 316 switch (layer_tree_host()->commit_number()) { |
| 317 case 1: |
| 318 // This should cause a single commit. |
| 319 scrollbar_->SetRasterScale(4.0f); |
| 320 break; |
| 321 default: |
| 322 // No extra commits. |
| 323 EXPECT_EQ(2, layer_tree_host()->commit_number()); |
| 324 } |
| 325 } |
| 326 |
| 327 virtual void AfterTest() OVERRIDE {} |
| 328 |
| 329 private: |
| 330 FakeContentLayerClient client_; |
| 331 scoped_refptr<FakeContentLayer> root_layer_; |
| 332 scoped_refptr<FakeScrollbarLayer> scrollbar_; |
| 333 }; |
| 334 |
| 335 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 336 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate); |
| 337 |
279 class LayerTreeHostTestCompositeAndReadback : public LayerTreeHostTest { | 338 class LayerTreeHostTestCompositeAndReadback : public LayerTreeHostTest { |
280 public: | 339 public: |
281 LayerTreeHostTestCompositeAndReadback() : num_commits_(0) {} | 340 LayerTreeHostTestCompositeAndReadback() : num_commits_(0) {} |
282 | 341 |
283 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 342 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
284 | 343 |
285 virtual void DidCommit() OVERRIDE { | 344 virtual void DidCommit() OVERRIDE { |
286 num_commits_++; | 345 num_commits_++; |
287 if (num_commits_ == 1) { | 346 if (num_commits_ == 1) { |
288 char pixels[4]; | 347 char pixels[4]; |
(...skipping 2034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2323 | 2382 |
2324 private: | 2383 private: |
2325 SetBoundsClient client_; | 2384 SetBoundsClient client_; |
2326 int num_commits_; | 2385 int num_commits_; |
2327 }; | 2386 }; |
2328 | 2387 |
2329 SINGLE_THREAD_TEST_F(LayerTreeHostTestChangeLayerPropertiesInPaintContents); | 2388 SINGLE_THREAD_TEST_F(LayerTreeHostTestChangeLayerPropertiesInPaintContents); |
2330 | 2389 |
2331 } // namespace | 2390 } // namespace |
2332 } // namespace cc | 2391 } // namespace cc |
OLD | NEW |