Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 5373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5384 bool deltas_sent_to_client_; | 5384 bool deltas_sent_to_client_; |
| 5385 }; | 5385 }; |
| 5386 | 5386 |
| 5387 MULTI_THREAD_TEST_F(LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer); | 5387 MULTI_THREAD_TEST_F(LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer); |
| 5388 | 5388 |
| 5389 class LayerTreeHostTestCrispUpAfterPinchEnds : public LayerTreeHostTest { | 5389 class LayerTreeHostTestCrispUpAfterPinchEnds : public LayerTreeHostTest { |
| 5390 protected: | 5390 protected: |
| 5391 LayerTreeHostTestCrispUpAfterPinchEnds() | 5391 LayerTreeHostTestCrispUpAfterPinchEnds() |
| 5392 : playback_allowed_event_(true, true) {} | 5392 : playback_allowed_event_(true, true) {} |
| 5393 | 5393 |
| 5394 void InitializeSettings(LayerTreeSettings* settings) override { | |
| 5395 settings->impl_side_painting = true; | |
| 5396 } | |
| 5397 | |
| 5398 void SetupTree() override { | 5394 void SetupTree() override { |
| 5399 frame_ = 1; | 5395 frame_ = 1; |
| 5400 posted_ = false; | 5396 posted_ = false; |
| 5401 client_.set_fill_with_nonsolid_color(true); | 5397 client_.set_fill_with_nonsolid_color(true); |
| 5402 | 5398 |
| 5403 scoped_refptr<Layer> root = Layer::Create(); | 5399 scoped_refptr<Layer> root = Layer::Create(); |
| 5404 root->SetBounds(gfx::Size(500, 500)); | 5400 root->SetBounds(gfx::Size(500, 500)); |
| 5405 | 5401 |
| 5406 scoped_refptr<Layer> pinch = Layer::Create(); | 5402 scoped_refptr<Layer> pinch = Layer::Create(); |
| 5407 pinch->SetBounds(gfx::Size(500, 500)); | 5403 pinch->SetBounds(gfx::Size(500, 500)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5454 DrawResult draw_result) override { | 5450 DrawResult draw_result) override { |
| 5455 float quad_scale_delta = FrameQuadScaleDeltaFromIdeal(frame_data); | 5451 float quad_scale_delta = FrameQuadScaleDeltaFromIdeal(frame_data); |
| 5456 switch (frame_) { | 5452 switch (frame_) { |
| 5457 case 1: | 5453 case 1: |
| 5458 // Drew at page scale 1 before any pinching. | 5454 // Drew at page scale 1 before any pinching. |
| 5459 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); | 5455 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); |
| 5460 EXPECT_EQ(1.f, quad_scale_delta); | 5456 EXPECT_EQ(1.f, quad_scale_delta); |
| 5461 PostNextAfterDraw(host_impl); | 5457 PostNextAfterDraw(host_impl); |
| 5462 break; | 5458 break; |
| 5463 case 2: | 5459 case 2: |
| 5460 // Wait for any activations that need to occur due to starting a pinch, | |
| 5461 // and drawing with a non-identity transform (for eg. LCD text being | |
| 5462 // disabled). | |
| 5463 if (host_impl->pending_tree()) | |
| 5464 break; | |
| 5464 if (quad_scale_delta != 1.f) | 5465 if (quad_scale_delta != 1.f) |
| 5465 break; | 5466 break; |
| 5466 // Drew at page scale 2.2 after pinching in. | 5467 // Drew at page scale 1.5 after pinching in. |
| 5467 EXPECT_EQ(2.2f, host_impl->active_tree()->total_page_scale_factor()); | 5468 EXPECT_EQ(1.5f, host_impl->active_tree()->total_page_scale_factor()); |
| 5468 EXPECT_EQ(1.f, quad_scale_delta); | 5469 EXPECT_EQ(1.f, quad_scale_delta); |
| 5469 PostNextAfterDraw(host_impl); | 5470 PostNextAfterDraw(host_impl); |
| 5470 break; | 5471 break; |
| 5471 case 3: | 5472 case 3: |
| 5472 if (quad_scale_delta != 2.2f) | 5473 // By pinching out, we will create a new tiling and raster it. This may |
| 5474 // cause some additional draws, though we should still be drawing with | |
| 5475 // the old 1.5 tiling. | |
| 5476 if (frame_data->has_no_damage) | |
| 5473 break; | 5477 break; |
| 5474 // Drew at page scale 1 with the 2.2 tiling while pinching out. | 5478 // Drew at page scale 1 with the 1.5 tiling while pinching out. |
| 5475 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); | 5479 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); |
| 5476 EXPECT_EQ(2.2f, quad_scale_delta); | 5480 EXPECT_EQ(1.5f, quad_scale_delta); |
| 5477 PostNextAfterDraw(host_impl); | 5481 // We don't PostNextAfterDraw here, instead we wait for the new tiling |
| 5482 // to finish rastering so we don't get any noise in further steps. | |
| 5478 break; | 5483 break; |
| 5479 case 4: | 5484 case 4: |
| 5480 // Drew at page scale 1 with the 2.2 tiling after pinching out completed | 5485 // Drew at page scale 1 with the 1.5 tiling after pinching out completed |
| 5481 // while waiting for texture uploads to complete. | 5486 // while waiting for texture uploads to complete. |
| 5482 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); | 5487 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); |
| 5483 // This frame will not have any damage, since it's actually the same as | |
|
danakj
2014/11/14 21:17:32
oops this comment should stay now. fixed.
| |
| 5484 // the last frame, and should contain no incomplete tiles. We just want | |
| 5485 // to make sure we drew here at least once after the pinch ended to be | |
| 5486 // sure that drawing after pinch doesn't leave us at the wrong scale | |
| 5487 // forever. | |
| 5488 EXPECT_TRUE(frame_data->has_no_damage); | 5488 EXPECT_TRUE(frame_data->has_no_damage); |
| 5489 // We want to make sure we drew here at least once after the pinch ended | |
| 5490 // to be sure that drawing after pinch doesn't leave us at the wrong | |
| 5491 // scale forever. | |
| 5489 PostNextAfterDraw(host_impl); | 5492 PostNextAfterDraw(host_impl); |
| 5490 break; | 5493 break; |
| 5491 case 5: | 5494 case 5: |
| 5492 if (quad_scale_delta != 1.f) | 5495 if (quad_scale_delta != 1.f) |
| 5493 break; | 5496 break; |
| 5494 // Drew at scale 1 after texture uploads are done. | 5497 // Drew at scale 1 after texture uploads are done. |
| 5495 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); | 5498 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); |
| 5496 EXPECT_EQ(1.f, quad_scale_delta); | 5499 EXPECT_EQ(1.f, quad_scale_delta); |
| 5497 EndTest(); | 5500 EndTest(); |
| 5498 break; | 5501 break; |
| 5499 } | 5502 } |
| 5500 return draw_result; | 5503 return draw_result; |
| 5501 } | 5504 } |
| 5502 | 5505 |
| 5503 void PostNextAfterDraw(LayerTreeHostImpl* host_impl) { | 5506 void PostNextAfterDraw(LayerTreeHostImpl* host_impl) { |
| 5504 if (posted_) | 5507 if (posted_) |
| 5505 return; | 5508 return; |
| 5506 posted_ = true; | 5509 posted_ = true; |
| 5507 ImplThreadTaskRunner()->PostDelayedTask( | 5510 ImplThreadTaskRunner()->PostDelayedTask( |
| 5508 FROM_HERE, base::Bind(&LayerTreeHostTestCrispUpAfterPinchEnds::Next, | 5511 FROM_HERE, base::Bind(&LayerTreeHostTestCrispUpAfterPinchEnds::Next, |
| 5509 base::Unretained(this), host_impl), | 5512 base::Unretained(this), host_impl), |
| 5510 // Use a delay to allow raster/upload to happen in between frames. This | 5513 // Use a delay to allow raster/upload to happen in between frames. This |
| 5511 // should cause flakiness if we fail to block raster/upload when | 5514 // should cause flakiness if we fail to block raster/upload when |
| 5512 // desired. | 5515 // desired. |
| 5513 base::TimeDelta::FromMilliseconds(16 * 6)); | 5516 base::TimeDelta::FromMilliseconds(16 * 4)); |
| 5514 } | 5517 } |
| 5515 | 5518 |
| 5516 void Next(LayerTreeHostImpl* host_impl) { | 5519 void Next(LayerTreeHostImpl* host_impl) { |
| 5517 ++frame_; | 5520 ++frame_; |
| 5518 posted_ = false; | 5521 posted_ = false; |
| 5519 switch (frame_) { | 5522 switch (frame_) { |
| 5520 case 2: | 5523 case 2: |
| 5521 // Pinch zoom in. | 5524 // Pinch zoom in. |
| 5522 host_impl->PinchGestureBegin(); | 5525 host_impl->PinchGestureBegin(); |
| 5523 host_impl->PinchGestureUpdate(2.2f, gfx::Point(100, 100)); | 5526 host_impl->PinchGestureUpdate(1.5f, gfx::Point(100, 100)); |
| 5524 host_impl->PinchGestureEnd(); | 5527 host_impl->PinchGestureEnd(); |
| 5525 break; | 5528 break; |
| 5526 case 3: | 5529 case 3: |
| 5527 // Pinch zoom back to 1.f but don't end it. | 5530 // Pinch zoom back to 1.f but don't end it, keep track of the tiles that |
| 5531 // are rastered. | |
| 5528 host_impl->PinchGestureBegin(); | 5532 host_impl->PinchGestureBegin(); |
| 5529 host_impl->PinchGestureUpdate(1.f / 2.2f, gfx::Point(100, 100)); | 5533 host_impl->PinchGestureUpdate(1.f / 2.2f, gfx::Point(100, 100)); |
| 5530 break; | 5534 break; |
| 5531 case 4: | 5535 case 4: |
| 5532 // End the pinch, but delay tile production. | 5536 // End the pinch, but delay tile production. |
| 5533 playback_allowed_event_.Reset(); | 5537 playback_allowed_event_.Reset(); |
| 5534 host_impl->PinchGestureEnd(); | 5538 host_impl->PinchGestureEnd(); |
| 5535 break; | 5539 break; |
| 5536 case 5: | 5540 case 5: |
| 5537 // Let tiles complete. | 5541 // Let tiles complete. |
| 5538 playback_allowed_event_.Signal(); | 5542 playback_allowed_event_.Signal(); |
| 5539 break; | 5543 break; |
| 5540 } | 5544 } |
| 5541 } | 5545 } |
| 5542 | 5546 |
| 5543 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, | 5547 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, |
| 5544 const Tile* tile) override { | 5548 const Tile* tile) override { |
| 5549 if (frame_ == 3) { | |
| 5550 // On frame 3, we will have a low res tile complete for the pinch-out | |
| 5551 // gesture even though it's not displayed. We wait for it here to prevent | |
| 5552 // flakiness. | |
| 5553 PostNextAfterDraw(host_impl); | |
| 5554 } | |
| 5545 // On frame_ == 4, we are preventing texture uploads from completing, | 5555 // On frame_ == 4, we are preventing texture uploads from completing, |
| 5546 // so this verifies they are not completing before frame_ == 5. | 5556 // so this verifies they are not completing before frame_ == 5. |
| 5547 // Flaky failures here indicate we're failing to prevent uploads from | 5557 // Flaky failures here indicate we're failing to prevent uploads from |
| 5548 // completing. | 5558 // completing. |
| 5549 EXPECT_NE(4, frame_); | 5559 EXPECT_NE(4, frame_) << tile->contents_scale(); |
| 5550 } | 5560 } |
| 5551 | 5561 |
| 5552 void AfterTest() override {} | 5562 void AfterTest() override {} |
| 5553 | 5563 |
| 5554 FakeContentLayerClient client_; | 5564 FakeContentLayerClient client_; |
| 5555 int frame_; | 5565 int frame_; |
| 5556 bool posted_; | 5566 bool posted_; |
| 5557 base::WaitableEvent playback_allowed_event_; | 5567 base::WaitableEvent playback_allowed_event_; |
| 5558 }; | 5568 }; |
| 5559 | 5569 |
| 5560 // TODO(danakj): Disabled for flake: crbug.com/433208 | 5570 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); |
| 5561 // MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); | |
| 5562 | 5571 |
| 5563 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy | 5572 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy |
| 5564 : public LayerTreeHostTestCrispUpAfterPinchEnds { | 5573 : public LayerTreeHostTestCrispUpAfterPinchEnds { |
| 5565 protected: | 5574 protected: |
| 5566 void InitializeSettings(LayerTreeSettings* settings) override { | 5575 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5567 settings->impl_side_painting = true; | |
| 5568 settings->use_one_copy = true; | 5576 settings->use_one_copy = true; |
| 5569 } | 5577 } |
| 5570 | 5578 |
| 5571 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( | 5579 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( |
| 5572 bool fallback) override { | 5580 bool fallback) override { |
| 5573 scoped_ptr<TestWebGraphicsContext3D> context3d = | 5581 scoped_ptr<TestWebGraphicsContext3D> context3d = |
| 5574 TestWebGraphicsContext3D::Create(); | 5582 TestWebGraphicsContext3D::Create(); |
| 5575 context3d->set_support_image(true); | 5583 context3d->set_support_image(true); |
| 5576 context3d->set_support_sync_query(true); | 5584 context3d->set_support_sync_query(true); |
| 5577 | 5585 |
| 5578 if (delegating_renderer()) | 5586 if (delegating_renderer()) |
| 5579 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); | 5587 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); |
| 5580 else | 5588 else |
| 5581 return FakeOutputSurface::Create3d(context3d.Pass()); | 5589 return FakeOutputSurface::Create3d(context3d.Pass()); |
| 5582 } | 5590 } |
| 5583 }; | 5591 }; |
| 5584 | 5592 |
| 5585 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy); | 5593 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy); |
| 5586 | 5594 |
| 5587 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles | 5595 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles |
| 5588 : public LayerTreeHostTest { | 5596 : public LayerTreeHostTest { |
| 5589 protected: | 5597 protected: |
| 5590 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() | 5598 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() |
| 5591 : playback_allowed_event_(true, true) {} | 5599 : playback_allowed_event_(true, true) {} |
| 5592 | 5600 |
| 5593 void InitializeSettings(LayerTreeSettings* settings) override { | 5601 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5594 settings->impl_side_painting = true; | 5602 settings->impl_side_painting = true; |
| 5595 } | 5603 } |
| 5596 | 5604 |
| 5597 void SetupTree() override { | 5605 void SetupTree() override { |
| 5598 step_ = 1; | 5606 step_ = 1; |
| 5599 continuous_draws_ = 0; | 5607 continuous_draws_ = 0; |
| 5608 expect_draw_ = false; | |
| 5600 client_.set_fill_with_nonsolid_color(true); | 5609 client_.set_fill_with_nonsolid_color(true); |
| 5601 | 5610 |
| 5602 scoped_refptr<Layer> root = Layer::Create(); | 5611 scoped_refptr<Layer> root = Layer::Create(); |
| 5603 root->SetBounds(gfx::Size(500, 500)); | 5612 root->SetBounds(gfx::Size(500, 500)); |
| 5604 | 5613 |
| 5605 scoped_refptr<Layer> pinch = Layer::Create(); | 5614 scoped_refptr<Layer> pinch = Layer::Create(); |
| 5606 pinch->SetBounds(gfx::Size(500, 500)); | 5615 pinch->SetBounds(gfx::Size(500, 500)); |
| 5607 pinch->SetScrollClipLayerId(root->id()); | 5616 pinch->SetScrollClipLayerId(root->id()); |
| 5608 pinch->SetIsContainerForFixedPositionLayers(true); | 5617 pinch->SetIsContainerForFixedPositionLayers(true); |
| 5609 root->AddChild(pinch); | 5618 root->AddChild(pinch); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5677 | 5686 |
| 5678 // We should not continue to draw any more. End the test after a timeout | 5687 // We should not continue to draw any more. End the test after a timeout |
| 5679 // to watch for any extraneous draws. | 5688 // to watch for any extraneous draws. |
| 5680 // TODO(brianderson): We could remove this delay and instead wait until | 5689 // TODO(brianderson): We could remove this delay and instead wait until |
| 5681 // the BeginFrameSource decides it doesn't need to send frames anymore, | 5690 // the BeginFrameSource decides it doesn't need to send frames anymore, |
| 5682 // or test that it already doesn't here. | 5691 // or test that it already doesn't here. |
| 5683 EndTestAfterDelayMs(16 * 4); | 5692 EndTestAfterDelayMs(16 * 4); |
| 5684 ++step_; | 5693 ++step_; |
| 5685 break; | 5694 break; |
| 5686 case 5: | 5695 case 5: |
| 5696 // We may get another draw if we activate due to the pinch (eg LCD text | |
| 5697 // gets disabled). | |
| 5698 if (expect_draw_) | |
| 5699 break; | |
| 5687 ADD_FAILURE() | 5700 ADD_FAILURE() |
| 5688 << "No draws should happen once we have a complete frame."; | 5701 << "No draws should happen once we have a complete frame."; |
| 5689 break; | 5702 break; |
| 5690 } | 5703 } |
| 5704 expect_draw_ = false; | |
| 5691 return draw_result; | 5705 return draw_result; |
| 5692 } | 5706 } |
| 5693 | 5707 |
| 5694 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 5708 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 5695 switch (step_) { | 5709 switch (step_) { |
| 5696 case 1: | 5710 case 1: |
| 5697 // Delay tile production. | 5711 // Delay tile production. |
| 5698 playback_allowed_event_.Reset(); | 5712 playback_allowed_event_.Reset(); |
| 5699 // Pinch zoom in to cause new tiles to be required. | 5713 // Pinch zoom in to cause new tiles to be required. |
| 5700 host_impl->PinchGestureBegin(); | 5714 host_impl->PinchGestureBegin(); |
| 5701 host_impl->PinchGestureUpdate(1.5f, gfx::Point(100, 100)); | 5715 host_impl->PinchGestureUpdate(1.5f, gfx::Point(100, 100)); |
| 5702 host_impl->PinchGestureEnd(); | 5716 host_impl->PinchGestureEnd(); |
| 5703 ++step_; | 5717 ++step_; |
| 5704 break; | 5718 break; |
| 5705 case 2: | 5719 case 2: |
| 5706 ++step_; | 5720 ++step_; |
| 5707 break; | 5721 break; |
| 5708 case 3: | 5722 case 3: |
| 5709 // We should continue to try draw while there are incomplete visible | 5723 // We should continue to try draw while there are incomplete visible |
| 5710 // tiles. | 5724 // tiles. |
| 5711 if (++continuous_draws_ > 5) { | 5725 if (++continuous_draws_ > 5) { |
| 5712 // Allow the tiles to complete. | 5726 // Allow the tiles to complete. |
| 5713 playback_allowed_event_.Signal(); | 5727 playback_allowed_event_.Signal(); |
| 5714 ++step_; | 5728 ++step_; |
| 5715 } | 5729 } |
| 5716 break; | 5730 break; |
| 5717 } | 5731 } |
| 5718 } | 5732 } |
| 5719 | 5733 |
| 5734 void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | |
| 5735 expect_draw_ = true; | |
| 5736 } | |
| 5737 | |
| 5720 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, | 5738 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, |
| 5721 const Tile* tile) override { | 5739 const Tile* tile) override { |
| 5722 // On step_ == 2, we are preventing texture uploads from completing, | 5740 // On step_ == 2, we are preventing texture uploads from completing, |
| 5723 // so this verifies they are not completing before step_ == 3. | 5741 // so this verifies they are not completing before step_ == 3. |
| 5724 // Flaky failures here indicate we're failing to prevent uploads from | 5742 // Flaky failures here indicate we're failing to prevent uploads from |
| 5725 // completing. | 5743 // completing. |
| 5726 EXPECT_NE(2, step_); | 5744 EXPECT_NE(2, step_); |
| 5727 } | 5745 } |
| 5728 | 5746 |
| 5729 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); } | 5747 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); } |
| 5730 | 5748 |
| 5731 FakeContentLayerClient client_; | 5749 FakeContentLayerClient client_; |
| 5732 int step_; | 5750 int step_; |
| 5733 int continuous_draws_; | 5751 int continuous_draws_; |
| 5752 bool expect_draw_; | |
| 5734 base::WaitableEvent playback_allowed_event_; | 5753 base::WaitableEvent playback_allowed_event_; |
| 5735 }; | 5754 }; |
| 5736 | 5755 |
| 5737 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); | 5756 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); |
| 5738 | 5757 |
| 5739 } // namespace cc | 5758 } // namespace cc |
| OLD | NEW |