| 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/resources/resource_update_queue.h" | 10 #include "cc/resources/resource_update_queue.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 DisplayItemList* display_list, | 29 DisplayItemList* display_list, |
| 30 const gfx::Rect& clip, | 30 const gfx::Rect& clip, |
| 31 PaintingControlSetting picture_control) override { | 31 PaintingControlSetting picture_control) override { |
| 32 NOTIMPLEMENTED(); | 32 NOTIMPLEMENTED(); |
| 33 } | 33 } |
| 34 bool FillsBoundsCompletely() const override { return false; }; | 34 bool FillsBoundsCompletely() const override { return false; }; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 TEST(PictureLayerTest, NoTilesIfEmptyBounds) { | 37 TEST(PictureLayerTest, NoTilesIfEmptyBounds) { |
| 38 MockContentLayerClient client; | 38 MockContentLayerClient client; |
| 39 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 39 scoped_refptr<PictureLayer> layer = |
| 40 PictureLayer::Create(LayerSettings(), &client); |
| 40 layer->SetBounds(gfx::Size(10, 10)); | 41 layer->SetBounds(gfx::Size(10, 10)); |
| 41 | 42 |
| 42 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); | 43 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
| 43 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); | 44 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); |
| 44 host->SetRootLayer(layer); | 45 host->SetRootLayer(layer); |
| 45 layer->SetIsDrawable(true); | 46 layer->SetIsDrawable(true); |
| 46 layer->SavePaintProperties(); | 47 layer->SavePaintProperties(); |
| 47 | 48 |
| 48 OcclusionTracker<Layer> occlusion(gfx::Rect(0, 0, 1000, 1000)); | 49 OcclusionTracker<Layer> occlusion(gfx::Rect(0, 0, 1000, 1000)); |
| 49 scoped_ptr<ResourceUpdateQueue> queue(new ResourceUpdateQueue); | 50 scoped_ptr<ResourceUpdateQueue> queue(new ResourceUpdateQueue); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 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) { |
| 81 MockContentLayerClient client; | 82 MockContentLayerClient client; |
| 82 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 83 scoped_refptr<PictureLayer> layer = |
| 84 PictureLayer::Create(LayerSettings(), &client); |
| 83 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); | 85 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
| 84 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); | 86 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); |
| 85 host->SetRootLayer(layer); | 87 host->SetRootLayer(layer); |
| 86 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 88 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 87 | 89 |
| 88 // Layer is suitable for gpu rasterization by default. | 90 // Layer is suitable for gpu rasterization by default. |
| 89 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); | 91 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); |
| 90 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); | 92 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); |
| 91 | 93 |
| 92 // Veto gpu rasterization. | 94 // Veto gpu rasterization. |
| 93 recording_source->SetUnsuitableForGpuRasterizationForTesting(); | 95 recording_source->SetUnsuitableForGpuRasterizationForTesting(); |
| 94 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); | 96 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); |
| 95 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); | 97 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); |
| 96 } | 98 } |
| 97 | 99 |
| 98 TEST(PictureLayerTest, UseTileGridSize) { | 100 TEST(PictureLayerTest, UseTileGridSize) { |
| 99 LayerTreeSettings settings; | 101 LayerTreeSettings settings; |
| 100 settings.default_tile_grid_size = gfx::Size(123, 123); | 102 settings.default_tile_grid_size = gfx::Size(123, 123); |
| 101 | 103 |
| 102 MockContentLayerClient client; | 104 MockContentLayerClient client; |
| 103 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 105 scoped_refptr<PictureLayer> layer = |
| 106 PictureLayer::Create(LayerSettings(), &client); |
| 104 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); | 107 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
| 105 scoped_ptr<FakeLayerTreeHost> host = | 108 scoped_ptr<FakeLayerTreeHost> host = |
| 106 FakeLayerTreeHost::Create(&host_client, settings); | 109 FakeLayerTreeHost::Create(&host_client, settings); |
| 107 host->SetRootLayer(layer); | 110 host->SetRootLayer(layer); |
| 108 | 111 |
| 109 // Tile-grid is set according to its setting. | 112 // Tile-grid is set according to its setting. |
| 110 gfx::Size size = | 113 gfx::Size size = |
| 111 layer->GetRecordingSourceForTesting()->GetTileGridSizeForTesting(); | 114 layer->GetRecordingSourceForTesting()->GetTileGridSizeForTesting(); |
| 112 EXPECT_EQ(size.width(), 123); | 115 EXPECT_EQ(size.width(), 123); |
| 113 EXPECT_EQ(size.height(), 123); | 116 EXPECT_EQ(size.height(), 123); |
| 114 } | 117 } |
| 115 | 118 |
| 116 // PicturePile uses the source frame number as a unit for measuring invalidation | 119 // PicturePile uses the source frame number as a unit for measuring invalidation |
| 117 // frequency. When a pile moves between compositors, the frame number increases | 120 // frequency. When a pile moves between compositors, the frame number increases |
| 118 // non-monotonically. This executes that code path under this scenario allowing | 121 // non-monotonically. This executes that code path under this scenario allowing |
| 119 // for the code to verify correctness with DCHECKs. | 122 // for the code to verify correctness with DCHECKs. |
| 120 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { | 123 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { |
| 121 LayerTreeSettings settings; | 124 LayerTreeSettings settings; |
| 122 settings.single_thread_proxy_scheduler = false; | 125 settings.single_thread_proxy_scheduler = false; |
| 123 | 126 |
| 124 FakeLayerTreeHostClient host_client1(FakeLayerTreeHostClient::DIRECT_3D); | 127 FakeLayerTreeHostClient host_client1(FakeLayerTreeHostClient::DIRECT_3D); |
| 125 FakeLayerTreeHostClient host_client2(FakeLayerTreeHostClient::DIRECT_3D); | 128 FakeLayerTreeHostClient host_client2(FakeLayerTreeHostClient::DIRECT_3D); |
| 126 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 129 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 127 new TestSharedBitmapManager()); | 130 new TestSharedBitmapManager()); |
| 128 | 131 |
| 129 MockContentLayerClient client; | 132 MockContentLayerClient client; |
| 130 scoped_refptr<FakePictureLayer> layer = FakePictureLayer::Create(&client); | 133 scoped_refptr<FakePictureLayer> layer = |
| 134 FakePictureLayer::Create(LayerSettings(), &client); |
| 131 | 135 |
| 132 scoped_ptr<LayerTreeHost> host1 = LayerTreeHost::CreateSingleThreaded( | 136 scoped_ptr<LayerTreeHost> host1 = LayerTreeHost::CreateSingleThreaded( |
| 133 &host_client1, &host_client1, shared_bitmap_manager.get(), nullptr, | 137 &host_client1, &host_client1, shared_bitmap_manager.get(), nullptr, |
| 134 nullptr, settings, base::ThreadTaskRunnerHandle::Get(), nullptr); | 138 nullptr, settings, base::ThreadTaskRunnerHandle::Get(), nullptr); |
| 135 host_client1.SetLayerTreeHost(host1.get()); | 139 host_client1.SetLayerTreeHost(host1.get()); |
| 136 | 140 |
| 137 scoped_ptr<LayerTreeHost> host2 = LayerTreeHost::CreateSingleThreaded( | 141 scoped_ptr<LayerTreeHost> host2 = LayerTreeHost::CreateSingleThreaded( |
| 138 &host_client2, &host_client2, shared_bitmap_manager.get(), nullptr, | 142 &host_client2, &host_client2, shared_bitmap_manager.get(), nullptr, |
| 139 nullptr, settings, base::ThreadTaskRunnerHandle::Get(), nullptr); | 143 nullptr, settings, base::ThreadTaskRunnerHandle::Get(), nullptr); |
| 140 host_client2.SetLayerTreeHost(host2.get()); | 144 host_client2.SetLayerTreeHost(host2.get()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 161 // Do a main frame, record the picture layers. The frame number has changed | 165 // Do a main frame, record the picture layers. The frame number has changed |
| 162 // non-monotonically. | 166 // non-monotonically. |
| 163 layer->SetNeedsDisplay(); | 167 layer->SetNeedsDisplay(); |
| 164 host2->Composite(base::TimeTicks::Now()); | 168 host2->Composite(base::TimeTicks::Now()); |
| 165 EXPECT_EQ(3u, layer->update_count()); | 169 EXPECT_EQ(3u, layer->update_count()); |
| 166 EXPECT_EQ(1, host2->source_frame_number()); | 170 EXPECT_EQ(1, host2->source_frame_number()); |
| 167 } | 171 } |
| 168 | 172 |
| 169 } // namespace | 173 } // namespace |
| 170 } // namespace cc | 174 } // namespace cc |
| OLD | NEW |