OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/picture_layer.h" | 5 #include "cc/layers/picture_layer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
11 #include "cc/animation/animation_host.h" | 11 #include "cc/animation/animation_host.h" |
12 #include "cc/layers/append_quads_data.h" | 12 #include "cc/layers/append_quads_data.h" |
13 #include "cc/layers/content_layer_client.h" | 13 #include "cc/layers/content_layer_client.h" |
14 #include "cc/layers/empty_content_layer_client.h" | 14 #include "cc/layers/empty_content_layer_client.h" |
15 #include "cc/layers/picture_layer_impl.h" | 15 #include "cc/layers/picture_layer_impl.h" |
16 #include "cc/playback/display_item_list_settings.h" | 16 #include "cc/playback/display_item_list_settings.h" |
17 #include "cc/proto/layer.pb.h" | 17 #include "cc/proto/layer.pb.h" |
18 #include "cc/test/fake_client_picture_cache.h" | 18 #include "cc/test/fake_client_picture_cache.h" |
19 #include "cc/test/fake_engine_picture_cache.h" | 19 #include "cc/test/fake_engine_picture_cache.h" |
20 #include "cc/test/fake_image_serialization_processor.h" | 20 #include "cc/test/fake_image_serialization_processor.h" |
21 #include "cc/test/fake_layer_tree_host.h" | 21 #include "cc/test/fake_layer_tree_host.h" |
22 #include "cc/test/fake_output_surface.h" | 22 #include "cc/test/fake_output_surface.h" |
23 #include "cc/test/fake_picture_layer.h" | 23 #include "cc/test/fake_picture_layer.h" |
24 #include "cc/test/fake_picture_layer_impl.h" | 24 #include "cc/test/fake_picture_layer_impl.h" |
25 #include "cc/test/fake_proxy.h" | 25 #include "cc/test/fake_proxy.h" |
26 #include "cc/test/fake_recording_source.h" | 26 #include "cc/test/fake_recording_source.h" |
27 #include "cc/test/layer_tree_settings_for_testing.h" | 27 #include "cc/test/layer_tree_settings_for_testing.h" |
28 #include "cc/test/skia_common.h" | 28 #include "cc/test/skia_common.h" |
29 #include "cc/test/stub_layer_tree_host_single_thread_client.h" | |
29 #include "cc/test/test_shared_bitmap_manager.h" | 30 #include "cc/test/test_shared_bitmap_manager.h" |
30 #include "cc/test/test_task_graph_runner.h" | 31 #include "cc/test/test_task_graph_runner.h" |
31 #include "cc/trees/single_thread_proxy.h" | 32 #include "cc/trees/single_thread_proxy.h" |
32 #include "testing/gmock/include/gmock/gmock.h" | 33 #include "testing/gmock/include/gmock/gmock.h" |
33 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
34 #include "third_party/skia/include/core/SkRefCnt.h" | 35 #include "third_party/skia/include/core/SkRefCnt.h" |
35 | 36 |
36 namespace cc { | 37 namespace cc { |
37 | 38 |
38 class TestSerializationPictureLayer : public PictureLayer { | 39 class TestSerializationPictureLayer : public PictureLayer { |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 // frequency. When a pile moves between compositors, the frame number increases | 461 // frequency. When a pile moves between compositors, the frame number increases |
461 // non-monotonically. This executes that code path under this scenario allowing | 462 // non-monotonically. This executes that code path under this scenario allowing |
462 // for the code to verify correctness with DCHECKs. | 463 // for the code to verify correctness with DCHECKs. |
463 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { | 464 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { |
464 LayerTreeSettings settings; | 465 LayerTreeSettings settings; |
465 settings.single_thread_proxy_scheduler = false; | 466 settings.single_thread_proxy_scheduler = false; |
466 settings.use_zero_copy = true; | 467 settings.use_zero_copy = true; |
467 settings.verify_clip_tree_calculations = true; | 468 settings.verify_clip_tree_calculations = true; |
468 settings.verify_transform_tree_calculations = true; | 469 settings.verify_transform_tree_calculations = true; |
469 | 470 |
471 StubLayerTreeHostSingleThreadClient single_thread_client; | |
470 FakeLayerTreeHostClient host_client1; | 472 FakeLayerTreeHostClient host_client1; |
471 FakeLayerTreeHostClient host_client2; | 473 FakeLayerTreeHostClient host_client2; |
472 TestSharedBitmapManager shared_bitmap_manager; | 474 TestSharedBitmapManager shared_bitmap_manager; |
473 TestTaskGraphRunner task_graph_runner; | 475 TestTaskGraphRunner task_graph_runner; |
474 | 476 |
475 ContentLayerClient* client = EmptyContentLayerClient::GetInstance(); | 477 ContentLayerClient* client = EmptyContentLayerClient::GetInstance(); |
476 scoped_refptr<FakePictureLayer> layer = FakePictureLayer::Create(client); | 478 scoped_refptr<FakePictureLayer> layer = FakePictureLayer::Create(client); |
477 | 479 |
478 LayerTreeHost::InitParams params; | 480 LayerTreeHost::InitParams params; |
479 params.client = &host_client1; | 481 params.client = &host_client1; |
480 params.shared_bitmap_manager = &shared_bitmap_manager; | 482 params.shared_bitmap_manager = &shared_bitmap_manager; |
481 params.settings = &settings; | 483 params.settings = &settings; |
482 params.task_graph_runner = &task_graph_runner; | 484 params.task_graph_runner = &task_graph_runner; |
483 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 485 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
484 params.animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 486 params.animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
485 std::unique_ptr<LayerTreeHost> host1 = | 487 std::unique_ptr<LayerTreeHost> host1 = |
486 LayerTreeHost::CreateSingleThreaded(&host_client1, ¶ms); | 488 LayerTreeHost::CreateSingleThreaded(&single_thread_client, ¶ms); |
vmpstr
2016/07/22 21:08:43
I guess similar question here (and elsewhere) abou
| |
487 host1->SetVisible(true); | 489 host1->SetVisible(true); |
488 host_client1.SetLayerTreeHost(host1.get()); | 490 host_client1.SetLayerTreeHost(host1.get()); |
489 | 491 |
490 // TODO(sad): InitParams will be movable. | 492 // TODO(sad): InitParams will be movable. |
491 LayerTreeHost::InitParams params2; | 493 LayerTreeHost::InitParams params2; |
492 params2.client = &host_client1; | 494 params2.client = &host_client1; |
493 params2.shared_bitmap_manager = &shared_bitmap_manager; | 495 params2.shared_bitmap_manager = &shared_bitmap_manager; |
494 params2.settings = &settings; | 496 params2.settings = &settings; |
495 params2.task_graph_runner = &task_graph_runner; | 497 params2.task_graph_runner = &task_graph_runner; |
496 params2.main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 498 params2.main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
497 params2.client = &host_client2; | 499 params2.client = &host_client2; |
498 params2.animation_host = | 500 params2.animation_host = |
499 AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 501 AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
500 std::unique_ptr<LayerTreeHost> host2 = | 502 std::unique_ptr<LayerTreeHost> host2 = |
501 LayerTreeHost::CreateSingleThreaded(&host_client2, ¶ms2); | 503 LayerTreeHost::CreateSingleThreaded(&single_thread_client, ¶ms2); |
502 host2->SetVisible(true); | 504 host2->SetVisible(true); |
503 host_client2.SetLayerTreeHost(host2.get()); | 505 host_client2.SetLayerTreeHost(host2.get()); |
504 | 506 |
505 // The PictureLayer is put in one LayerTreeHost. | 507 // The PictureLayer is put in one LayerTreeHost. |
506 host1->SetRootLayer(layer); | 508 host1->SetRootLayer(layer); |
507 // Do a main frame, record the picture layers. | 509 // Do a main frame, record the picture layers. |
508 EXPECT_EQ(0, layer->update_count()); | 510 EXPECT_EQ(0, layer->update_count()); |
509 layer->SetNeedsDisplay(); | 511 layer->SetNeedsDisplay(); |
510 host1->Composite(base::TimeTicks::Now()); | 512 host1->Composite(base::TimeTicks::Now()); |
511 EXPECT_EQ(1, layer->update_count()); | 513 EXPECT_EQ(1, layer->update_count()); |
(...skipping 12 matching lines...) Expand all Loading... | |
524 // Do a main frame, record the picture layers. The frame number has changed | 526 // Do a main frame, record the picture layers. The frame number has changed |
525 // non-monotonically. | 527 // non-monotonically. |
526 layer->SetNeedsDisplay(); | 528 layer->SetNeedsDisplay(); |
527 host2->Composite(base::TimeTicks::Now()); | 529 host2->Composite(base::TimeTicks::Now()); |
528 EXPECT_EQ(3, layer->update_count()); | 530 EXPECT_EQ(3, layer->update_count()); |
529 EXPECT_EQ(1, host2->source_frame_number()); | 531 EXPECT_EQ(1, host2->source_frame_number()); |
530 } | 532 } |
531 | 533 |
532 } // namespace | 534 } // namespace |
533 } // namespace cc | 535 } // namespace cc |
OLD | NEW |