| 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_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/test/layer_tree_pixel_test.h" | 10 #include "cc/test/layer_tree_pixel_test.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 background->AddChild(green); | 60 background->AddChild(green); |
| 61 | 61 |
| 62 gfx::Size mask_bounds(100, 100); | 62 gfx::Size mask_bounds(100, 100); |
| 63 MaskContentLayerClient client(mask_bounds); | 63 MaskContentLayerClient client(mask_bounds); |
| 64 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 64 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); |
| 65 mask->SetBounds(mask_bounds); | 65 mask->SetBounds(mask_bounds); |
| 66 mask->SetIsDrawable(true); | 66 mask->SetIsDrawable(true); |
| 67 mask->SetIsMask(true); | 67 mask->SetIsMask(true); |
| 68 green->SetMaskLayer(mask.get()); | 68 green->SetMaskLayer(mask.get()); |
| 69 | 69 |
| 70 RunPixelTest(GL_WITH_BITMAP, | 70 RunPixelTest(PIXEL_TEST_GL, |
| 71 background, | 71 background, |
| 72 base::FilePath(FILE_PATH_LITERAL("mask_of_layer.png"))); | 72 base::FilePath(FILE_PATH_LITERAL("mask_of_layer.png"))); |
| 73 } | 73 } |
| 74 | 74 |
| 75 TEST_F(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) { | 75 TEST_F(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) { |
| 76 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 76 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
| 77 gfx::Rect(200, 200), SK_ColorWHITE); | 77 gfx::Rect(200, 200), SK_ColorWHITE); |
| 78 | 78 |
| 79 gfx::Size mask_bounds(100, 100); | 79 gfx::Size mask_bounds(100, 100); |
| 80 | 80 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 91 client.PaintContents(&canvas, | 91 client.PaintContents(&canvas, |
| 92 gfx::Rect(mask_bounds), | 92 gfx::Rect(mask_bounds), |
| 93 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); | 93 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); |
| 94 mask->SetBitmap(bitmap); | 94 mask->SetBitmap(bitmap); |
| 95 | 95 |
| 96 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 96 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
| 97 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 97 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
| 98 green->SetMaskLayer(mask.get()); | 98 green->SetMaskLayer(mask.get()); |
| 99 background->AddChild(green); | 99 background->AddChild(green); |
| 100 | 100 |
| 101 RunPixelTest(GL_WITH_BITMAP, | 101 RunPixelTest(PIXEL_TEST_GL, |
| 102 background, | 102 background, |
| 103 base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); | 103 base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); |
| 104 } | 104 } |
| 105 | 105 |
| 106 TEST_F(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { | 106 TEST_F(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { |
| 107 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 107 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
| 108 gfx::Rect(200, 200), SK_ColorWHITE); | 108 gfx::Rect(200, 200), SK_ColorWHITE); |
| 109 | 109 |
| 110 // Clip to the top half of the green layer. | 110 // Clip to the top half of the green layer. |
| 111 scoped_refptr<Layer> clip = Layer::Create(); | 111 scoped_refptr<Layer> clip = Layer::Create(); |
| 112 clip->SetPosition(gfx::Point(0, 0)); | 112 clip->SetPosition(gfx::Point(0, 0)); |
| 113 clip->SetBounds(gfx::Size(200, 100)); | 113 clip->SetBounds(gfx::Size(200, 100)); |
| 114 clip->SetMasksToBounds(true); | 114 clip->SetMasksToBounds(true); |
| 115 background->AddChild(clip); | 115 background->AddChild(clip); |
| 116 | 116 |
| 117 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 117 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
| 118 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 118 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
| 119 clip->AddChild(green); | 119 clip->AddChild(green); |
| 120 | 120 |
| 121 gfx::Size mask_bounds(100, 100); | 121 gfx::Size mask_bounds(100, 100); |
| 122 MaskContentLayerClient client(mask_bounds); | 122 MaskContentLayerClient client(mask_bounds); |
| 123 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 123 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); |
| 124 mask->SetBounds(mask_bounds); | 124 mask->SetBounds(mask_bounds); |
| 125 mask->SetIsDrawable(true); | 125 mask->SetIsDrawable(true); |
| 126 mask->SetIsMask(true); | 126 mask->SetIsMask(true); |
| 127 green->SetMaskLayer(mask.get()); | 127 green->SetMaskLayer(mask.get()); |
| 128 | 128 |
| 129 RunPixelTest(GL_WITH_BITMAP, | 129 RunPixelTest(PIXEL_TEST_GL, |
| 130 background, | 130 background, |
| 131 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); | 131 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); |
| 132 } | 132 } |
| 133 | 133 |
| 134 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplica) { | 134 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplica) { |
| 135 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 135 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
| 136 gfx::Rect(200, 200), SK_ColorWHITE); | 136 gfx::Rect(200, 200), SK_ColorWHITE); |
| 137 | 137 |
| 138 gfx::Size mask_bounds(100, 100); | 138 gfx::Size mask_bounds(100, 100); |
| 139 MaskContentLayerClient client(mask_bounds); | 139 MaskContentLayerClient client(mask_bounds); |
| 140 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 140 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); |
| 141 mask->SetBounds(mask_bounds); | 141 mask->SetBounds(mask_bounds); |
| 142 mask->SetIsDrawable(true); | 142 mask->SetIsDrawable(true); |
| 143 mask->SetIsMask(true); | 143 mask->SetIsMask(true); |
| 144 | 144 |
| 145 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 145 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
| 146 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 146 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
| 147 background->AddChild(green); | 147 background->AddChild(green); |
| 148 green->SetMaskLayer(mask.get()); | 148 green->SetMaskLayer(mask.get()); |
| 149 | 149 |
| 150 gfx::Transform replica_transform; | 150 gfx::Transform replica_transform; |
| 151 replica_transform.Rotate(-90.0); | 151 replica_transform.Rotate(-90.0); |
| 152 | 152 |
| 153 scoped_refptr<Layer> replica = Layer::Create(); | 153 scoped_refptr<Layer> replica = Layer::Create(); |
| 154 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); | 154 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); |
| 155 replica->SetPosition(gfx::Point(100, 100)); | 155 replica->SetPosition(gfx::Point(100, 100)); |
| 156 replica->SetTransform(replica_transform); | 156 replica->SetTransform(replica_transform); |
| 157 green->SetReplicaLayer(replica.get()); | 157 green->SetReplicaLayer(replica.get()); |
| 158 | 158 |
| 159 RunPixelTest(GL_WITH_BITMAP, | 159 RunPixelTest(PIXEL_TEST_GL, |
| 160 background, | 160 background, |
| 161 base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); | 161 base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); |
| 162 } | 162 } |
| 163 | 163 |
| 164 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { | 164 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { |
| 165 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 165 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
| 166 gfx::Rect(200, 200), SK_ColorWHITE); | 166 gfx::Rect(200, 200), SK_ColorWHITE); |
| 167 | 167 |
| 168 gfx::Size mask_bounds(100, 100); | 168 gfx::Size mask_bounds(100, 100); |
| 169 MaskContentLayerClient client(mask_bounds); | 169 MaskContentLayerClient client(mask_bounds); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 187 | 187 |
| 188 gfx::Transform replica_transform; | 188 gfx::Transform replica_transform; |
| 189 replica_transform.Rotate(-90.0); | 189 replica_transform.Rotate(-90.0); |
| 190 | 190 |
| 191 scoped_refptr<Layer> replica = Layer::Create(); | 191 scoped_refptr<Layer> replica = Layer::Create(); |
| 192 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); | 192 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); |
| 193 replica->SetPosition(gfx::Point(100, 100)); | 193 replica->SetPosition(gfx::Point(100, 100)); |
| 194 replica->SetTransform(replica_transform); | 194 replica->SetTransform(replica_transform); |
| 195 green->SetReplicaLayer(replica.get()); | 195 green->SetReplicaLayer(replica.get()); |
| 196 | 196 |
| 197 RunPixelTest(GL_WITH_BITMAP, | 197 RunPixelTest(PIXEL_TEST_GL, |
| 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 } |
| 202 | 202 |
| 203 TEST_F(LayerTreeHostMasksPixelTest, MaskOfReplica) { | 203 TEST_F(LayerTreeHostMasksPixelTest, MaskOfReplica) { |
| 204 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 204 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
| 205 gfx::Rect(200, 200), SK_ColorWHITE); | 205 gfx::Rect(200, 200), SK_ColorWHITE); |
| 206 | 206 |
| 207 gfx::Size mask_bounds(100, 100); | 207 gfx::Size mask_bounds(100, 100); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 223 replica_transform.Rotate(180.0); | 223 replica_transform.Rotate(180.0); |
| 224 replica_transform.Translate(100.0, 0.0); | 224 replica_transform.Translate(100.0, 0.0); |
| 225 | 225 |
| 226 scoped_refptr<Layer> replica = Layer::Create(); | 226 scoped_refptr<Layer> replica = Layer::Create(); |
| 227 replica->SetTransformOrigin(gfx::Point3F(100.f, 100.f, 0.f)); | 227 replica->SetTransformOrigin(gfx::Point3F(100.f, 100.f, 0.f)); |
| 228 replica->SetPosition(gfx::Point()); | 228 replica->SetPosition(gfx::Point()); |
| 229 replica->SetTransform(replica_transform); | 229 replica->SetTransform(replica_transform); |
| 230 replica->SetMaskLayer(mask.get()); | 230 replica->SetMaskLayer(mask.get()); |
| 231 green->SetReplicaLayer(replica.get()); | 231 green->SetReplicaLayer(replica.get()); |
| 232 | 232 |
| 233 RunPixelTest(GL_WITH_BITMAP, | 233 RunPixelTest(PIXEL_TEST_GL, |
| 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 gfx::Size mask_bounds(100, 100); | 242 gfx::Size mask_bounds(100, 100); |
| 243 MaskContentLayerClient client(mask_bounds); | 243 MaskContentLayerClient client(mask_bounds); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 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->SetTransformOrigin(gfx::Point3F(100.f, 100.f, 0.f)); | 269 replica->SetTransformOrigin(gfx::Point3F(100.f, 100.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 RunPixelTest(GL_WITH_BITMAP, | 275 RunPixelTest(PIXEL_TEST_GL, |
| 276 background, | 276 background, |
| 277 base::FilePath(FILE_PATH_LITERAL( | 277 base::FilePath( |
| 278 "mask_of_replica_of_clipped_layer.png"))); | 278 FILE_PATH_LITERAL("mask_of_replica_of_clipped_layer.png"))); |
| 279 } | 279 } |
| 280 | 280 |
| 281 } // namespace | 281 } // namespace |
| 282 } // namespace cc | 282 } // namespace cc |
| 283 | 283 |
| 284 #endif // OS_ANDROID | 284 #endif // OS_ANDROID |
| OLD | NEW |