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

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

Issue 737943002: Update from https://crrev.com/304715 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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
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 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 void SetTestLayer(Layer* test_layer) { test_layer_ = test_layer; } 1105 void SetTestLayer(Layer* test_layer) { test_layer_ = test_layer; }
1106 1106
1107 void PaintContents( 1107 void PaintContents(
1108 SkCanvas* canvas, 1108 SkCanvas* canvas,
1109 const gfx::Rect& clip, 1109 const gfx::Rect& clip,
1110 ContentLayerClient::GraphicsContextStatus gc_status) override { 1110 ContentLayerClient::GraphicsContextStatus gc_status) override {
1111 // Set layer opacity to 0. 1111 // Set layer opacity to 0.
1112 if (test_layer_) 1112 if (test_layer_)
1113 test_layer_->SetOpacity(0.f); 1113 test_layer_->SetOpacity(0.f);
1114 } 1114 }
1115 void DidChangeLayerCanUseLCDText() override {}
1116 bool FillsBoundsCompletely() const override { return false; } 1115 bool FillsBoundsCompletely() const override { return false; }
1117 1116
1118 private: 1117 private:
1119 Layer* test_layer_; 1118 Layer* test_layer_;
1120 }; 1119 };
1121 1120
1122 class ContentLayerWithUpdateTracking : public ContentLayer { 1121 class ContentLayerWithUpdateTracking : public ContentLayer {
1123 public: 1122 public:
1124 static scoped_refptr<ContentLayerWithUpdateTracking> Create( 1123 static scoped_refptr<ContentLayerWithUpdateTracking> Create(
1125 ContentLayerClient* client) { 1124 ContentLayerClient* client) {
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2299 FakeContentLayerClient client_; 2298 FakeContentLayerClient client_;
2300 scoped_refptr<FakeContentLayer> root_layer_; 2299 scoped_refptr<FakeContentLayer> root_layer_;
2301 scoped_refptr<FakeContentLayer> child_layer1_; 2300 scoped_refptr<FakeContentLayer> child_layer1_;
2302 scoped_refptr<FakeContentLayer> child_layer2_; 2301 scoped_refptr<FakeContentLayer> child_layer2_;
2303 int num_commits_; 2302 int num_commits_;
2304 }; 2303 };
2305 2304
2306 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( 2305 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
2307 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted); 2306 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted);
2308 2307
2309 class LayerTreeHostTestLCDNotification : public LayerTreeHostTest { 2308 class LayerTreeHostTestLCDChange : public LayerTreeHostTest {
2310 public: 2309 public:
2311 class NotificationClient : public ContentLayerClient { 2310 class PaintClient : public FakeContentLayerClient {
2312 public: 2311 public:
2313 NotificationClient() 2312 PaintClient() : paint_count_(0) {}
2314 : layer_(0), paint_count_(0), lcd_notification_count_(0) {}
2315 2313
2316 void set_layer(Layer* layer) { layer_ = layer; }
2317 int paint_count() const { return paint_count_; } 2314 int paint_count() const { return paint_count_; }
2318 int lcd_notification_count() const { return lcd_notification_count_; }
2319 2315
2320 void PaintContents( 2316 void PaintContents(
2321 SkCanvas* canvas, 2317 SkCanvas* canvas,
2322 const gfx::Rect& clip, 2318 const gfx::Rect& clip,
2323 ContentLayerClient::GraphicsContextStatus gc_status) override { 2319 ContentLayerClient::GraphicsContextStatus gc_status) override {
2320 FakeContentLayerClient::PaintContents(canvas, clip, gc_status);
2324 ++paint_count_; 2321 ++paint_count_;
2325 } 2322 }
2326 void DidChangeLayerCanUseLCDText() override { 2323
2327 ++lcd_notification_count_;
2328 layer_->SetNeedsDisplay();
2329 }
2330 bool FillsBoundsCompletely() const override { return false; } 2324 bool FillsBoundsCompletely() const override { return false; }
2331 2325
2332 private: 2326 private:
2333 Layer* layer_;
2334 int paint_count_; 2327 int paint_count_;
2335 int lcd_notification_count_;
2336 }; 2328 };
2337 2329
2338 void SetupTree() override { 2330 void SetupTree() override {
2331 num_tiles_rastered_ = 0;
2332
2339 scoped_refptr<Layer> root_layer; 2333 scoped_refptr<Layer> root_layer;
2340 if (layer_tree_host()->settings().impl_side_painting) 2334 if (layer_tree_host()->settings().impl_side_painting)
2341 root_layer = PictureLayer::Create(&client_); 2335 root_layer = PictureLayer::Create(&client_);
2342 else 2336 else
2343 root_layer = ContentLayer::Create(&client_); 2337 root_layer = ContentLayer::Create(&client_);
2338 client_.set_fill_with_nonsolid_color(true);
2344 root_layer->SetIsDrawable(true); 2339 root_layer->SetIsDrawable(true);
2345 root_layer->SetBounds(gfx::Size(1, 1)); 2340 root_layer->SetBounds(gfx::Size(10, 10));
2341 root_layer->SetContentsOpaque(true);
2346 2342
2347 layer_tree_host()->SetRootLayer(root_layer); 2343 layer_tree_host()->SetRootLayer(root_layer);
2348 client_.set_layer(root_layer.get());
2349 2344
2350 // The expecations are based on the assumption that the default 2345 // The expecations are based on the assumption that the default
2351 // LCD settings are: 2346 // LCD settings are:
2352 EXPECT_TRUE(layer_tree_host()->settings().can_use_lcd_text); 2347 EXPECT_TRUE(layer_tree_host()->settings().can_use_lcd_text);
2353 EXPECT_FALSE(root_layer->can_use_lcd_text()); 2348 EXPECT_FALSE(root_layer->can_use_lcd_text());
2354 2349
2355 LayerTreeHostTest::SetupTree(); 2350 LayerTreeHostTest::SetupTree();
2356 } 2351 }
2357 2352
2358 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 2353 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2359 void AfterTest() override {}
2360 2354
2361 void DidCommit() override { 2355 void DidCommitAndDrawFrame() override {
2362 switch (layer_tree_host()->source_frame_number()) { 2356 switch (layer_tree_host()->source_frame_number()) {
2363 case 1: 2357 case 1:
2364 // The first update consists of one LCD notification and one paint. 2358 // The first update consists of a paint of the whole layer.
2365 EXPECT_EQ(1, client_.lcd_notification_count());
2366 EXPECT_EQ(1, client_.paint_count()); 2359 EXPECT_EQ(1, client_.paint_count());
2367 // LCD text must have been enabled on the layer. 2360 // LCD text must have been enabled on the layer.
2368 EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text()); 2361 EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text());
2369 PostSetNeedsCommitToMainThread(); 2362 PostSetNeedsCommitToMainThread();
2370 break; 2363 break;
2371 case 2: 2364 case 2:
2372 // Since nothing changed on layer, there should be no notification 2365 // Since nothing changed on layer, there should be no paint.
2373 // or paint on the second update.
2374 EXPECT_EQ(1, client_.lcd_notification_count());
2375 EXPECT_EQ(1, client_.paint_count()); 2366 EXPECT_EQ(1, client_.paint_count());
2376 // LCD text must not have changed. 2367 // LCD text must not have changed.
2377 EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text()); 2368 EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text());
2378 // Change layer opacity that should trigger lcd notification. 2369 // Change layer opacity that should trigger lcd change.
2379 layer_tree_host()->root_layer()->SetOpacity(.5f); 2370 layer_tree_host()->root_layer()->SetOpacity(.5f);
2380 // No need to request a commit - setting opacity will do it.
2381 break; 2371 break;
2382 default: 2372 case 3:
2383 // Verify that there is no extra commit due to layer invalidation. 2373 // LCD text doesn't require re-recording, so no painting should occur.
2384 EXPECT_EQ(3, layer_tree_host()->source_frame_number()); 2374 EXPECT_EQ(1, client_.paint_count());
2385 // LCD notification count should have incremented due to
2386 // change in layer opacity.
2387 EXPECT_EQ(2, client_.lcd_notification_count());
2388 // Paint count should be incremented due to invalidation.
2389 EXPECT_EQ(2, client_.paint_count());
2390 // LCD text must have been disabled on the layer due to opacity. 2375 // LCD text must have been disabled on the layer due to opacity.
2391 EXPECT_FALSE(layer_tree_host()->root_layer()->can_use_lcd_text()); 2376 EXPECT_FALSE(layer_tree_host()->root_layer()->can_use_lcd_text());
2377 // Change layer opacity that should not trigger lcd change.
2378 layer_tree_host()->root_layer()->SetOpacity(1.f);
2379 break;
2380 case 4:
2381 // LCD text doesn't require re-recording, so no painting should occur.
2382 EXPECT_EQ(1, client_.paint_count());
2383 // Even though LCD text could be allowed.
2384 EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text());
2392 EndTest(); 2385 EndTest();
2393 break; 2386 break;
2394 } 2387 }
2395 } 2388 }
2396 2389
2390 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl,
2391 const Tile* tile) override {
2392 ++num_tiles_rastered_;
2393 }
2394
2395 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
2396 switch (host_impl->active_tree()->source_frame_number()) {
2397 case 0:
2398 // The first draw.
2399 EXPECT_EQ(1, num_tiles_rastered_);
2400 break;
2401 case 1:
2402 // Nothing changed on the layer.
2403 EXPECT_EQ(1, num_tiles_rastered_);
2404 break;
2405 case 2:
2406 // LCD text was disabled, it should be re-rastered with LCD text off.
2407 EXPECT_EQ(2, num_tiles_rastered_);
2408 break;
2409 case 3:
2410 // LCD text was enabled but it's sticky and stays off.
2411 EXPECT_EQ(2, num_tiles_rastered_);
2412 break;
2413 }
2414 }
2415
2416 void AfterTest() override {}
2417
2397 private: 2418 private:
2398 NotificationClient client_; 2419 PaintClient client_;
2420 int num_tiles_rastered_;
2399 }; 2421 };
2400 2422
2401 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDNotification); 2423 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestLCDChange);
2402 2424
2403 // Verify that the BeginFrame notification is used to initiate rendering. 2425 // Verify that the BeginFrame notification is used to initiate rendering.
2404 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { 2426 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest {
2405 public: 2427 public:
2406 void InitializeSettings(LayerTreeSettings* settings) override { 2428 void InitializeSettings(LayerTreeSettings* settings) override {
2407 settings->use_external_begin_frame_source = true; 2429 settings->use_external_begin_frame_source = true;
2408 } 2430 }
2409 2431
2410 void BeginTest() override { 2432 void BeginTest() override {
2411 // This will trigger a SetNeedsBeginFrame which will trigger a 2433 // This will trigger a SetNeedsBeginFrame which will trigger a
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2562 2584
2563 void set_layer(Layer* layer) { layer_ = layer; } 2585 void set_layer(Layer* layer) { layer_ = layer; }
2564 2586
2565 void PaintContents( 2587 void PaintContents(
2566 SkCanvas* canvas, 2588 SkCanvas* canvas,
2567 const gfx::Rect& clip, 2589 const gfx::Rect& clip,
2568 ContentLayerClient::GraphicsContextStatus gc_status) override { 2590 ContentLayerClient::GraphicsContextStatus gc_status) override {
2569 layer_->SetBounds(gfx::Size(2, 2)); 2591 layer_->SetBounds(gfx::Size(2, 2));
2570 } 2592 }
2571 2593
2572 void DidChangeLayerCanUseLCDText() override {}
2573
2574 bool FillsBoundsCompletely() const override { return false; } 2594 bool FillsBoundsCompletely() const override { return false; }
2575 2595
2576 private: 2596 private:
2577 Layer* layer_; 2597 Layer* layer_;
2578 }; 2598 };
2579 2599
2580 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {} 2600 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {}
2581 2601
2582 void SetupTree() override { 2602 void SetupTree() override {
2583 if (layer_tree_host()->settings().impl_side_painting) { 2603 if (layer_tree_host()->settings().impl_side_painting) {
(...skipping 2796 matching lines...) Expand 10 before | Expand all | Expand 10 after
5380 pinch->SetScrollClipLayerId(root->id()); 5400 pinch->SetScrollClipLayerId(root->id());
5381 pinch->SetIsContainerForFixedPositionLayers(true); 5401 pinch->SetIsContainerForFixedPositionLayers(true);
5382 root->AddChild(pinch); 5402 root->AddChild(pinch);
5383 5403
5384 scoped_ptr<FakePicturePile> pile(new FakePicturePile); 5404 scoped_ptr<FakePicturePile> pile(new FakePicturePile);
5385 pile->SetPlaybackAllowedEvent(&playback_allowed_event_); 5405 pile->SetPlaybackAllowedEvent(&playback_allowed_event_);
5386 scoped_refptr<FakePictureLayer> layer = 5406 scoped_refptr<FakePictureLayer> layer =
5387 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); 5407 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass());
5388 layer->SetBounds(gfx::Size(500, 500)); 5408 layer->SetBounds(gfx::Size(500, 500));
5389 layer->SetContentsOpaque(true); 5409 layer->SetContentsOpaque(true);
5410 // Avoid LCD text on the layer so we don't cause extra commits when we
5411 // pinch.
5412 layer->disable_lcd_text();
5390 pinch->AddChild(layer); 5413 pinch->AddChild(layer);
5391 5414
5392 layer_tree_host()->RegisterViewportLayers(root, pinch, pinch); 5415 layer_tree_host()->RegisterViewportLayers(root, pinch, pinch);
5393 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); 5416 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f);
5394 layer_tree_host()->SetRootLayer(root); 5417 layer_tree_host()->SetRootLayer(root);
5395 LayerTreeHostTest::SetupTree(); 5418 LayerTreeHostTest::SetupTree();
5396 } 5419 }
5397 5420
5398 // Returns the delta scale of all quads in the frame's root pass from their 5421 // Returns the delta scale of all quads in the frame's root pass from their
5399 // ideal, or 0 if they are not all the same. 5422 // ideal, or 0 if they are not all the same.
(...skipping 26 matching lines...) Expand all
5426 DrawResult draw_result) override { 5449 DrawResult draw_result) override {
5427 float quad_scale_delta = FrameQuadScaleDeltaFromIdeal(frame_data); 5450 float quad_scale_delta = FrameQuadScaleDeltaFromIdeal(frame_data);
5428 switch (frame_) { 5451 switch (frame_) {
5429 case 1: 5452 case 1:
5430 // Drew at page scale 1 before any pinching. 5453 // Drew at page scale 1 before any pinching.
5431 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); 5454 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor());
5432 EXPECT_EQ(1.f, quad_scale_delta); 5455 EXPECT_EQ(1.f, quad_scale_delta);
5433 PostNextAfterDraw(host_impl); 5456 PostNextAfterDraw(host_impl);
5434 break; 5457 break;
5435 case 2: 5458 case 2:
5436 // Wait for any activations that need to occur due to starting a pinch,
5437 // and drawing with a non-identity transform (for eg. LCD text being
5438 // disabled).
5439 if (host_impl->pending_tree())
5440 break;
5441 if (quad_scale_delta != 1.f) 5459 if (quad_scale_delta != 1.f)
5442 break; 5460 break;
5443 // Drew at page scale 1.5 after pinching in. 5461 // Drew at page scale 1.5 after pinching in.
5444 EXPECT_EQ(1.5f, host_impl->active_tree()->total_page_scale_factor()); 5462 EXPECT_EQ(1.5f, host_impl->active_tree()->total_page_scale_factor());
5445 EXPECT_EQ(1.f, quad_scale_delta); 5463 EXPECT_EQ(1.f, quad_scale_delta);
5446 PostNextAfterDraw(host_impl); 5464 PostNextAfterDraw(host_impl);
5447 break; 5465 break;
5448 case 3: 5466 case 3:
5449 // By pinching out, we will create a new tiling and raster it. This may 5467 // By pinching out, we will create a new tiling and raster it. This may
5450 // cause some additional draws, though we should still be drawing with 5468 // cause some additional draws, though we should still be drawing with
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
5575 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() 5593 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles()
5576 : playback_allowed_event_(true, true) {} 5594 : playback_allowed_event_(true, true) {}
5577 5595
5578 void InitializeSettings(LayerTreeSettings* settings) override { 5596 void InitializeSettings(LayerTreeSettings* settings) override {
5579 settings->impl_side_painting = true; 5597 settings->impl_side_painting = true;
5580 } 5598 }
5581 5599
5582 void SetupTree() override { 5600 void SetupTree() override {
5583 step_ = 1; 5601 step_ = 1;
5584 continuous_draws_ = 0; 5602 continuous_draws_ = 0;
5585 expect_draw_ = false;
5586 client_.set_fill_with_nonsolid_color(true); 5603 client_.set_fill_with_nonsolid_color(true);
5587 5604
5588 scoped_refptr<Layer> root = Layer::Create(); 5605 scoped_refptr<Layer> root = Layer::Create();
5589 root->SetBounds(gfx::Size(500, 500)); 5606 root->SetBounds(gfx::Size(500, 500));
5590 5607
5591 scoped_refptr<Layer> pinch = Layer::Create(); 5608 scoped_refptr<Layer> pinch = Layer::Create();
5592 pinch->SetBounds(gfx::Size(500, 500)); 5609 pinch->SetBounds(gfx::Size(500, 500));
5593 pinch->SetScrollClipLayerId(root->id()); 5610 pinch->SetScrollClipLayerId(root->id());
5594 pinch->SetIsContainerForFixedPositionLayers(true); 5611 pinch->SetIsContainerForFixedPositionLayers(true);
5595 root->AddChild(pinch); 5612 root->AddChild(pinch);
5596 5613
5597 scoped_ptr<FakePicturePile> pile(new FakePicturePile); 5614 scoped_ptr<FakePicturePile> pile(new FakePicturePile);
5598 pile->SetPlaybackAllowedEvent(&playback_allowed_event_); 5615 pile->SetPlaybackAllowedEvent(&playback_allowed_event_);
5599 scoped_refptr<FakePictureLayer> layer = 5616 scoped_refptr<FakePictureLayer> layer =
5600 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); 5617 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass());
5601 layer->SetBounds(gfx::Size(500, 500)); 5618 layer->SetBounds(gfx::Size(500, 500));
5602 layer->SetContentsOpaque(true); 5619 layer->SetContentsOpaque(true);
5620 // Avoid LCD text on the layer so we don't cause extra commits when we
5621 // pinch.
5622 layer->disable_lcd_text();
5603 pinch->AddChild(layer); 5623 pinch->AddChild(layer);
5604 5624
5605 layer_tree_host()->RegisterViewportLayers(root, pinch, pinch); 5625 layer_tree_host()->RegisterViewportLayers(root, pinch, pinch);
5606 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); 5626 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f);
5607 layer_tree_host()->SetRootLayer(root); 5627 layer_tree_host()->SetRootLayer(root);
5608 LayerTreeHostTest::SetupTree(); 5628 LayerTreeHostTest::SetupTree();
5609 } 5629 }
5610 5630
5611 // Returns the delta scale of all quads in the frame's root pass from their 5631 // Returns the delta scale of all quads in the frame's root pass from their
5612 // ideal, or 0 if they are not all the same. 5632 // ideal, or 0 if they are not all the same.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
5655 EXPECT_EQ(1.f / 1.5f, quad_scale_delta); 5675 EXPECT_EQ(1.f / 1.5f, quad_scale_delta);
5656 break; 5676 break;
5657 case 4: 5677 case 4:
5658 if (quad_scale_delta != 1.f) 5678 if (quad_scale_delta != 1.f)
5659 break; 5679 break;
5660 // Drew at scale 1.5 when all the tiles completed. 5680 // Drew at scale 1.5 when all the tiles completed.
5661 EXPECT_EQ(1.5f, host_impl->active_tree()->total_page_scale_factor()); 5681 EXPECT_EQ(1.5f, host_impl->active_tree()->total_page_scale_factor());
5662 EXPECT_EQ(1.f, quad_scale_delta); 5682 EXPECT_EQ(1.f, quad_scale_delta);
5663 break; 5683 break;
5664 case 5: 5684 case 5:
5665 // TODO(danakj): We may get one more draw because the NotifyReadyToDraw 5685 // TODO(danakj): We get more draws before the NotifyReadyToDraw
5666 // is asynchronous from the previous draw and happens late. 5686 // because it is asynchronous from the previous draw and happens late.
5667 break; 5687 break;
5668 case 6: 5688 case 6:
5669 // We may get another draw if we activate due to the pinch (eg LCD text 5689 // NotifyReadyToDraw happened. If we were already inside a frame, we may
5670 // gets disabled). 5690 // try to draw once more.
5671 if (expect_draw_) 5691 break;
5672 break; 5692 case 7:
5673 NOTREACHED() << "No draws should happen once we have a complete frame."; 5693 NOTREACHED() << "No draws should happen once we have a complete frame.";
5674 break; 5694 break;
5675 } 5695 }
5676 expect_draw_ = false;
5677 return draw_result; 5696 return draw_result;
5678 } 5697 }
5679 5698
5680 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 5699 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
5681 switch (step_) { 5700 switch (step_) {
5682 case 1: 5701 case 1:
5683 // Delay tile production. 5702 // Delay tile production.
5684 playback_allowed_event_.Reset(); 5703 playback_allowed_event_.Reset();
5685 // Pinch zoom in to cause new tiles to be required. 5704 // Pinch zoom in to cause new tiles to be required.
5686 host_impl->PinchGestureBegin(); 5705 host_impl->PinchGestureBegin();
5687 host_impl->PinchGestureUpdate(1.5f, gfx::Point(100, 100)); 5706 host_impl->PinchGestureUpdate(1.5f, gfx::Point(100, 100));
5688 host_impl->PinchGestureEnd(); 5707 host_impl->PinchGestureEnd();
5689 ++step_; 5708 ++step_;
5690 break; 5709 break;
5691 case 2: 5710 case 2:
5692 ++step_; 5711 ++step_;
5693 break; 5712 break;
5694 case 3: 5713 case 3:
5695 // We should continue to try draw while there are incomplete visible 5714 // We should continue to try draw while there are incomplete visible
5696 // tiles. 5715 // tiles.
5697 if (++continuous_draws_ > 5) { 5716 if (++continuous_draws_ > 5) {
5698 // Allow the tiles to complete. 5717 // Allow the tiles to complete.
5699 playback_allowed_event_.Signal(); 5718 playback_allowed_event_.Signal();
5700 ++step_; 5719 ++step_;
5701 } 5720 }
5702 break; 5721 break;
5703 case 4: 5722 case 4:
5704 // TODO(danakj): Now we wait for NotifyReadyToDraw to avoid flakiness 5723 ++step_;
5705 // since it happens asynchronously. 5724 break;
5725 case 5:
5726 // Waiting for NotifyReadyToDraw.
5727 break;
5728 case 6:
5729 // NotifyReadyToDraw happened.
5706 ++step_; 5730 ++step_;
5707 break; 5731 break;
5708 } 5732 }
5709 } 5733 }
5710 5734
5711 void NotifyReadyToDrawOnThread(LayerTreeHostImpl* host_impl) override { 5735 void NotifyReadyToDrawOnThread(LayerTreeHostImpl* host_impl) override {
5712 if (step_ == 5) { 5736 if (step_ == 5) {
5713 // We should not continue to draw any more. End the test after a timeout 5737 ++step_;
5714 // to watch for any extraneous draws. 5738 // NotifyReadyToDraw has happened, we may draw once more, but should not
5739 // get any more draws after that. End the test after a timeout to watch
5740 // for any extraneous draws.
5715 // TODO(brianderson): We could remove this delay and instead wait until 5741 // TODO(brianderson): We could remove this delay and instead wait until
5716 // the BeginFrameSource decides it doesn't need to send frames anymore, 5742 // the BeginFrameSource decides it doesn't need to send frames anymore,
5717 // or test that it already doesn't here. 5743 // or test that it already doesn't here.
5718 EndTestAfterDelayMs(16 * 4); 5744 EndTestAfterDelayMs(16 * 4);
5719 ++step_;
5720 expect_draw_ = true;
5721 } 5745 }
5722 } 5746 }
5723 5747
5724 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
5725 expect_draw_ = true;
5726 }
5727
5728 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, 5748 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl,
5729 const Tile* tile) override { 5749 const Tile* tile) override {
5730 // On step_ == 2, we are preventing texture uploads from completing, 5750 // On step_ == 2, we are preventing texture uploads from completing,
5731 // so this verifies they are not completing before step_ == 3. 5751 // so this verifies they are not completing before step_ == 3.
5732 // Flaky failures here indicate we're failing to prevent uploads from 5752 // Flaky failures here indicate we're failing to prevent uploads from
5733 // completing. 5753 // completing.
5734 EXPECT_NE(2, step_); 5754 EXPECT_NE(2, step_);
5735 } 5755 }
5736 5756
5737 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); } 5757 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); }
5738 5758
5739 FakeContentLayerClient client_; 5759 FakeContentLayerClient client_;
5740 int step_; 5760 int step_;
5741 int continuous_draws_; 5761 int continuous_draws_;
5742 bool expect_draw_;
5743 base::WaitableEvent playback_allowed_event_; 5762 base::WaitableEvent playback_allowed_event_;
5744 }; 5763 };
5745 5764
5746 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); 5765 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles);
5747 5766
5748 } // namespace cc 5767 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698