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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 if (num_commits_ >= 1) { | 296 if (num_commits_ >= 1) { |
297 // After the first commit, we should not be able to draw. | 297 // After the first commit, we should not be able to draw. |
298 EXPECT_FALSE(impl->CanDraw()); | 298 EXPECT_FALSE(impl->CanDraw()); |
299 } | 299 } |
300 } | 300 } |
301 | 301 |
302 virtual void DidCommit() OVERRIDE { | 302 virtual void DidCommit() OVERRIDE { |
303 num_commits_++; | 303 num_commits_++; |
304 if (num_commits_ == 1) { | 304 if (num_commits_ == 1) { |
305 // Make the viewport empty so the host says it can't draw. | 305 // Make the viewport empty so the host says it can't draw. |
306 layer_tree_host()->SetViewportSize(gfx::Size(0, 0), gfx::Size(0, 0)); | 306 layer_tree_host()->SetViewportSize(gfx::Size(0, 0)); |
307 } else if (num_commits_ == 2) { | 307 } else if (num_commits_ == 2) { |
308 char pixels[4]; | 308 char pixels[4]; |
309 layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1)); | 309 layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1)); |
310 } else if (num_commits_ == 3) { | 310 } else if (num_commits_ == 3) { |
311 // Let it draw so we go idle and end the test. | 311 // Let it draw so we go idle and end the test. |
312 layer_tree_host()->SetViewportSize(gfx::Size(1, 1), gfx::Size(1, 1)); | 312 layer_tree_host()->SetViewportSize(gfx::Size(1, 1)); |
313 done_ = true; | 313 done_ = true; |
314 EndTest(); | 314 EndTest(); |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 virtual void AfterTest() OVERRIDE {} | 318 virtual void AfterTest() OVERRIDE {} |
319 | 319 |
320 private: | 320 private: |
321 int num_commits_; | 321 int num_commits_; |
322 bool done_; | 322 bool done_; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 442 |
443 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortFrameWhenInvisible); | 443 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortFrameWhenInvisible); |
444 | 444 |
445 // This test verifies that properties on the layer tree host are commited | 445 // This test verifies that properties on the layer tree host are commited |
446 // to the impl side. | 446 // to the impl side. |
447 class LayerTreeHostTestCommit : public LayerTreeHostTest { | 447 class LayerTreeHostTestCommit : public LayerTreeHostTest { |
448 public: | 448 public: |
449 LayerTreeHostTestCommit() {} | 449 LayerTreeHostTestCommit() {} |
450 | 450 |
451 virtual void BeginTest() OVERRIDE { | 451 virtual void BeginTest() OVERRIDE { |
452 layer_tree_host()->SetViewportSize(gfx::Size(20, 20), gfx::Size(20, 20)); | 452 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); |
453 layer_tree_host()->set_background_color(SK_ColorGRAY); | 453 layer_tree_host()->set_background_color(SK_ColorGRAY); |
454 layer_tree_host()->SetPageScaleFactorAndLimits(5.f, 5.f, 5.f); | 454 layer_tree_host()->SetPageScaleFactorAndLimits(5.f, 5.f, 5.f); |
455 | 455 |
456 PostSetNeedsCommitToMainThread(); | 456 PostSetNeedsCommitToMainThread(); |
457 } | 457 } |
458 | 458 |
459 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 459 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
460 EXPECT_EQ(gfx::Size(20, 20), impl->layout_viewport_size()); | 460 EXPECT_EQ(gfx::Size(20, 20), impl->device_viewport_size()); |
461 EXPECT_EQ(SK_ColorGRAY, impl->active_tree()->background_color()); | 461 EXPECT_EQ(SK_ColorGRAY, impl->active_tree()->background_color()); |
462 EXPECT_EQ(5.f, impl->active_tree()->page_scale_factor()); | 462 EXPECT_EQ(5.f, impl->active_tree()->page_scale_factor()); |
463 | 463 |
464 EndTest(); | 464 EndTest(); |
465 } | 465 } |
466 | 466 |
467 virtual void AfterTest() OVERRIDE {} | 467 virtual void AfterTest() OVERRIDE {} |
468 }; | 468 }; |
469 | 469 |
470 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit); | 470 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { | 587 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { |
588 public: | 588 public: |
589 LayerTreeHostTestOpacityChange() | 589 LayerTreeHostTestOpacityChange() |
590 : test_opacity_change_delegate_(), | 590 : test_opacity_change_delegate_(), |
591 update_check_layer_(ContentLayerWithUpdateTracking::Create( | 591 update_check_layer_(ContentLayerWithUpdateTracking::Create( |
592 &test_opacity_change_delegate_)) { | 592 &test_opacity_change_delegate_)) { |
593 test_opacity_change_delegate_.SetTestLayer(update_check_layer_.get()); | 593 test_opacity_change_delegate_.SetTestLayer(update_check_layer_.get()); |
594 } | 594 } |
595 | 595 |
596 virtual void BeginTest() OVERRIDE { | 596 virtual void BeginTest() OVERRIDE { |
597 layer_tree_host()->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 597 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); |
598 layer_tree_host()->root_layer()->AddChild(update_check_layer_); | 598 layer_tree_host()->root_layer()->AddChild(update_check_layer_); |
599 | 599 |
600 PostSetNeedsCommitToMainThread(); | 600 PostSetNeedsCommitToMainThread(); |
601 } | 601 } |
602 | 602 |
603 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 603 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
604 EndTest(); | 604 EndTest(); |
605 } | 605 } |
606 | 606 |
607 virtual void AfterTest() OVERRIDE { | 607 virtual void AfterTest() OVERRIDE { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 }; | 642 }; |
643 | 643 |
644 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers | 644 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers |
645 : public LayerTreeHostTest { | 645 : public LayerTreeHostTest { |
646 public: | 646 public: |
647 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() | 647 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() |
648 : root_layer_(NoScaleContentLayer::Create(&client_)), | 648 : root_layer_(NoScaleContentLayer::Create(&client_)), |
649 child_layer_(ContentLayer::Create(&client_)) {} | 649 child_layer_(ContentLayer::Create(&client_)) {} |
650 | 650 |
651 virtual void BeginTest() OVERRIDE { | 651 virtual void BeginTest() OVERRIDE { |
652 layer_tree_host()->SetViewportSize(gfx::Size(40, 40), gfx::Size(60, 60)); | 652 layer_tree_host()->SetViewportSize(gfx::Size(60, 60)); |
653 layer_tree_host()->SetDeviceScaleFactor(1.5); | 653 layer_tree_host()->SetDeviceScaleFactor(1.5); |
654 EXPECT_EQ(gfx::Size(40, 40), layer_tree_host()->layout_viewport_size()); | |
655 EXPECT_EQ(gfx::Size(60, 60), layer_tree_host()->device_viewport_size()); | 654 EXPECT_EQ(gfx::Size(60, 60), layer_tree_host()->device_viewport_size()); |
656 | 655 |
657 root_layer_->AddChild(child_layer_); | 656 root_layer_->AddChild(child_layer_); |
658 | 657 |
659 root_layer_->SetIsDrawable(true); | 658 root_layer_->SetIsDrawable(true); |
660 root_layer_->SetBounds(gfx::Size(30, 30)); | 659 root_layer_->SetBounds(gfx::Size(30, 30)); |
661 root_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f)); | 660 root_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f)); |
662 | 661 |
663 child_layer_->SetIsDrawable(true); | 662 child_layer_->SetIsDrawable(true); |
664 child_layer_->SetPosition(gfx::Point(2, 2)); | 663 child_layer_->SetPosition(gfx::Point(2, 2)); |
(...skipping 11 matching lines...) Expand all Loading... |
676 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 675 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
677 // Should only do one commit. | 676 // Should only do one commit. |
678 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); | 677 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); |
679 // Device scale factor should come over to impl. | 678 // Device scale factor should come over to impl. |
680 EXPECT_NEAR(impl->device_scale_factor(), 1.5f, 0.00001f); | 679 EXPECT_NEAR(impl->device_scale_factor(), 1.5f, 0.00001f); |
681 | 680 |
682 // Both layers are on impl. | 681 // Both layers are on impl. |
683 ASSERT_EQ(1u, impl->active_tree()->root_layer()->children().size()); | 682 ASSERT_EQ(1u, impl->active_tree()->root_layer()->children().size()); |
684 | 683 |
685 // Device viewport is scaled. | 684 // Device viewport is scaled. |
686 EXPECT_EQ(gfx::Size(40, 40), impl->layout_viewport_size()); | |
687 EXPECT_EQ(gfx::Size(60, 60), impl->device_viewport_size()); | 685 EXPECT_EQ(gfx::Size(60, 60), impl->device_viewport_size()); |
688 | 686 |
689 LayerImpl* root = impl->active_tree()->root_layer(); | 687 LayerImpl* root = impl->active_tree()->root_layer(); |
690 LayerImpl* child = impl->active_tree()->root_layer()->children()[0]; | 688 LayerImpl* child = impl->active_tree()->root_layer()->children()[0]; |
691 | 689 |
692 // Positions remain in layout pixels. | 690 // Positions remain in layout pixels. |
693 EXPECT_EQ(gfx::Point(0, 0), root->position()); | 691 EXPECT_EQ(gfx::Point(0, 0), root->position()); |
694 EXPECT_EQ(gfx::Point(2, 2), child->position()); | 692 EXPECT_EQ(gfx::Point(2, 2), child->position()); |
695 | 693 |
696 // Compute all the layer transforms for the frame. | 694 // Compute all the layer transforms for the frame. |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 child_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f)); | 1022 child_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f)); |
1025 scrollbar_with_paints_->SetNeedsDisplayRect( | 1023 scrollbar_with_paints_->SetNeedsDisplayRect( |
1026 gfx::RectF(0.f, 0.f, 5.f, 5.f)); | 1024 gfx::RectF(0.f, 0.f, 5.f, 5.f)); |
1027 scrollbar_without_paints_->SetNeedsDisplayRect( | 1025 scrollbar_without_paints_->SetNeedsDisplayRect( |
1028 gfx::RectF(0.f, 0.f, 5.f, 5.f)); | 1026 gfx::RectF(0.f, 0.f, 5.f, 5.f)); |
1029 break; | 1027 break; |
1030 case 3: | 1028 case 3: |
1031 child_->SetNeedsDisplay(); | 1029 child_->SetNeedsDisplay(); |
1032 scrollbar_with_paints_->SetNeedsDisplay(); | 1030 scrollbar_with_paints_->SetNeedsDisplay(); |
1033 scrollbar_without_paints_->SetNeedsDisplay(); | 1031 scrollbar_without_paints_->SetNeedsDisplay(); |
1034 layer_tree_host()->SetViewportSize(gfx::Size(10, 10), | 1032 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); |
1035 gfx::Size(10, 10)); | |
1036 break; | 1033 break; |
1037 case 4: | 1034 case 4: |
1038 layer_tree_host()->SetViewportSize(gfx::Size(10, 20), | 1035 layer_tree_host()->SetViewportSize(gfx::Size(10, 20)); |
1039 gfx::Size(10, 20)); | |
1040 break; | 1036 break; |
1041 case 5: | 1037 case 5: |
1042 break; | 1038 break; |
1043 default: | 1039 default: |
1044 NOTREACHED(); | 1040 NOTREACHED(); |
1045 break; | 1041 break; |
1046 } | 1042 } |
1047 } | 1043 } |
1048 | 1044 |
1049 virtual void AfterTest() OVERRIDE {} | 1045 virtual void AfterTest() OVERRIDE {} |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 surface_layer2_( | 1129 surface_layer2_( |
1134 FakeContentLayer::Create(&client_)), | 1130 FakeContentLayer::Create(&client_)), |
1135 replica_layer2_( | 1131 replica_layer2_( |
1136 FakeContentLayer::Create(&client_)) {} | 1132 FakeContentLayer::Create(&client_)) {} |
1137 | 1133 |
1138 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 1134 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
1139 settings->cache_render_pass_contents = true; | 1135 settings->cache_render_pass_contents = true; |
1140 } | 1136 } |
1141 | 1137 |
1142 virtual void BeginTest() OVERRIDE { | 1138 virtual void BeginTest() OVERRIDE { |
1143 layer_tree_host()->SetViewportSize(gfx::Size(100, 100), | 1139 layer_tree_host()->SetViewportSize(gfx::Size(100, 100)); |
1144 gfx::Size(100, 100)); | |
1145 | 1140 |
1146 root_layer_->SetBounds(gfx::Size(100, 100)); | 1141 root_layer_->SetBounds(gfx::Size(100, 100)); |
1147 surface_layer1_->SetBounds(gfx::Size(100, 100)); | 1142 surface_layer1_->SetBounds(gfx::Size(100, 100)); |
1148 surface_layer1_->SetForceRenderSurface(true); | 1143 surface_layer1_->SetForceRenderSurface(true); |
1149 surface_layer1_->SetOpacity(0.5f); | 1144 surface_layer1_->SetOpacity(0.5f); |
1150 surface_layer2_->SetBounds(gfx::Size(100, 100)); | 1145 surface_layer2_->SetBounds(gfx::Size(100, 100)); |
1151 surface_layer2_->SetForceRenderSurface(true); | 1146 surface_layer2_->SetForceRenderSurface(true); |
1152 surface_layer2_->SetOpacity(0.5f); | 1147 surface_layer2_->SetOpacity(0.5f); |
1153 | 1148 |
1154 surface_layer1_->SetReplicaLayer(replica_layer1_.get()); | 1149 surface_layer1_->SetReplicaLayer(replica_layer1_.get()); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 | 1307 |
1313 class LayerTreeHostTestEvictTextures : public LayerTreeHostTest { | 1308 class LayerTreeHostTestEvictTextures : public LayerTreeHostTest { |
1314 public: | 1309 public: |
1315 LayerTreeHostTestEvictTextures() | 1310 LayerTreeHostTestEvictTextures() |
1316 : layer_(EvictionTestLayer::Create()), | 1311 : layer_(EvictionTestLayer::Create()), |
1317 impl_for_evict_textures_(0), | 1312 impl_for_evict_textures_(0), |
1318 num_commits_(0) {} | 1313 num_commits_(0) {} |
1319 | 1314 |
1320 virtual void BeginTest() OVERRIDE { | 1315 virtual void BeginTest() OVERRIDE { |
1321 layer_tree_host()->SetRootLayer(layer_); | 1316 layer_tree_host()->SetRootLayer(layer_); |
1322 layer_tree_host()->SetViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); | 1317 layer_tree_host()->SetViewportSize(gfx::Size(10, 20)); |
1323 | 1318 |
1324 gfx::Transform identity_matrix; | 1319 gfx::Transform identity_matrix; |
1325 SetLayerPropertiesForTesting(layer_.get(), | 1320 SetLayerPropertiesForTesting(layer_.get(), |
1326 0, | 1321 0, |
1327 identity_matrix, | 1322 identity_matrix, |
1328 gfx::PointF(0.f, 0.f), | 1323 gfx::PointF(0.f, 0.f), |
1329 gfx::PointF(0.f, 0.f), | 1324 gfx::PointF(0.f, 0.f), |
1330 gfx::Size(10, 20), | 1325 gfx::Size(10, 20), |
1331 true); | 1326 true); |
1332 | 1327 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 }; | 1434 }; |
1440 | 1435 |
1441 MULTI_THREAD_TEST_F(LayerTreeHostTestEvictTextures); | 1436 MULTI_THREAD_TEST_F(LayerTreeHostTestEvictTextures); |
1442 | 1437 |
1443 class LayerTreeHostTestContinuousCommit : public LayerTreeHostTest { | 1438 class LayerTreeHostTestContinuousCommit : public LayerTreeHostTest { |
1444 public: | 1439 public: |
1445 LayerTreeHostTestContinuousCommit() | 1440 LayerTreeHostTestContinuousCommit() |
1446 : num_commit_complete_(0), num_draw_layers_(0) {} | 1441 : num_commit_complete_(0), num_draw_layers_(0) {} |
1447 | 1442 |
1448 virtual void BeginTest() OVERRIDE { | 1443 virtual void BeginTest() OVERRIDE { |
1449 layer_tree_host()->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 1444 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); |
1450 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); | 1445 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); |
1451 | 1446 |
1452 PostSetNeedsCommitToMainThread(); | 1447 PostSetNeedsCommitToMainThread(); |
1453 } | 1448 } |
1454 | 1449 |
1455 virtual void DidCommit() OVERRIDE { | 1450 virtual void DidCommit() OVERRIDE { |
1456 if (num_draw_layers_ == 2) | 1451 if (num_draw_layers_ == 2) |
1457 return; | 1452 return; |
1458 layer_tree_host()->root_layer()->SetNeedsDisplay(); | 1453 layer_tree_host()->root_layer()->SetNeedsDisplay(); |
1459 } | 1454 } |
(...skipping 20 matching lines...) Expand all Loading... |
1480 }; | 1475 }; |
1481 | 1476 |
1482 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousCommit); | 1477 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousCommit); |
1483 | 1478 |
1484 class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { | 1479 class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { |
1485 public: | 1480 public: |
1486 LayerTreeHostTestContinuousInvalidate() | 1481 LayerTreeHostTestContinuousInvalidate() |
1487 : num_commit_complete_(0), num_draw_layers_(0) {} | 1482 : num_commit_complete_(0), num_draw_layers_(0) {} |
1488 | 1483 |
1489 virtual void BeginTest() OVERRIDE { | 1484 virtual void BeginTest() OVERRIDE { |
1490 layer_tree_host()->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 1485 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); |
1491 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); | 1486 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); |
1492 | 1487 |
1493 content_layer_ = ContentLayer::Create(&client_); | 1488 content_layer_ = ContentLayer::Create(&client_); |
1494 content_layer_->SetBounds(gfx::Size(10, 10)); | 1489 content_layer_->SetBounds(gfx::Size(10, 10)); |
1495 content_layer_->SetPosition(gfx::PointF(0.f, 0.f)); | 1490 content_layer_->SetPosition(gfx::PointF(0.f, 0.f)); |
1496 content_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f)); | 1491 content_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f)); |
1497 content_layer_->SetIsDrawable(true); | 1492 content_layer_->SetIsDrawable(true); |
1498 layer_tree_host()->root_layer()->AddChild(content_layer_); | 1493 layer_tree_host()->root_layer()->AddChild(content_layer_); |
1499 | 1494 |
1500 PostSetNeedsCommitToMainThread(); | 1495 PostSetNeedsCommitToMainThread(); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1713 canvas->drawRect(rect, paint); | 1708 canvas->drawRect(rect, paint); |
1714 } | 1709 } |
1715 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} | 1710 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} |
1716 }; | 1711 }; |
1717 | 1712 |
1718 virtual void BeginTest() OVERRIDE { | 1713 virtual void BeginTest() OVERRIDE { |
1719 layer_->SetIsDrawable(true); | 1714 layer_->SetIsDrawable(true); |
1720 layer_->SetBounds(bounds_); | 1715 layer_->SetBounds(bounds_); |
1721 // Outside viewport so tiles don't have to be initialized for commit. | 1716 // Outside viewport so tiles don't have to be initialized for commit. |
1722 layer_->SetPosition(gfx::Point(100, 100)); | 1717 layer_->SetPosition(gfx::Point(100, 100)); |
1723 layer_tree_host()->SetViewportSize(bounds_, bounds_); | 1718 layer_tree_host()->SetViewportSize(bounds_); |
1724 layer_tree_host()->SetRootLayer(layer_); | 1719 layer_tree_host()->SetRootLayer(layer_); |
1725 | 1720 |
1726 EXPECT_TRUE(layer_tree_host()->InitializeRendererIfNeeded()); | 1721 EXPECT_TRUE(layer_tree_host()->InitializeRendererIfNeeded()); |
1727 PostSetNeedsCommitToMainThread(); | 1722 PostSetNeedsCommitToMainThread(); |
1728 } | 1723 } |
1729 | 1724 |
1730 virtual void DidCommitAndDrawFrame() OVERRIDE { | 1725 virtual void DidCommitAndDrawFrame() OVERRIDE { |
1731 picture_ = layer_tree_host()->CapturePicture(); | 1726 picture_ = layer_tree_host()->CapturePicture(); |
1732 EndTest(); | 1727 EndTest(); |
1733 } | 1728 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted | 1798 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted |
1804 : public LayerTreeHostTest { | 1799 : public LayerTreeHostTest { |
1805 public: | 1800 public: |
1806 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() | 1801 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() |
1807 : root_layer_(FakeContentLayer::Create(&client_)), | 1802 : root_layer_(FakeContentLayer::Create(&client_)), |
1808 child_layer1_(FakeContentLayer::Create(&client_)), | 1803 child_layer1_(FakeContentLayer::Create(&client_)), |
1809 child_layer2_(FakeContentLayer::Create(&client_)), | 1804 child_layer2_(FakeContentLayer::Create(&client_)), |
1810 num_commits_(0) {} | 1805 num_commits_(0) {} |
1811 | 1806 |
1812 virtual void BeginTest() OVERRIDE { | 1807 virtual void BeginTest() OVERRIDE { |
1813 layer_tree_host()->SetViewportSize(gfx::Size(100, 100), | 1808 layer_tree_host()->SetViewportSize(gfx::Size(100, 100)); |
1814 gfx::Size(100, 100)); | |
1815 root_layer_->SetBounds(gfx::Size(100, 100)); | 1809 root_layer_->SetBounds(gfx::Size(100, 100)); |
1816 child_layer1_->SetBounds(gfx::Size(100, 100)); | 1810 child_layer1_->SetBounds(gfx::Size(100, 100)); |
1817 child_layer2_->SetBounds(gfx::Size(100, 100)); | 1811 child_layer2_->SetBounds(gfx::Size(100, 100)); |
1818 root_layer_->AddChild(child_layer1_); | 1812 root_layer_->AddChild(child_layer1_); |
1819 root_layer_->AddChild(child_layer2_); | 1813 root_layer_->AddChild(child_layer2_); |
1820 layer_tree_host()->SetRootLayer(root_layer_); | 1814 layer_tree_host()->SetRootLayer(root_layer_); |
1821 PostSetNeedsCommitToMainThread(); | 1815 PostSetNeedsCommitToMainThread(); |
1822 } | 1816 } |
1823 | 1817 |
1824 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, | 1818 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 : root_layer_(ContentLayer::Create(&client_)), num_commits_(0) {} | 1928 : root_layer_(ContentLayer::Create(&client_)), num_commits_(0) {} |
1935 | 1929 |
1936 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 1930 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
1937 settings->use_pinch_zoom_scrollbars = true; | 1931 settings->use_pinch_zoom_scrollbars = true; |
1938 } | 1932 } |
1939 | 1933 |
1940 virtual void BeginTest() OVERRIDE { | 1934 virtual void BeginTest() OVERRIDE { |
1941 root_layer_->SetIsDrawable(true); | 1935 root_layer_->SetIsDrawable(true); |
1942 root_layer_->SetBounds(gfx::Size(100, 100)); | 1936 root_layer_->SetBounds(gfx::Size(100, 100)); |
1943 layer_tree_host()->SetRootLayer(root_layer_); | 1937 layer_tree_host()->SetRootLayer(root_layer_); |
1944 layer_tree_host()->SetViewportSize(gfx::Size(100, 100), | 1938 layer_tree_host()->SetViewportSize(gfx::Size(100, 100)); |
1945 gfx::Size(100, 100)); | |
1946 PostSetNeedsCommitToMainThread(); | 1939 PostSetNeedsCommitToMainThread(); |
1947 } | 1940 } |
1948 | 1941 |
1949 virtual void DidCommit() OVERRIDE { | 1942 virtual void DidCommit() OVERRIDE { |
1950 num_commits_++; | 1943 num_commits_++; |
1951 | 1944 |
1952 ScrollbarLayer* layer1 = root_layer_->children()[0]->ToScrollbarLayer(); | 1945 ScrollbarLayer* layer1 = root_layer_->children()[0]->ToScrollbarLayer(); |
1953 ASSERT_TRUE(layer1); | 1946 ASSERT_TRUE(layer1); |
1954 ScrollbarLayer* layer2 = root_layer_->children()[1]->ToScrollbarLayer(); | 1947 ScrollbarLayer* layer2 = root_layer_->children()[1]->ToScrollbarLayer(); |
1955 ASSERT_TRUE(layer2); | 1948 ASSERT_TRUE(layer2); |
1956 | 1949 |
1957 // Get scrollbar thickness from horizontal scrollbar's height. | 1950 // Get scrollbar thickness from horizontal scrollbar's height. |
1958 int thickness = layer1->bounds().height(); | 1951 int thickness = layer1->bounds().height(); |
1959 | 1952 |
1960 if (!layer1->Orientation() == WebKit::WebScrollbar::Horizontal) | 1953 if (!layer1->Orientation() == WebKit::WebScrollbar::Horizontal) |
1961 std::swap(layer1, layer2); | 1954 std::swap(layer1, layer2); |
1962 | 1955 |
1963 gfx::Size viewport_size = layer_tree_host()->layout_viewport_size(); | 1956 gfx::Size viewport_size = layer_tree_host()->device_viewport_size(); |
1964 EXPECT_EQ(viewport_size.width() - thickness, layer1->bounds().width()); | 1957 EXPECT_EQ(viewport_size.width() - thickness, layer1->bounds().width()); |
1965 EXPECT_EQ(viewport_size.height() - thickness, layer2->bounds().height()); | 1958 EXPECT_EQ(viewport_size.height() - thickness, layer2->bounds().height()); |
1966 | 1959 |
1967 switch (num_commits_) { | 1960 switch (num_commits_) { |
1968 case 1: | 1961 case 1: |
1969 // Resizing the viewport should also resize the pinch-zoom scrollbars. | 1962 // Resizing the viewport should also resize the pinch-zoom scrollbars. |
1970 layer_tree_host()->SetViewportSize(gfx::Size(120, 150), | 1963 layer_tree_host()->SetViewportSize(gfx::Size(120, 150)); |
1971 gfx::Size(120, 150)); | |
1972 break; | 1964 break; |
1973 default: | 1965 default: |
1974 EndTest(); | 1966 EndTest(); |
1975 } | 1967 } |
1976 } | 1968 } |
1977 | 1969 |
1978 virtual void AfterTest() OVERRIDE {} | 1970 virtual void AfterTest() OVERRIDE {} |
1979 | 1971 |
1980 private: | 1972 private: |
1981 FakeContentLayerClient client_; | 1973 FakeContentLayerClient client_; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2180 } | 2172 } |
2181 | 2173 |
2182 private: | 2174 private: |
2183 base::TimeTicks frame_time_; | 2175 base::TimeTicks frame_time_; |
2184 }; | 2176 }; |
2185 | 2177 |
2186 MULTI_THREAD_TEST_F(LayerTreeHostTestVSyncNotification); | 2178 MULTI_THREAD_TEST_F(LayerTreeHostTestVSyncNotification); |
2187 | 2179 |
2188 } // namespace | 2180 } // namespace |
2189 } // namespace cc | 2181 } // namespace cc |
OLD | NEW |