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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 #include "cc/layers/content_layer.h" | 6 #include "cc/layers/content_layer.h" |
7 #include "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
8 #include "cc/layers/image_layer.h" | 8 #include "cc/layers/image_layer.h" |
9 #include "cc/test/layer_tree_pixel_test.h" | 9 #include "cc/test/layer_tree_pixel_test.h" |
10 #include "cc/test/pixel_comparator.h" | 10 #include "cc/test/pixel_comparator.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 50 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
51 background->AddChild(green); | 51 background->AddChild(green); |
52 | 52 |
53 MaskContentLayerClient client; | 53 MaskContentLayerClient client; |
54 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); | 54 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); |
55 mask->SetBounds(gfx::Size(100, 100)); | 55 mask->SetBounds(gfx::Size(100, 100)); |
56 mask->SetIsDrawable(true); | 56 mask->SetIsDrawable(true); |
57 mask->SetIsMask(true); | 57 mask->SetIsMask(true); |
58 green->SetMaskLayer(mask.get()); | 58 green->SetMaskLayer(mask.get()); |
59 | 59 |
60 RunPixelTest(background, | 60 RunPixelTest(GL_WITH_BITMAP, |
61 base::FilePath(FILE_PATH_LITERAL( | 61 background, |
62 "mask_of_layer.png"))); | 62 base::FilePath(FILE_PATH_LITERAL("mask_of_layer.png"))); |
63 } | 63 } |
64 | 64 |
65 TEST_F(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) { | 65 TEST_F(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) { |
66 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 66 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
67 gfx::Rect(200, 200), SK_ColorWHITE); | 67 gfx::Rect(200, 200), SK_ColorWHITE); |
68 | 68 |
69 scoped_refptr<ImageLayer> mask = ImageLayer::Create(); | 69 scoped_refptr<ImageLayer> mask = ImageLayer::Create(); |
70 mask->SetIsDrawable(true); | 70 mask->SetIsDrawable(true); |
71 mask->SetIsMask(true); | 71 mask->SetIsMask(true); |
72 mask->SetBounds(gfx::Size(100, 100)); | 72 mask->SetBounds(gfx::Size(100, 100)); |
73 | 73 |
74 SkBitmap bitmap; | 74 SkBitmap bitmap; |
75 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400); | 75 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400); |
76 bitmap.allocPixels(); | 76 bitmap.allocPixels(); |
77 SkCanvas canvas(bitmap); | 77 SkCanvas canvas(bitmap); |
78 canvas.scale(SkIntToScalar(4), SkIntToScalar(4)); | 78 canvas.scale(SkIntToScalar(4), SkIntToScalar(4)); |
79 MaskContentLayerClient client; | 79 MaskContentLayerClient client; |
80 client.PaintContents(&canvas, | 80 client.PaintContents(&canvas, |
81 gfx::Rect(100, 100), | 81 gfx::Rect(100, 100), |
82 NULL); | 82 NULL); |
83 mask->SetBitmap(bitmap); | 83 mask->SetBitmap(bitmap); |
84 | 84 |
85 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 85 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
86 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 86 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
87 green->SetMaskLayer(mask.get()); | 87 green->SetMaskLayer(mask.get()); |
88 background->AddChild(green); | 88 background->AddChild(green); |
89 | 89 |
90 RunPixelTest(background, | 90 RunPixelTest(GL_WITH_BITMAP, |
91 base::FilePath(FILE_PATH_LITERAL( | 91 background, |
92 "image_mask_of_layer.png"))); | 92 base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); |
93 } | 93 } |
94 | 94 |
95 TEST_F(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { | 95 TEST_F(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { |
96 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 96 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
97 gfx::Rect(200, 200), SK_ColorWHITE); | 97 gfx::Rect(200, 200), SK_ColorWHITE); |
98 | 98 |
99 // Clip to the top half of the green layer. | 99 // Clip to the top half of the green layer. |
100 scoped_refptr<Layer> clip = Layer::Create(); | 100 scoped_refptr<Layer> clip = Layer::Create(); |
101 clip->SetAnchorPoint(gfx::PointF(0.f, 0.f)); | 101 clip->SetAnchorPoint(gfx::PointF(0.f, 0.f)); |
102 clip->SetPosition(gfx::Point(0, 0)); | 102 clip->SetPosition(gfx::Point(0, 0)); |
103 clip->SetBounds(gfx::Size(200, 100)); | 103 clip->SetBounds(gfx::Size(200, 100)); |
104 clip->SetMasksToBounds(true); | 104 clip->SetMasksToBounds(true); |
105 background->AddChild(clip); | 105 background->AddChild(clip); |
106 | 106 |
107 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 107 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
108 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 108 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
109 clip->AddChild(green); | 109 clip->AddChild(green); |
110 | 110 |
111 MaskContentLayerClient client; | 111 MaskContentLayerClient client; |
112 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); | 112 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); |
113 mask->SetBounds(gfx::Size(100, 100)); | 113 mask->SetBounds(gfx::Size(100, 100)); |
114 mask->SetIsDrawable(true); | 114 mask->SetIsDrawable(true); |
115 mask->SetIsMask(true); | 115 mask->SetIsMask(true); |
116 green->SetMaskLayer(mask.get()); | 116 green->SetMaskLayer(mask.get()); |
117 | 117 |
118 RunPixelTest(background, | 118 RunPixelTest(GL_WITH_BITMAP, |
119 base::FilePath(FILE_PATH_LITERAL( | 119 background, |
120 "mask_of_clipped_layer.png"))); | 120 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); |
121 } | 121 } |
122 | 122 |
123 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplica) { | 123 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplica) { |
124 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 124 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
125 gfx::Rect(200, 200), SK_ColorWHITE); | 125 gfx::Rect(200, 200), SK_ColorWHITE); |
126 | 126 |
127 MaskContentLayerClient client; | 127 MaskContentLayerClient client; |
128 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); | 128 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); |
129 mask->SetBounds(gfx::Size(100, 100)); | 129 mask->SetBounds(gfx::Size(100, 100)); |
130 mask->SetIsDrawable(true); | 130 mask->SetIsDrawable(true); |
131 mask->SetIsMask(true); | 131 mask->SetIsMask(true); |
132 | 132 |
133 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 133 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
134 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 134 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
135 background->AddChild(green); | 135 background->AddChild(green); |
136 green->SetMaskLayer(mask.get()); | 136 green->SetMaskLayer(mask.get()); |
137 | 137 |
138 gfx::Transform replica_transform; | 138 gfx::Transform replica_transform; |
139 replica_transform.Rotate(-90.0); | 139 replica_transform.Rotate(-90.0); |
140 | 140 |
141 scoped_refptr<Layer> replica = Layer::Create(); | 141 scoped_refptr<Layer> replica = Layer::Create(); |
142 replica->SetAnchorPoint(gfx::PointF(0.5f, 0.5f)); | 142 replica->SetAnchorPoint(gfx::PointF(0.5f, 0.5f)); |
143 replica->SetPosition(gfx::Point(100, 100)); | 143 replica->SetPosition(gfx::Point(100, 100)); |
144 replica->SetTransform(replica_transform); | 144 replica->SetTransform(replica_transform); |
145 green->SetReplicaLayer(replica.get()); | 145 green->SetReplicaLayer(replica.get()); |
146 | 146 |
147 RunPixelTest(background, | 147 RunPixelTest(GL_WITH_BITMAP, |
148 base::FilePath(FILE_PATH_LITERAL( | 148 background, |
149 "mask_with_replica.png"))); | 149 base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); |
150 } | 150 } |
151 | 151 |
152 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { | 152 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { |
153 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 153 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
154 gfx::Rect(200, 200), SK_ColorWHITE); | 154 gfx::Rect(200, 200), SK_ColorWHITE); |
155 | 155 |
156 MaskContentLayerClient client; | 156 MaskContentLayerClient client; |
157 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); | 157 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); |
158 mask->SetBounds(gfx::Size(100, 100)); | 158 mask->SetBounds(gfx::Size(100, 100)); |
159 mask->SetIsDrawable(true); | 159 mask->SetIsDrawable(true); |
(...skipping 15 matching lines...) Expand all Loading... |
175 | 175 |
176 gfx::Transform replica_transform; | 176 gfx::Transform replica_transform; |
177 replica_transform.Rotate(-90.0); | 177 replica_transform.Rotate(-90.0); |
178 | 178 |
179 scoped_refptr<Layer> replica = Layer::Create(); | 179 scoped_refptr<Layer> replica = Layer::Create(); |
180 replica->SetAnchorPoint(gfx::PointF(0.5f, 0.5f)); | 180 replica->SetAnchorPoint(gfx::PointF(0.5f, 0.5f)); |
181 replica->SetPosition(gfx::Point(100, 100)); | 181 replica->SetPosition(gfx::Point(100, 100)); |
182 replica->SetTransform(replica_transform); | 182 replica->SetTransform(replica_transform); |
183 green->SetReplicaLayer(replica.get()); | 183 green->SetReplicaLayer(replica.get()); |
184 | 184 |
185 RunPixelTest(background, | 185 RunPixelTest(GL_WITH_BITMAP, |
| 186 background, |
186 base::FilePath(FILE_PATH_LITERAL( | 187 base::FilePath(FILE_PATH_LITERAL( |
187 "mask_with_replica_of_clipped_layer.png"))); | 188 "mask_with_replica_of_clipped_layer.png"))); |
188 } | 189 } |
189 | 190 |
190 TEST_F(LayerTreeHostMasksPixelTest, MaskOfReplica) { | 191 TEST_F(LayerTreeHostMasksPixelTest, MaskOfReplica) { |
191 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 192 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
192 gfx::Rect(200, 200), SK_ColorWHITE); | 193 gfx::Rect(200, 200), SK_ColorWHITE); |
193 | 194 |
194 MaskContentLayerClient client; | 195 MaskContentLayerClient client; |
195 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); | 196 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); |
(...skipping 13 matching lines...) Expand all Loading... |
209 replica_transform.Rotate(180.0); | 210 replica_transform.Rotate(180.0); |
210 replica_transform.Translate(100.0, 0.0); | 211 replica_transform.Translate(100.0, 0.0); |
211 | 212 |
212 scoped_refptr<Layer> replica = Layer::Create(); | 213 scoped_refptr<Layer> replica = Layer::Create(); |
213 replica->SetAnchorPoint(gfx::PointF(1.f, 1.f)); | 214 replica->SetAnchorPoint(gfx::PointF(1.f, 1.f)); |
214 replica->SetPosition(gfx::Point()); | 215 replica->SetPosition(gfx::Point()); |
215 replica->SetTransform(replica_transform); | 216 replica->SetTransform(replica_transform); |
216 replica->SetMaskLayer(mask.get()); | 217 replica->SetMaskLayer(mask.get()); |
217 green->SetReplicaLayer(replica.get()); | 218 green->SetReplicaLayer(replica.get()); |
218 | 219 |
219 RunPixelTest(background, | 220 RunPixelTest(GL_WITH_BITMAP, |
220 base::FilePath(FILE_PATH_LITERAL( | 221 background, |
221 "mask_of_replica.png"))); | 222 base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png"))); |
222 } | 223 } |
223 | 224 |
224 TEST_F(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) { | 225 TEST_F(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) { |
225 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 226 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
226 gfx::Rect(200, 200), SK_ColorWHITE); | 227 gfx::Rect(200, 200), SK_ColorWHITE); |
227 | 228 |
228 MaskContentLayerClient client; | 229 MaskContentLayerClient client; |
229 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); | 230 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); |
230 mask->SetBounds(gfx::Size(100, 100)); | 231 mask->SetBounds(gfx::Size(100, 100)); |
231 mask->SetIsDrawable(true); | 232 mask->SetIsDrawable(true); |
(...skipping 19 matching lines...) Expand all Loading... |
251 replica_transform.Rotate(180.0); | 252 replica_transform.Rotate(180.0); |
252 replica_transform.Translate(100.0, 0.0); | 253 replica_transform.Translate(100.0, 0.0); |
253 | 254 |
254 scoped_refptr<Layer> replica = Layer::Create(); | 255 scoped_refptr<Layer> replica = Layer::Create(); |
255 replica->SetAnchorPoint(gfx::PointF(1.f, 1.f)); | 256 replica->SetAnchorPoint(gfx::PointF(1.f, 1.f)); |
256 replica->SetPosition(gfx::Point()); | 257 replica->SetPosition(gfx::Point()); |
257 replica->SetTransform(replica_transform); | 258 replica->SetTransform(replica_transform); |
258 replica->SetMaskLayer(mask.get()); | 259 replica->SetMaskLayer(mask.get()); |
259 green->SetReplicaLayer(replica.get()); | 260 green->SetReplicaLayer(replica.get()); |
260 | 261 |
261 RunPixelTest(background, | 262 RunPixelTest(GL_WITH_BITMAP, |
| 263 background, |
262 base::FilePath(FILE_PATH_LITERAL( | 264 base::FilePath(FILE_PATH_LITERAL( |
263 "mask_of_replica_of_clipped_layer.png"))); | 265 "mask_of_replica_of_clipped_layer.png"))); |
264 } | 266 } |
265 | 267 |
266 } // namespace | 268 } // namespace |
267 } // namespace cc | 269 } // namespace cc |
268 | 270 |
269 #endif // OS_ANDROID | 271 #endif // OS_ANDROID |
OLD | NEW |