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 "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
8 #include "cc/layers/content_layer_client.h" | 8 #include "cc/layers/content_layer_client.h" |
9 #include "cc/layers/picture_layer_impl.h" | 9 #include "cc/layers/picture_layer_impl.h" |
10 #include "cc/test/fake_display_list_recording_source.h" | |
10 #include "cc/test/fake_layer_tree_host.h" | 11 #include "cc/test/fake_layer_tree_host.h" |
11 #include "cc/test/fake_picture_layer.h" | 12 #include "cc/test/fake_picture_layer.h" |
12 #include "cc/test/fake_picture_layer_impl.h" | 13 #include "cc/test/fake_picture_layer_impl.h" |
13 #include "cc/test/fake_proxy.h" | 14 #include "cc/test/fake_proxy.h" |
14 #include "cc/test/test_shared_bitmap_manager.h" | 15 #include "cc/test/test_shared_bitmap_manager.h" |
15 #include "cc/test/test_task_graph_runner.h" | 16 #include "cc/test/test_task_graph_runner.h" |
16 #include "cc/trees/single_thread_proxy.h" | 17 #include "cc/trees/single_thread_proxy.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace cc { | 20 namespace cc { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 | 71 |
71 layer->PushPropertiesTo(layer_impl.get()); | 72 layer->PushPropertiesTo(layer_impl.get()); |
72 EXPECT_FALSE(layer_impl->CanHaveTilings()); | 73 EXPECT_FALSE(layer_impl->CanHaveTilings()); |
73 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); | 74 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); |
74 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize()); | 75 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize()); |
75 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings()); | 76 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings()); |
76 } | 77 } |
77 } | 78 } |
78 | 79 |
79 TEST(PictureLayerTest, SuitableForGpuRasterization) { | 80 TEST(PictureLayerTest, SuitableForGpuRasterization) { |
81 scoped_ptr<FakeDisplayListRecordingSource> fake_recording_source( | |
82 new FakeDisplayListRecordingSource(gfx::Size(100, 100))); | |
80 MockContentLayerClient client; | 83 MockContentLayerClient client; |
81 scoped_refptr<PictureLayer> layer = | 84 scoped_refptr<FakePictureLayer> layer = |
82 PictureLayer::Create(LayerSettings(), &client); | 85 FakePictureLayer::CreateWithRecordingSource(LayerSettings(), &client, |
86 fake_recording_source.Pass()); | |
87 | |
83 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); | 88 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
84 TestTaskGraphRunner task_graph_runner; | 89 TestTaskGraphRunner task_graph_runner; |
85 scoped_ptr<FakeLayerTreeHost> host = | 90 scoped_ptr<FakeLayerTreeHost> host = |
86 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); | 91 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); |
87 host->SetRootLayer(layer); | 92 host->SetRootLayer(layer); |
88 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 93 FakeDisplayListRecordingSource* recording_source = |
danakj
2015/09/16 23:04:49
nit: can you grab this pointer before you Pass it
pdr.
2015/09/17 20:52:45
Good idea. Done.
| |
94 static_cast<FakeDisplayListRecordingSource*>( | |
95 layer->GetRecordingSourceForTesting()); | |
89 | 96 |
90 // Layer is suitable for gpu rasterization by default. | 97 // Layer is suitable for gpu rasterization by default. |
91 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); | 98 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); |
92 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); | 99 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); |
93 | 100 |
94 // Veto gpu rasterization. | 101 // Veto gpu rasterization. |
95 recording_source->SetUnsuitableForGpuRasterizationForTesting(); | 102 recording_source->SetUnsuitableForGpuRasterization(); |
96 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); | 103 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); |
hendrikw
2015/09/16 23:15:57
This part of the test is a bit weird for me, we se
danakj
2015/09/16 23:20:50
Ya this EXPECT could go away. This test is basical
| |
97 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); | 104 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); |
98 } | 105 } |
99 | 106 |
100 // PicturePile uses the source frame number as a unit for measuring invalidation | 107 // PicturePile uses the source frame number as a unit for measuring invalidation |
101 // frequency. When a pile moves between compositors, the frame number increases | 108 // frequency. When a pile moves between compositors, the frame number increases |
102 // non-monotonically. This executes that code path under this scenario allowing | 109 // non-monotonically. This executes that code path under this scenario allowing |
103 // for the code to verify correctness with DCHECKs. | 110 // for the code to verify correctness with DCHECKs. |
104 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { | 111 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { |
105 LayerTreeSettings settings; | 112 LayerTreeSettings settings; |
106 settings.single_thread_proxy_scheduler = false; | 113 settings.single_thread_proxy_scheduler = false; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 // Do a main frame, record the picture layers. The frame number has changed | 159 // Do a main frame, record the picture layers. The frame number has changed |
153 // non-monotonically. | 160 // non-monotonically. |
154 layer->SetNeedsDisplay(); | 161 layer->SetNeedsDisplay(); |
155 host2->Composite(base::TimeTicks::Now()); | 162 host2->Composite(base::TimeTicks::Now()); |
156 EXPECT_EQ(3, layer->update_count()); | 163 EXPECT_EQ(3, layer->update_count()); |
157 EXPECT_EQ(1, host2->source_frame_number()); | 164 EXPECT_EQ(1, host2->source_frame_number()); |
158 } | 165 } |
159 | 166 |
160 } // namespace | 167 } // namespace |
161 } // namespace cc | 168 } // namespace cc |
OLD | NEW |