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