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/layers/solid_color_layer.h" | 9 #include "cc/layers/solid_color_layer.h" |
10 #include "cc/test/layer_tree_pixel_test.h" | 10 #include "cc/test/layer_tree_pixel_test.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 background, | 100 background, |
101 base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); | 101 base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); |
102 } | 102 } |
103 | 103 |
104 TEST_F(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { | 104 TEST_F(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { |
105 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 105 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
106 gfx::Rect(200, 200), SK_ColorWHITE); | 106 gfx::Rect(200, 200), SK_ColorWHITE); |
107 | 107 |
108 // Clip to the top half of the green layer. | 108 // Clip to the top half of the green layer. |
109 scoped_refptr<Layer> clip = Layer::Create(); | 109 scoped_refptr<Layer> clip = Layer::Create(); |
110 clip->SetAnchorPoint(gfx::PointF(0.f, 0.f)); | 110 clip->SetTransformOrigin(gfx::Point3F(0.f, 0.f, 0.f)); |
111 clip->SetPosition(gfx::Point(0, 0)); | 111 clip->SetPosition(gfx::Point(0, 0)); |
112 clip->SetBounds(gfx::Size(200, 100)); | 112 clip->SetBounds(gfx::Size(200, 100)); |
113 clip->SetMasksToBounds(true); | 113 clip->SetMasksToBounds(true); |
114 background->AddChild(clip); | 114 background->AddChild(clip); |
115 | 115 |
116 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 116 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
117 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 117 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
118 clip->AddChild(green); | 118 clip->AddChild(green); |
119 | 119 |
120 MaskContentLayerClient client; | 120 MaskContentLayerClient client; |
(...skipping 21 matching lines...) Expand all Loading... |
142 | 142 |
143 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 143 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
144 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 144 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
145 background->AddChild(green); | 145 background->AddChild(green); |
146 green->SetMaskLayer(mask.get()); | 146 green->SetMaskLayer(mask.get()); |
147 | 147 |
148 gfx::Transform replica_transform; | 148 gfx::Transform replica_transform; |
149 replica_transform.Rotate(-90.0); | 149 replica_transform.Rotate(-90.0); |
150 | 150 |
151 scoped_refptr<Layer> replica = Layer::Create(); | 151 scoped_refptr<Layer> replica = Layer::Create(); |
152 replica->SetAnchorPoint(gfx::PointF(0.5f, 0.5f)); | 152 replica->SetTransformOrigin(gfx::Point3F(0.5f, 0.5f, 0.f)); |
153 replica->SetPosition(gfx::Point(100, 100)); | 153 replica->SetPosition(gfx::Point(100, 100)); |
154 replica->SetTransform(replica_transform); | 154 replica->SetTransform(replica_transform); |
155 green->SetReplicaLayer(replica.get()); | 155 green->SetReplicaLayer(replica.get()); |
156 | 156 |
157 this->impl_side_painting_ = false; | 157 this->impl_side_painting_ = false; |
158 RunPixelTest(GL_WITH_BITMAP, | 158 RunPixelTest(GL_WITH_BITMAP, |
159 background, | 159 background, |
160 base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); | 160 base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); |
161 } | 161 } |
162 | 162 |
163 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { | 163 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { |
164 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 164 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
165 gfx::Rect(200, 200), SK_ColorWHITE); | 165 gfx::Rect(200, 200), SK_ColorWHITE); |
166 | 166 |
167 MaskContentLayerClient client; | 167 MaskContentLayerClient client; |
168 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); | 168 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); |
169 mask->SetBounds(gfx::Size(100, 100)); | 169 mask->SetBounds(gfx::Size(100, 100)); |
170 mask->SetIsDrawable(true); | 170 mask->SetIsDrawable(true); |
171 mask->SetIsMask(true); | 171 mask->SetIsMask(true); |
172 | 172 |
173 // Clip to the bottom half of the green layer, and the left half of the | 173 // Clip to the bottom half of the green layer, and the left half of the |
174 // replica. | 174 // replica. |
175 scoped_refptr<Layer> clip = Layer::Create(); | 175 scoped_refptr<Layer> clip = Layer::Create(); |
176 clip->SetAnchorPoint(gfx::PointF(0.f, 0.f)); | 176 clip->SetTransformOrigin(gfx::Point3F(0.f, 0.f, 0.f)); |
177 clip->SetPosition(gfx::Point(0, 50)); | 177 clip->SetPosition(gfx::Point(0, 50)); |
178 clip->SetBounds(gfx::Size(150, 150)); | 178 clip->SetBounds(gfx::Size(150, 150)); |
179 clip->SetMasksToBounds(true); | 179 clip->SetMasksToBounds(true); |
180 background->AddChild(clip); | 180 background->AddChild(clip); |
181 | 181 |
182 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 182 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
183 gfx::Rect(0, -50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 183 gfx::Rect(0, -50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
184 clip->AddChild(green); | 184 clip->AddChild(green); |
185 green->SetMaskLayer(mask.get()); | 185 green->SetMaskLayer(mask.get()); |
186 | 186 |
187 gfx::Transform replica_transform; | 187 gfx::Transform replica_transform; |
188 replica_transform.Rotate(-90.0); | 188 replica_transform.Rotate(-90.0); |
189 | 189 |
190 scoped_refptr<Layer> replica = Layer::Create(); | 190 scoped_refptr<Layer> replica = Layer::Create(); |
191 replica->SetAnchorPoint(gfx::PointF(0.5f, 0.5f)); | 191 replica->SetTransformOrigin(gfx::Point3F(0.5f, 0.5f, 0.f)); |
192 replica->SetPosition(gfx::Point(100, 100)); | 192 replica->SetPosition(gfx::Point(100, 100)); |
193 replica->SetTransform(replica_transform); | 193 replica->SetTransform(replica_transform); |
194 green->SetReplicaLayer(replica.get()); | 194 green->SetReplicaLayer(replica.get()); |
195 | 195 |
196 this->impl_side_painting_ = false; | 196 this->impl_side_painting_ = false; |
197 RunPixelTest(GL_WITH_BITMAP, | 197 RunPixelTest(GL_WITH_BITMAP, |
198 background, | 198 background, |
199 base::FilePath(FILE_PATH_LITERAL( | 199 base::FilePath(FILE_PATH_LITERAL( |
200 "mask_with_replica_of_clipped_layer.png"))); | 200 "mask_with_replica_of_clipped_layer.png"))); |
201 } | 201 } |
(...skipping 14 matching lines...) Expand all Loading... |
216 | 216 |
217 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( | 217 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( |
218 gfx::Rect(-50, 50, 50, 50), kCSSOrange); | 218 gfx::Rect(-50, 50, 50, 50), kCSSOrange); |
219 green->AddChild(orange); | 219 green->AddChild(orange); |
220 | 220 |
221 gfx::Transform replica_transform; | 221 gfx::Transform replica_transform; |
222 replica_transform.Rotate(180.0); | 222 replica_transform.Rotate(180.0); |
223 replica_transform.Translate(100.0, 0.0); | 223 replica_transform.Translate(100.0, 0.0); |
224 | 224 |
225 scoped_refptr<Layer> replica = Layer::Create(); | 225 scoped_refptr<Layer> replica = Layer::Create(); |
226 replica->SetAnchorPoint(gfx::PointF(1.f, 1.f)); | 226 replica->SetTransformOrigin(gfx::Point3F(1.f, 1.f, 0.f)); |
227 replica->SetPosition(gfx::Point()); | 227 replica->SetPosition(gfx::Point()); |
228 replica->SetTransform(replica_transform); | 228 replica->SetTransform(replica_transform); |
229 replica->SetMaskLayer(mask.get()); | 229 replica->SetMaskLayer(mask.get()); |
230 green->SetReplicaLayer(replica.get()); | 230 green->SetReplicaLayer(replica.get()); |
231 | 231 |
232 this->impl_side_painting_ = false; | 232 this->impl_side_painting_ = false; |
233 RunPixelTest(GL_WITH_BITMAP, | 233 RunPixelTest(GL_WITH_BITMAP, |
234 background, | 234 background, |
235 base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png"))); | 235 base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png"))); |
236 } | 236 } |
237 | 237 |
238 TEST_F(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) { | 238 TEST_F(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) { |
239 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 239 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
240 gfx::Rect(200, 200), SK_ColorWHITE); | 240 gfx::Rect(200, 200), SK_ColorWHITE); |
241 | 241 |
242 MaskContentLayerClient client; | 242 MaskContentLayerClient client; |
243 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); | 243 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client); |
244 mask->SetBounds(gfx::Size(100, 100)); | 244 mask->SetBounds(gfx::Size(100, 100)); |
245 mask->SetIsDrawable(true); | 245 mask->SetIsDrawable(true); |
246 mask->SetIsMask(true); | 246 mask->SetIsMask(true); |
247 | 247 |
248 // Clip to the bottom 3/4 of the green layer, and the top 3/4 of the replica. | 248 // Clip to the bottom 3/4 of the green layer, and the top 3/4 of the replica. |
249 scoped_refptr<Layer> clip = Layer::Create(); | 249 scoped_refptr<Layer> clip = Layer::Create(); |
250 clip->SetAnchorPoint(gfx::PointF(0.f, 0.f)); | 250 clip->SetTransformOrigin(gfx::Point3F(0.f, 0.f, 0.f)); |
251 clip->SetPosition(gfx::Point(0, 25)); | 251 clip->SetPosition(gfx::Point(0, 25)); |
252 clip->SetBounds(gfx::Size(200, 150)); | 252 clip->SetBounds(gfx::Size(200, 150)); |
253 clip->SetMasksToBounds(true); | 253 clip->SetMasksToBounds(true); |
254 background->AddChild(clip); | 254 background->AddChild(clip); |
255 | 255 |
256 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 256 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
257 gfx::Rect(50, -25, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 257 gfx::Rect(50, -25, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
258 clip->AddChild(green); | 258 clip->AddChild(green); |
259 | 259 |
260 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( | 260 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( |
261 gfx::Rect(-50, 50, 50, 50), kCSSOrange); | 261 gfx::Rect(-50, 50, 50, 50), kCSSOrange); |
262 green->AddChild(orange); | 262 green->AddChild(orange); |
263 | 263 |
264 gfx::Transform replica_transform; | 264 gfx::Transform replica_transform; |
265 replica_transform.Rotate(180.0); | 265 replica_transform.Rotate(180.0); |
266 replica_transform.Translate(100.0, 0.0); | 266 replica_transform.Translate(100.0, 0.0); |
267 | 267 |
268 scoped_refptr<Layer> replica = Layer::Create(); | 268 scoped_refptr<Layer> replica = Layer::Create(); |
269 replica->SetAnchorPoint(gfx::PointF(1.f, 1.f)); | 269 replica->SetTransformOrigin(gfx::Point3F(1.f, 1.f, 0.f)); |
270 replica->SetPosition(gfx::Point()); | 270 replica->SetPosition(gfx::Point()); |
271 replica->SetTransform(replica_transform); | 271 replica->SetTransform(replica_transform); |
272 replica->SetMaskLayer(mask.get()); | 272 replica->SetMaskLayer(mask.get()); |
273 green->SetReplicaLayer(replica.get()); | 273 green->SetReplicaLayer(replica.get()); |
274 | 274 |
275 this->impl_side_painting_ = false; | 275 this->impl_side_painting_ = false; |
276 RunPixelTest(GL_WITH_BITMAP, | 276 RunPixelTest(GL_WITH_BITMAP, |
277 background, | 277 background, |
278 base::FilePath(FILE_PATH_LITERAL( | 278 base::FilePath(FILE_PATH_LITERAL( |
279 "mask_of_replica_of_clipped_layer.png"))); | 279 "mask_of_replica_of_clipped_layer.png"))); |
280 } | 280 } |
281 | 281 |
282 } // namespace | 282 } // namespace |
283 } // namespace cc | 283 } // namespace cc |
284 | 284 |
285 #endif // OS_ANDROID | 285 #endif // OS_ANDROID |
OLD | NEW |