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 | 5488 // This frame will not have any damage, since it's actually the same as |
| 5484 // the last frame, and should contain no incomplete tiles. We just want | 5489 // 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 | 5490 // 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 | 5491 // sure that drawing after pinch doesn't leave us at the wrong scale |
| 5487 // forever. | 5492 // forever. |
| 5488 EXPECT_TRUE(frame_data->has_no_damage); | 5493 EXPECT_TRUE(frame_data->has_no_damage); |
| 5489 PostNextAfterDraw(host_impl); | 5494 PostNextAfterDraw(host_impl); |
| 5490 break; | 5495 break; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 5503 void PostNextAfterDraw(LayerTreeHostImpl* host_impl) { | 5508 void PostNextAfterDraw(LayerTreeHostImpl* host_impl) { |
| 5504 if (posted_) | 5509 if (posted_) |
| 5505 return; | 5510 return; |
| 5506 posted_ = true; | 5511 posted_ = true; |
| 5507 ImplThreadTaskRunner()->PostDelayedTask( | 5512 ImplThreadTaskRunner()->PostDelayedTask( |
| 5508 FROM_HERE, base::Bind(&LayerTreeHostTestCrispUpAfterPinchEnds::Next, | 5513 FROM_HERE, base::Bind(&LayerTreeHostTestCrispUpAfterPinchEnds::Next, |
| 5509 base::Unretained(this), host_impl), | 5514 base::Unretained(this), host_impl), |
| 5510 // Use a delay to allow raster/upload to happen in between frames. This | 5515 // 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 | 5516 // should cause flakiness if we fail to block raster/upload when |
| 5512 // desired. | 5517 // desired. |
| 5513 base::TimeDelta::FromMilliseconds(16 * 6)); | 5518 base::TimeDelta::FromMilliseconds(16 * 4)); |
| 5514 } | 5519 } |
| 5515 | 5520 |
| 5516 void Next(LayerTreeHostImpl* host_impl) { | 5521 void Next(LayerTreeHostImpl* host_impl) { |
| 5517 ++frame_; | 5522 ++frame_; |
| 5518 posted_ = false; | 5523 posted_ = false; |
| 5519 switch (frame_) { | 5524 switch (frame_) { |
| 5520 case 2: | 5525 case 2: |
| 5521 // Pinch zoom in. | 5526 // Pinch zoom in. |
| 5522 host_impl->PinchGestureBegin(); | 5527 host_impl->PinchGestureBegin(); |
| 5523 host_impl->PinchGestureUpdate(2.2f, gfx::Point(100, 100)); | 5528 host_impl->PinchGestureUpdate(1.5f, gfx::Point(100, 100)); |
| 5524 host_impl->PinchGestureEnd(); | 5529 host_impl->PinchGestureEnd(); |
| 5525 break; | 5530 break; |
| 5526 case 3: | 5531 case 3: |
| 5527 // Pinch zoom back to 1.f but don't end it. | 5532 // Pinch zoom back to 1.f but don't end it. |
| 5528 host_impl->PinchGestureBegin(); | 5533 host_impl->PinchGestureBegin(); |
| 5529 host_impl->PinchGestureUpdate(1.f / 2.2f, gfx::Point(100, 100)); | 5534 host_impl->PinchGestureUpdate(1.f / 2.2f, gfx::Point(100, 100)); |
| 5530 break; | 5535 break; |
| 5531 case 4: | 5536 case 4: |
| 5532 // End the pinch, but delay tile production. | 5537 // End the pinch, but delay tile production. |
| 5533 playback_allowed_event_.Reset(); | 5538 playback_allowed_event_.Reset(); |
| 5534 host_impl->PinchGestureEnd(); | 5539 host_impl->PinchGestureEnd(); |
| 5535 break; | 5540 break; |
| 5536 case 5: | 5541 case 5: |
| 5537 // Let tiles complete. | 5542 // Let tiles complete. |
| 5538 playback_allowed_event_.Signal(); | 5543 playback_allowed_event_.Signal(); |
| 5539 break; | 5544 break; |
| 5540 } | 5545 } |
| 5541 } | 5546 } |
| 5542 | 5547 |
| 5543 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, | 5548 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, |
| 5544 const Tile* tile) override { | 5549 const Tile* tile) override { |
| 5550 if (frame_ == 3) { | |
| 5551 // On frame 3, we will have a low res tile complete for the pinch-out | |
|
vmpstr
2014/11/14 21:29:49
Is doing a ASSERT_EQ(LOW_RESOLUTION, tile->{priori
| |
| 5552 // gesture even though it's not displayed. We wait for it here to prevent | |
| 5553 // flakiness. | |
| 5554 PostNextAfterDraw(host_impl); | |
| 5555 } | |
| 5545 // On frame_ == 4, we are preventing texture uploads from completing, | 5556 // On frame_ == 4, we are preventing texture uploads from completing, |
| 5546 // so this verifies they are not completing before frame_ == 5. | 5557 // so this verifies they are not completing before frame_ == 5. |
| 5547 // Flaky failures here indicate we're failing to prevent uploads from | 5558 // Flaky failures here indicate we're failing to prevent uploads from |
| 5548 // completing. | 5559 // completing. |
| 5549 EXPECT_NE(4, frame_); | 5560 EXPECT_NE(4, frame_) << tile->contents_scale(); |
| 5550 } | 5561 } |
| 5551 | 5562 |
| 5552 void AfterTest() override {} | 5563 void AfterTest() override {} |
| 5553 | 5564 |
| 5554 FakeContentLayerClient client_; | 5565 FakeContentLayerClient client_; |
| 5555 int frame_; | 5566 int frame_; |
| 5556 bool posted_; | 5567 bool posted_; |
| 5557 base::WaitableEvent playback_allowed_event_; | 5568 base::WaitableEvent playback_allowed_event_; |
| 5558 }; | 5569 }; |
| 5559 | 5570 |
| 5560 // TODO(danakj): Disabled for flake: crbug.com/433208 | 5571 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); |
| 5561 // MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); | |
| 5562 | 5572 |
| 5563 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy | 5573 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy |
| 5564 : public LayerTreeHostTestCrispUpAfterPinchEnds { | 5574 : public LayerTreeHostTestCrispUpAfterPinchEnds { |
| 5565 protected: | 5575 protected: |
| 5566 void InitializeSettings(LayerTreeSettings* settings) override { | 5576 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5567 settings->impl_side_painting = true; | |
| 5568 settings->use_one_copy = true; | 5577 settings->use_one_copy = true; |
| 5569 } | 5578 } |
| 5570 | 5579 |
| 5571 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( | 5580 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( |
| 5572 bool fallback) override { | 5581 bool fallback) override { |
| 5573 scoped_ptr<TestWebGraphicsContext3D> context3d = | 5582 scoped_ptr<TestWebGraphicsContext3D> context3d = |
| 5574 TestWebGraphicsContext3D::Create(); | 5583 TestWebGraphicsContext3D::Create(); |
| 5575 context3d->set_support_image(true); | 5584 context3d->set_support_image(true); |
| 5576 context3d->set_support_sync_query(true); | 5585 context3d->set_support_sync_query(true); |
| 5577 | 5586 |
| 5578 if (delegating_renderer()) | 5587 if (delegating_renderer()) |
| 5579 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); | 5588 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); |
| 5580 else | 5589 else |
| 5581 return FakeOutputSurface::Create3d(context3d.Pass()); | 5590 return FakeOutputSurface::Create3d(context3d.Pass()); |
| 5582 } | 5591 } |
| 5583 }; | 5592 }; |
| 5584 | 5593 |
| 5585 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy); | 5594 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy); |
| 5586 | 5595 |
| 5587 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles | 5596 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles |
| 5588 : public LayerTreeHostTest { | 5597 : public LayerTreeHostTest { |
| 5589 protected: | 5598 protected: |
| 5590 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() | 5599 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() |
| 5591 : playback_allowed_event_(true, true) {} | 5600 : playback_allowed_event_(true, true) {} |
| 5592 | 5601 |
| 5593 void InitializeSettings(LayerTreeSettings* settings) override { | 5602 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5594 settings->impl_side_painting = true; | 5603 settings->impl_side_painting = true; |
| 5595 } | 5604 } |
| 5596 | 5605 |
| 5597 void SetupTree() override { | 5606 void SetupTree() override { |
| 5598 step_ = 1; | 5607 step_ = 1; |
| 5599 continuous_draws_ = 0; | 5608 continuous_draws_ = 0; |
| 5609 expect_draw_ = false; | |
| 5600 client_.set_fill_with_nonsolid_color(true); | 5610 client_.set_fill_with_nonsolid_color(true); |
| 5601 | 5611 |
| 5602 scoped_refptr<Layer> root = Layer::Create(); | 5612 scoped_refptr<Layer> root = Layer::Create(); |
| 5603 root->SetBounds(gfx::Size(500, 500)); | 5613 root->SetBounds(gfx::Size(500, 500)); |
| 5604 | 5614 |
| 5605 scoped_refptr<Layer> pinch = Layer::Create(); | 5615 scoped_refptr<Layer> pinch = Layer::Create(); |
| 5606 pinch->SetBounds(gfx::Size(500, 500)); | 5616 pinch->SetBounds(gfx::Size(500, 500)); |
| 5607 pinch->SetScrollClipLayerId(root->id()); | 5617 pinch->SetScrollClipLayerId(root->id()); |
| 5608 pinch->SetIsContainerForFixedPositionLayers(true); | 5618 pinch->SetIsContainerForFixedPositionLayers(true); |
| 5609 root->AddChild(pinch); | 5619 root->AddChild(pinch); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5677 | 5687 |
| 5678 // We should not continue to draw any more. End the test after a timeout | 5688 // We should not continue to draw any more. End the test after a timeout |
| 5679 // to watch for any extraneous draws. | 5689 // to watch for any extraneous draws. |
| 5680 // TODO(brianderson): We could remove this delay and instead wait until | 5690 // TODO(brianderson): We could remove this delay and instead wait until |
| 5681 // the BeginFrameSource decides it doesn't need to send frames anymore, | 5691 // the BeginFrameSource decides it doesn't need to send frames anymore, |
| 5682 // or test that it already doesn't here. | 5692 // or test that it already doesn't here. |
| 5683 EndTestAfterDelayMs(16 * 4); | 5693 EndTestAfterDelayMs(16 * 4); |
| 5684 ++step_; | 5694 ++step_; |
| 5685 break; | 5695 break; |
| 5686 case 5: | 5696 case 5: |
| 5697 // We may get another draw if we activate due to the pinch (for eg. LCD | |
| 5698 // text gets disabled). | |
| 5699 if (expect_draw_) | |
| 5700 break; | |
| 5687 ADD_FAILURE() | 5701 ADD_FAILURE() |
| 5688 << "No draws should happen once we have a complete frame."; | 5702 << "No draws should happen once we have a complete frame."; |
| 5689 break; | 5703 break; |
| 5690 } | 5704 } |
| 5705 expect_draw_ = false; | |
| 5691 return draw_result; | 5706 return draw_result; |
| 5692 } | 5707 } |
| 5693 | 5708 |
| 5694 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 5709 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 5695 switch (step_) { | 5710 switch (step_) { |
| 5696 case 1: | 5711 case 1: |
| 5697 // Delay tile production. | 5712 // Delay tile production. |
| 5698 playback_allowed_event_.Reset(); | 5713 playback_allowed_event_.Reset(); |
| 5699 // Pinch zoom in to cause new tiles to be required. | 5714 // Pinch zoom in to cause new tiles to be required. |
| 5700 host_impl->PinchGestureBegin(); | 5715 host_impl->PinchGestureBegin(); |
| 5701 host_impl->PinchGestureUpdate(1.5f, gfx::Point(100, 100)); | 5716 host_impl->PinchGestureUpdate(1.5f, gfx::Point(100, 100)); |
| 5702 host_impl->PinchGestureEnd(); | 5717 host_impl->PinchGestureEnd(); |
| 5703 ++step_; | 5718 ++step_; |
| 5704 break; | 5719 break; |
| 5705 case 2: | 5720 case 2: |
| 5706 ++step_; | 5721 ++step_; |
| 5707 break; | 5722 break; |
| 5708 case 3: | 5723 case 3: |
| 5709 // We should continue to try draw while there are incomplete visible | 5724 // We should continue to try draw while there are incomplete visible |
| 5710 // tiles. | 5725 // tiles. |
| 5711 if (++continuous_draws_ > 5) { | 5726 if (++continuous_draws_ > 5) { |
| 5712 // Allow the tiles to complete. | 5727 // Allow the tiles to complete. |
| 5713 playback_allowed_event_.Signal(); | 5728 playback_allowed_event_.Signal(); |
| 5714 ++step_; | 5729 ++step_; |
| 5715 } | 5730 } |
| 5716 break; | 5731 break; |
| 5717 } | 5732 } |
| 5718 } | 5733 } |
| 5719 | 5734 |
| 5735 void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | |
| 5736 expect_draw_ = true; | |
| 5737 } | |
| 5738 | |
| 5720 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, | 5739 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, |
| 5721 const Tile* tile) override { | 5740 const Tile* tile) override { |
| 5722 // On step_ == 2, we are preventing texture uploads from completing, | 5741 // On step_ == 2, we are preventing texture uploads from completing, |
| 5723 // so this verifies they are not completing before step_ == 3. | 5742 // so this verifies they are not completing before step_ == 3. |
| 5724 // Flaky failures here indicate we're failing to prevent uploads from | 5743 // Flaky failures here indicate we're failing to prevent uploads from |
| 5725 // completing. | 5744 // completing. |
| 5726 EXPECT_NE(2, step_); | 5745 EXPECT_NE(2, step_); |
| 5727 } | 5746 } |
| 5728 | 5747 |
| 5729 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); } | 5748 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); } |
| 5730 | 5749 |
| 5731 FakeContentLayerClient client_; | 5750 FakeContentLayerClient client_; |
| 5732 int step_; | 5751 int step_; |
| 5733 int continuous_draws_; | 5752 int continuous_draws_; |
| 5753 bool expect_draw_; | |
| 5734 base::WaitableEvent playback_allowed_event_; | 5754 base::WaitableEvent playback_allowed_event_; |
| 5735 }; | 5755 }; |
| 5736 | 5756 |
| 5737 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); | 5757 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); |
| 5738 | 5758 |
| 5739 } // namespace cc | 5759 } // namespace cc |
| OLD | NEW |