Chromium Code Reviews| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 int num_draws_; | 267 int num_draws_; |
| 268 }; | 268 }; |
| 269 | 269 |
| 270 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedraw); | 270 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedraw); |
| 271 | 271 |
| 272 // After setNeedsRedrawRect(invalid_rect) the final damage_rect | 272 // After setNeedsRedrawRect(invalid_rect) the final damage_rect |
| 273 // must contain invalid_rect. | 273 // must contain invalid_rect. |
| 274 class LayerTreeHostTestSetNeedsRedrawRect : public LayerTreeHostTest { | 274 class LayerTreeHostTestSetNeedsRedrawRect : public LayerTreeHostTest { |
| 275 public: | 275 public: |
| 276 LayerTreeHostTestSetNeedsRedrawRect() | 276 LayerTreeHostTestSetNeedsRedrawRect() |
| 277 : num_draws_(0), | 277 : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {} |
| 278 bounds_(50, 50), | |
| 279 invalid_rect_(10, 10, 20, 20), | |
| 280 root_layer_(ContentLayer::Create(&client_)) {} | |
| 281 | 278 |
| 282 virtual void BeginTest() override { | 279 virtual void BeginTest() override { |
| 280 if (layer_tree_host()->settings().impl_side_painting) | |
| 281 root_layer_ = FakePictureLayer::Create(&client_); | |
| 282 else | |
| 283 root_layer_ = ContentLayer::Create(&client_); | |
| 284 | |
| 283 root_layer_->SetIsDrawable(true); | 285 root_layer_->SetIsDrawable(true); |
| 284 root_layer_->SetBounds(bounds_); | 286 root_layer_->SetBounds(bounds_); |
| 285 layer_tree_host()->SetRootLayer(root_layer_); | 287 layer_tree_host()->SetRootLayer(root_layer_); |
| 286 layer_tree_host()->SetViewportSize(bounds_); | 288 layer_tree_host()->SetViewportSize(bounds_); |
| 287 PostSetNeedsCommitToMainThread(); | 289 PostSetNeedsCommitToMainThread(); |
| 288 } | 290 } |
| 289 | 291 |
| 290 virtual DrawResult PrepareToDrawOnThread( | 292 virtual DrawResult PrepareToDrawOnThread( |
| 291 LayerTreeHostImpl* host_impl, | 293 LayerTreeHostImpl* host_impl, |
| 292 LayerTreeHostImpl::FrameData* frame_data, | 294 LayerTreeHostImpl::FrameData* frame_data, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 317 num_draws_++; | 319 num_draws_++; |
| 318 } | 320 } |
| 319 | 321 |
| 320 virtual void AfterTest() override { EXPECT_EQ(2, num_draws_); } | 322 virtual void AfterTest() override { EXPECT_EQ(2, num_draws_); } |
| 321 | 323 |
| 322 private: | 324 private: |
| 323 int num_draws_; | 325 int num_draws_; |
| 324 const gfx::Size bounds_; | 326 const gfx::Size bounds_; |
| 325 const gfx::Rect invalid_rect_; | 327 const gfx::Rect invalid_rect_; |
| 326 FakeContentLayerClient client_; | 328 FakeContentLayerClient client_; |
| 327 scoped_refptr<ContentLayer> root_layer_; | 329 scoped_refptr<Layer> root_layer_; |
| 328 }; | 330 }; |
| 329 | 331 |
| 330 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedrawRect); | 332 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedrawRect); |
| 331 | 333 |
| 332 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { | 334 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { |
| 333 public: | 335 public: |
| 334 virtual void InitializeSettings(LayerTreeSettings* settings) override { | 336 virtual void InitializeSettings(LayerTreeSettings* settings) override { |
| 335 settings->layer_transforms_should_scale_layer_contents = true; | 337 settings->layer_transforms_should_scale_layer_contents = true; |
| 336 } | 338 } |
| 337 | 339 |
| 338 virtual void SetupTree() override { | 340 virtual void SetupTree() override { |
| 339 root_layer_ = Layer::Create(); | 341 root_layer_ = Layer::Create(); |
| 340 root_layer_->SetBounds(gfx::Size(10, 20)); | 342 root_layer_->SetBounds(gfx::Size(10, 20)); |
| 341 | 343 |
| 342 scaled_layer_ = FakeContentLayer::Create(&client_); | 344 if (layer_tree_host()->settings().impl_side_painting) |
| 345 scaled_layer_ = FakePictureLayer::Create(&client_); | |
| 346 else | |
| 347 scaled_layer_ = FakeContentLayer::Create(&client_); | |
| 343 scaled_layer_->SetBounds(gfx::Size(1, 1)); | 348 scaled_layer_->SetBounds(gfx::Size(1, 1)); |
| 344 root_layer_->AddChild(scaled_layer_); | 349 root_layer_->AddChild(scaled_layer_); |
| 345 | 350 |
| 346 layer_tree_host()->SetRootLayer(root_layer_); | 351 layer_tree_host()->SetRootLayer(root_layer_); |
| 347 LayerTreeHostTest::SetupTree(); | 352 LayerTreeHostTest::SetupTree(); |
| 348 } | 353 } |
| 349 | 354 |
| 350 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 355 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 351 | 356 |
| 352 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 357 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 353 if (host_impl->active_tree()->source_frame_number() == 1) | 358 if (host_impl->active_tree()->source_frame_number() == 1) |
| 354 EndTest(); | 359 EndTest(); |
| 355 } | 360 } |
| 356 | 361 |
| 357 virtual void DidCommit() override { | 362 virtual void DidCommit() override { |
| 358 switch (layer_tree_host()->source_frame_number()) { | 363 switch (layer_tree_host()->source_frame_number()) { |
| 359 case 1: | 364 case 1: |
| 360 // Changing the device scale factor causes a commit. It also changes | 365 // Changing the device scale factor causes a commit. It also changes |
|
danakj
2014/10/18 19:39:26
move this comment into the else block
sohanjg
2014/10/20 07:10:03
Done.
| |
| 361 // the content bounds of |scaled_layer_|, which should not generate | 366 // the content bounds of |scaled_layer_|, which should not generate |
| 362 // a second commit as a result. | 367 // a second commit as a result. |
| 363 layer_tree_host()->SetDeviceScaleFactor(4.f); | 368 if (layer_tree_host()->settings().impl_side_painting) |
| 369 scaled_layer_->SetBounds(gfx::Size(4, 4)); | |
|
danakj
2014/10/18 19:39:26
comment saying SetBounds grows the layer and expos
sohanjg
2014/10/20 07:10:03
Done.
| |
| 370 else | |
| 371 layer_tree_host()->SetDeviceScaleFactor(4.f); | |
| 364 break; | 372 break; |
| 365 default: | 373 default: |
| 366 // No extra commits. | 374 // No extra commits. |
| 367 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); | 375 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); |
| 368 } | 376 } |
| 369 } | 377 } |
| 370 | 378 |
| 371 virtual void AfterTest() override { | 379 virtual void AfterTest() override { |
| 372 EXPECT_EQ(gfx::Size(4, 4).ToString(), | 380 EXPECT_EQ(gfx::Size(4, 4).ToString(), |
| 373 scaled_layer_->content_bounds().ToString()); | 381 scaled_layer_->content_bounds().ToString()); |
| 374 } | 382 } |
| 375 | 383 |
| 376 private: | 384 private: |
| 377 FakeContentLayerClient client_; | 385 FakeContentLayerClient client_; |
| 378 scoped_refptr<Layer> root_layer_; | 386 scoped_refptr<Layer> root_layer_; |
| 379 scoped_refptr<FakeContentLayer> scaled_layer_; | 387 scoped_refptr<Layer> scaled_layer_; |
| 380 }; | 388 }; |
| 381 | 389 |
| 382 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoExtraCommitFromInvalidate); | 390 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoExtraCommitFromInvalidate); |
| 383 | 391 |
| 384 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate | 392 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate |
| 385 : public LayerTreeHostTest { | 393 : public LayerTreeHostTest { |
| 386 public: | 394 public: |
| 387 virtual void InitializeSettings(LayerTreeSettings* settings) override { | 395 virtual void InitializeSettings(LayerTreeSettings* settings) override { |
| 388 settings->layer_transforms_should_scale_layer_contents = true; | 396 settings->layer_transforms_should_scale_layer_contents = true; |
| 389 } | 397 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 scoped_refptr<Layer> root_layer_; | 444 scoped_refptr<Layer> root_layer_; |
| 437 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; | 445 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; |
| 438 }; | 446 }; |
| 439 | 447 |
| 440 SINGLE_AND_MULTI_THREAD_TEST_F( | 448 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 441 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate); | 449 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate); |
| 442 | 450 |
| 443 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { | 451 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { |
| 444 public: | 452 public: |
| 445 LayerTreeHostTestSetNextCommitForcesRedraw() | 453 LayerTreeHostTestSetNextCommitForcesRedraw() |
| 446 : num_draws_(0), | 454 : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {} |
| 447 bounds_(50, 50), | |
| 448 invalid_rect_(10, 10, 20, 20), | |
| 449 root_layer_(ContentLayer::Create(&client_)) {} | |
| 450 | 455 |
| 451 virtual void BeginTest() override { | 456 virtual void BeginTest() override { |
| 457 if (layer_tree_host()->settings().impl_side_painting) | |
| 458 root_layer_ = FakePictureLayer::Create(&client_); | |
| 459 else | |
| 460 root_layer_ = ContentLayer::Create(&client_); | |
| 461 | |
| 452 root_layer_->SetIsDrawable(true); | 462 root_layer_->SetIsDrawable(true); |
| 453 root_layer_->SetBounds(bounds_); | 463 root_layer_->SetBounds(bounds_); |
| 454 layer_tree_host()->SetRootLayer(root_layer_); | 464 layer_tree_host()->SetRootLayer(root_layer_); |
| 455 layer_tree_host()->SetViewportSize(bounds_); | 465 layer_tree_host()->SetViewportSize(bounds_); |
| 456 PostSetNeedsCommitToMainThread(); | 466 PostSetNeedsCommitToMainThread(); |
| 457 } | 467 } |
| 458 | 468 |
| 459 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 469 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 460 if (num_draws_ == 3 && host_impl->settings().impl_side_painting) | 470 if (num_draws_ == 3 && host_impl->settings().impl_side_painting) |
| 461 host_impl->SetNeedsRedrawRect(invalid_rect_); | 471 host_impl->SetNeedsRedrawRect(invalid_rect_); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 num_draws_++; | 529 num_draws_++; |
| 520 } | 530 } |
| 521 | 531 |
| 522 virtual void AfterTest() override { EXPECT_EQ(5, num_draws_); } | 532 virtual void AfterTest() override { EXPECT_EQ(5, num_draws_); } |
| 523 | 533 |
| 524 private: | 534 private: |
| 525 int num_draws_; | 535 int num_draws_; |
| 526 const gfx::Size bounds_; | 536 const gfx::Size bounds_; |
| 527 const gfx::Rect invalid_rect_; | 537 const gfx::Rect invalid_rect_; |
| 528 FakeContentLayerClient client_; | 538 FakeContentLayerClient client_; |
| 529 scoped_refptr<ContentLayer> root_layer_; | 539 scoped_refptr<Layer> root_layer_; |
| 530 }; | 540 }; |
| 531 | 541 |
| 532 SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F( | 542 SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F( |
| 533 LayerTreeHostTestSetNextCommitForcesRedraw); | 543 LayerTreeHostTestSetNextCommitForcesRedraw); |
| 534 | 544 |
| 535 // Tests that if a layer is not drawn because of some reason in the parent then | 545 // Tests that if a layer is not drawn because of some reason in the parent then |
| 536 // its damage is preserved until the next time it is drawn. | 546 // its damage is preserved until the next time it is drawn. |
| 537 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { | 547 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { |
| 538 public: | 548 public: |
| 539 LayerTreeHostTestUndrawnLayersDamageLater() | 549 LayerTreeHostTestUndrawnLayersDamageLater() {} |
| 540 : root_layer_(ContentLayer::Create(&client_)) {} | |
| 541 | 550 |
| 542 virtual void SetupTree() override { | 551 virtual void SetupTree() override { |
| 552 if (layer_tree_host()->settings().impl_side_painting) | |
| 553 root_layer_ = FakePictureLayer::Create(&client_); | |
| 554 else | |
| 555 root_layer_ = ContentLayer::Create(&client_); | |
| 556 | |
| 543 root_layer_->SetIsDrawable(true); | 557 root_layer_->SetIsDrawable(true); |
| 544 root_layer_->SetBounds(gfx::Size(50, 50)); | 558 root_layer_->SetBounds(gfx::Size(50, 50)); |
| 545 layer_tree_host()->SetRootLayer(root_layer_); | 559 layer_tree_host()->SetRootLayer(root_layer_); |
| 546 | 560 |
| 547 // The initially transparent layer has a larger child layer, which is | 561 // The initially transparent layer has a larger child layer, which is |
| 548 // not initially drawn because of the this (parent) layer. | 562 // not initially drawn because of the this (parent) layer. |
| 549 parent_layer_ = FakeContentLayer::Create(&client_); | 563 if (layer_tree_host()->settings().impl_side_painting) |
| 564 parent_layer_ = FakePictureLayer::Create(&client_); | |
| 565 else | |
| 566 parent_layer_ = FakeContentLayer::Create(&client_); | |
| 567 | |
| 550 parent_layer_->SetBounds(gfx::Size(15, 15)); | 568 parent_layer_->SetBounds(gfx::Size(15, 15)); |
| 551 parent_layer_->SetOpacity(0.0f); | 569 parent_layer_->SetOpacity(0.0f); |
| 552 root_layer_->AddChild(parent_layer_); | 570 root_layer_->AddChild(parent_layer_); |
| 553 | 571 |
| 554 child_layer_ = FakeContentLayer::Create(&client_); | 572 if (layer_tree_host()->settings().impl_side_painting) |
| 573 child_layer_ = FakePictureLayer::Create(&client_); | |
| 574 else | |
| 575 child_layer_ = FakeContentLayer::Create(&client_); | |
| 576 | |
| 555 child_layer_->SetBounds(gfx::Size(25, 25)); | 577 child_layer_->SetBounds(gfx::Size(25, 25)); |
| 556 parent_layer_->AddChild(child_layer_); | 578 parent_layer_->AddChild(child_layer_); |
| 557 | 579 |
| 558 LayerTreeHostTest::SetupTree(); | 580 LayerTreeHostTest::SetupTree(); |
| 559 } | 581 } |
| 560 | 582 |
| 561 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 583 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 562 | 584 |
| 563 virtual DrawResult PrepareToDrawOnThread( | 585 virtual DrawResult PrepareToDrawOnThread( |
| 564 LayerTreeHostImpl* host_impl, | 586 LayerTreeHostImpl* host_impl, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 break; | 632 break; |
| 611 default: | 633 default: |
| 612 NOTREACHED(); | 634 NOTREACHED(); |
| 613 } | 635 } |
| 614 } | 636 } |
| 615 | 637 |
| 616 virtual void AfterTest() override {} | 638 virtual void AfterTest() override {} |
| 617 | 639 |
| 618 private: | 640 private: |
| 619 FakeContentLayerClient client_; | 641 FakeContentLayerClient client_; |
| 620 scoped_refptr<ContentLayer> root_layer_; | 642 scoped_refptr<Layer> root_layer_; |
| 621 scoped_refptr<FakeContentLayer> parent_layer_; | 643 scoped_refptr<Layer> parent_layer_; |
| 622 scoped_refptr<FakeContentLayer> child_layer_; | 644 scoped_refptr<Layer> child_layer_; |
| 623 }; | 645 }; |
| 624 | 646 |
| 625 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater); | 647 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater); |
| 626 | 648 |
| 627 // Tests that if a layer is not drawn because of some reason in the parent, | 649 // Tests that if a layer is not drawn because of some reason in the parent, |
| 628 // causing its content bounds to not be computed, then when it is later drawn, | 650 // causing its content bounds to not be computed, then when it is later drawn, |
| 629 // its content bounds get pushed. | 651 // its content bounds get pushed. |
| 630 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater | 652 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater |
| 631 : public LayerTreeHostTest { | 653 : public LayerTreeHostTest { |
| 632 public: | 654 public: |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 987 | 1009 |
| 988 int paint_contents_count_; | 1010 int paint_contents_count_; |
| 989 }; | 1011 }; |
| 990 | 1012 |
| 991 // Layer opacity change during paint should not prevent compositor resources | 1013 // Layer opacity change during paint should not prevent compositor resources |
| 992 // from being updated during commit. | 1014 // from being updated during commit. |
| 993 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { | 1015 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { |
| 994 public: | 1016 public: |
| 995 LayerTreeHostTestOpacityChange() | 1017 LayerTreeHostTestOpacityChange() |
| 996 : test_opacity_change_delegate_(), | 1018 : test_opacity_change_delegate_(), |
| 997 update_check_layer_(ContentLayerWithUpdateTracking::Create( | 1019 update_check_layer_( |
| 998 &test_opacity_change_delegate_)) { | 1020 FakePictureLayer::Create(&test_opacity_change_delegate_)) { |
| 999 test_opacity_change_delegate_.SetTestLayer(update_check_layer_.get()); | 1021 test_opacity_change_delegate_.SetTestLayer(update_check_layer_.get()); |
| 1000 } | 1022 } |
| 1001 | 1023 |
| 1002 virtual void BeginTest() override { | 1024 virtual void BeginTest() override { |
| 1003 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); | 1025 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); |
| 1004 layer_tree_host()->root_layer()->AddChild(update_check_layer_); | 1026 layer_tree_host()->root_layer()->AddChild(update_check_layer_); |
| 1005 | 1027 |
| 1006 PostSetNeedsCommitToMainThread(); | 1028 PostSetNeedsCommitToMainThread(); |
| 1007 } | 1029 } |
| 1008 | 1030 |
| 1009 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 1031 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 1010 EndTest(); | 1032 EndTest(); |
| 1011 } | 1033 } |
| 1012 | 1034 |
| 1013 virtual void AfterTest() override { | 1035 virtual void AfterTest() override { |
| 1014 // Update() should have been called once. | 1036 // Update() should have been called once. |
| 1015 EXPECT_EQ(1, update_check_layer_->PaintContentsCount()); | 1037 EXPECT_EQ(1, (int)update_check_layer_->update_count()); |
|
danakj
2014/10/18 19:39:26
don't cast with c-style cast ever, you should use
sohanjg
2014/10/20 07:10:03
Done.
| |
| 1016 } | 1038 } |
| 1017 | 1039 |
| 1018 private: | 1040 private: |
| 1019 TestOpacityChangeLayerDelegate test_opacity_change_delegate_; | 1041 TestOpacityChangeLayerDelegate test_opacity_change_delegate_; |
| 1020 scoped_refptr<ContentLayerWithUpdateTracking> update_check_layer_; | 1042 scoped_refptr<FakePictureLayer> update_check_layer_; |
| 1021 }; | 1043 }; |
| 1022 | 1044 |
| 1023 MULTI_THREAD_TEST_F(LayerTreeHostTestOpacityChange); | 1045 TEST_F(LayerTreeHostTestOpacityChange, |
| 1024 | 1046 RunMultiThread_DirectRenderer_ImplSidePaint) { |
| 1025 class NoScaleContentLayer : public ContentLayer { | 1047 RunTest(true, false, true); |
|
danakj
2014/10/18 19:39:26
Just make the test work with/without implside for
sohanjg
2014/10/20 07:10:03
Done.
| |
| 1026 public: | 1048 } |
| 1027 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) { | 1049 TEST_F(LayerTreeHostTestOpacityChange, |
| 1028 return make_scoped_refptr(new NoScaleContentLayer(client)); | 1050 RunMultiThread_DelegatingRenderer_ImplSidePaint) { |
| 1029 } | 1051 RunTest(true, true, true); |
| 1030 | 1052 } |
| 1031 virtual void CalculateContentsScale(float ideal_contents_scale, | |
| 1032 float* contents_scale_x, | |
| 1033 float* contents_scale_y, | |
| 1034 gfx::Size* contentBounds) override { | |
| 1035 // Skip over the ContentLayer's method to the base Layer class. | |
| 1036 Layer::CalculateContentsScale(ideal_contents_scale, | |
| 1037 contents_scale_x, | |
| 1038 contents_scale_y, | |
| 1039 contentBounds); | |
| 1040 } | |
| 1041 | |
| 1042 private: | |
| 1043 explicit NoScaleContentLayer(ContentLayerClient* client) | |
| 1044 : ContentLayer(client) {} | |
| 1045 virtual ~NoScaleContentLayer() {} | |
| 1046 }; | |
| 1047 | 1053 |
| 1048 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers | 1054 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers |
| 1049 : public LayerTreeHostTest { | 1055 : public LayerTreeHostTest { |
| 1050 public: | 1056 public: |
| 1051 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() | 1057 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() { |
| 1052 : root_layer_(NoScaleContentLayer::Create(&client_)), | 1058 // Paint non-solid color. |
|
danakj
2014/10/18 19:39:26
You can use this now https://code.google.com/p/chr
sohanjg
2014/10/20 07:10:03
Moved to BeginTest, but set_fill_with_nonsolid_col
danakj
2014/10/22 15:10:19
Why does it not work?
sohanjg
2014/10/29 08:31:00
Because CanHaveTilings fail for solid color check
danakj
2014/10/29 14:27:47
Are you saying PictureLayer::Update never happens?
sohanjg
2014/10/31 10:58:52
No, commit is happening just the DetermineIfSolidC
| |
| 1053 child_layer_(ContentLayer::Create(&client_)) {} | 1059 SkPaint paint; |
| 1060 paint.setColor(SkColorSetARGB(100, 80, 200, 200)); | |
| 1061 client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint); | |
| 1062 root_layer_ = FakePictureLayer::Create(&client_); | |
| 1063 child_layer_ = FakePictureLayer::Create(&client_); | |
| 1064 } | |
| 1054 | 1065 |
| 1055 virtual void BeginTest() override { | 1066 virtual void BeginTest() override { |
| 1056 layer_tree_host()->SetViewportSize(gfx::Size(60, 60)); | 1067 layer_tree_host()->SetViewportSize(gfx::Size(60, 60)); |
| 1057 layer_tree_host()->SetDeviceScaleFactor(1.5); | 1068 layer_tree_host()->SetDeviceScaleFactor(1.5); |
| 1058 EXPECT_EQ(gfx::Size(60, 60), layer_tree_host()->device_viewport_size()); | 1069 EXPECT_EQ(gfx::Size(60, 60), layer_tree_host()->device_viewport_size()); |
| 1059 | 1070 |
| 1060 root_layer_->AddChild(child_layer_); | 1071 root_layer_->AddChild(child_layer_); |
| 1061 | 1072 |
| 1062 root_layer_->SetIsDrawable(true); | 1073 root_layer_->SetIsDrawable(true); |
| 1063 root_layer_->SetBounds(gfx::Size(30, 30)); | 1074 root_layer_->SetBounds(gfx::Size(30, 30)); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1076 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); | 1087 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); |
| 1077 // Device scale factor should come over to impl. | 1088 // Device scale factor should come over to impl. |
| 1078 EXPECT_NEAR(impl->device_scale_factor(), 1.5f, 0.00001f); | 1089 EXPECT_NEAR(impl->device_scale_factor(), 1.5f, 0.00001f); |
| 1079 | 1090 |
| 1080 // Both layers are on impl. | 1091 // Both layers are on impl. |
| 1081 ASSERT_EQ(1u, impl->active_tree()->root_layer()->children().size()); | 1092 ASSERT_EQ(1u, impl->active_tree()->root_layer()->children().size()); |
| 1082 | 1093 |
| 1083 // Device viewport is scaled. | 1094 // Device viewport is scaled. |
| 1084 EXPECT_EQ(gfx::Size(60, 60), impl->DrawViewportSize()); | 1095 EXPECT_EQ(gfx::Size(60, 60), impl->DrawViewportSize()); |
| 1085 | 1096 |
| 1086 LayerImpl* root = impl->active_tree()->root_layer(); | 1097 FakePictureLayerImpl* root = |
| 1087 LayerImpl* child = impl->active_tree()->root_layer()->children()[0]; | 1098 static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer()); |
| 1099 FakePictureLayerImpl* child = static_cast<FakePictureLayerImpl*>( | |
| 1100 impl->active_tree()->root_layer()->children()[0]); | |
| 1088 | 1101 |
| 1089 // Positions remain in layout pixels. | 1102 // Positions remain in layout pixels. |
| 1090 EXPECT_EQ(gfx::Point(0, 0), root->position()); | 1103 EXPECT_EQ(gfx::Point(0, 0), root->position()); |
| 1091 EXPECT_EQ(gfx::Point(2, 2), child->position()); | 1104 EXPECT_EQ(gfx::Point(2, 2), child->position()); |
| 1092 | 1105 |
| 1093 // Compute all the layer transforms for the frame. | 1106 // Compute all the layer transforms for the frame. |
| 1094 LayerTreeHostImpl::FrameData frame_data; | 1107 LayerTreeHostImpl::FrameData frame_data; |
| 1095 impl->PrepareToDraw(&frame_data); | 1108 impl->PrepareToDraw(&frame_data); |
| 1096 impl->DidDrawAllLayers(frame_data); | 1109 impl->DidDrawAllLayers(frame_data); |
| 1097 | 1110 |
| 1098 const LayerImplList& render_surface_layer_list = | 1111 const LayerImplList& render_surface_layer_list = |
| 1099 *frame_data.render_surface_layer_list; | 1112 *frame_data.render_surface_layer_list; |
| 1100 | 1113 |
| 1101 // Both layers should be drawing into the root render surface. | 1114 // Both layers should be drawing into the root render surface. |
| 1102 ASSERT_EQ(1u, render_surface_layer_list.size()); | 1115 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 1103 ASSERT_EQ(root->render_surface(), | 1116 ASSERT_EQ(root->render_surface(), |
| 1104 render_surface_layer_list[0]->render_surface()); | 1117 render_surface_layer_list[0]->render_surface()); |
| 1105 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 1118 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 1106 | 1119 |
| 1107 // The root render surface is the size of the viewport. | 1120 // The root render surface is the size of the viewport. |
| 1108 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), | 1121 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), |
| 1109 root->render_surface()->content_rect()); | 1122 root->render_surface()->content_rect()); |
| 1110 | 1123 |
| 1111 // The content bounds of the child should be scaled. | 1124 // The max tiling scale of the child should be scaled. |
| 1112 gfx::Size child_bounds_scaled = | 1125 EXPECT_EQ(1.5, child->MaximumTilingContentsScale()); |
|
danakj
2014/10/18 19:39:26
MaxTilingContentsScale is a float isn't it? 1.5f?
sohanjg
2014/10/20 07:10:03
Acknowledged.
| |
| 1113 gfx::ToCeiledSize(gfx::ScaleSize(child->bounds(), 1.5)); | |
| 1114 EXPECT_EQ(child_bounds_scaled, child->content_bounds()); | |
| 1115 | 1126 |
| 1116 gfx::Transform scale_transform; | 1127 gfx::Transform scale_transform; |
| 1117 scale_transform.Scale(impl->device_scale_factor(), | 1128 scale_transform.Scale(impl->device_scale_factor(), |
| 1118 impl->device_scale_factor()); | 1129 impl->device_scale_factor()); |
| 1119 | 1130 |
| 1120 // The root layer is scaled by 2x. | 1131 // The root layer is scaled by 2x. |
| 1121 gfx::Transform root_screen_space_transform = scale_transform; | 1132 gfx::Transform root_screen_space_transform = scale_transform; |
| 1122 gfx::Transform root_draw_transform = scale_transform; | 1133 gfx::Transform root_draw_transform = scale_transform; |
| 1123 | 1134 |
| 1124 EXPECT_EQ(root_draw_transform, root->draw_transform()); | 1135 EXPECT_EQ(root_draw_transform, root->draw_transform()); |
| 1125 EXPECT_EQ(root_screen_space_transform, root->screen_space_transform()); | 1136 EXPECT_EQ(root_screen_space_transform, root->screen_space_transform()); |
| 1126 | 1137 |
| 1127 // The child is at position 2,2, which is transformed to 3,3 after the scale | 1138 // The child is at position 2,2, which is transformed to 3,3 after the scale |
| 1128 gfx::Transform child_screen_space_transform; | 1139 gfx::Transform child_transform; |
| 1129 child_screen_space_transform.Translate(3.f, 3.f); | 1140 child_transform.Translate(3.f, 3.f); |
| 1130 gfx::Transform child_draw_transform = child_screen_space_transform; | |
| 1131 | 1141 |
|
danakj
2014/10/18 19:39:26
drop whitespace
sohanjg
2014/10/20 07:10:03
Done.
| |
| 1132 EXPECT_TRANSFORMATION_MATRIX_EQ(child_draw_transform, | 1142 child_transform.Scale(child->MaximumTilingContentsScale(), |
| 1133 child->draw_transform()); | 1143 child->MaximumTilingContentsScale()); |
| 1134 EXPECT_TRANSFORMATION_MATRIX_EQ(child_screen_space_transform, | 1144 |
| 1145 EXPECT_TRANSFORMATION_MATRIX_EQ(child_transform, child->draw_transform()); | |
| 1146 EXPECT_TRANSFORMATION_MATRIX_EQ(child_transform, | |
| 1135 child->screen_space_transform()); | 1147 child->screen_space_transform()); |
| 1136 | 1148 |
| 1137 EndTest(); | 1149 EndTest(); |
| 1138 } | 1150 } |
| 1139 | 1151 |
| 1140 virtual void AfterTest() override {} | 1152 virtual void AfterTest() override {} |
| 1141 | 1153 |
| 1142 private: | 1154 private: |
| 1143 FakeContentLayerClient client_; | 1155 FakeContentLayerClient client_; |
| 1144 scoped_refptr<NoScaleContentLayer> root_layer_; | 1156 scoped_refptr<FakePictureLayer> root_layer_; |
| 1145 scoped_refptr<ContentLayer> child_layer_; | 1157 scoped_refptr<FakePictureLayer> child_layer_; |
| 1146 }; | 1158 }; |
| 1147 | 1159 |
| 1148 MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers); | 1160 TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers, |
|
danakj
2014/10/18 19:39:26
Keep using the macro please. You can just override
sohanjg
2014/10/20 07:10:03
Done.
| |
| 1161 RunMultiThread_DirectRenderer_ImplSidePaint) { | |
| 1162 RunTest(true, false, true); | |
| 1163 } | |
| 1164 TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers, | |
| 1165 RunMultiThread_DelegatingRenderer_ImplSidePaint) { | |
| 1166 RunTest(true, true, true); | |
| 1167 } | |
| 1149 | 1168 |
| 1169 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. | |
| 1150 // Verify atomicity of commits and reuse of textures. | 1170 // Verify atomicity of commits and reuse of textures. |
| 1151 class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest { | 1171 class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest { |
| 1152 public: | 1172 public: |
| 1153 virtual void InitializeSettings(LayerTreeSettings* settings) override { | 1173 virtual void InitializeSettings(LayerTreeSettings* settings) override { |
| 1154 settings->texture_id_allocation_chunk_size = 1; | 1174 settings->texture_id_allocation_chunk_size = 1; |
| 1155 // Make sure partial texture updates are turned off. | 1175 // Make sure partial texture updates are turned off. |
| 1156 settings->max_partial_texture_updates = 0; | 1176 settings->max_partial_texture_updates = 0; |
| 1157 // Linear fade animator prevents scrollbars from drawing immediately. | 1177 // Linear fade animator prevents scrollbars from drawing immediately. |
| 1158 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; | 1178 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; |
| 1159 } | 1179 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1248 protected: | 1268 protected: |
| 1249 FakeContentLayerClient client_; | 1269 FakeContentLayerClient client_; |
| 1250 scoped_refptr<FakeContentLayer> layer_; | 1270 scoped_refptr<FakeContentLayer> layer_; |
| 1251 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; | 1271 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; |
| 1252 int drew_frame_; | 1272 int drew_frame_; |
| 1253 }; | 1273 }; |
| 1254 | 1274 |
| 1255 MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( | 1275 MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( |
| 1256 LayerTreeHostTestDirectRendererAtomicCommit); | 1276 LayerTreeHostTestDirectRendererAtomicCommit); |
| 1257 | 1277 |
| 1278 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. | |
| 1258 class LayerTreeHostTestDelegatingRendererAtomicCommit | 1279 class LayerTreeHostTestDelegatingRendererAtomicCommit |
| 1259 : public LayerTreeHostTestDirectRendererAtomicCommit { | 1280 : public LayerTreeHostTestDirectRendererAtomicCommit { |
| 1260 public: | 1281 public: |
| 1261 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 1282 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| 1262 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates); | 1283 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates); |
| 1263 | 1284 |
| 1264 TestWebGraphicsContext3D* context = TestContext(); | 1285 TestWebGraphicsContext3D* context = TestContext(); |
| 1265 | 1286 |
| 1266 switch (impl->active_tree()->source_frame_number()) { | 1287 switch (impl->active_tree()->source_frame_number()) { |
| 1267 case 0: | 1288 case 0: |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1315 layer->RemoveAllChildren(); | 1336 layer->RemoveAllChildren(); |
| 1316 if (parent) | 1337 if (parent) |
| 1317 parent->AddChild(layer); | 1338 parent->AddChild(layer); |
| 1318 layer->SetTransform(transform); | 1339 layer->SetTransform(transform); |
| 1319 layer->SetTransformOrigin(transform_origin); | 1340 layer->SetTransformOrigin(transform_origin); |
| 1320 layer->SetPosition(position); | 1341 layer->SetPosition(position); |
| 1321 layer->SetBounds(bounds); | 1342 layer->SetBounds(bounds); |
| 1322 layer->SetContentsOpaque(opaque); | 1343 layer->SetContentsOpaque(opaque); |
| 1323 } | 1344 } |
| 1324 | 1345 |
| 1346 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. | |
| 1325 class LayerTreeHostTestAtomicCommitWithPartialUpdate | 1347 class LayerTreeHostTestAtomicCommitWithPartialUpdate |
| 1326 : public LayerTreeHostTest { | 1348 : public LayerTreeHostTest { |
| 1327 public: | 1349 public: |
| 1328 virtual void InitializeSettings(LayerTreeSettings* settings) override { | 1350 virtual void InitializeSettings(LayerTreeSettings* settings) override { |
| 1329 settings->texture_id_allocation_chunk_size = 1; | 1351 settings->texture_id_allocation_chunk_size = 1; |
| 1330 // Allow one partial texture update. | 1352 // Allow one partial texture update. |
| 1331 settings->max_partial_texture_updates = 1; | 1353 settings->max_partial_texture_updates = 1; |
| 1332 // No partial updates when impl side painting is enabled. | 1354 // No partial updates when impl side painting is enabled. |
| 1333 settings->impl_side_painting = false; | 1355 settings->impl_side_painting = false; |
| 1334 } | 1356 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1488 private: | 1510 private: |
| 1489 FakeContentLayerClient client_; | 1511 FakeContentLayerClient client_; |
| 1490 scoped_refptr<FakeContentLayer> parent_; | 1512 scoped_refptr<FakeContentLayer> parent_; |
| 1491 scoped_refptr<FakeContentLayer> child_; | 1513 scoped_refptr<FakeContentLayer> child_; |
| 1492 }; | 1514 }; |
| 1493 | 1515 |
| 1494 // Partial updates are not possible with a delegating renderer. | 1516 // Partial updates are not possible with a delegating renderer. |
| 1495 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1517 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 1496 LayerTreeHostTestAtomicCommitWithPartialUpdate); | 1518 LayerTreeHostTestAtomicCommitWithPartialUpdate); |
| 1497 | 1519 |
| 1498 class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit | 1520 class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit |
|
sohanjg
2014/10/16 16:06:52
This test change i will update as a separate CL.
danakj
2014/10/18 19:39:26
leave a TODO to make it work with implside paintin
sohanjg
2014/10/20 07:10:03
Done.
| |
| 1499 : public LayerTreeHostTest { | 1521 : public LayerTreeHostTest { |
| 1500 protected: | 1522 protected: |
| 1501 virtual void SetupTree() override { | 1523 virtual void SetupTree() override { |
| 1502 root_layer_ = FakeContentLayer::Create(&client_); | 1524 root_layer_ = FakeContentLayer::Create(&client_); |
| 1503 root_layer_->SetBounds(gfx::Size(100, 100)); | 1525 root_layer_->SetBounds(gfx::Size(100, 100)); |
| 1504 | 1526 |
| 1505 surface_layer1_ = FakeContentLayer::Create(&client_); | 1527 surface_layer1_ = FakeContentLayer::Create(&client_); |
| 1506 surface_layer1_->SetBounds(gfx::Size(100, 100)); | 1528 surface_layer1_->SetBounds(gfx::Size(100, 100)); |
| 1507 surface_layer1_->SetForceRenderSurface(true); | 1529 surface_layer1_->SetForceRenderSurface(true); |
| 1508 surface_layer1_->SetOpacity(0.5f); | 1530 surface_layer1_->SetOpacity(0.5f); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1810 | 1832 |
| 1811 class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { | 1833 class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { |
| 1812 public: | 1834 public: |
| 1813 LayerTreeHostTestContinuousInvalidate() | 1835 LayerTreeHostTestContinuousInvalidate() |
| 1814 : num_commit_complete_(0), num_draw_layers_(0) {} | 1836 : num_commit_complete_(0), num_draw_layers_(0) {} |
| 1815 | 1837 |
| 1816 virtual void BeginTest() override { | 1838 virtual void BeginTest() override { |
| 1817 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); | 1839 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); |
| 1818 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); | 1840 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); |
| 1819 | 1841 |
| 1820 content_layer_ = ContentLayer::Create(&client_); | 1842 if (layer_tree_host()->settings().impl_side_painting) |
| 1821 content_layer_->SetBounds(gfx::Size(10, 10)); | 1843 layer_ = FakePictureLayer::Create(&client_); |
| 1822 content_layer_->SetPosition(gfx::PointF(0.f, 0.f)); | 1844 else |
| 1823 content_layer_->SetIsDrawable(true); | 1845 layer_ = FakeContentLayer::Create(&client_); |
| 1824 layer_tree_host()->root_layer()->AddChild(content_layer_); | 1846 |
| 1847 layer_->SetBounds(gfx::Size(10, 10)); | |
| 1848 layer_->SetPosition(gfx::PointF(0.f, 0.f)); | |
| 1849 layer_->SetIsDrawable(true); | |
| 1850 layer_tree_host()->root_layer()->AddChild(layer_); | |
| 1825 | 1851 |
| 1826 PostSetNeedsCommitToMainThread(); | 1852 PostSetNeedsCommitToMainThread(); |
| 1827 } | 1853 } |
| 1828 | 1854 |
| 1829 virtual void DidCommitAndDrawFrame() override { | 1855 virtual void DidCommitAndDrawFrame() override { |
| 1830 if (num_draw_layers_ == 2) | 1856 if (num_draw_layers_ == 2) |
| 1831 return; | 1857 return; |
| 1832 content_layer_->SetNeedsDisplay(); | 1858 layer_->SetNeedsDisplay(); |
| 1833 } | 1859 } |
| 1834 | 1860 |
| 1835 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 1861 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 1836 if (num_draw_layers_ == 1) | 1862 if (num_draw_layers_ == 1) |
| 1837 num_commit_complete_++; | 1863 num_commit_complete_++; |
| 1838 } | 1864 } |
| 1839 | 1865 |
| 1840 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 1866 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 1841 num_draw_layers_++; | 1867 num_draw_layers_++; |
| 1842 if (num_draw_layers_ == 2) | 1868 if (num_draw_layers_ == 2) |
| 1843 EndTest(); | 1869 EndTest(); |
| 1844 } | 1870 } |
| 1845 | 1871 |
| 1846 virtual void AfterTest() override { | 1872 virtual void AfterTest() override { |
| 1847 // Check that we didn't commit twice between first and second draw. | 1873 // Check that we didn't commit twice between first and second draw. |
| 1848 EXPECT_EQ(1, num_commit_complete_); | 1874 EXPECT_EQ(1, num_commit_complete_); |
| 1849 } | 1875 } |
| 1850 | 1876 |
| 1851 private: | 1877 private: |
| 1852 FakeContentLayerClient client_; | 1878 FakeContentLayerClient client_; |
| 1853 scoped_refptr<Layer> content_layer_; | 1879 scoped_refptr<Layer> layer_; |
| 1854 int num_commit_complete_; | 1880 int num_commit_complete_; |
| 1855 int num_draw_layers_; | 1881 int num_draw_layers_; |
| 1856 }; | 1882 }; |
| 1857 | 1883 |
| 1858 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestContinuousInvalidate); | 1884 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousInvalidate); |
| 1859 | 1885 |
| 1860 class LayerTreeHostTestDeferCommits : public LayerTreeHostTest { | 1886 class LayerTreeHostTestDeferCommits : public LayerTreeHostTest { |
| 1861 public: | 1887 public: |
| 1862 LayerTreeHostTestDeferCommits() | 1888 LayerTreeHostTestDeferCommits() |
| 1863 : num_commits_deferred_(0), num_complete_commits_(0) {} | 1889 : num_commits_deferred_(0), num_complete_commits_(0) {} |
| 1864 | 1890 |
| 1865 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1891 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1866 | 1892 |
| 1867 virtual void DidDeferCommit() override { | 1893 virtual void DidDeferCommit() override { |
| 1868 num_commits_deferred_++; | 1894 num_commits_deferred_++; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2047 shared_bitmap_manager.get(), | 2073 shared_bitmap_manager.get(), |
| 2048 NULL, | 2074 NULL, |
| 2049 settings, | 2075 settings, |
| 2050 base::MessageLoopProxy::current()); | 2076 base::MessageLoopProxy::current()); |
| 2051 client.SetLayerTreeHost(host.get()); | 2077 client.SetLayerTreeHost(host.get()); |
| 2052 host->Composite(base::TimeTicks::Now()); | 2078 host->Composite(base::TimeTicks::Now()); |
| 2053 | 2079 |
| 2054 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); | 2080 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); |
| 2055 } | 2081 } |
| 2056 | 2082 |
| 2083 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. | |
| 2057 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted | 2084 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted |
| 2058 : public LayerTreeHostTest { | 2085 : public LayerTreeHostTest { |
| 2059 public: | 2086 public: |
| 2060 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() | 2087 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() |
| 2061 : root_layer_(FakeContentLayer::Create(&client_)), | 2088 : root_layer_(FakeContentLayer::Create(&client_)), |
| 2062 child_layer1_(FakeContentLayer::Create(&client_)), | 2089 child_layer1_(FakeContentLayer::Create(&client_)), |
| 2063 child_layer2_(FakeContentLayer::Create(&client_)), | 2090 child_layer2_(FakeContentLayer::Create(&client_)), |
| 2064 num_commits_(0) {} | 2091 num_commits_(0) {} |
| 2065 | 2092 |
| 2066 virtual void BeginTest() override { | 2093 virtual void BeginTest() override { |
| (...skipping 2296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4363 output_surface->SetMemoryPolicyToSetAtBind( | 4390 output_surface->SetMemoryPolicyToSetAtBind( |
| 4364 make_scoped_ptr(new ManagedMemoryPolicy( | 4391 make_scoped_ptr(new ManagedMemoryPolicy( |
| 4365 second_context_provider_.get() ? second_output_surface_memory_limit_ | 4392 second_context_provider_.get() ? second_output_surface_memory_limit_ |
| 4366 : first_output_surface_memory_limit_, | 4393 : first_output_surface_memory_limit_, |
| 4367 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, | 4394 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, |
| 4368 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); | 4395 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); |
| 4369 return output_surface.Pass(); | 4396 return output_surface.Pass(); |
| 4370 } | 4397 } |
| 4371 | 4398 |
| 4372 virtual void SetupTree() override { | 4399 virtual void SetupTree() override { |
| 4373 root_ = FakeContentLayer::Create(&client_); | 4400 if (layer_tree_host()->settings().impl_side_painting) |
| 4401 root_ = FakePictureLayer::Create(&client_); | |
| 4402 else | |
| 4403 root_ = FakeContentLayer::Create(&client_); | |
| 4404 | |
| 4374 root_->SetBounds(gfx::Size(20, 20)); | 4405 root_->SetBounds(gfx::Size(20, 20)); |
| 4375 layer_tree_host()->SetRootLayer(root_); | 4406 layer_tree_host()->SetRootLayer(root_); |
| 4376 LayerTreeHostTest::SetupTree(); | 4407 LayerTreeHostTest::SetupTree(); |
| 4377 } | 4408 } |
| 4378 | 4409 |
| 4379 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 4410 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 4380 | 4411 |
| 4381 virtual void DidCommitAndDrawFrame() override { | 4412 virtual void DidCommitAndDrawFrame() override { |
| 4382 // Lost context sometimes takes two frames to recreate. The third frame | 4413 // Lost context sometimes takes two frames to recreate. The third frame |
| 4383 // is sometimes aborted, so wait until the fourth frame to verify that | 4414 // is sometimes aborted, so wait until the fourth frame to verify that |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 4406 } | 4437 } |
| 4407 } | 4438 } |
| 4408 | 4439 |
| 4409 virtual void AfterTest() override {} | 4440 virtual void AfterTest() override {} |
| 4410 | 4441 |
| 4411 scoped_refptr<TestContextProvider> first_context_provider_; | 4442 scoped_refptr<TestContextProvider> first_context_provider_; |
| 4412 scoped_refptr<TestContextProvider> second_context_provider_; | 4443 scoped_refptr<TestContextProvider> second_context_provider_; |
| 4413 size_t first_output_surface_memory_limit_; | 4444 size_t first_output_surface_memory_limit_; |
| 4414 size_t second_output_surface_memory_limit_; | 4445 size_t second_output_surface_memory_limit_; |
| 4415 FakeContentLayerClient client_; | 4446 FakeContentLayerClient client_; |
| 4416 scoped_refptr<FakeContentLayer> root_; | 4447 scoped_refptr<Layer> root_; |
| 4417 }; | 4448 }; |
| 4418 | 4449 |
| 4419 // No output to copy for delegated renderers. | |
| 4420 SINGLE_AND_MULTI_THREAD_TEST_F( | 4450 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 4421 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); | 4451 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); |
| 4422 | 4452 |
| 4423 struct TestSwapPromiseResult { | 4453 struct TestSwapPromiseResult { |
| 4424 TestSwapPromiseResult() | 4454 TestSwapPromiseResult() |
| 4425 : did_swap_called(false), | 4455 : did_swap_called(false), |
| 4426 did_not_swap_called(false), | 4456 did_not_swap_called(false), |
| 4427 dtor_called(false), | 4457 dtor_called(false), |
| 4428 reason(SwapPromise::DID_NOT_SWAP_UNKNOWN) {} | 4458 reason(SwapPromise::DID_NOT_SWAP_UNKNOWN) {} |
| 4429 | 4459 |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5164 } | 5194 } |
| 5165 | 5195 |
| 5166 int commit_count_; | 5196 int commit_count_; |
| 5167 TestSwapPromiseResult swap_promise_result_[3]; | 5197 TestSwapPromiseResult swap_promise_result_[3]; |
| 5168 }; | 5198 }; |
| 5169 | 5199 |
| 5170 // Impl-side painting is not supported for synchronous compositing. | 5200 // Impl-side painting is not supported for synchronous compositing. |
| 5171 SINGLE_THREAD_NOIMPL_TEST_F(LayerTreeHostTestSynchronousCompositeSwapPromise); | 5201 SINGLE_THREAD_NOIMPL_TEST_F(LayerTreeHostTestSynchronousCompositeSwapPromise); |
| 5172 | 5202 |
| 5173 } // namespace cc | 5203 } // namespace cc |
| OLD | NEW |