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