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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 private: | 468 private: |
469 int num_draws_; | 469 int num_draws_; |
470 const gfx::Size bounds_; | 470 const gfx::Size bounds_; |
471 const gfx::Rect invalid_rect_; | 471 const gfx::Rect invalid_rect_; |
472 FakeContentLayerClient client_; | 472 FakeContentLayerClient client_; |
473 scoped_refptr<Layer> root_layer_; | 473 scoped_refptr<Layer> root_layer_; |
474 }; | 474 }; |
475 | 475 |
476 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedrawRect); | 476 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedrawRect); |
477 | 477 |
| 478 // After a viewport size change, PushProperties must be called a second time. |
| 479 class LayerTreeHostTestGpuRasterDeviceSizeChanged : public LayerTreeHostTest { |
| 480 public: |
| 481 LayerTreeHostTestGpuRasterDeviceSizeChanged() |
| 482 : num_draws_(0), bounds_(400, 50), invalid_rect_(10, 10, 20, 20) {} |
| 483 |
| 484 void BeginTest() override { |
| 485 root_layer_ = FakePictureLayer::Create(&client_); |
| 486 root_layer_->SetIsDrawable(true); |
| 487 root_layer_->SetBounds(bounds_); |
| 488 layer_tree_host()->SetRootLayer(root_layer_); |
| 489 layer_tree_host()->SetViewportSize(bounds_); |
| 490 PostSetNeedsCommitToMainThread(); |
| 491 } |
| 492 |
| 493 void InitializeSettings(LayerTreeSettings* settings) override { |
| 494 settings->gpu_rasterization_enabled = true; |
| 495 settings->gpu_rasterization_forced = true; |
| 496 } |
| 497 |
| 498 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 499 // Perform 2 commits. |
| 500 if (!num_draws_) { |
| 501 PostSetNeedsRedrawRectToMainThread(invalid_rect_); |
| 502 } else { |
| 503 EndTest(); |
| 504 } |
| 505 num_draws_++; |
| 506 } |
| 507 |
| 508 void DidCommitAndDrawFrame() override { |
| 509 // On the second commit, resize the viewport. |
| 510 if (num_draws_ == 1) { |
| 511 gfx::Size bounds2_(500, 60); |
| 512 layer_tree_host()->SetViewportSize(bounds2_); |
| 513 } |
| 514 } |
| 515 |
| 516 void AfterTest() override { |
| 517 EXPECT_EQ(2, num_draws_); |
| 518 EXPECT_EQ(2, root_layer_->push_properties_count()); |
| 519 } |
| 520 |
| 521 private: |
| 522 int num_draws_; |
| 523 const gfx::Size bounds_; |
| 524 const gfx::Rect invalid_rect_; |
| 525 FakeContentLayerClient client_; |
| 526 scoped_refptr<FakePictureLayer> root_layer_; |
| 527 }; |
| 528 |
| 529 MULTI_THREAD_DELEGATING_RENDERER_IMPL_TEST_F( |
| 530 LayerTreeHostTestGpuRasterDeviceSizeChanged); |
| 531 |
478 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { | 532 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { |
479 public: | 533 public: |
480 void InitializeSettings(LayerTreeSettings* settings) override { | 534 void InitializeSettings(LayerTreeSettings* settings) override { |
481 settings->layer_transforms_should_scale_layer_contents = true; | 535 settings->layer_transforms_should_scale_layer_contents = true; |
482 } | 536 } |
483 | 537 |
484 void SetupTree() override { | 538 void SetupTree() override { |
485 root_layer_ = Layer::Create(); | 539 root_layer_ = Layer::Create(); |
486 root_layer_->SetBounds(gfx::Size(10, 20)); | 540 root_layer_->SetBounds(gfx::Size(10, 20)); |
487 root_layer_->CreateRenderSurface(); | 541 root_layer_->CreateRenderSurface(); |
(...skipping 5873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6361 | 6415 |
6362 void AfterTest() override {} | 6416 void AfterTest() override {} |
6363 | 6417 |
6364 private: | 6418 private: |
6365 scoped_refptr<Layer> child_; | 6419 scoped_refptr<Layer> child_; |
6366 }; | 6420 }; |
6367 | 6421 |
6368 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); | 6422 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); |
6369 | 6423 |
6370 } // namespace cc | 6424 } // namespace cc |
OLD | NEW |