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 "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
8 #include "cc/layers/picture_layer_impl.h" | 8 #include "cc/layers/picture_layer_impl.h" |
9 #include "cc/resources/resource_update_queue.h" | 9 #include "cc/resources/resource_update_queue.h" |
10 #include "cc/test/fake_layer_tree_host.h" | 10 #include "cc/test/fake_layer_tree_host.h" |
11 #include "cc/test/fake_picture_layer_impl.h" | 11 #include "cc/test/fake_picture_layer_impl.h" |
12 #include "cc/test/fake_proxy.h" | 12 #include "cc/test/fake_proxy.h" |
| 13 #include "cc/test/gpu_rasterization_settings.h" |
| 14 #include "cc/test/hybrid_rasterization_settings.h" |
13 #include "cc/test/impl_side_painting_settings.h" | 15 #include "cc/test/impl_side_painting_settings.h" |
14 #include "cc/trees/occlusion_tracker.h" | 16 #include "cc/trees/occlusion_tracker.h" |
15 #include "cc/trees/single_thread_proxy.h" | 17 #include "cc/trees/single_thread_proxy.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
17 | 19 |
18 namespace cc { | 20 namespace cc { |
19 namespace { | 21 namespace { |
20 | 22 |
21 class MockContentLayerClient : public ContentLayerClient { | 23 class MockContentLayerClient : public ContentLayerClient { |
22 public: | 24 public: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1); | 62 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1); |
61 | 63 |
62 layer->PushPropertiesTo(layer_impl.get()); | 64 layer->PushPropertiesTo(layer_impl.get()); |
63 EXPECT_FALSE(layer_impl->CanHaveTilings()); | 65 EXPECT_FALSE(layer_impl->CanHaveTilings()); |
64 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); | 66 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); |
65 EXPECT_TRUE(layer_impl->pile()->size() == gfx::Size(0, 0)); | 67 EXPECT_TRUE(layer_impl->pile()->size() == gfx::Size(0, 0)); |
66 EXPECT_FALSE(layer_impl->pile()->HasRecordings()); | 68 EXPECT_FALSE(layer_impl->pile()->HasRecordings()); |
67 } | 69 } |
68 } | 70 } |
69 | 71 |
| 72 TEST(PictureLayerTest, ForcedCpuRaster) { |
| 73 MockContentLayerClient client; |
| 74 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 75 |
| 76 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); |
| 77 host->SetRootLayer(layer); |
| 78 |
| 79 // The default value is false. |
| 80 EXPECT_FALSE(layer->ShouldUseGpuRasterization()); |
| 81 |
| 82 // Gpu rasterization cannot be enabled even with raster hint. |
| 83 layer->SetHasGpuRasterizationHint(true); |
| 84 EXPECT_FALSE(layer->ShouldUseGpuRasterization()); |
| 85 } |
| 86 |
| 87 TEST(PictureLayerTest, ForcedGpuRaster) { |
| 88 MockContentLayerClient client; |
| 89 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 90 |
| 91 scoped_ptr<FakeLayerTreeHost> host = |
| 92 FakeLayerTreeHost::Create(GpuRasterizationSettings()); |
| 93 host->SetRootLayer(layer); |
| 94 |
| 95 // The default value is true. |
| 96 EXPECT_TRUE(layer->ShouldUseGpuRasterization()); |
| 97 |
| 98 // Gpu rasterization cannot be disabled even with raster hint. |
| 99 layer->SetHasGpuRasterizationHint(false); |
| 100 EXPECT_TRUE(layer->ShouldUseGpuRasterization()); |
| 101 |
| 102 // Gpu rasterization cannot be disabled even with skia veto. |
| 103 PicturePile* pile = layer->GetPicturePileForTesting(); |
| 104 EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization()); |
| 105 pile->SetUnsuitableForGpuRasterizationForTesting(); |
| 106 EXPECT_TRUE(layer->ShouldUseGpuRasterization()); |
| 107 } |
| 108 |
| 109 TEST(PictureLayerTest, HybridRaster) { |
| 110 MockContentLayerClient client; |
| 111 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 112 |
| 113 scoped_ptr<FakeLayerTreeHost> host = |
| 114 FakeLayerTreeHost::Create(HybridRasterizationSettings()); |
| 115 host->SetRootLayer(layer); |
| 116 |
| 117 // The default value is false. |
| 118 EXPECT_FALSE(layer->ShouldUseGpuRasterization()); |
| 119 |
| 120 // Gpu rasterization can be enabled first time. |
| 121 layer->SetHasGpuRasterizationHint(true); |
| 122 EXPECT_TRUE(layer->ShouldUseGpuRasterization()); |
| 123 |
| 124 // Gpu rasterization can always be disabled. |
| 125 layer->SetHasGpuRasterizationHint(false); |
| 126 EXPECT_FALSE(layer->ShouldUseGpuRasterization()); |
| 127 |
| 128 // Gpu rasterization cannot be enabled once disabled. |
| 129 layer->SetHasGpuRasterizationHint(true); |
| 130 EXPECT_FALSE(layer->ShouldUseGpuRasterization()); |
| 131 } |
| 132 |
| 133 TEST(PictureLayerTest, VetoGpuRaster) { |
| 134 MockContentLayerClient client; |
| 135 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 136 |
| 137 scoped_ptr<FakeLayerTreeHost> host = |
| 138 FakeLayerTreeHost::Create(HybridRasterizationSettings()); |
| 139 host->SetRootLayer(layer); |
| 140 |
| 141 EXPECT_FALSE(layer->ShouldUseGpuRasterization()); |
| 142 |
| 143 layer->SetHasGpuRasterizationHint(true); |
| 144 EXPECT_TRUE(layer->ShouldUseGpuRasterization()); |
| 145 |
| 146 // Veto gpu rasterization. |
| 147 PicturePile* pile = layer->GetPicturePileForTesting(); |
| 148 EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization()); |
| 149 pile->SetUnsuitableForGpuRasterizationForTesting(); |
| 150 EXPECT_FALSE(layer->ShouldUseGpuRasterization()); |
| 151 } |
| 152 |
70 } // namespace | 153 } // namespace |
71 } // namespace cc | 154 } // namespace cc |
OLD | NEW |