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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "cc/layers/content_layer_client.h" | 8 #include "cc/layers/content_layer_client.h" |
9 #include "cc/layers/picture_image_layer.h" | 9 #include "cc/layers/picture_image_layer.h" |
10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
11 #include "cc/layers/solid_color_layer.h" | 11 #include "cc/layers/solid_color_layer.h" |
12 #include "cc/playback/display_item_list_settings.h" | 12 #include "cc/playback/display_item_list_settings.h" |
13 #include "cc/playback/drawing_display_item.h" | 13 #include "cc/playback/drawing_display_item.h" |
14 #include "cc/test/layer_tree_pixel_resource_test.h" | 14 #include "cc/test/layer_tree_pixel_resource_test.h" |
15 #include "cc/test/pixel_comparator.h" | 15 #include "cc/test/pixel_comparator.h" |
| 16 #include "cc/test/solid_color_content_layer_client.h" |
16 #include "third_party/skia/include/core/SkImage.h" | 17 #include "third_party/skia/include/core/SkImage.h" |
17 #include "third_party/skia/include/core/SkPictureRecorder.h" | 18 #include "third_party/skia/include/core/SkPictureRecorder.h" |
18 #include "third_party/skia/include/core/SkSurface.h" | 19 #include "third_party/skia/include/core/SkSurface.h" |
19 | 20 |
20 #if !defined(OS_ANDROID) | 21 #if !defined(OS_ANDROID) |
21 | 22 |
22 namespace cc { | 23 namespace cc { |
23 namespace { | 24 namespace { |
24 | 25 |
25 typedef ParameterizedPixelResourceTest LayerTreeHostMasksPixelTest; | 26 typedef ParameterizedPixelResourceTest LayerTreeHostMasksPixelTest; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 scoped_refptr<Layer> replica = Layer::Create(); | 172 scoped_refptr<Layer> replica = Layer::Create(); |
172 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f)); | 173 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f)); |
173 replica->SetPosition(gfx::PointF(50.f, 50.f)); | 174 replica->SetPosition(gfx::PointF(50.f, 50.f)); |
174 replica->SetTransform(replica_transform); | 175 replica->SetTransform(replica_transform); |
175 green->SetReplicaLayer(replica.get()); | 176 green->SetReplicaLayer(replica.get()); |
176 | 177 |
177 RunPixelResourceTest( | 178 RunPixelResourceTest( |
178 background, base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); | 179 background, base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); |
179 } | 180 } |
180 | 181 |
| 182 // Test collapsing of render passes containing a single tile quad and |
| 183 // drawing them directly with masks and replicas. |
| 184 TEST_P(LayerTreeHostMasksPixelTest, ContentLayerMaskWithReplica) { |
| 185 scoped_refptr<SolidColorLayer> background = |
| 186 CreateSolidColorLayer(gfx::Rect(100, 100), SK_ColorWHITE); |
| 187 |
| 188 gfx::Size mask_bounds(50, 50); |
| 189 MaskContentLayerClient client(mask_bounds); |
| 190 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); |
| 191 mask->SetBounds(mask_bounds); |
| 192 mask->SetIsDrawable(true); |
| 193 mask->SetIsMask(true); |
| 194 |
| 195 // Use a border to defeat solid color detection to force a tile quad. |
| 196 SolidColorContentLayerClient green_client(kCSSGreen, mask_bounds, 1, |
| 197 SK_ColorBLACK); |
| 198 scoped_refptr<PictureLayer> green = PictureLayer::Create(&green_client); |
| 199 green->SetBounds(mask_bounds); |
| 200 green->SetIsDrawable(true); |
| 201 background->AddChild(green); |
| 202 green->SetMaskLayer(mask.get()); |
| 203 |
| 204 gfx::Transform replica_transform; |
| 205 replica_transform.Rotate(-90.0); |
| 206 |
| 207 scoped_refptr<Layer> replica = Layer::Create(); |
| 208 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f)); |
| 209 replica->SetPosition(gfx::PointF(50.f, 50.f)); |
| 210 replica->SetTransform(replica_transform); |
| 211 green->SetReplicaLayer(replica.get()); |
| 212 |
| 213 RunPixelResourceTest( |
| 214 background, base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); |
| 215 } |
| 216 |
181 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { | 217 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { |
182 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 218 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
183 gfx::Rect(100, 100), SK_ColorWHITE); | 219 gfx::Rect(100, 100), SK_ColorWHITE); |
184 | 220 |
185 gfx::Size mask_bounds(50, 50); | 221 gfx::Size mask_bounds(50, 50); |
186 MaskContentLayerClient client(mask_bounds); | 222 MaskContentLayerClient client(mask_bounds); |
187 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 223 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); |
188 mask->SetBounds(mask_bounds); | 224 mask->SetBounds(mask_bounds); |
189 mask->SetIsDrawable(true); | 225 mask->SetIsDrawable(true); |
190 mask->SetIsMask(true); | 226 mask->SetIsMask(true); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 | 518 |
483 RunPixelResourceTest(background, | 519 RunPixelResourceTest(background, |
484 base::FilePath( | 520 base::FilePath( |
485 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); | 521 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); |
486 } | 522 } |
487 | 523 |
488 } // namespace | 524 } // namespace |
489 } // namespace cc | 525 } // namespace cc |
490 | 526 |
491 #endif // !defined(OS_ANDROID) | 527 #endif // !defined(OS_ANDROID) |
OLD | NEW |