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" |
11 #include "cc/animation/timing_function.h" | 11 #include "cc/animation/timing_function.h" |
12 #include "cc/base/swap_promise.h" | 12 #include "cc/base/swap_promise.h" |
13 #include "cc/debug/frame_rate_counter.h" | 13 #include "cc/debug/frame_rate_counter.h" |
14 #include "cc/layers/content_layer.h" | 14 #include "cc/layers/content_layer.h" |
15 #include "cc/layers/content_layer_client.h" | 15 #include "cc/layers/content_layer_client.h" |
16 #include "cc/layers/io_surface_layer.h" | 16 #include "cc/layers/io_surface_layer.h" |
17 #include "cc/layers/layer_impl.h" | 17 #include "cc/layers/layer_impl.h" |
18 #include "cc/layers/painted_scrollbar_layer.h" | 18 #include "cc/layers/painted_scrollbar_layer.h" |
19 #include "cc/layers/picture_layer.h" | 19 #include "cc/layers/picture_layer.h" |
20 #include "cc/layers/solid_color_layer.h" | 20 #include "cc/layers/solid_color_layer.h" |
21 #include "cc/layers/video_layer.h" | 21 #include "cc/layers/video_layer.h" |
22 #include "cc/output/begin_frame_args.h" | 22 #include "cc/output/begin_frame_args.h" |
23 #include "cc/output/compositor_frame_ack.h" | 23 #include "cc/output/compositor_frame_ack.h" |
24 #include "cc/output/copy_output_request.h" | 24 #include "cc/output/copy_output_request.h" |
25 #include "cc/output/copy_output_result.h" | 25 #include "cc/output/copy_output_result.h" |
26 #include "cc/output/output_surface.h" | 26 #include "cc/output/output_surface.h" |
27 #include "cc/quads/draw_quad.h" | 27 #include "cc/quads/draw_quad.h" |
28 #include "cc/quads/io_surface_draw_quad.h" | 28 #include "cc/quads/io_surface_draw_quad.h" |
| 29 #include "cc/quads/tile_draw_quad.h" |
29 #include "cc/resources/prioritized_resource.h" | 30 #include "cc/resources/prioritized_resource.h" |
30 #include "cc/resources/prioritized_resource_manager.h" | 31 #include "cc/resources/prioritized_resource_manager.h" |
31 #include "cc/resources/resource_update_queue.h" | 32 #include "cc/resources/resource_update_queue.h" |
32 #include "cc/test/fake_content_layer.h" | 33 #include "cc/test/fake_content_layer.h" |
33 #include "cc/test/fake_content_layer_client.h" | 34 #include "cc/test/fake_content_layer_client.h" |
34 #include "cc/test/fake_content_layer_impl.h" | 35 #include "cc/test/fake_content_layer_impl.h" |
35 #include "cc/test/fake_layer_tree_host_client.h" | 36 #include "cc/test/fake_layer_tree_host_client.h" |
36 #include "cc/test/fake_output_surface.h" | 37 #include "cc/test/fake_output_surface.h" |
37 #include "cc/test/fake_painted_scrollbar_layer.h" | 38 #include "cc/test/fake_painted_scrollbar_layer.h" |
38 #include "cc/test/fake_picture_layer.h" | 39 #include "cc/test/fake_picture_layer.h" |
39 #include "cc/test/fake_picture_layer_impl.h" | 40 #include "cc/test/fake_picture_layer_impl.h" |
| 41 #include "cc/test/fake_picture_pile.h" |
40 #include "cc/test/fake_proxy.h" | 42 #include "cc/test/fake_proxy.h" |
41 #include "cc/test/fake_scoped_ui_resource.h" | 43 #include "cc/test/fake_scoped_ui_resource.h" |
42 #include "cc/test/fake_video_frame_provider.h" | 44 #include "cc/test/fake_video_frame_provider.h" |
43 #include "cc/test/geometry_test_utils.h" | 45 #include "cc/test/geometry_test_utils.h" |
44 #include "cc/test/layer_tree_test.h" | 46 #include "cc/test/layer_tree_test.h" |
45 #include "cc/test/test_shared_bitmap_manager.h" | 47 #include "cc/test/test_shared_bitmap_manager.h" |
46 #include "cc/test/test_web_graphics_context_3d.h" | 48 #include "cc/test/test_web_graphics_context_3d.h" |
| 49 #include "cc/test/thread_blocker.h" |
47 #include "cc/trees/layer_tree_host_impl.h" | 50 #include "cc/trees/layer_tree_host_impl.h" |
48 #include "cc/trees/layer_tree_impl.h" | 51 #include "cc/trees/layer_tree_impl.h" |
49 #include "cc/trees/single_thread_proxy.h" | 52 #include "cc/trees/single_thread_proxy.h" |
50 #include "cc/trees/thread_proxy.h" | 53 #include "cc/trees/thread_proxy.h" |
51 #include "gpu/GLES2/gl2extchromium.h" | 54 #include "gpu/GLES2/gl2extchromium.h" |
52 #include "skia/ext/refptr.h" | 55 #include "skia/ext/refptr.h" |
53 #include "testing/gmock/include/gmock/gmock.h" | 56 #include "testing/gmock/include/gmock/gmock.h" |
54 #include "third_party/khronos/GLES2/gl2.h" | 57 #include "third_party/khronos/GLES2/gl2.h" |
55 #include "third_party/khronos/GLES2/gl2ext.h" | 58 #include "third_party/khronos/GLES2/gl2ext.h" |
56 #include "third_party/skia/include/core/SkPicture.h" | 59 #include "third_party/skia/include/core/SkPicture.h" |
(...skipping 4960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5017 void InitializeSettings(LayerTreeSettings* settings) override { | 5020 void InitializeSettings(LayerTreeSettings* settings) override { |
5018 settings->impl_side_painting = true; | 5021 settings->impl_side_painting = true; |
5019 | 5022 |
5020 EXPECT_FALSE(settings->gpu_rasterization_forced); | 5023 EXPECT_FALSE(settings->gpu_rasterization_forced); |
5021 settings->gpu_rasterization_forced = true; | 5024 settings->gpu_rasterization_forced = true; |
5022 } | 5025 } |
5023 | 5026 |
5024 void SetupTree() override { | 5027 void SetupTree() override { |
5025 LayerTreeHostTest::SetupTree(); | 5028 LayerTreeHostTest::SetupTree(); |
5026 | 5029 |
5027 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_); | 5030 scoped_refptr<FakePictureLayer> layer = |
| 5031 FakePictureLayer::Create(&layer_client_); |
5028 layer->SetBounds(gfx::Size(10, 10)); | 5032 layer->SetBounds(gfx::Size(10, 10)); |
5029 layer->SetIsDrawable(true); | 5033 layer->SetIsDrawable(true); |
5030 layer_tree_host()->root_layer()->AddChild(layer); | 5034 layer_tree_host()->root_layer()->AddChild(layer); |
5031 } | 5035 } |
5032 | 5036 |
5033 void BeginTest() override { | 5037 void BeginTest() override { |
5034 Layer* root = layer_tree_host()->root_layer(); | 5038 Layer* root = layer_tree_host()->root_layer(); |
5035 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); | 5039 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); |
5036 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 5040 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
5037 | 5041 |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5347 | 5351 |
5348 void AfterTest() override { | 5352 void AfterTest() override { |
5349 EXPECT_TRUE(deltas_sent_to_client_); | 5353 EXPECT_TRUE(deltas_sent_to_client_); |
5350 } | 5354 } |
5351 | 5355 |
5352 ScrollAndScaleSet info_; | 5356 ScrollAndScaleSet info_; |
5353 bool deltas_sent_to_client_; | 5357 bool deltas_sent_to_client_; |
5354 }; | 5358 }; |
5355 | 5359 |
5356 MULTI_THREAD_TEST_F(LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer); | 5360 MULTI_THREAD_TEST_F(LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer); |
| 5361 |
| 5362 class LayerTreeHostTestCrispUpAfterPinchEnds : public LayerTreeHostTest { |
| 5363 protected: |
| 5364 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5365 settings->impl_side_painting = true; |
| 5366 } |
| 5367 |
| 5368 void SetupTree() override { |
| 5369 frame_ = 1; |
| 5370 posted_ = false; |
| 5371 client_.set_fill_with_nonsolid_color(true); |
| 5372 |
| 5373 scoped_refptr<Layer> root = Layer::Create(); |
| 5374 root->SetBounds(gfx::Size(500, 500)); |
| 5375 |
| 5376 scoped_refptr<Layer> pinch = Layer::Create(); |
| 5377 pinch->SetBounds(gfx::Size(500, 500)); |
| 5378 pinch->SetScrollClipLayerId(root->id()); |
| 5379 pinch->SetIsContainerForFixedPositionLayers(true); |
| 5380 root->AddChild(pinch); |
| 5381 |
| 5382 scoped_refptr<FakePictureLayer> layer = |
| 5383 FakePictureLayer::CreateWithRecordingSource( |
| 5384 &client_, |
| 5385 make_scoped_ptr(new FakePicturePile(&raster_thread_blocker_))); |
| 5386 layer->SetBounds(gfx::Size(500, 500)); |
| 5387 layer->SetContentsOpaque(true); |
| 5388 pinch->AddChild(layer); |
| 5389 |
| 5390 layer_tree_host()->RegisterViewportLayers(root, pinch, pinch); |
| 5391 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); |
| 5392 layer_tree_host()->SetRootLayer(root); |
| 5393 LayerTreeHostTest::SetupTree(); |
| 5394 } |
| 5395 |
| 5396 // Returns the delta scale of all quads in the frame's root pass from their |
| 5397 // ideal, or 0 if they are not all the same. |
| 5398 float FrameQuadScaleDeltaFromIdeal(LayerTreeHostImpl::FrameData* frame_data) { |
| 5399 if (frame_data->has_no_damage) |
| 5400 return 0.f; |
| 5401 float frame_scale = 0.f; |
| 5402 RenderPass* root_pass = frame_data->render_passes.back(); |
| 5403 for (const auto& draw_quad : root_pass->quad_list) { |
| 5404 // Checkerboards mean an incomplete frame. |
| 5405 if (draw_quad->material != DrawQuad::TILED_CONTENT) |
| 5406 return 0.f; |
| 5407 const TileDrawQuad* quad = TileDrawQuad::MaterialCast(draw_quad); |
| 5408 float quad_scale = |
| 5409 quad->tex_coord_rect.width() / static_cast<float>(quad->rect.width()); |
| 5410 float transform_scale = |
| 5411 SkMScalarToFloat(quad->quadTransform().matrix().get(0, 0)); |
| 5412 float scale = quad_scale / transform_scale; |
| 5413 if (frame_scale != 0.f && frame_scale != scale) |
| 5414 return 0.f; |
| 5415 frame_scale = scale; |
| 5416 } |
| 5417 return frame_scale; |
| 5418 } |
| 5419 |
| 5420 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 5421 |
| 5422 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 5423 LayerTreeHostImpl::FrameData* frame_data, |
| 5424 DrawResult draw_result) override { |
| 5425 float quad_scale_delta = FrameQuadScaleDeltaFromIdeal(frame_data); |
| 5426 switch (frame_) { |
| 5427 case 1: |
| 5428 // Drew at page scale 1 before any pinching. |
| 5429 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); |
| 5430 EXPECT_EQ(1.f, quad_scale_delta); |
| 5431 PostNextAfterDraw(host_impl); |
| 5432 break; |
| 5433 case 2: |
| 5434 if (quad_scale_delta != 1.f) |
| 5435 break; |
| 5436 // Drew at page scale 2.2 after pinching in. |
| 5437 EXPECT_EQ(2.2f, host_impl->active_tree()->total_page_scale_factor()); |
| 5438 EXPECT_EQ(1.f, quad_scale_delta); |
| 5439 PostNextAfterDraw(host_impl); |
| 5440 break; |
| 5441 case 3: |
| 5442 if (quad_scale_delta != 2.2f) |
| 5443 break; |
| 5444 // Drew at page scale 1 with the 2.2 tiling while pinching out. |
| 5445 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); |
| 5446 EXPECT_EQ(2.2f, quad_scale_delta); |
| 5447 PostNextAfterDraw(host_impl); |
| 5448 break; |
| 5449 case 4: |
| 5450 // Drew at page scale 1 with the 2.2 tiling after pinching out completed |
| 5451 // while waiting for texture uploads to complete. |
| 5452 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); |
| 5453 // This frame will not have any damage, since it's actually the same as |
| 5454 // the last frame, and should contain no incomplete tiles. We just want |
| 5455 // to make sure we drew here at least once after the pinch ended to be |
| 5456 // sure that drawing after pinch doesn't leave us at the wrong scale |
| 5457 // forever. |
| 5458 EXPECT_TRUE(frame_data->has_no_damage); |
| 5459 PostNextAfterDraw(host_impl); |
| 5460 break; |
| 5461 case 5: |
| 5462 if (quad_scale_delta != 1.f) |
| 5463 break; |
| 5464 // Drew at scale 1 after texture uploads are done. |
| 5465 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); |
| 5466 EXPECT_EQ(1.f, quad_scale_delta); |
| 5467 EndTest(); |
| 5468 break; |
| 5469 } |
| 5470 return draw_result; |
| 5471 } |
| 5472 |
| 5473 void PostNextAfterDraw(LayerTreeHostImpl* host_impl) { |
| 5474 if (posted_) |
| 5475 return; |
| 5476 posted_ = true; |
| 5477 ImplThreadTaskRunner()->PostDelayedTask( |
| 5478 FROM_HERE, base::Bind(&LayerTreeHostTestCrispUpAfterPinchEnds::Next, |
| 5479 base::Unretained(this), host_impl), |
| 5480 // Use a delay to allow raster/upload to happen in between frames. This |
| 5481 // should cause flakiness if we fail to block raster/upload when |
| 5482 // desired. |
| 5483 base::TimeDelta::FromMilliseconds(16 * 6)); |
| 5484 } |
| 5485 |
| 5486 void Next(LayerTreeHostImpl* host_impl) { |
| 5487 ++frame_; |
| 5488 posted_ = false; |
| 5489 switch (frame_) { |
| 5490 case 2: |
| 5491 // Pinch zoom in. |
| 5492 host_impl->PinchGestureBegin(); |
| 5493 host_impl->PinchGestureUpdate(2.2f, gfx::Point(100, 100)); |
| 5494 host_impl->PinchGestureEnd(); |
| 5495 break; |
| 5496 case 3: |
| 5497 // Pinch zoom back to 1.f but don't end it. |
| 5498 host_impl->PinchGestureBegin(); |
| 5499 host_impl->PinchGestureUpdate(1.f / 2.2f, gfx::Point(100, 100)); |
| 5500 break; |
| 5501 case 4: |
| 5502 // End the pinch, but delay tile production. |
| 5503 raster_thread_blocker_.BlockWait(); |
| 5504 host_impl->PinchGestureEnd(); |
| 5505 break; |
| 5506 case 5: |
| 5507 // Let tiles complete. |
| 5508 raster_thread_blocker_.UnblockWait(); |
| 5509 // TestContext()->set_query_result_available_ext(1); |
| 5510 break; |
| 5511 } |
| 5512 } |
| 5513 |
| 5514 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, |
| 5515 const Tile* tile) override { |
| 5516 // On frame_ == 4, we are preventing texture uploads from completing, |
| 5517 // so this verifies they are not completing before frame_ == 5. |
| 5518 // Flaky failures here indicate we're failing to prevent uploads from |
| 5519 // completing. |
| 5520 EXPECT_NE(4, frame_); |
| 5521 } |
| 5522 |
| 5523 void AfterTest() override {} |
| 5524 |
| 5525 FakeContentLayerClient client_; |
| 5526 int frame_; |
| 5527 bool posted_; |
| 5528 ThreadBlocker raster_thread_blocker_; |
| 5529 }; |
| 5530 |
| 5531 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); |
| 5532 |
| 5533 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy |
| 5534 : public LayerTreeHostTestCrispUpAfterPinchEnds { |
| 5535 protected: |
| 5536 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5537 settings->impl_side_painting = true; |
| 5538 settings->use_one_copy = true; |
| 5539 } |
| 5540 |
| 5541 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( |
| 5542 bool fallback) override { |
| 5543 scoped_ptr<TestWebGraphicsContext3D> context3d = |
| 5544 TestWebGraphicsContext3D::Create(); |
| 5545 context3d->set_support_image(true); |
| 5546 context3d->set_support_sync_query(true); |
| 5547 |
| 5548 if (delegating_renderer()) |
| 5549 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); |
| 5550 else |
| 5551 return FakeOutputSurface::Create3d(context3d.Pass()); |
| 5552 } |
| 5553 }; |
| 5554 |
| 5555 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy); |
| 5556 |
| 5557 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles |
| 5558 : public LayerTreeHostTest { |
| 5559 protected: |
| 5560 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5561 settings->impl_side_painting = true; |
| 5562 } |
| 5563 |
| 5564 void SetupTree() override { |
| 5565 step_ = 1; |
| 5566 continuous_draws_ = 0; |
| 5567 client_.set_fill_with_nonsolid_color(true); |
| 5568 |
| 5569 scoped_refptr<Layer> root = Layer::Create(); |
| 5570 root->SetBounds(gfx::Size(500, 500)); |
| 5571 |
| 5572 scoped_refptr<Layer> pinch = Layer::Create(); |
| 5573 pinch->SetBounds(gfx::Size(500, 500)); |
| 5574 pinch->SetScrollClipLayerId(root->id()); |
| 5575 pinch->SetIsContainerForFixedPositionLayers(true); |
| 5576 root->AddChild(pinch); |
| 5577 |
| 5578 scoped_refptr<FakePictureLayer> layer = |
| 5579 FakePictureLayer::CreateWithRecordingSource( |
| 5580 &client_, |
| 5581 make_scoped_ptr(new FakePicturePile(&raster_thread_blocker_))); |
| 5582 layer->SetBounds(gfx::Size(500, 500)); |
| 5583 layer->SetContentsOpaque(true); |
| 5584 pinch->AddChild(layer); |
| 5585 |
| 5586 layer_tree_host()->RegisterViewportLayers(root, pinch, pinch); |
| 5587 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); |
| 5588 layer_tree_host()->SetRootLayer(root); |
| 5589 LayerTreeHostTest::SetupTree(); |
| 5590 } |
| 5591 |
| 5592 // Returns the delta scale of all quads in the frame's root pass from their |
| 5593 // ideal, or 0 if they are not all the same. |
| 5594 float FrameQuadScaleDeltaFromIdeal(LayerTreeHostImpl::FrameData* frame_data) { |
| 5595 if (frame_data->has_no_damage) |
| 5596 return 0.f; |
| 5597 float frame_scale = 0.f; |
| 5598 RenderPass* root_pass = frame_data->render_passes.back(); |
| 5599 for (const auto& draw_quad : root_pass->quad_list) { |
| 5600 const TileDrawQuad* quad = TileDrawQuad::MaterialCast(draw_quad); |
| 5601 float quad_scale = |
| 5602 quad->tex_coord_rect.width() / static_cast<float>(quad->rect.width()); |
| 5603 float transform_scale = |
| 5604 SkMScalarToFloat(quad->quadTransform().matrix().get(0, 0)); |
| 5605 float scale = quad_scale / transform_scale; |
| 5606 if (frame_scale != 0.f && frame_scale != scale) |
| 5607 return 0.f; |
| 5608 frame_scale = scale; |
| 5609 } |
| 5610 return frame_scale; |
| 5611 } |
| 5612 |
| 5613 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 5614 |
| 5615 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 5616 LayerTreeHostImpl::FrameData* frame_data, |
| 5617 DrawResult draw_result) override { |
| 5618 float quad_scale_delta = FrameQuadScaleDeltaFromIdeal(frame_data); |
| 5619 switch (step_) { |
| 5620 case 1: |
| 5621 // Drew at scale 1 before any pinching. |
| 5622 EXPECT_EQ(1.f, host_impl->active_tree()->total_page_scale_factor()); |
| 5623 EXPECT_EQ(1.f, quad_scale_delta); |
| 5624 break; |
| 5625 case 2: |
| 5626 if (quad_scale_delta != 1.f / 1.5f) |
| 5627 break; |
| 5628 // Drew at scale 1 still though the ideal is 1.5. |
| 5629 EXPECT_EQ(1.5f, host_impl->active_tree()->total_page_scale_factor()); |
| 5630 EXPECT_EQ(1.f / 1.5f, quad_scale_delta); |
| 5631 break; |
| 5632 case 3: |
| 5633 // Continuous draws are attempted. |
| 5634 EXPECT_EQ(1.5f, host_impl->active_tree()->total_page_scale_factor()); |
| 5635 if (!frame_data->has_no_damage) |
| 5636 EXPECT_EQ(1.f / 1.5f, quad_scale_delta); |
| 5637 break; |
| 5638 case 4: |
| 5639 if (quad_scale_delta != 1.f) |
| 5640 break; |
| 5641 // Drew at scale 1.5 when all the tiles completed. |
| 5642 EXPECT_EQ(1.5f, host_impl->active_tree()->total_page_scale_factor()); |
| 5643 EXPECT_EQ(1.f, quad_scale_delta); |
| 5644 |
| 5645 // We should not continue to draw any more. End the test after a timeout |
| 5646 // to watch for any extraneous draws. |
| 5647 // TODO(brianderson): We could remove this delay and instead wait until |
| 5648 // the BeginFrameSource decides it doesn't need to send frames anymore, |
| 5649 // or test that it already doesn't here. |
| 5650 EndTestAfterDelayMs(16 * 4); |
| 5651 ++step_; |
| 5652 break; |
| 5653 case 5: |
| 5654 ADD_FAILURE() |
| 5655 << "No draws should happen once we have a complete frame."; |
| 5656 break; |
| 5657 } |
| 5658 return draw_result; |
| 5659 } |
| 5660 |
| 5661 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 5662 switch (step_) { |
| 5663 case 1: |
| 5664 // Delay tile production. |
| 5665 raster_thread_blocker_.BlockWait(); |
| 5666 // Pinch zoom in to cause new tiles to be required. |
| 5667 host_impl->PinchGestureBegin(); |
| 5668 host_impl->PinchGestureUpdate(1.5f, gfx::Point(100, 100)); |
| 5669 host_impl->PinchGestureEnd(); |
| 5670 ++step_; |
| 5671 break; |
| 5672 case 2: |
| 5673 ++step_; |
| 5674 break; |
| 5675 case 3: |
| 5676 // We should continue to try draw while there are incomplete visible |
| 5677 // tiles. |
| 5678 if (++continuous_draws_ > 5) { |
| 5679 // Allow the tiles to complete. |
| 5680 raster_thread_blocker_.UnblockWait(); |
| 5681 ++step_; |
| 5682 } |
| 5683 break; |
| 5684 } |
| 5685 } |
| 5686 |
| 5687 void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, |
| 5688 const Tile* tile) override { |
| 5689 // On step_ == 2, we are preventing texture uploads from completing, |
| 5690 // so this verifies they are not completing before step_ == 3. |
| 5691 // Flaky failures here indicate we're failing to prevent uploads from |
| 5692 // completing. |
| 5693 EXPECT_NE(2, step_); |
| 5694 } |
| 5695 |
| 5696 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); } |
| 5697 |
| 5698 FakeContentLayerClient client_; |
| 5699 int step_; |
| 5700 int continuous_draws_; |
| 5701 ThreadBlocker raster_thread_blocker_; |
| 5702 }; |
| 5703 |
| 5704 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); |
| 5705 |
5357 } // namespace cc | 5706 } // namespace cc |
OLD | NEW |