| 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/playback/display_item_list_settings.h" | 10 #include "cc/playback/display_item_list_settings.h" |
| 11 #include "cc/test/fake_display_list_recording_source.h" | |
| 12 #include "cc/test/fake_layer_tree_host.h" | 11 #include "cc/test/fake_layer_tree_host.h" |
| 13 #include "cc/test/fake_picture_layer.h" | 12 #include "cc/test/fake_picture_layer.h" |
| 14 #include "cc/test/fake_picture_layer_impl.h" | 13 #include "cc/test/fake_picture_layer_impl.h" |
| 15 #include "cc/test/fake_proxy.h" | 14 #include "cc/test/fake_proxy.h" |
| 16 #include "cc/test/test_shared_bitmap_manager.h" | 15 #include "cc/test/test_shared_bitmap_manager.h" |
| 17 #include "cc/test/test_task_graph_runner.h" | 16 #include "cc/test/test_task_graph_runner.h" |
| 18 #include "cc/trees/single_thread_proxy.h" | 17 #include "cc/trees/single_thread_proxy.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 19 |
| 21 namespace cc { | 20 namespace cc { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 71 |
| 73 layer->PushPropertiesTo(layer_impl.get()); | 72 layer->PushPropertiesTo(layer_impl.get()); |
| 74 EXPECT_FALSE(layer_impl->CanHaveTilings()); | 73 EXPECT_FALSE(layer_impl->CanHaveTilings()); |
| 75 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); | 74 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); |
| 76 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize()); | 75 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize()); |
| 77 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings()); | 76 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings()); |
| 78 } | 77 } |
| 79 } | 78 } |
| 80 | 79 |
| 81 TEST(PictureLayerTest, SuitableForGpuRasterization) { | 80 TEST(PictureLayerTest, SuitableForGpuRasterization) { |
| 82 scoped_ptr<FakeDisplayListRecordingSource> recording_source_owned( | |
| 83 new FakeDisplayListRecordingSource(gfx::Size(100, 100))); | |
| 84 FakeDisplayListRecordingSource* recording_source = | |
| 85 recording_source_owned.get(); | |
| 86 | |
| 87 MockContentLayerClient client; | 81 MockContentLayerClient client; |
| 88 scoped_refptr<FakePictureLayer> layer = | 82 scoped_refptr<PictureLayer> layer = |
| 89 FakePictureLayer::CreateWithRecordingSource( | 83 PictureLayer::Create(LayerSettings(), &client); |
| 90 LayerSettings(), &client, recording_source_owned.Pass()); | |
| 91 | |
| 92 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); | 84 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
| 93 TestTaskGraphRunner task_graph_runner; | 85 TestTaskGraphRunner task_graph_runner; |
| 94 scoped_ptr<FakeLayerTreeHost> host = | 86 scoped_ptr<FakeLayerTreeHost> host = |
| 95 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); | 87 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); |
| 96 host->SetRootLayer(layer); | 88 host->SetRootLayer(layer); |
| 97 | 89 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 98 // Update layers to initialize the recording source. | |
| 99 gfx::Size layer_bounds(200, 200); | |
| 100 gfx::Rect layer_rect(layer_bounds); | |
| 101 Region invalidation(layer_rect); | |
| 102 recording_source->UpdateAndExpandInvalidation( | |
| 103 &client, &invalidation, layer_bounds, layer_rect, 1, | |
| 104 RecordingSource::RECORD_NORMALLY); | |
| 105 | 90 |
| 106 // Layer is suitable for gpu rasterization by default. | 91 // Layer is suitable for gpu rasterization by default. |
| 107 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); | 92 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); |
| 108 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); | 93 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); |
| 109 | 94 |
| 110 // Veto gpu rasterization. | 95 // Veto gpu rasterization. |
| 111 recording_source->SetUnsuitableForGpuRasterization(); | 96 recording_source->SetUnsuitableForGpuRasterizationForTesting(); |
| 112 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); | 97 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); |
| 113 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); | 98 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); |
| 114 } | 99 } |
| 115 | 100 |
| 116 // PicturePile uses the source frame number as a unit for measuring invalidation | 101 // PicturePile uses the source frame number as a unit for measuring invalidation |
| 117 // frequency. When a pile moves between compositors, the frame number increases | 102 // frequency. When a pile moves between compositors, the frame number increases |
| 118 // non-monotonically. This executes that code path under this scenario allowing | 103 // non-monotonically. This executes that code path under this scenario allowing |
| 119 // for the code to verify correctness with DCHECKs. | 104 // for the code to verify correctness with DCHECKs. |
| 120 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { | 105 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { |
| 121 LayerTreeSettings settings; | 106 LayerTreeSettings settings; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // Do a main frame, record the picture layers. The frame number has changed | 153 // Do a main frame, record the picture layers. The frame number has changed |
| 169 // non-monotonically. | 154 // non-monotonically. |
| 170 layer->SetNeedsDisplay(); | 155 layer->SetNeedsDisplay(); |
| 171 host2->Composite(base::TimeTicks::Now()); | 156 host2->Composite(base::TimeTicks::Now()); |
| 172 EXPECT_EQ(3, layer->update_count()); | 157 EXPECT_EQ(3, layer->update_count()); |
| 173 EXPECT_EQ(1, host2->source_frame_number()); | 158 EXPECT_EQ(1, host2->source_frame_number()); |
| 174 } | 159 } |
| 175 | 160 |
| 176 } // namespace | 161 } // namespace |
| 177 } // namespace cc | 162 } // namespace cc |
| OLD | NEW |