Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: cc/trees/layer_tree_host_pixeltest_masks.cc

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_client.h" 6 #include "cc/layers/content_layer_client.h"
7 #include "cc/layers/picture_image_layer.h" 7 #include "cc/layers/picture_image_layer.h"
8 #include "cc/layers/picture_layer.h" 8 #include "cc/layers/picture_layer.h"
9 #include "cc/layers/solid_color_layer.h" 9 #include "cc/layers/solid_color_layer.h"
10 #include "cc/playback/display_item_list_settings.h" 10 #include "cc/playback/display_item_list_settings.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 RunPixelResourceTest( 133 RunPixelResourceTest(
134 background, base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); 134 background, base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png")));
135 } 135 }
136 136
137 TEST_P(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { 137 TEST_P(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) {
138 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 138 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
139 gfx::Rect(100, 100), SK_ColorWHITE); 139 gfx::Rect(100, 100), SK_ColorWHITE);
140 140
141 // Clip to the top half of the green layer. 141 // Clip to the top half of the green layer.
142 scoped_refptr<Layer> clip = Layer::Create(layer_settings()); 142 scoped_refptr<Layer> clip = Layer::Create(layer_settings());
143 clip->SetPosition(gfx::Point(0, 0)); 143 clip->SetPosition(gfx::PointF());
144 clip->SetBounds(gfx::Size(100, 50)); 144 clip->SetBounds(gfx::Size(100, 50));
145 clip->SetMasksToBounds(true); 145 clip->SetMasksToBounds(true);
146 background->AddChild(clip); 146 background->AddChild(clip);
147 147
148 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 148 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
149 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); 149 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
150 clip->AddChild(green); 150 clip->AddChild(green);
151 151
152 gfx::Size mask_bounds(50, 50); 152 gfx::Size mask_bounds(50, 50);
153 MaskContentLayerClient client(mask_bounds); 153 MaskContentLayerClient client(mask_bounds);
(...skipping 24 matching lines...) Expand all
178 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 178 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
179 gfx::Rect(0, 0, 50, 50), kCSSGreen, 1, SK_ColorBLACK); 179 gfx::Rect(0, 0, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
180 background->AddChild(green); 180 background->AddChild(green);
181 green->SetMaskLayer(mask.get()); 181 green->SetMaskLayer(mask.get());
182 182
183 gfx::Transform replica_transform; 183 gfx::Transform replica_transform;
184 replica_transform.Rotate(-90.0); 184 replica_transform.Rotate(-90.0);
185 185
186 scoped_refptr<Layer> replica = Layer::Create(layer_settings()); 186 scoped_refptr<Layer> replica = Layer::Create(layer_settings());
187 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f)); 187 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f));
188 replica->SetPosition(gfx::Point(50, 50)); 188 replica->SetPosition(gfx::PointF(50.f, 50.f));
189 replica->SetTransform(replica_transform); 189 replica->SetTransform(replica_transform);
190 green->SetReplicaLayer(replica.get()); 190 green->SetReplicaLayer(replica.get());
191 191
192 RunPixelResourceTest( 192 RunPixelResourceTest(
193 background, base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); 193 background, base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png")));
194 } 194 }
195 195
196 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { 196 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) {
197 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 197 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
198 gfx::Rect(100, 100), SK_ColorWHITE); 198 gfx::Rect(100, 100), SK_ColorWHITE);
199 199
200 gfx::Size mask_bounds(50, 50); 200 gfx::Size mask_bounds(50, 50);
201 MaskContentLayerClient client(mask_bounds); 201 MaskContentLayerClient client(mask_bounds);
202 scoped_refptr<PictureLayer> mask = 202 scoped_refptr<PictureLayer> mask =
203 PictureLayer::Create(layer_settings(), &client); 203 PictureLayer::Create(layer_settings(), &client);
204 mask->SetBounds(mask_bounds); 204 mask->SetBounds(mask_bounds);
205 mask->SetIsDrawable(true); 205 mask->SetIsDrawable(true);
206 mask->SetIsMask(true); 206 mask->SetIsMask(true);
207 207
208 // Clip to the bottom half of the green layer, and the left half of the 208 // Clip to the bottom half of the green layer, and the left half of the
209 // replica. 209 // replica.
210 scoped_refptr<Layer> clip = Layer::Create(layer_settings()); 210 scoped_refptr<Layer> clip = Layer::Create(layer_settings());
211 clip->SetPosition(gfx::Point(0, 25)); 211 clip->SetPosition(gfx::PointF(0.f, 25.f));
212 clip->SetBounds(gfx::Size(75, 75)); 212 clip->SetBounds(gfx::Size(75, 75));
213 clip->SetMasksToBounds(true); 213 clip->SetMasksToBounds(true);
214 background->AddChild(clip); 214 background->AddChild(clip);
215 215
216 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 216 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
217 gfx::Rect(0, -25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); 217 gfx::Rect(0, -25, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
218 clip->AddChild(green); 218 clip->AddChild(green);
219 green->SetMaskLayer(mask.get()); 219 green->SetMaskLayer(mask.get());
220 220
221 gfx::Transform replica_transform; 221 gfx::Transform replica_transform;
222 replica_transform.Rotate(-90.0); 222 replica_transform.Rotate(-90.0);
223 223
224 scoped_refptr<Layer> replica = Layer::Create(layer_settings()); 224 scoped_refptr<Layer> replica = Layer::Create(layer_settings());
225 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f)); 225 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f));
226 replica->SetPosition(gfx::Point(50, 50)); 226 replica->SetPosition(gfx::PointF(50.f, 50.f));
227 replica->SetTransform(replica_transform); 227 replica->SetTransform(replica_transform);
228 green->SetReplicaLayer(replica.get()); 228 green->SetReplicaLayer(replica.get());
229 229
230 RunPixelResourceTest(background, 230 RunPixelResourceTest(background,
231 base::FilePath(FILE_PATH_LITERAL( 231 base::FilePath(FILE_PATH_LITERAL(
232 "mask_with_replica_of_clipped_layer.png"))); 232 "mask_with_replica_of_clipped_layer.png")));
233 } 233 }
234 234
235 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplica) { 235 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplica) {
236 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 236 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
(...skipping 14 matching lines...) Expand all
251 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( 251 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer(
252 gfx::Rect(-25, 25, 25, 25), kCSSOrange); 252 gfx::Rect(-25, 25, 25, 25), kCSSOrange);
253 green->AddChild(orange); 253 green->AddChild(orange);
254 254
255 gfx::Transform replica_transform; 255 gfx::Transform replica_transform;
256 replica_transform.Rotate(180.0); 256 replica_transform.Rotate(180.0);
257 replica_transform.Translate(50.0, 0.0); 257 replica_transform.Translate(50.0, 0.0);
258 258
259 scoped_refptr<Layer> replica = Layer::Create(layer_settings()); 259 scoped_refptr<Layer> replica = Layer::Create(layer_settings());
260 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); 260 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f));
261 replica->SetPosition(gfx::Point()); 261 replica->SetPosition(gfx::PointF());
262 replica->SetTransform(replica_transform); 262 replica->SetTransform(replica_transform);
263 replica->SetMaskLayer(mask.get()); 263 replica->SetMaskLayer(mask.get());
264 green->SetReplicaLayer(replica.get()); 264 green->SetReplicaLayer(replica.get());
265 265
266 RunPixelResourceTest( 266 RunPixelResourceTest(
267 background, base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png"))); 267 background, base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png")));
268 } 268 }
269 269
270 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) { 270 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) {
271 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 271 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
272 gfx::Rect(100, 100), SK_ColorWHITE); 272 gfx::Rect(100, 100), SK_ColorWHITE);
273 273
274 gfx::Size mask_bounds(50, 50); 274 gfx::Size mask_bounds(50, 50);
275 MaskContentLayerClient client(mask_bounds); 275 MaskContentLayerClient client(mask_bounds);
276 scoped_refptr<PictureLayer> mask = 276 scoped_refptr<PictureLayer> mask =
277 PictureLayer::Create(layer_settings(), &client); 277 PictureLayer::Create(layer_settings(), &client);
278 mask->SetBounds(mask_bounds); 278 mask->SetBounds(mask_bounds);
279 mask->SetIsDrawable(true); 279 mask->SetIsDrawable(true);
280 mask->SetIsMask(true); 280 mask->SetIsMask(true);
281 281
282 // Clip to the bottom 3/4 of the green layer, and the top 3/4 of the replica. 282 // Clip to the bottom 3/4 of the green layer, and the top 3/4 of the replica.
283 scoped_refptr<Layer> clip = Layer::Create(layer_settings()); 283 scoped_refptr<Layer> clip = Layer::Create(layer_settings());
284 clip->SetPosition(gfx::Point(0, 12)); 284 clip->SetPosition(gfx::PointF(0.f, 12.f));
285 clip->SetBounds(gfx::Size(100, 75)); 285 clip->SetBounds(gfx::Size(100, 75));
286 clip->SetMasksToBounds(true); 286 clip->SetMasksToBounds(true);
287 background->AddChild(clip); 287 background->AddChild(clip);
288 288
289 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 289 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
290 gfx::Rect(25, -12, 50, 50), kCSSGreen, 1, SK_ColorBLACK); 290 gfx::Rect(25, -12, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
291 clip->AddChild(green); 291 clip->AddChild(green);
292 292
293 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( 293 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer(
294 gfx::Rect(-25, 25, 25, 25), kCSSOrange); 294 gfx::Rect(-25, 25, 25, 25), kCSSOrange);
295 green->AddChild(orange); 295 green->AddChild(orange);
296 296
297 gfx::Transform replica_transform; 297 gfx::Transform replica_transform;
298 replica_transform.Rotate(180.0); 298 replica_transform.Rotate(180.0);
299 replica_transform.Translate(50.0, 0.0); 299 replica_transform.Translate(50.0, 0.0);
300 300
301 scoped_refptr<Layer> replica = Layer::Create(layer_settings()); 301 scoped_refptr<Layer> replica = Layer::Create(layer_settings());
302 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); 302 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f));
303 replica->SetPosition(gfx::Point()); 303 replica->SetPosition(gfx::PointF());
304 replica->SetTransform(replica_transform); 304 replica->SetTransform(replica_transform);
305 replica->SetMaskLayer(mask.get()); 305 replica->SetMaskLayer(mask.get());
306 green->SetReplicaLayer(replica.get()); 306 green->SetReplicaLayer(replica.get());
307 307
308 RunPixelResourceTest(background, 308 RunPixelResourceTest(background,
309 base::FilePath(FILE_PATH_LITERAL( 309 base::FilePath(FILE_PATH_LITERAL(
310 "mask_of_replica_of_clipped_layer.png"))); 310 "mask_of_replica_of_clipped_layer.png")));
311 } 311 }
312 312
313 class CheckerContentLayerClient : public ContentLayerClient { 313 class CheckerContentLayerClient : public ContentLayerClient {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 526
527 RunPixelResourceTest(background, 527 RunPixelResourceTest(background,
528 base::FilePath( 528 base::FilePath(
529 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); 529 FILE_PATH_LITERAL("mask_of_layer_with_blend.png")));
530 } 530 }
531 531
532 } // namespace 532 } // namespace
533 } // namespace cc 533 } // namespace cc
534 534
535 #endif // !defined(OS_ANDROID) 535 #endif // !defined(OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698