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, max_texture_size on the pending tree must be |
| 479 // updated to the new viewport size. |
| 480 class LayerTreeHostTestGpuRasterDeviceSizeChanged : public LayerTreeHostTest { |
| 481 public: |
| 482 LayerTreeHostTestGpuRasterDeviceSizeChanged() |
| 483 : num_draws_(0), bounds_(500, 64), invalid_rect_(10, 10, 20, 20) {} |
| 484 |
| 485 void BeginTest() override { |
| 486 client_.set_fill_with_nonsolid_color(true); |
| 487 root_layer_ = FakePictureLayer::Create(&client_); |
| 488 root_layer_->SetIsDrawable(true); |
| 489 gfx::Transform transform; |
| 490 // Translate the layer out of the viewport to force it to not update its |
| 491 // tile size via PushProperties. |
| 492 transform.Translate(10000.0, 10000.0); |
| 493 root_layer_->SetTransform(transform); |
| 494 root_layer_->SetBounds(bounds_); |
| 495 layer_tree_host()->SetRootLayer(root_layer_); |
| 496 layer_tree_host()->SetViewportSize(bounds_); |
| 497 |
| 498 PostSetNeedsCommitToMainThread(); |
| 499 } |
| 500 |
| 501 void InitializeSettings(LayerTreeSettings* settings) override { |
| 502 settings->gpu_rasterization_enabled = true; |
| 503 settings->gpu_rasterization_forced = true; |
| 504 } |
| 505 |
| 506 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 507 // Perform 2 commits. |
| 508 if (!num_draws_) { |
| 509 PostSetNeedsRedrawRectToMainThread(invalid_rect_); |
| 510 } else { |
| 511 EndTest(); |
| 512 } |
| 513 num_draws_++; |
| 514 } |
| 515 |
| 516 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 517 if (num_draws_ == 2) { |
| 518 auto pending_tree = host_impl->pending_tree(); |
| 519 auto pending_root_layer_impl = |
| 520 static_cast<FakePictureLayerImpl*>(pending_tree->root_layer()); |
| 521 EXPECT_NE(pending_root_layer_impl, nullptr); |
| 522 auto tiling_set = pending_root_layer_impl->picture_layer_tiling_set(); |
| 523 auto tiling = tiling_set->tiling_at(0); |
| 524 EXPECT_EQ(400, tiling->TilingDataForTesting().max_texture_size().width()); |
| 525 } |
| 526 } |
| 527 |
| 528 void DidCommitAndDrawFrame() override { |
| 529 // On the second commit, resize the viewport. |
| 530 if (num_draws_ == 1) { |
| 531 layer_tree_host()->SetViewportSize(gfx::Size(400, 64)); |
| 532 } |
| 533 } |
| 534 |
| 535 void AfterTest() override { EXPECT_EQ(2, num_draws_); } |
| 536 |
| 537 private: |
| 538 int num_draws_; |
| 539 const gfx::Size bounds_; |
| 540 const gfx::Rect invalid_rect_; |
| 541 FakeContentLayerClient client_; |
| 542 scoped_refptr<FakePictureLayer> root_layer_; |
| 543 }; |
| 544 |
| 545 MULTI_THREAD_DELEGATING_RENDERER_IMPL_TEST_F( |
| 546 LayerTreeHostTestGpuRasterDeviceSizeChanged); |
| 547 |
478 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { | 548 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { |
479 public: | 549 public: |
480 void InitializeSettings(LayerTreeSettings* settings) override { | 550 void InitializeSettings(LayerTreeSettings* settings) override { |
481 settings->layer_transforms_should_scale_layer_contents = true; | 551 settings->layer_transforms_should_scale_layer_contents = true; |
482 } | 552 } |
483 | 553 |
484 void SetupTree() override { | 554 void SetupTree() override { |
485 root_layer_ = Layer::Create(); | 555 root_layer_ = Layer::Create(); |
486 root_layer_->SetBounds(gfx::Size(10, 20)); | 556 root_layer_->SetBounds(gfx::Size(10, 20)); |
487 root_layer_->CreateRenderSurface(); | 557 root_layer_->CreateRenderSurface(); |
(...skipping 5873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6361 | 6431 |
6362 void AfterTest() override {} | 6432 void AfterTest() override {} |
6363 | 6433 |
6364 private: | 6434 private: |
6365 scoped_refptr<Layer> child_; | 6435 scoped_refptr<Layer> child_; |
6366 }; | 6436 }; |
6367 | 6437 |
6368 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); | 6438 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); |
6369 | 6439 |
6370 } // namespace cc | 6440 } // namespace cc |
OLD | NEW |