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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 int num_draws_; | 265 int num_draws_; |
266 }; | 266 }; |
267 | 267 |
268 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedraw); | 268 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedraw); |
269 | 269 |
270 // After setNeedsRedrawRect(invalid_rect) the final damage_rect | 270 // After setNeedsRedrawRect(invalid_rect) the final damage_rect |
271 // must contain invalid_rect. | 271 // must contain invalid_rect. |
272 class LayerTreeHostTestSetNeedsRedrawRect : public LayerTreeHostTest { | 272 class LayerTreeHostTestSetNeedsRedrawRect : public LayerTreeHostTest { |
273 public: | 273 public: |
274 LayerTreeHostTestSetNeedsRedrawRect() | 274 LayerTreeHostTestSetNeedsRedrawRect() |
275 : num_draws_(0), | 275 : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {} |
276 bounds_(50, 50), | |
277 invalid_rect_(10, 10, 20, 20), | |
278 root_layer_(ContentLayer::Create(&client_)) {} | |
279 | 276 |
280 void BeginTest() override { | 277 virtual void BeginTest() override { |
danakj
2014/11/12 16:44:27
remove virtual, override is enough
sohanjg
2014/11/13 09:14:27
Done.
| |
278 if (layer_tree_host()->settings().impl_side_painting) | |
279 root_layer_ = FakePictureLayer::Create(&client_); | |
280 else | |
281 root_layer_ = ContentLayer::Create(&client_); | |
281 root_layer_->SetIsDrawable(true); | 282 root_layer_->SetIsDrawable(true); |
282 root_layer_->SetBounds(bounds_); | 283 root_layer_->SetBounds(bounds_); |
283 layer_tree_host()->SetRootLayer(root_layer_); | 284 layer_tree_host()->SetRootLayer(root_layer_); |
284 layer_tree_host()->SetViewportSize(bounds_); | 285 layer_tree_host()->SetViewportSize(bounds_); |
285 PostSetNeedsCommitToMainThread(); | 286 PostSetNeedsCommitToMainThread(); |
286 } | 287 } |
287 | 288 |
288 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 289 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
289 LayerTreeHostImpl::FrameData* frame_data, | 290 LayerTreeHostImpl::FrameData* frame_data, |
290 DrawResult draw_result) override { | 291 DrawResult draw_result) override { |
(...skipping 23 matching lines...) Expand all Loading... | |
314 num_draws_++; | 315 num_draws_++; |
315 } | 316 } |
316 | 317 |
317 void AfterTest() override { EXPECT_EQ(2, num_draws_); } | 318 void AfterTest() override { EXPECT_EQ(2, num_draws_); } |
318 | 319 |
319 private: | 320 private: |
320 int num_draws_; | 321 int num_draws_; |
321 const gfx::Size bounds_; | 322 const gfx::Size bounds_; |
322 const gfx::Rect invalid_rect_; | 323 const gfx::Rect invalid_rect_; |
323 FakeContentLayerClient client_; | 324 FakeContentLayerClient client_; |
324 scoped_refptr<ContentLayer> root_layer_; | 325 scoped_refptr<Layer> root_layer_; |
325 }; | 326 }; |
326 | 327 |
327 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedrawRect); | 328 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedrawRect); |
328 | 329 |
329 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { | 330 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { |
330 public: | 331 public: |
331 void InitializeSettings(LayerTreeSettings* settings) override { | 332 void InitializeSettings(LayerTreeSettings* settings) override { |
332 settings->layer_transforms_should_scale_layer_contents = true; | 333 settings->layer_transforms_should_scale_layer_contents = true; |
333 } | 334 } |
334 | 335 |
335 void SetupTree() override { | 336 void SetupTree() override { |
336 root_layer_ = Layer::Create(); | 337 root_layer_ = Layer::Create(); |
337 root_layer_->SetBounds(gfx::Size(10, 20)); | 338 root_layer_->SetBounds(gfx::Size(10, 20)); |
338 | 339 |
339 scaled_layer_ = FakeContentLayer::Create(&client_); | 340 if (layer_tree_host()->settings().impl_side_painting) |
341 scaled_layer_ = FakePictureLayer::Create(&client_); | |
342 else | |
343 scaled_layer_ = FakeContentLayer::Create(&client_); | |
340 scaled_layer_->SetBounds(gfx::Size(1, 1)); | 344 scaled_layer_->SetBounds(gfx::Size(1, 1)); |
341 root_layer_->AddChild(scaled_layer_); | 345 root_layer_->AddChild(scaled_layer_); |
342 | 346 |
343 layer_tree_host()->SetRootLayer(root_layer_); | 347 layer_tree_host()->SetRootLayer(root_layer_); |
344 LayerTreeHostTest::SetupTree(); | 348 LayerTreeHostTest::SetupTree(); |
345 } | 349 } |
346 | 350 |
347 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 351 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
348 | 352 |
349 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 353 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
350 if (host_impl->active_tree()->source_frame_number() == 1) | 354 if (host_impl->active_tree()->source_frame_number() == 1) |
351 EndTest(); | 355 EndTest(); |
352 } | 356 } |
353 | 357 |
354 void DidCommit() override { | 358 void DidCommit() override { |
355 switch (layer_tree_host()->source_frame_number()) { | 359 switch (layer_tree_host()->source_frame_number()) { |
356 case 1: | 360 case 1: |
357 // Changing the device scale factor causes a commit. It also changes | 361 // SetBounds grows the layer and exposes new content. |
358 // the content bounds of |scaled_layer_|, which should not generate | 362 if (layer_tree_host()->settings().impl_side_painting) |
danakj
2014/11/12 16:44:27
{}
sohanjg
2014/11/13 09:14:27
Done.
| |
359 // a second commit as a result. | 363 scaled_layer_->SetBounds(gfx::Size(4, 4)); |
360 layer_tree_host()->SetDeviceScaleFactor(4.f); | 364 else |
danakj
2014/11/12 16:44:27
{}
sohanjg
2014/11/13 09:14:27
Done.
| |
365 // Changing the device scale factor causes a commit. It also changes | |
366 // the content bounds of |scaled_layer_|, which should not generate | |
367 // a second commit as a result. | |
368 layer_tree_host()->SetDeviceScaleFactor(4.f); | |
361 break; | 369 break; |
362 default: | 370 default: |
363 // No extra commits. | 371 // No extra commits. |
364 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); | 372 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); |
365 } | 373 } |
366 } | 374 } |
367 | 375 |
368 void AfterTest() override { | 376 void AfterTest() override { |
369 EXPECT_EQ(gfx::Size(4, 4).ToString(), | 377 EXPECT_EQ(gfx::Size(4, 4).ToString(), |
370 scaled_layer_->content_bounds().ToString()); | 378 scaled_layer_->content_bounds().ToString()); |
371 } | 379 } |
372 | 380 |
373 private: | 381 private: |
374 FakeContentLayerClient client_; | 382 FakeContentLayerClient client_; |
375 scoped_refptr<Layer> root_layer_; | 383 scoped_refptr<Layer> root_layer_; |
376 scoped_refptr<FakeContentLayer> scaled_layer_; | 384 scoped_refptr<Layer> scaled_layer_; |
377 }; | 385 }; |
378 | 386 |
379 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoExtraCommitFromInvalidate); | 387 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoExtraCommitFromInvalidate); |
380 | 388 |
381 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate | 389 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate |
382 : public LayerTreeHostTest { | 390 : public LayerTreeHostTest { |
383 public: | 391 public: |
384 void InitializeSettings(LayerTreeSettings* settings) override { | 392 void InitializeSettings(LayerTreeSettings* settings) override { |
385 settings->layer_transforms_should_scale_layer_contents = true; | 393 settings->layer_transforms_should_scale_layer_contents = true; |
386 } | 394 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 scoped_refptr<Layer> root_layer_; | 441 scoped_refptr<Layer> root_layer_; |
434 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; | 442 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; |
435 }; | 443 }; |
436 | 444 |
437 SINGLE_AND_MULTI_THREAD_TEST_F( | 445 SINGLE_AND_MULTI_THREAD_TEST_F( |
438 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate); | 446 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate); |
439 | 447 |
440 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { | 448 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { |
441 public: | 449 public: |
442 LayerTreeHostTestSetNextCommitForcesRedraw() | 450 LayerTreeHostTestSetNextCommitForcesRedraw() |
443 : num_draws_(0), | 451 : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {} |
444 bounds_(50, 50), | |
445 invalid_rect_(10, 10, 20, 20), | |
446 root_layer_(ContentLayer::Create(&client_)) {} | |
447 | 452 |
448 void BeginTest() override { | 453 virtual void BeginTest() override { |
danakj
2014/11/12 16:44:27
ditto for all the virtuals
sohanjg
2014/11/13 09:14:27
Done.
| |
454 if (layer_tree_host()->settings().impl_side_painting) | |
455 root_layer_ = FakePictureLayer::Create(&client_); | |
456 else | |
457 root_layer_ = ContentLayer::Create(&client_); | |
449 root_layer_->SetIsDrawable(true); | 458 root_layer_->SetIsDrawable(true); |
450 root_layer_->SetBounds(bounds_); | 459 root_layer_->SetBounds(bounds_); |
451 layer_tree_host()->SetRootLayer(root_layer_); | 460 layer_tree_host()->SetRootLayer(root_layer_); |
452 layer_tree_host()->SetViewportSize(bounds_); | 461 layer_tree_host()->SetViewportSize(bounds_); |
453 PostSetNeedsCommitToMainThread(); | 462 PostSetNeedsCommitToMainThread(); |
454 } | 463 } |
455 | 464 |
456 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 465 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
457 if (num_draws_ == 3 && host_impl->settings().impl_side_painting) | 466 if (num_draws_ == 3 && host_impl->settings().impl_side_painting) |
458 host_impl->SetNeedsRedrawRect(invalid_rect_); | 467 host_impl->SetNeedsRedrawRect(invalid_rect_); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
515 num_draws_++; | 524 num_draws_++; |
516 } | 525 } |
517 | 526 |
518 void AfterTest() override { EXPECT_EQ(5, num_draws_); } | 527 void AfterTest() override { EXPECT_EQ(5, num_draws_); } |
519 | 528 |
520 private: | 529 private: |
521 int num_draws_; | 530 int num_draws_; |
522 const gfx::Size bounds_; | 531 const gfx::Size bounds_; |
523 const gfx::Rect invalid_rect_; | 532 const gfx::Rect invalid_rect_; |
524 FakeContentLayerClient client_; | 533 FakeContentLayerClient client_; |
525 scoped_refptr<ContentLayer> root_layer_; | 534 scoped_refptr<Layer> root_layer_; |
526 }; | 535 }; |
527 | 536 |
528 SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F( | 537 SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F( |
529 LayerTreeHostTestSetNextCommitForcesRedraw); | 538 LayerTreeHostTestSetNextCommitForcesRedraw); |
530 | 539 |
531 // Tests that if a layer is not drawn because of some reason in the parent then | 540 // Tests that if a layer is not drawn because of some reason in the parent then |
532 // its damage is preserved until the next time it is drawn. | 541 // its damage is preserved until the next time it is drawn. |
533 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { | 542 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { |
534 public: | 543 public: |
535 LayerTreeHostTestUndrawnLayersDamageLater() | 544 LayerTreeHostTestUndrawnLayersDamageLater() {} |
536 : root_layer_(ContentLayer::Create(&client_)) {} | |
537 | 545 |
538 void SetupTree() override { | 546 virtual void SetupTree() override { |
547 if (layer_tree_host()->settings().impl_side_painting) | |
548 root_layer_ = FakePictureLayer::Create(&client_); | |
549 else | |
550 root_layer_ = ContentLayer::Create(&client_); | |
539 root_layer_->SetIsDrawable(true); | 551 root_layer_->SetIsDrawable(true); |
540 root_layer_->SetBounds(gfx::Size(50, 50)); | 552 root_layer_->SetBounds(gfx::Size(50, 50)); |
541 layer_tree_host()->SetRootLayer(root_layer_); | 553 layer_tree_host()->SetRootLayer(root_layer_); |
542 | 554 |
543 // The initially transparent layer has a larger child layer, which is | 555 // The initially transparent layer has a larger child layer, which is |
544 // not initially drawn because of the this (parent) layer. | 556 // not initially drawn because of the this (parent) layer. |
545 parent_layer_ = FakeContentLayer::Create(&client_); | 557 if (layer_tree_host()->settings().impl_side_painting) |
558 parent_layer_ = FakePictureLayer::Create(&client_); | |
559 else | |
560 parent_layer_ = FakeContentLayer::Create(&client_); | |
546 parent_layer_->SetBounds(gfx::Size(15, 15)); | 561 parent_layer_->SetBounds(gfx::Size(15, 15)); |
547 parent_layer_->SetOpacity(0.0f); | 562 parent_layer_->SetOpacity(0.0f); |
548 root_layer_->AddChild(parent_layer_); | 563 root_layer_->AddChild(parent_layer_); |
549 | 564 |
550 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_); | |
551 child_layer_->SetBounds(gfx::Size(25, 25)); | 569 child_layer_->SetBounds(gfx::Size(25, 25)); |
552 parent_layer_->AddChild(child_layer_); | 570 parent_layer_->AddChild(child_layer_); |
553 | 571 |
554 LayerTreeHostTest::SetupTree(); | 572 LayerTreeHostTest::SetupTree(); |
555 } | 573 } |
556 | 574 |
557 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 575 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
558 | 576 |
559 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 577 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
560 LayerTreeHostImpl::FrameData* frame_data, | 578 LayerTreeHostImpl::FrameData* frame_data, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
605 break; | 623 break; |
606 default: | 624 default: |
607 NOTREACHED(); | 625 NOTREACHED(); |
608 } | 626 } |
609 } | 627 } |
610 | 628 |
611 void AfterTest() override {} | 629 void AfterTest() override {} |
612 | 630 |
613 private: | 631 private: |
614 FakeContentLayerClient client_; | 632 FakeContentLayerClient client_; |
615 scoped_refptr<ContentLayer> root_layer_; | 633 scoped_refptr<Layer> root_layer_; |
616 scoped_refptr<FakeContentLayer> parent_layer_; | 634 scoped_refptr<Layer> parent_layer_; |
617 scoped_refptr<FakeContentLayer> child_layer_; | 635 scoped_refptr<Layer> child_layer_; |
618 }; | 636 }; |
619 | 637 |
620 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater); | 638 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater); |
621 | 639 |
622 // Tests that if a layer is not drawn because of some reason in the parent, | 640 // Tests that if a layer is not drawn because of some reason in the parent, |
623 // causing its content bounds to not be computed, then when it is later drawn, | 641 // causing its content bounds to not be computed, then when it is later drawn, |
624 // its content bounds get pushed. | 642 // its content bounds get pushed. |
625 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater | 643 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater |
626 : public LayerTreeHostTest { | 644 : public LayerTreeHostTest { |
627 public: | 645 public: |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
980 } | 998 } |
981 ~ContentLayerWithUpdateTracking() override {} | 999 ~ContentLayerWithUpdateTracking() override {} |
982 | 1000 |
983 int paint_contents_count_; | 1001 int paint_contents_count_; |
984 }; | 1002 }; |
985 | 1003 |
986 // Layer opacity change during paint should not prevent compositor resources | 1004 // Layer opacity change during paint should not prevent compositor resources |
987 // from being updated during commit. | 1005 // from being updated during commit. |
988 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { | 1006 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { |
989 public: | 1007 public: |
990 LayerTreeHostTestOpacityChange() | 1008 LayerTreeHostTestOpacityChange() : test_opacity_change_delegate_() {} |
991 : test_opacity_change_delegate_(), | |
992 update_check_layer_(ContentLayerWithUpdateTracking::Create( | |
993 &test_opacity_change_delegate_)) { | |
994 test_opacity_change_delegate_.SetTestLayer(update_check_layer_.get()); | |
995 } | |
996 | 1009 |
997 void BeginTest() override { | 1010 virtual void BeginTest() override { |
1011 if (layer_tree_host()->settings().impl_side_painting) { | |
1012 update_check_picture_layer_ = | |
1013 FakePictureLayer::Create(&test_opacity_change_delegate_); | |
1014 test_opacity_change_delegate_.SetTestLayer( | |
1015 update_check_picture_layer_.get()); | |
1016 is_impl_paint = true; | |
1017 } else { | |
1018 update_check_content_layer_ = ContentLayerWithUpdateTracking::Create( | |
1019 &test_opacity_change_delegate_); | |
1020 test_opacity_change_delegate_.SetTestLayer( | |
1021 update_check_content_layer_.get()); | |
1022 is_impl_paint = false; | |
1023 } | |
998 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); | 1024 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); |
999 layer_tree_host()->root_layer()->AddChild(update_check_layer_); | 1025 if (layer_tree_host()->settings().impl_side_painting) |
1026 layer_tree_host()->root_layer()->AddChild(update_check_picture_layer_); | |
1027 else | |
1028 layer_tree_host()->root_layer()->AddChild(update_check_content_layer_); | |
1000 | 1029 |
1001 PostSetNeedsCommitToMainThread(); | 1030 PostSetNeedsCommitToMainThread(); |
1002 } | 1031 } |
1003 | 1032 |
1004 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { EndTest(); } | 1033 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { EndTest(); } |
1005 | 1034 |
1006 void AfterTest() override { | 1035 void AfterTest() override { |
1007 // Update() should have been called once. | 1036 // Update() should have been called once. |
1008 EXPECT_EQ(1, update_check_layer_->PaintContentsCount()); | 1037 if (is_impl_paint) |
1038 EXPECT_EQ(1u, update_check_picture_layer_->update_count()); | |
1039 else | |
1040 EXPECT_EQ(1, update_check_content_layer_->PaintContentsCount()); | |
1009 } | 1041 } |
1010 | 1042 |
1011 private: | 1043 private: |
1012 TestOpacityChangeLayerDelegate test_opacity_change_delegate_; | 1044 TestOpacityChangeLayerDelegate test_opacity_change_delegate_; |
1013 scoped_refptr<ContentLayerWithUpdateTracking> update_check_layer_; | 1045 scoped_refptr<ContentLayerWithUpdateTracking> update_check_content_layer_; |
1046 scoped_refptr<FakePictureLayer> update_check_picture_layer_; | |
1047 bool is_impl_paint; | |
danakj
2014/11/12 16:44:27
is_impl_paint_
| |
1014 }; | 1048 }; |
1015 | 1049 |
1016 MULTI_THREAD_TEST_F(LayerTreeHostTestOpacityChange); | 1050 MULTI_THREAD_TEST_F(LayerTreeHostTestOpacityChange); |
1017 | 1051 |
1018 class NoScaleContentLayer : public ContentLayer { | |
1019 public: | |
1020 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) { | |
1021 return make_scoped_refptr(new NoScaleContentLayer(client)); | |
1022 } | |
1023 | |
1024 void CalculateContentsScale(float ideal_contents_scale, | |
1025 float* contents_scale_x, | |
1026 float* contents_scale_y, | |
1027 gfx::Size* contentBounds) override { | |
1028 // Skip over the ContentLayer's method to the base Layer class. | |
1029 Layer::CalculateContentsScale(ideal_contents_scale, | |
1030 contents_scale_x, | |
1031 contents_scale_y, | |
1032 contentBounds); | |
1033 } | |
1034 | |
1035 private: | |
1036 explicit NoScaleContentLayer(ContentLayerClient* client) | |
1037 : ContentLayer(client) {} | |
1038 ~NoScaleContentLayer() override {} | |
1039 }; | |
1040 | |
1041 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers | 1052 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers |
1042 : public LayerTreeHostTest { | 1053 : public LayerTreeHostTest { |
1043 public: | 1054 public: |
1044 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() | 1055 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() {} |
1045 : root_layer_(NoScaleContentLayer::Create(&client_)), | |
1046 child_layer_(ContentLayer::Create(&client_)) {} | |
1047 | 1056 |
1048 void BeginTest() override { | 1057 virtual void InitializeSettings(LayerTreeSettings* settings) override { |
1058 // PictureLayer can only be used with impl side painting enabled. | |
1059 settings->impl_side_painting = true; | |
1060 } | |
1061 | |
1062 virtual void BeginTest() override { | |
1063 // Paint non-solid color. | |
1064 client_.set_fill_with_nonsolid_color(true); | |
1065 root_layer_ = FakePictureLayer::Create(&client_); | |
1066 child_layer_ = FakePictureLayer::Create(&client_); | |
1067 | |
1049 layer_tree_host()->SetViewportSize(gfx::Size(60, 60)); | 1068 layer_tree_host()->SetViewportSize(gfx::Size(60, 60)); |
1050 layer_tree_host()->SetDeviceScaleFactor(1.5); | 1069 layer_tree_host()->SetDeviceScaleFactor(1.5); |
1051 EXPECT_EQ(gfx::Size(60, 60), layer_tree_host()->device_viewport_size()); | 1070 EXPECT_EQ(gfx::Size(60, 60), layer_tree_host()->device_viewport_size()); |
1052 | 1071 |
1053 root_layer_->AddChild(child_layer_); | 1072 root_layer_->AddChild(child_layer_); |
1054 | 1073 |
1055 root_layer_->SetIsDrawable(true); | 1074 root_layer_->SetIsDrawable(true); |
1056 root_layer_->SetBounds(gfx::Size(30, 30)); | 1075 root_layer_->SetBounds(gfx::Size(30, 30)); |
1057 | 1076 |
1058 child_layer_->SetIsDrawable(true); | 1077 child_layer_->SetIsDrawable(true); |
(...skipping 10 matching lines...) Expand all Loading... | |
1069 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); | 1088 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); |
1070 // Device scale factor should come over to impl. | 1089 // Device scale factor should come over to impl. |
1071 EXPECT_NEAR(impl->device_scale_factor(), 1.5f, 0.00001f); | 1090 EXPECT_NEAR(impl->device_scale_factor(), 1.5f, 0.00001f); |
1072 | 1091 |
1073 // Both layers are on impl. | 1092 // Both layers are on impl. |
1074 ASSERT_EQ(1u, impl->active_tree()->root_layer()->children().size()); | 1093 ASSERT_EQ(1u, impl->active_tree()->root_layer()->children().size()); |
1075 | 1094 |
1076 // Device viewport is scaled. | 1095 // Device viewport is scaled. |
1077 EXPECT_EQ(gfx::Size(60, 60), impl->DrawViewportSize()); | 1096 EXPECT_EQ(gfx::Size(60, 60), impl->DrawViewportSize()); |
1078 | 1097 |
1079 LayerImpl* root = impl->active_tree()->root_layer(); | 1098 FakePictureLayerImpl* root = |
1080 LayerImpl* child = impl->active_tree()->root_layer()->children()[0]; | 1099 static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer()); |
1100 FakePictureLayerImpl* child = static_cast<FakePictureLayerImpl*>( | |
1101 impl->active_tree()->root_layer()->children()[0]); | |
1081 | 1102 |
1082 // Positions remain in layout pixels. | 1103 // Positions remain in layout pixels. |
1083 EXPECT_EQ(gfx::Point(0, 0), root->position()); | 1104 EXPECT_EQ(gfx::Point(0, 0), root->position()); |
1084 EXPECT_EQ(gfx::Point(2, 2), child->position()); | 1105 EXPECT_EQ(gfx::Point(2, 2), child->position()); |
1085 | 1106 |
1086 // Compute all the layer transforms for the frame. | 1107 // Compute all the layer transforms for the frame. |
1087 LayerTreeHostImpl::FrameData frame_data; | 1108 LayerTreeHostImpl::FrameData frame_data; |
1088 impl->PrepareToDraw(&frame_data); | 1109 impl->PrepareToDraw(&frame_data); |
1089 impl->DidDrawAllLayers(frame_data); | 1110 impl->DidDrawAllLayers(frame_data); |
1090 | 1111 |
1091 const LayerImplList& render_surface_layer_list = | 1112 const LayerImplList& render_surface_layer_list = |
1092 *frame_data.render_surface_layer_list; | 1113 *frame_data.render_surface_layer_list; |
1093 | 1114 |
1094 // Both layers should be drawing into the root render surface. | 1115 // Both layers should be drawing into the root render surface. |
1095 ASSERT_EQ(1u, render_surface_layer_list.size()); | 1116 ASSERT_EQ(1u, render_surface_layer_list.size()); |
1096 ASSERT_EQ(root->render_surface(), | 1117 ASSERT_EQ(root->render_surface(), |
1097 render_surface_layer_list[0]->render_surface()); | 1118 render_surface_layer_list[0]->render_surface()); |
1098 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 1119 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
1099 | 1120 |
1100 // The root render surface is the size of the viewport. | 1121 // The root render surface is the size of the viewport. |
1101 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), | 1122 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), |
1102 root->render_surface()->content_rect()); | 1123 root->render_surface()->content_rect()); |
1103 | 1124 |
1104 // The content bounds of the child should be scaled. | 1125 // The max tiling scale of the child should be scaled. |
1105 gfx::Size child_bounds_scaled = | 1126 EXPECT_FLOAT_EQ(1.5f, child->MaximumTilingContentsScale()); |
1106 gfx::ToCeiledSize(gfx::ScaleSize(child->bounds(), 1.5)); | |
1107 EXPECT_EQ(child_bounds_scaled, child->content_bounds()); | |
1108 | 1127 |
1109 gfx::Transform scale_transform; | 1128 gfx::Transform scale_transform; |
1110 scale_transform.Scale(impl->device_scale_factor(), | 1129 scale_transform.Scale(impl->device_scale_factor(), |
1111 impl->device_scale_factor()); | 1130 impl->device_scale_factor()); |
1112 | 1131 |
1113 // The root layer is scaled by 2x. | 1132 // The root layer is scaled by 2x. |
1114 gfx::Transform root_screen_space_transform = scale_transform; | 1133 gfx::Transform root_screen_space_transform = scale_transform; |
1115 gfx::Transform root_draw_transform = scale_transform; | 1134 gfx::Transform root_draw_transform = scale_transform; |
1116 | 1135 |
1117 EXPECT_EQ(root_draw_transform, root->draw_transform()); | 1136 EXPECT_EQ(root_draw_transform, root->draw_transform()); |
1118 EXPECT_EQ(root_screen_space_transform, root->screen_space_transform()); | 1137 EXPECT_EQ(root_screen_space_transform, root->screen_space_transform()); |
1119 | 1138 |
1120 // The child is at position 2,2, which is transformed to 3,3 after the scale | 1139 // The child is at position 2,2, which is transformed to 3,3 after the scale |
1121 gfx::Transform child_screen_space_transform; | 1140 gfx::Transform child_transform; |
1122 child_screen_space_transform.Translate(3.f, 3.f); | 1141 child_transform.Translate(3.f, 3.f); |
1123 gfx::Transform child_draw_transform = child_screen_space_transform; | 1142 child_transform.Scale(child->MaximumTilingContentsScale(), |
1143 child->MaximumTilingContentsScale()); | |
1124 | 1144 |
1125 EXPECT_TRANSFORMATION_MATRIX_EQ(child_draw_transform, | 1145 EXPECT_TRANSFORMATION_MATRIX_EQ(child_transform, child->draw_transform()); |
1126 child->draw_transform()); | 1146 EXPECT_TRANSFORMATION_MATRIX_EQ(child_transform, |
1127 EXPECT_TRANSFORMATION_MATRIX_EQ(child_screen_space_transform, | |
1128 child->screen_space_transform()); | 1147 child->screen_space_transform()); |
1129 | 1148 |
1130 EndTest(); | 1149 EndTest(); |
1131 } | 1150 } |
1132 | 1151 |
1133 void AfterTest() override {} | 1152 void AfterTest() override {} |
1134 | 1153 |
1135 private: | 1154 private: |
1136 FakeContentLayerClient client_; | 1155 FakeContentLayerClient client_; |
1137 scoped_refptr<NoScaleContentLayer> root_layer_; | 1156 scoped_refptr<FakePictureLayer> root_layer_; |
1138 scoped_refptr<ContentLayer> child_layer_; | 1157 scoped_refptr<FakePictureLayer> child_layer_; |
1139 }; | 1158 }; |
1140 | 1159 |
1141 MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers); | 1160 MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers); |
1142 | 1161 |
1162 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. | |
1143 // Verify atomicity of commits and reuse of textures. | 1163 // Verify atomicity of commits and reuse of textures. |
1144 class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest { | 1164 class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest { |
1145 public: | 1165 public: |
1146 void InitializeSettings(LayerTreeSettings* settings) override { | 1166 void InitializeSettings(LayerTreeSettings* settings) override { |
1147 settings->texture_id_allocation_chunk_size = 1; | 1167 settings->texture_id_allocation_chunk_size = 1; |
1148 // Make sure partial texture updates are turned off. | 1168 // Make sure partial texture updates are turned off. |
1149 settings->max_partial_texture_updates = 0; | 1169 settings->max_partial_texture_updates = 0; |
1150 // Linear fade animator prevents scrollbars from drawing immediately. | 1170 // Linear fade animator prevents scrollbars from drawing immediately. |
1151 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; | 1171 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; |
1152 } | 1172 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1241 protected: | 1261 protected: |
1242 FakeContentLayerClient client_; | 1262 FakeContentLayerClient client_; |
1243 scoped_refptr<FakeContentLayer> layer_; | 1263 scoped_refptr<FakeContentLayer> layer_; |
1244 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; | 1264 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; |
1245 int drew_frame_; | 1265 int drew_frame_; |
1246 }; | 1266 }; |
1247 | 1267 |
1248 MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( | 1268 MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( |
1249 LayerTreeHostTestDirectRendererAtomicCommit); | 1269 LayerTreeHostTestDirectRendererAtomicCommit); |
1250 | 1270 |
1271 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. | |
1251 class LayerTreeHostTestDelegatingRendererAtomicCommit | 1272 class LayerTreeHostTestDelegatingRendererAtomicCommit |
1252 : public LayerTreeHostTestDirectRendererAtomicCommit { | 1273 : public LayerTreeHostTestDirectRendererAtomicCommit { |
1253 public: | 1274 public: |
1254 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 1275 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
1255 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates); | 1276 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates); |
1256 | 1277 |
1257 TestWebGraphicsContext3D* context = TestContext(); | 1278 TestWebGraphicsContext3D* context = TestContext(); |
1258 | 1279 |
1259 switch (impl->active_tree()->source_frame_number()) { | 1280 switch (impl->active_tree()->source_frame_number()) { |
1260 case 0: | 1281 case 0: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1308 layer->RemoveAllChildren(); | 1329 layer->RemoveAllChildren(); |
1309 if (parent) | 1330 if (parent) |
1310 parent->AddChild(layer); | 1331 parent->AddChild(layer); |
1311 layer->SetTransform(transform); | 1332 layer->SetTransform(transform); |
1312 layer->SetTransformOrigin(transform_origin); | 1333 layer->SetTransformOrigin(transform_origin); |
1313 layer->SetPosition(position); | 1334 layer->SetPosition(position); |
1314 layer->SetBounds(bounds); | 1335 layer->SetBounds(bounds); |
1315 layer->SetContentsOpaque(opaque); | 1336 layer->SetContentsOpaque(opaque); |
1316 } | 1337 } |
1317 | 1338 |
1339 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. | |
1318 class LayerTreeHostTestAtomicCommitWithPartialUpdate | 1340 class LayerTreeHostTestAtomicCommitWithPartialUpdate |
1319 : public LayerTreeHostTest { | 1341 : public LayerTreeHostTest { |
1320 public: | 1342 public: |
1321 void InitializeSettings(LayerTreeSettings* settings) override { | 1343 void InitializeSettings(LayerTreeSettings* settings) override { |
1322 settings->texture_id_allocation_chunk_size = 1; | 1344 settings->texture_id_allocation_chunk_size = 1; |
1323 // Allow one partial texture update. | 1345 // Allow one partial texture update. |
1324 settings->max_partial_texture_updates = 1; | 1346 settings->max_partial_texture_updates = 1; |
1325 // No partial updates when impl side painting is enabled. | 1347 // No partial updates when impl side painting is enabled. |
1326 settings->impl_side_painting = false; | 1348 settings->impl_side_painting = false; |
1327 } | 1349 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1481 private: | 1503 private: |
1482 FakeContentLayerClient client_; | 1504 FakeContentLayerClient client_; |
1483 scoped_refptr<FakeContentLayer> parent_; | 1505 scoped_refptr<FakeContentLayer> parent_; |
1484 scoped_refptr<FakeContentLayer> child_; | 1506 scoped_refptr<FakeContentLayer> child_; |
1485 }; | 1507 }; |
1486 | 1508 |
1487 // Partial updates are not possible with a delegating renderer. | 1509 // Partial updates are not possible with a delegating renderer. |
1488 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1510 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1489 LayerTreeHostTestAtomicCommitWithPartialUpdate); | 1511 LayerTreeHostTestAtomicCommitWithPartialUpdate); |
1490 | 1512 |
1513 // TODO(sohanjg) : Make it work with impl-side painting. | |
1491 class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit | 1514 class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit |
1492 : public LayerTreeHostTest { | 1515 : public LayerTreeHostTest { |
1493 protected: | 1516 protected: |
1494 void SetupTree() override { | 1517 void SetupTree() override { |
1495 root_layer_ = FakeContentLayer::Create(&client_); | 1518 root_layer_ = FakeContentLayer::Create(&client_); |
1496 root_layer_->SetBounds(gfx::Size(100, 100)); | 1519 root_layer_->SetBounds(gfx::Size(100, 100)); |
1497 | 1520 |
1498 surface_layer1_ = FakeContentLayer::Create(&client_); | 1521 surface_layer1_ = FakeContentLayer::Create(&client_); |
1499 surface_layer1_->SetBounds(gfx::Size(100, 100)); | 1522 surface_layer1_->SetBounds(gfx::Size(100, 100)); |
1500 surface_layer1_->SetForceRenderSurface(true); | 1523 surface_layer1_->SetForceRenderSurface(true); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1801 | 1824 |
1802 class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { | 1825 class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { |
1803 public: | 1826 public: |
1804 LayerTreeHostTestContinuousInvalidate() | 1827 LayerTreeHostTestContinuousInvalidate() |
1805 : num_commit_complete_(0), num_draw_layers_(0) {} | 1828 : num_commit_complete_(0), num_draw_layers_(0) {} |
1806 | 1829 |
1807 void BeginTest() override { | 1830 void BeginTest() override { |
1808 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); | 1831 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); |
1809 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); | 1832 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); |
1810 | 1833 |
1811 content_layer_ = ContentLayer::Create(&client_); | 1834 if (layer_tree_host()->settings().impl_side_painting) |
1812 content_layer_->SetBounds(gfx::Size(10, 10)); | 1835 layer_ = FakePictureLayer::Create(&client_); |
1813 content_layer_->SetPosition(gfx::PointF(0.f, 0.f)); | 1836 else |
1814 content_layer_->SetIsDrawable(true); | 1837 layer_ = FakeContentLayer::Create(&client_); |
1815 layer_tree_host()->root_layer()->AddChild(content_layer_); | 1838 |
1839 layer_->SetBounds(gfx::Size(10, 10)); | |
1840 layer_->SetPosition(gfx::PointF(0.f, 0.f)); | |
1841 layer_->SetIsDrawable(true); | |
1842 layer_tree_host()->root_layer()->AddChild(layer_); | |
1816 | 1843 |
1817 PostSetNeedsCommitToMainThread(); | 1844 PostSetNeedsCommitToMainThread(); |
1818 } | 1845 } |
1819 | 1846 |
1820 void DidCommitAndDrawFrame() override { | 1847 void DidCommitAndDrawFrame() override { |
1821 if (num_draw_layers_ == 2) | 1848 if (num_draw_layers_ == 2) |
1822 return; | 1849 return; |
1823 content_layer_->SetNeedsDisplay(); | 1850 layer_->SetNeedsDisplay(); |
1824 } | 1851 } |
1825 | 1852 |
1826 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 1853 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
1827 if (num_draw_layers_ == 1) | 1854 if (num_draw_layers_ == 1) |
1828 num_commit_complete_++; | 1855 num_commit_complete_++; |
1829 } | 1856 } |
1830 | 1857 |
1831 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 1858 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
1832 num_draw_layers_++; | 1859 num_draw_layers_++; |
1833 if (num_draw_layers_ == 2) | 1860 if (num_draw_layers_ == 2) |
1834 EndTest(); | 1861 EndTest(); |
1835 } | 1862 } |
1836 | 1863 |
1837 void AfterTest() override { | 1864 void AfterTest() override { |
1838 // Check that we didn't commit twice between first and second draw. | 1865 // Check that we didn't commit twice between first and second draw. |
1839 EXPECT_EQ(1, num_commit_complete_); | 1866 EXPECT_EQ(1, num_commit_complete_); |
1840 } | 1867 } |
1841 | 1868 |
1842 private: | 1869 private: |
1843 FakeContentLayerClient client_; | 1870 FakeContentLayerClient client_; |
1844 scoped_refptr<Layer> content_layer_; | 1871 scoped_refptr<Layer> layer_; |
1845 int num_commit_complete_; | 1872 int num_commit_complete_; |
1846 int num_draw_layers_; | 1873 int num_draw_layers_; |
1847 }; | 1874 }; |
1848 | 1875 |
1849 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestContinuousInvalidate); | 1876 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousInvalidate); |
1850 | 1877 |
1851 class LayerTreeHostTestDeferCommits : public LayerTreeHostTest { | 1878 class LayerTreeHostTestDeferCommits : public LayerTreeHostTest { |
1852 public: | 1879 public: |
1853 LayerTreeHostTestDeferCommits() | 1880 LayerTreeHostTestDeferCommits() |
1854 : num_commits_deferred_(0), num_complete_commits_(0) {} | 1881 : num_commits_deferred_(0), num_complete_commits_(0) {} |
1855 | 1882 |
1856 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1883 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
1857 | 1884 |
1858 void DidDeferCommit() override { | 1885 void DidDeferCommit() override { |
1859 num_commits_deferred_++; | 1886 num_commits_deferred_++; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2038 shared_bitmap_manager.get(), | 2065 shared_bitmap_manager.get(), |
2039 NULL, | 2066 NULL, |
2040 settings, | 2067 settings, |
2041 base::MessageLoopProxy::current()); | 2068 base::MessageLoopProxy::current()); |
2042 client.SetLayerTreeHost(host.get()); | 2069 client.SetLayerTreeHost(host.get()); |
2043 host->Composite(base::TimeTicks::Now()); | 2070 host->Composite(base::TimeTicks::Now()); |
2044 | 2071 |
2045 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); | 2072 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); |
2046 } | 2073 } |
2047 | 2074 |
2075 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. | |
2048 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted | 2076 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted |
2049 : public LayerTreeHostTest { | 2077 : public LayerTreeHostTest { |
2050 public: | 2078 public: |
2051 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() | 2079 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() |
2052 : root_layer_(FakeContentLayer::Create(&client_)), | 2080 : root_layer_(FakeContentLayer::Create(&client_)), |
2053 child_layer1_(FakeContentLayer::Create(&client_)), | 2081 child_layer1_(FakeContentLayer::Create(&client_)), |
2054 child_layer2_(FakeContentLayer::Create(&client_)), | 2082 child_layer2_(FakeContentLayer::Create(&client_)), |
2055 num_commits_(0) {} | 2083 num_commits_(0) {} |
2056 | 2084 |
2057 void BeginTest() override { | 2085 void BeginTest() override { |
(...skipping 2292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4350 output_surface->SetMemoryPolicyToSetAtBind( | 4378 output_surface->SetMemoryPolicyToSetAtBind( |
4351 make_scoped_ptr(new ManagedMemoryPolicy( | 4379 make_scoped_ptr(new ManagedMemoryPolicy( |
4352 second_context_provider_.get() ? second_output_surface_memory_limit_ | 4380 second_context_provider_.get() ? second_output_surface_memory_limit_ |
4353 : first_output_surface_memory_limit_, | 4381 : first_output_surface_memory_limit_, |
4354 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, | 4382 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, |
4355 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); | 4383 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); |
4356 return output_surface.Pass(); | 4384 return output_surface.Pass(); |
4357 } | 4385 } |
4358 | 4386 |
4359 void SetupTree() override { | 4387 void SetupTree() override { |
4360 root_ = FakeContentLayer::Create(&client_); | 4388 if (layer_tree_host()->settings().impl_side_painting) |
4389 root_ = FakePictureLayer::Create(&client_); | |
4390 else | |
4391 root_ = FakeContentLayer::Create(&client_); | |
4361 root_->SetBounds(gfx::Size(20, 20)); | 4392 root_->SetBounds(gfx::Size(20, 20)); |
4362 layer_tree_host()->SetRootLayer(root_); | 4393 layer_tree_host()->SetRootLayer(root_); |
4363 LayerTreeHostTest::SetupTree(); | 4394 LayerTreeHostTest::SetupTree(); |
4364 } | 4395 } |
4365 | 4396 |
4366 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 4397 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
4367 | 4398 |
4368 void DidCommitAndDrawFrame() override { | 4399 void DidCommitAndDrawFrame() override { |
4369 // Lost context sometimes takes two frames to recreate. The third frame | 4400 // Lost context sometimes takes two frames to recreate. The third frame |
4370 // is sometimes aborted, so wait until the fourth frame to verify that | 4401 // is sometimes aborted, so wait until the fourth frame to verify that |
(...skipping 21 matching lines...) Expand all Loading... | |
4392 } | 4423 } |
4393 } | 4424 } |
4394 | 4425 |
4395 void AfterTest() override {} | 4426 void AfterTest() override {} |
4396 | 4427 |
4397 scoped_refptr<TestContextProvider> first_context_provider_; | 4428 scoped_refptr<TestContextProvider> first_context_provider_; |
4398 scoped_refptr<TestContextProvider> second_context_provider_; | 4429 scoped_refptr<TestContextProvider> second_context_provider_; |
4399 size_t first_output_surface_memory_limit_; | 4430 size_t first_output_surface_memory_limit_; |
4400 size_t second_output_surface_memory_limit_; | 4431 size_t second_output_surface_memory_limit_; |
4401 FakeContentLayerClient client_; | 4432 FakeContentLayerClient client_; |
4402 scoped_refptr<FakeContentLayer> root_; | 4433 scoped_refptr<Layer> root_; |
4403 }; | 4434 }; |
4404 | 4435 |
4405 // No output to copy for delegated renderers. | |
4406 SINGLE_AND_MULTI_THREAD_TEST_F( | 4436 SINGLE_AND_MULTI_THREAD_TEST_F( |
4407 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); | 4437 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); |
4408 | 4438 |
4409 struct TestSwapPromiseResult { | 4439 struct TestSwapPromiseResult { |
4410 TestSwapPromiseResult() | 4440 TestSwapPromiseResult() |
4411 : did_swap_called(false), | 4441 : did_swap_called(false), |
4412 did_not_swap_called(false), | 4442 did_not_swap_called(false), |
4413 dtor_called(false), | 4443 dtor_called(false), |
4414 reason(SwapPromise::DID_NOT_SWAP_UNKNOWN) {} | 4444 reason(SwapPromise::DID_NOT_SWAP_UNKNOWN) {} |
4415 | 4445 |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5199 void AfterTest() override { | 5229 void AfterTest() override { |
5200 EXPECT_TRUE(deltas_sent_to_client_); | 5230 EXPECT_TRUE(deltas_sent_to_client_); |
5201 } | 5231 } |
5202 | 5232 |
5203 ScrollAndScaleSet info_; | 5233 ScrollAndScaleSet info_; |
5204 bool deltas_sent_to_client_; | 5234 bool deltas_sent_to_client_; |
5205 }; | 5235 }; |
5206 | 5236 |
5207 MULTI_THREAD_TEST_F(LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer); | 5237 MULTI_THREAD_TEST_F(LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer); |
5208 } // namespace cc | 5238 } // namespace cc |
OLD | NEW |