Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 732503005: cc: Unflake and re-enable the new pinch zoom unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: flakypinch: nowill Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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.
5488 EXPECT_TRUE(frame_data->has_no_damage); 5492 EXPECT_TRUE(frame_data->has_no_damage);
5489 PostNextAfterDraw(host_impl); 5493 PostNextAfterDraw(host_impl);
5490 break; 5494 break;
5491 case 5: 5495 case 5:
5492 if (quad_scale_delta != 1.f) 5496 if (quad_scale_delta != 1.f)
5493 break; 5497 break;
5494 // Drew at scale 1 after texture uploads are done. 5498 // Drew at scale 1 after texture uploads are done.
5495 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); 5499 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor());
5496 EXPECT_EQ(1.f, quad_scale_delta); 5500 EXPECT_EQ(1.f, quad_scale_delta);
5497 EndTest(); 5501 EndTest();
5498 break; 5502 break;
5499 } 5503 }
5500 return draw_result; 5504 return draw_result;
5501 } 5505 }
5502 5506
5503 void PostNextAfterDraw(LayerTreeHostImpl* host_impl) { 5507 void PostNextAfterDraw(LayerTreeHostImpl* host_impl) {
5504 if (posted_) 5508 if (posted_)
5505 return; 5509 return;
5506 posted_ = true; 5510 posted_ = true;
5507 ImplThreadTaskRunner()->PostDelayedTask( 5511 ImplThreadTaskRunner()->PostDelayedTask(
5508 FROM_HERE, base::Bind(&LayerTreeHostTestCrispUpAfterPinchEnds::Next, 5512 FROM_HERE, base::Bind(&LayerTreeHostTestCrispUpAfterPinchEnds::Next,
5509 base::Unretained(this), host_impl), 5513 base::Unretained(this), host_impl),
5510 // Use a delay to allow raster/upload to happen in between frames. This 5514 // 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 5515 // should cause flakiness if we fail to block raster/upload when
5512 // desired. 5516 // desired.
5513 base::TimeDelta::FromMilliseconds(16 * 6)); 5517 base::TimeDelta::FromMilliseconds(16 * 4));
5514 } 5518 }
5515 5519
5516 void Next(LayerTreeHostImpl* host_impl) { 5520 void Next(LayerTreeHostImpl* host_impl) {
5517 ++frame_; 5521 ++frame_;
5518 posted_ = false; 5522 posted_ = false;
5519 switch (frame_) { 5523 switch (frame_) {
5520 case 2: 5524 case 2:
5521 // Pinch zoom in. 5525 // Pinch zoom in.
5522 host_impl->PinchGestureBegin(); 5526 host_impl->PinchGestureBegin();
5523 host_impl->PinchGestureUpdate(2.2f, gfx::Point(100, 100)); 5527 host_impl->PinchGestureUpdate(1.5f, gfx::Point(100, 100));
5524 host_impl->PinchGestureEnd(); 5528 host_impl->PinchGestureEnd();
5525 break; 5529 break;
5526 case 3: 5530 case 3:
5527 // Pinch zoom back to 1.f but don't end it. 5531 // Pinch zoom back to 1.f but don't end it.
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 / 1.5f, 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 lower 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 EXPECT_EQ(0.75f, tile->contents_scale());
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 // TODO(danakj): Disabled for flake: crbug.com/433208 5594 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy);
5586 #if !defined(OS_LINUX) || defined(NDEBUG)
5587 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy);
5588 #endif
5589 5595
5590 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles 5596 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles
5591 : public LayerTreeHostTest { 5597 : public LayerTreeHostTest {
5592 protected: 5598 protected:
5593 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() 5599 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles()
5594 : playback_allowed_event_(true, true) {} 5600 : playback_allowed_event_(true, true) {}
5595 5601
5596 void InitializeSettings(LayerTreeSettings* settings) override { 5602 void InitializeSettings(LayerTreeSettings* settings) override {
5597 settings->impl_side_painting = true; 5603 settings->impl_side_painting = true;
5598 } 5604 }
5599 5605
5600 void SetupTree() override { 5606 void SetupTree() override {
5601 step_ = 1; 5607 step_ = 1;
5602 continuous_draws_ = 0; 5608 continuous_draws_ = 0;
5609 expect_draw_ = false;
5603 client_.set_fill_with_nonsolid_color(true); 5610 client_.set_fill_with_nonsolid_color(true);
5604 5611
5605 scoped_refptr<Layer> root = Layer::Create(); 5612 scoped_refptr<Layer> root = Layer::Create();
5606 root->SetBounds(gfx::Size(500, 500)); 5613 root->SetBounds(gfx::Size(500, 500));
5607 5614
5608 scoped_refptr<Layer> pinch = Layer::Create(); 5615 scoped_refptr<Layer> pinch = Layer::Create();
5609 pinch->SetBounds(gfx::Size(500, 500)); 5616 pinch->SetBounds(gfx::Size(500, 500));
5610 pinch->SetScrollClipLayerId(root->id()); 5617 pinch->SetScrollClipLayerId(root->id());
5611 pinch->SetIsContainerForFixedPositionLayers(true); 5618 pinch->SetIsContainerForFixedPositionLayers(true);
5612 root->AddChild(pinch); 5619 root->AddChild(pinch);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
5670 EXPECT_EQ(1.5f, host_impl->active_tree()->total_page_scale_factor()); 5677 EXPECT_EQ(1.5f, host_impl->active_tree()->total_page_scale_factor());
5671 if (!frame_data->has_no_damage) 5678 if (!frame_data->has_no_damage)
5672 EXPECT_EQ(1.f / 1.5f, quad_scale_delta); 5679 EXPECT_EQ(1.f / 1.5f, quad_scale_delta);
5673 break; 5680 break;
5674 case 4: 5681 case 4:
5675 if (quad_scale_delta != 1.f) 5682 if (quad_scale_delta != 1.f)
5676 break; 5683 break;
5677 // Drew at scale 1.5 when all the tiles completed. 5684 // Drew at scale 1.5 when all the tiles completed.
5678 EXPECT_EQ(1.5f, host_impl->active_tree()->total_page_scale_factor()); 5685 EXPECT_EQ(1.5f, host_impl->active_tree()->total_page_scale_factor());
5679 EXPECT_EQ(1.f, quad_scale_delta); 5686 EXPECT_EQ(1.f, quad_scale_delta);
5680
5681 // We should not continue to draw any more. End the test after a timeout
5682 // to watch for any extraneous draws.
5683 // TODO(brianderson): We could remove this delay and instead wait until
5684 // the BeginFrameSource decides it doesn't need to send frames anymore,
5685 // or test that it already doesn't here.
5686 EndTestAfterDelayMs(16 * 4);
5687 ++step_;
5688 break; 5687 break;
5689 case 5: 5688 case 5:
5690 ADD_FAILURE() 5689 // TODO(danakj): We may get one more draw because the NotifyReadyToDraw
5691 << "No draws should happen once we have a complete frame."; 5690 // is asynchronous from the previous draw and happens late.
5691 break;
5692 case 6:
5693 // We may get another draw if we activate due to the pinch (eg LCD text
enne (OOO) 2014/11/17 19:25:13 Weird. Could you just start without LCD text enab
danakj 2014/11/17 19:28:36 In the LCD patch, the layer gets init with LCD tru
enne (OOO) 2014/11/17 20:37:50 I think it'd be worth doing (maybe with opacity !=
5694 // gets disabled).
5695 if (expect_draw_)
5696 break;
5697 NOTREACHED() << "No draws should happen once we have a complete frame.";
5692 break; 5698 break;
5693 } 5699 }
5700 expect_draw_ = false;
5694 return draw_result; 5701 return draw_result;
5695 } 5702 }
5696 5703
5697 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 5704 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
5698 switch (step_) { 5705 switch (step_) {
5699 case 1: 5706 case 1:
5700 // Delay tile production. 5707 // Delay tile production.
5701 playback_allowed_event_.Reset(); 5708 playback_allowed_event_.Reset();
5702 // Pinch zoom in to cause new tiles to be required. 5709 // Pinch zoom in to cause new tiles to be required.
5703 host_impl->PinchGestureBegin(); 5710 host_impl->PinchGestureBegin();
5704 host_impl->PinchGestureUpdate(1.5f, gfx::Point(100, 100)); 5711 host_impl->PinchGestureUpdate(1.5f, gfx::Point(100, 100));
5705 host_impl->PinchGestureEnd(); 5712 host_impl->PinchGestureEnd();
5706 ++step_; 5713 ++step_;
5707 break; 5714 break;
5708 case 2: 5715 case 2:
5709 ++step_; 5716 ++step_;
5710 break; 5717 break;
5711 case 3: 5718 case 3:
5712 // We should continue to try draw while there are incomplete visible 5719 // We should continue to try draw while there are incomplete visible
5713 // tiles. 5720 // tiles.
5714 if (++continuous_draws_ > 5) { 5721 if (++continuous_draws_ > 5) {
5715 // Allow the tiles to complete. 5722 // Allow the tiles to complete.
5716 playback_allowed_event_.Signal(); 5723 playback_allowed_event_.Signal();
5717 ++step_; 5724 ++step_;
5718 } 5725 }
5719 break; 5726 break;
5727 case 4:
5728 // TODO(danakj): Now we wait for NotifyReadyToDraw to avoid flakiness
5729 // since it happens asynchronously.
5730 ++step_;
5731 break;
5720 } 5732 }
5721 } 5733 }
5722 5734
5735 void NotifyReadyToDrawOnThread(LayerTreeHostImpl* host_impl) override {
5736 if (step_ == 5) {
5737 // We should not continue to draw any more. End the test after a timeout
5738 // to watch for any extraneous draws.
5739 // TODO(brianderson): We could remove this delay and instead wait until
5740 // the BeginFrameSource decides it doesn't need to send frames anymore,
5741 // or test that it already doesn't here.
5742 EndTestAfterDelayMs(16 * 4);
5743 ++step_;
5744 expect_draw_ = true;
5745 }
5746 }
5747
5748 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
5749 expect_draw_ = true;
5750 }
5751
5723 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, 5752 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl,
5724 const Tile* tile) override { 5753 const Tile* tile) override {
5725 // On step_ == 2, we are preventing texture uploads from completing, 5754 // On step_ == 2, we are preventing texture uploads from completing,
5726 // so this verifies they are not completing before step_ == 3. 5755 // so this verifies they are not completing before step_ == 3.
5727 // Flaky failures here indicate we're failing to prevent uploads from 5756 // Flaky failures here indicate we're failing to prevent uploads from
5728 // completing. 5757 // completing.
5729 EXPECT_NE(2, step_); 5758 EXPECT_NE(2, step_);
5730 } 5759 }
5731 5760
5732 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); } 5761 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); }
5733 5762
5734 FakeContentLayerClient client_; 5763 FakeContentLayerClient client_;
5735 int step_; 5764 int step_;
5736 int continuous_draws_; 5765 int continuous_draws_;
5766 bool expect_draw_;
5737 base::WaitableEvent playback_allowed_event_; 5767 base::WaitableEvent playback_allowed_event_;
5738 }; 5768 };
5739 5769
5740 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); 5770 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles);
5741 5771
5742 } // namespace cc 5772 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698