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 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 scoped_refptr<Layer> root_layer_; | 438 scoped_refptr<Layer> root_layer_; |
437 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; | 439 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; |
438 }; | 440 }; |
439 | 441 |
440 SINGLE_AND_MULTI_THREAD_TEST_F( | 442 SINGLE_AND_MULTI_THREAD_TEST_F( |
441 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate); | 443 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate); |
442 | 444 |
443 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { | 445 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { |
444 public: | 446 public: |
445 LayerTreeHostTestSetNextCommitForcesRedraw() | 447 LayerTreeHostTestSetNextCommitForcesRedraw() |
446 : num_draws_(0), | 448 : 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 | 449 |
451 virtual void BeginTest() OVERRIDE { | 450 virtual void BeginTest() OVERRIDE { |
451 if (layer_tree_host()->settings().impl_side_painting) | |
452 root_layer_ = FakePictureLayer::Create(&client_); | |
453 else | |
454 root_layer_ = ContentLayer::Create(&client_); | |
455 | |
452 root_layer_->SetIsDrawable(true); | 456 root_layer_->SetIsDrawable(true); |
453 root_layer_->SetBounds(bounds_); | 457 root_layer_->SetBounds(bounds_); |
454 layer_tree_host()->SetRootLayer(root_layer_); | 458 layer_tree_host()->SetRootLayer(root_layer_); |
455 layer_tree_host()->SetViewportSize(bounds_); | 459 layer_tree_host()->SetViewportSize(bounds_); |
456 PostSetNeedsCommitToMainThread(); | 460 PostSetNeedsCommitToMainThread(); |
457 } | 461 } |
458 | 462 |
459 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 463 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
460 if (num_draws_ == 3 && host_impl->settings().impl_side_painting) | 464 if (num_draws_ == 3 && host_impl->settings().impl_side_painting) |
461 host_impl->SetNeedsRedrawRect(invalid_rect_); | 465 host_impl->SetNeedsRedrawRect(invalid_rect_); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
519 num_draws_++; | 523 num_draws_++; |
520 } | 524 } |
521 | 525 |
522 virtual void AfterTest() OVERRIDE { EXPECT_EQ(5, num_draws_); } | 526 virtual void AfterTest() OVERRIDE { EXPECT_EQ(5, num_draws_); } |
523 | 527 |
524 private: | 528 private: |
525 int num_draws_; | 529 int num_draws_; |
526 const gfx::Size bounds_; | 530 const gfx::Size bounds_; |
527 const gfx::Rect invalid_rect_; | 531 const gfx::Rect invalid_rect_; |
528 FakeContentLayerClient client_; | 532 FakeContentLayerClient client_; |
529 scoped_refptr<ContentLayer> root_layer_; | 533 scoped_refptr<Layer> root_layer_; |
530 }; | 534 }; |
531 | 535 |
532 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw); | 536 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw); |
533 | 537 |
534 // Tests that if a layer is not drawn because of some reason in the parent then | 538 // Tests that if a layer is not drawn because of some reason in the parent then |
535 // its damage is preserved until the next time it is drawn. | 539 // its damage is preserved until the next time it is drawn. |
536 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { | 540 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { |
537 public: | 541 public: |
538 LayerTreeHostTestUndrawnLayersDamageLater() | 542 LayerTreeHostTestUndrawnLayersDamageLater() {} |
539 : root_layer_(ContentLayer::Create(&client_)) {} | |
540 | 543 |
541 virtual void SetupTree() OVERRIDE { | 544 virtual void SetupTree() OVERRIDE { |
545 if (layer_tree_host()->settings().impl_side_painting) | |
546 root_layer_ = FakePictureLayer::Create(&client_); | |
547 else | |
548 root_layer_ = ContentLayer::Create(&client_); | |
549 | |
542 root_layer_->SetIsDrawable(true); | 550 root_layer_->SetIsDrawable(true); |
543 root_layer_->SetBounds(gfx::Size(50, 50)); | 551 root_layer_->SetBounds(gfx::Size(50, 50)); |
544 layer_tree_host()->SetRootLayer(root_layer_); | 552 layer_tree_host()->SetRootLayer(root_layer_); |
545 | 553 |
546 // The initially transparent layer has a larger child layer, which is | 554 // The initially transparent layer has a larger child layer, which is |
547 // not initially drawn because of the this (parent) layer. | 555 // not initially drawn because of the this (parent) layer. |
548 parent_layer_ = FakeContentLayer::Create(&client_); | 556 if (layer_tree_host()->settings().impl_side_painting) |
557 parent_layer_ = FakePictureLayer::Create(&client_); | |
558 else | |
559 parent_layer_ = FakeContentLayer::Create(&client_); | |
560 | |
549 parent_layer_->SetBounds(gfx::Size(15, 15)); | 561 parent_layer_->SetBounds(gfx::Size(15, 15)); |
550 parent_layer_->SetOpacity(0.0f); | 562 parent_layer_->SetOpacity(0.0f); |
551 root_layer_->AddChild(parent_layer_); | 563 root_layer_->AddChild(parent_layer_); |
552 | 564 |
553 child_layer_ = FakeContentLayer::Create(&client_); | 565 if (layer_tree_host()->settings().impl_side_painting) |
566 child_layer_ = FakePictureLayer::Create(&client_); | |
567 else | |
568 child_layer_ = FakeContentLayer::Create(&client_); | |
569 | |
554 child_layer_->SetBounds(gfx::Size(25, 25)); | 570 child_layer_->SetBounds(gfx::Size(25, 25)); |
555 parent_layer_->AddChild(child_layer_); | 571 parent_layer_->AddChild(child_layer_); |
556 | 572 |
557 LayerTreeHostTest::SetupTree(); | 573 LayerTreeHostTest::SetupTree(); |
558 } | 574 } |
559 | 575 |
560 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 576 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
561 | 577 |
562 virtual DrawResult PrepareToDrawOnThread( | 578 virtual DrawResult PrepareToDrawOnThread( |
563 LayerTreeHostImpl* host_impl, | 579 LayerTreeHostImpl* host_impl, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
609 break; | 625 break; |
610 default: | 626 default: |
611 NOTREACHED(); | 627 NOTREACHED(); |
612 } | 628 } |
613 } | 629 } |
614 | 630 |
615 virtual void AfterTest() OVERRIDE {} | 631 virtual void AfterTest() OVERRIDE {} |
616 | 632 |
617 private: | 633 private: |
618 FakeContentLayerClient client_; | 634 FakeContentLayerClient client_; |
619 scoped_refptr<ContentLayer> root_layer_; | 635 scoped_refptr<Layer> root_layer_; |
620 scoped_refptr<FakeContentLayer> parent_layer_; | 636 scoped_refptr<Layer> parent_layer_; |
621 scoped_refptr<FakeContentLayer> child_layer_; | 637 scoped_refptr<Layer> child_layer_; |
622 }; | 638 }; |
623 | 639 |
624 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater); | 640 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater); |
625 | 641 |
626 // Tests that if a layer is not drawn because of some reason in the parent, | 642 // Tests that if a layer is not drawn because of some reason in the parent, |
627 // causing its content bounds to not be computed, then when it is later drawn, | 643 // causing its content bounds to not be computed, then when it is later drawn, |
628 // its content bounds get pushed. | 644 // its content bounds get pushed. |
629 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater | 645 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater |
630 : public LayerTreeHostTest { | 646 : public LayerTreeHostTest { |
631 public: | 647 public: |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
950 if (test_layer_) | 966 if (test_layer_) |
951 test_layer_->SetOpacity(0.f); | 967 test_layer_->SetOpacity(0.f); |
952 } | 968 } |
953 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} | 969 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} |
954 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } | 970 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } |
955 | 971 |
956 private: | 972 private: |
957 Layer* test_layer_; | 973 Layer* test_layer_; |
958 }; | 974 }; |
959 | 975 |
960 class ContentLayerWithUpdateTracking : public ContentLayer { | 976 class ContentLayerWithUpdateTracking : public ContentLayer { |
sohanjg
2014/09/10 14:11:19
Do we change this to use PictureLayer ? LayerTreeH
danakj
2014/09/10 15:24:29
Ya, leave this class alone, and just use FakePictu
sohanjg
2014/09/15 10:38:39
Acknowledged.
| |
961 public: | 977 public: |
962 static scoped_refptr<ContentLayerWithUpdateTracking> Create( | 978 static scoped_refptr<ContentLayerWithUpdateTracking> Create( |
963 ContentLayerClient* client) { | 979 ContentLayerClient* client) { |
964 return make_scoped_refptr(new ContentLayerWithUpdateTracking(client)); | 980 return make_scoped_refptr(new ContentLayerWithUpdateTracking(client)); |
965 } | 981 } |
966 | 982 |
967 int PaintContentsCount() { return paint_contents_count_; } | 983 int PaintContentsCount() { return paint_contents_count_; } |
968 void ResetPaintContentsCount() { paint_contents_count_ = 0; } | 984 void ResetPaintContentsCount() { paint_contents_count_ = 0; } |
969 | 985 |
970 virtual bool Update(ResourceUpdateQueue* queue, | 986 virtual bool Update(ResourceUpdateQueue* queue, |
971 const OcclusionTracker<Layer>* occlusion) OVERRIDE { | 987 const OcclusionTracker<Layer>* occlusion) OVERRIDE { |
972 bool updated = ContentLayer::Update(queue, occlusion); | 988 bool updated = ContentLayer::Update(queue, occlusion); |
973 paint_contents_count_++; | 989 paint_contents_count_++; |
974 return updated; | 990 return updated; |
975 } | 991 } |
976 | 992 |
977 private: | 993 private: |
978 explicit ContentLayerWithUpdateTracking(ContentLayerClient* client) | 994 explicit ContentLayerWithUpdateTracking(ContentLayerClient* client) |
979 : ContentLayer(client), paint_contents_count_(0) { | 995 : ContentLayer(client), paint_contents_count_(0) { |
980 SetBounds(gfx::Size(10, 10)); | 996 SetBounds(gfx::Size(10, 10)); |
981 SetIsDrawable(true); | 997 SetIsDrawable(true); |
982 } | 998 } |
983 virtual ~ContentLayerWithUpdateTracking() {} | 999 virtual ~ContentLayerWithUpdateTracking() {} |
984 | 1000 |
985 int paint_contents_count_; | 1001 int paint_contents_count_; |
986 }; | 1002 }; |
987 | 1003 |
988 // Layer opacity change during paint should not prevent compositor resources | 1004 // Layer opacity change during paint should not prevent compositor resources |
989 // from being updated during commit. | 1005 // from being updated during commit. |
990 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { | 1006 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { |
sohanjg
2014/09/10 14:11:18
LayerTreeHostTestOpacityChange looks to be valid o
danakj
2014/09/10 15:24:29
Ya let's change this. Blink could change the opaci
sohanjg
2014/09/15 10:38:39
Acknowledged.
| |
991 public: | 1007 public: |
992 LayerTreeHostTestOpacityChange() | 1008 LayerTreeHostTestOpacityChange() |
993 : test_opacity_change_delegate_(), | 1009 : test_opacity_change_delegate_(), |
994 update_check_layer_(ContentLayerWithUpdateTracking::Create( | 1010 update_check_layer_(ContentLayerWithUpdateTracking::Create( |
995 &test_opacity_change_delegate_)) { | 1011 &test_opacity_change_delegate_)) { |
996 test_opacity_change_delegate_.SetTestLayer(update_check_layer_.get()); | 1012 test_opacity_change_delegate_.SetTestLayer(update_check_layer_.get()); |
997 } | 1013 } |
998 | 1014 |
999 virtual void BeginTest() OVERRIDE { | 1015 virtual void BeginTest() OVERRIDE { |
1000 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); | 1016 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); |
(...skipping 11 matching lines...) Expand all Loading... | |
1012 EXPECT_EQ(1, update_check_layer_->PaintContentsCount()); | 1028 EXPECT_EQ(1, update_check_layer_->PaintContentsCount()); |
1013 } | 1029 } |
1014 | 1030 |
1015 private: | 1031 private: |
1016 TestOpacityChangeLayerDelegate test_opacity_change_delegate_; | 1032 TestOpacityChangeLayerDelegate test_opacity_change_delegate_; |
1017 scoped_refptr<ContentLayerWithUpdateTracking> update_check_layer_; | 1033 scoped_refptr<ContentLayerWithUpdateTracking> update_check_layer_; |
1018 }; | 1034 }; |
1019 | 1035 |
1020 MULTI_THREAD_TEST_F(LayerTreeHostTestOpacityChange); | 1036 MULTI_THREAD_TEST_F(LayerTreeHostTestOpacityChange); |
1021 | 1037 |
1022 class NoScaleContentLayer : public ContentLayer { | 1038 class NoScalePictureLayer : public PictureLayer { |
1023 public: | 1039 public: |
1024 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) { | 1040 static scoped_refptr<NoScalePictureLayer> Create(ContentLayerClient* client) { |
1025 return make_scoped_refptr(new NoScaleContentLayer(client)); | 1041 return make_scoped_refptr(new NoScalePictureLayer(client)); |
1026 } | 1042 } |
1027 | 1043 |
1028 virtual void CalculateContentsScale(float ideal_contents_scale, | 1044 virtual void CalculateContentsScale(float ideal_contents_scale, |
1029 float* contents_scale_x, | 1045 float* contents_scale_x, |
1030 float* contents_scale_y, | 1046 float* contents_scale_y, |
1031 gfx::Size* contentBounds) OVERRIDE { | 1047 gfx::Size* contentBounds) OVERRIDE { |
1032 // Skip over the ContentLayer's method to the base Layer class. | 1048 // Skip over the ContentLayer's method to the base Layer class. |
1033 Layer::CalculateContentsScale(ideal_contents_scale, | 1049 Layer::CalculateContentsScale(ideal_contents_scale, |
1034 contents_scale_x, | 1050 contents_scale_x, |
1035 contents_scale_y, | 1051 contents_scale_y, |
1036 contentBounds); | 1052 contentBounds); |
1037 } | 1053 } |
1038 | 1054 |
1039 private: | 1055 private: |
1040 explicit NoScaleContentLayer(ContentLayerClient* client) | 1056 explicit NoScalePictureLayer(ContentLayerClient* client) |
1041 : ContentLayer(client) {} | 1057 : PictureLayer(client) {} |
1042 virtual ~NoScaleContentLayer() {} | 1058 virtual ~NoScalePictureLayer() {} |
1043 }; | 1059 }; |
1044 | 1060 |
1045 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers | 1061 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers |
1046 : public LayerTreeHostTest { | 1062 : public LayerTreeHostTest { |
1047 public: | 1063 public: |
1048 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() | 1064 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() |
1049 : root_layer_(NoScaleContentLayer::Create(&client_)), | 1065 : root_layer_(NoScalePictureLayer::Create(&client_)), |
1050 child_layer_(ContentLayer::Create(&client_)) {} | 1066 child_layer_(PictureLayer::Create(&client_)) {} |
1051 | 1067 |
1052 virtual void BeginTest() OVERRIDE { | 1068 virtual void BeginTest() OVERRIDE { |
1053 layer_tree_host()->SetViewportSize(gfx::Size(60, 60)); | 1069 layer_tree_host()->SetViewportSize(gfx::Size(60, 60)); |
1054 layer_tree_host()->SetDeviceScaleFactor(1.5); | 1070 layer_tree_host()->SetDeviceScaleFactor(1.5); |
1055 EXPECT_EQ(gfx::Size(60, 60), layer_tree_host()->device_viewport_size()); | 1071 EXPECT_EQ(gfx::Size(60, 60), layer_tree_host()->device_viewport_size()); |
1056 | 1072 |
1057 root_layer_->AddChild(child_layer_); | 1073 root_layer_->AddChild(child_layer_); |
1058 | 1074 |
1059 root_layer_->SetIsDrawable(true); | 1075 root_layer_->SetIsDrawable(true); |
1060 root_layer_->SetBounds(gfx::Size(30, 30)); | 1076 root_layer_->SetBounds(gfx::Size(30, 30)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1101 render_surface_layer_list[0]->render_surface()); | 1117 render_surface_layer_list[0]->render_surface()); |
1102 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 1118 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
1103 | 1119 |
1104 // The root render surface is the size of the viewport. | 1120 // The root render surface is the size of the viewport. |
1105 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), | 1121 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), |
1106 root->render_surface()->content_rect()); | 1122 root->render_surface()->content_rect()); |
1107 | 1123 |
1108 // The content bounds of the child should be scaled. | 1124 // The content bounds of the child should be scaled. |
1109 gfx::Size child_bounds_scaled = | 1125 gfx::Size child_bounds_scaled = |
1110 gfx::ToCeiledSize(gfx::ScaleSize(child->bounds(), 1.5)); | 1126 gfx::ToCeiledSize(gfx::ScaleSize(child->bounds(), 1.5)); |
1111 EXPECT_EQ(child_bounds_scaled, child->content_bounds()); | 1127 EXPECT_EQ(child_bounds_scaled, child->content_bounds()); |
sohanjg
2014/09/11 14:53:57
when using picturelayer the content_bounds, are no
danakj
2014/09/11 17:17:30
No, that's the change you made to picture layer to
sohanjg
2014/09/15 10:38:39
Acknowledged.
| |
1112 | 1128 |
1113 gfx::Transform scale_transform; | 1129 gfx::Transform scale_transform; |
1114 scale_transform.Scale(impl->device_scale_factor(), | 1130 scale_transform.Scale(impl->device_scale_factor(), |
1115 impl->device_scale_factor()); | 1131 impl->device_scale_factor()); |
1116 | 1132 |
1117 // The root layer is scaled by 2x. | 1133 // The root layer is scaled by 2x. |
1118 gfx::Transform root_screen_space_transform = scale_transform; | 1134 gfx::Transform root_screen_space_transform = scale_transform; |
1119 gfx::Transform root_draw_transform = scale_transform; | 1135 gfx::Transform root_draw_transform = scale_transform; |
1120 | 1136 |
1121 EXPECT_EQ(root_draw_transform, root->draw_transform()); | 1137 EXPECT_EQ(root_draw_transform, root->draw_transform()); |
1122 EXPECT_EQ(root_screen_space_transform, root->screen_space_transform()); | 1138 EXPECT_EQ(root_screen_space_transform, root->screen_space_transform()); |
1123 | 1139 |
sohanjg
2014/09/11 14:53:57
when using picturelayer the transforms, are not sc
| |
1124 // The child is at position 2,2, which is transformed to 3,3 after the scale | 1140 // The child is at position 2,2, which is transformed to 3,3 after the scale |
1125 gfx::Transform child_screen_space_transform; | 1141 gfx::Transform child_screen_space_transform; |
1126 child_screen_space_transform.Translate(3.f, 3.f); | 1142 child_screen_space_transform.Translate(3.f, 3.f); |
1127 gfx::Transform child_draw_transform = child_screen_space_transform; | 1143 gfx::Transform child_draw_transform = child_screen_space_transform; |
1128 | 1144 |
1129 EXPECT_TRANSFORMATION_MATRIX_EQ(child_draw_transform, | 1145 EXPECT_TRANSFORMATION_MATRIX_EQ(child_draw_transform, |
1130 child->draw_transform()); | 1146 child->draw_transform()); |
1131 EXPECT_TRANSFORMATION_MATRIX_EQ(child_screen_space_transform, | 1147 EXPECT_TRANSFORMATION_MATRIX_EQ(child_screen_space_transform, |
1132 child->screen_space_transform()); | 1148 child->screen_space_transform()); |
1133 | 1149 |
1134 EndTest(); | 1150 EndTest(); |
1135 } | 1151 } |
1136 | 1152 |
1137 virtual void AfterTest() OVERRIDE {} | 1153 virtual void AfterTest() OVERRIDE {} |
1138 | 1154 |
1139 private: | 1155 private: |
1140 FakeContentLayerClient client_; | 1156 FakeContentLayerClient client_; |
1141 scoped_refptr<NoScaleContentLayer> root_layer_; | 1157 scoped_refptr<NoScalePictureLayer> root_layer_; |
1142 scoped_refptr<ContentLayer> child_layer_; | 1158 scoped_refptr<PictureLayer> child_layer_; |
1143 }; | 1159 }; |
1144 | 1160 |
1145 MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers); | 1161 MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers); |
danakj
2014/09/10 15:24:29
Does this test work? I'm a bit surprised you can a
sohanjg
2014/09/15 10:38:39
Acknowledged.
| |
1146 | 1162 |
1147 // Verify atomicity of commits and reuse of textures. | 1163 // Verify atomicity of commits and reuse of textures. |
1148 class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest { | 1164 class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest { |
danakj
2014/09/10 15:24:29
This test doesn't make sense for impl-side you can
sohanjg
2014/09/15 10:38:39
Acknowledged.
| |
1149 public: | 1165 public: |
1150 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 1166 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
1151 settings->texture_id_allocation_chunk_size = 1; | 1167 settings->texture_id_allocation_chunk_size = 1; |
1152 // Make sure partial texture updates are turned off. | 1168 // Make sure partial texture updates are turned off. |
1153 settings->max_partial_texture_updates = 0; | 1169 settings->max_partial_texture_updates = 0; |
1154 // Linear fade animator prevents scrollbars from drawing immediately. | 1170 // Linear fade animator prevents scrollbars from drawing immediately. |
1155 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; | 1171 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; |
1156 } | 1172 } |
1157 | 1173 |
1158 virtual void SetupTree() OVERRIDE { | 1174 virtual void SetupTree() OVERRIDE { |
1159 layer_ = FakeContentLayer::Create(&client_); | 1175 layer_ = FakePictureLayer::Create(&client_); |
1160 layer_->SetBounds(gfx::Size(10, 20)); | 1176 layer_->SetBounds(gfx::Size(10, 20)); |
1161 | 1177 |
1162 bool paint_scrollbar = true; | 1178 bool paint_scrollbar = true; |
1163 bool has_thumb = false; | 1179 bool has_thumb = false; |
1164 scrollbar_ = FakePaintedScrollbarLayer::Create( | 1180 scrollbar_ = FakePaintedScrollbarLayer::Create( |
1165 paint_scrollbar, has_thumb, layer_->id()); | 1181 paint_scrollbar, has_thumb, layer_->id()); |
1166 scrollbar_->SetPosition(gfx::Point(0, 10)); | 1182 scrollbar_->SetPosition(gfx::Point(0, 10)); |
1167 scrollbar_->SetBounds(gfx::Size(10, 10)); | 1183 scrollbar_->SetBounds(gfx::Size(10, 10)); |
1168 | 1184 |
1169 layer_->AddChild(scrollbar_); | 1185 layer_->AddChild(scrollbar_); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1237 | 1253 |
1238 virtual void Layout() OVERRIDE { | 1254 virtual void Layout() OVERRIDE { |
1239 layer_->SetNeedsDisplay(); | 1255 layer_->SetNeedsDisplay(); |
1240 scrollbar_->SetNeedsDisplay(); | 1256 scrollbar_->SetNeedsDisplay(); |
1241 } | 1257 } |
1242 | 1258 |
1243 virtual void AfterTest() OVERRIDE {} | 1259 virtual void AfterTest() OVERRIDE {} |
1244 | 1260 |
1245 protected: | 1261 protected: |
1246 FakeContentLayerClient client_; | 1262 FakeContentLayerClient client_; |
1247 scoped_refptr<FakeContentLayer> layer_; | 1263 scoped_refptr<FakePictureLayer> layer_; |
1248 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; | 1264 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; |
1249 int drew_frame_; | 1265 int drew_frame_; |
1250 }; | 1266 }; |
1251 | 1267 |
1252 MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( | 1268 TEST_F(LayerTreeHostTestDirectRendererAtomicCommit, |
1253 LayerTreeHostTestDirectRendererAtomicCommit); | 1269 RunMultiThread_DirectRenderer_ImplSidePaint) { |
1270 RunTest(true, false, true); | |
1271 } | |
1254 | 1272 |
1255 class LayerTreeHostTestDelegatingRendererAtomicCommit | 1273 class LayerTreeHostTestDelegatingRendererAtomicCommit |
1256 : public LayerTreeHostTestDirectRendererAtomicCommit { | 1274 : public LayerTreeHostTestDirectRendererAtomicCommit { |
1257 public: | 1275 public: |
1258 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1276 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
1259 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates); | 1277 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates); |
1260 | 1278 |
1261 TestWebGraphicsContext3D* context = TestContext(); | 1279 TestWebGraphicsContext3D* context = TestContext(); |
1262 | 1280 |
1263 switch (impl->active_tree()->source_frame_number()) { | 1281 switch (impl->active_tree()->source_frame_number()) { |
(...skipping 3770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5034 const gfx::Size bounds_; | 5052 const gfx::Size bounds_; |
5035 FakeContentLayerClient client_; | 5053 FakeContentLayerClient client_; |
5036 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 5054 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
5037 scoped_refptr<FakePictureLayer> picture_layer_; | 5055 scoped_refptr<FakePictureLayer> picture_layer_; |
5038 Layer* child_layer_; | 5056 Layer* child_layer_; |
5039 }; | 5057 }; |
5040 | 5058 |
5041 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 5059 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
5042 | 5060 |
5043 } // namespace cc | 5061 } // namespace cc |
OLD | NEW |