OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // not be marked opaque. | 236 // not be marked opaque. |
237 | 237 |
238 context.setCompositeOperation(CompositeSourceOver); | 238 context.setCompositeOperation(CompositeSourceOver); |
239 context.beginTransparencyLayer(1); | 239 context.beginTransparencyLayer(1); |
240 context.fillRect(FloatRect(10, 10, 10, 10), opaque, CompositeSourceOver); | 240 context.fillRect(FloatRect(10, 10, 10, 10), opaque, CompositeSourceOver); |
241 | 241 |
242 context.setCompositeOperation(CompositeDestinationIn); | 242 context.setCompositeOperation(CompositeDestinationIn); |
243 context.beginTransparencyLayer(1); | 243 context.beginTransparencyLayer(1); |
244 | 244 |
245 OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100)); | 245 OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100)); |
| 246 EXPECT_FALSE(!alphaImage); |
246 alphaImage->context()->fillRect(IntRect(0, 0, 100, 100), alpha); | 247 alphaImage->context()->fillRect(IntRect(0, 0, 100, 100), alpha); |
247 | 248 |
248 context.setCompositeOperation(CompositeSourceOver); | 249 context.setCompositeOperation(CompositeSourceOver); |
249 context.drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10)); | 250 context.drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10)); |
250 | 251 |
251 context.endLayer(); | 252 context.endLayer(); |
252 context.endLayer(); | 253 context.endLayer(); |
253 | 254 |
254 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); | 255 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); |
255 EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect()); | 256 EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect()); |
(...skipping 17 matching lines...) Expand all Loading... |
273 // not be marked opaque. | 274 // not be marked opaque. |
274 | 275 |
275 context.setCompositeOperation(CompositeSourceOver); | 276 context.setCompositeOperation(CompositeSourceOver); |
276 context.beginTransparencyLayer(1); | 277 context.beginTransparencyLayer(1); |
277 context.fillRect(FloatRect(10, 10, 10, 10), opaque, CompositeSourceOver); | 278 context.fillRect(FloatRect(10, 10, 10, 10), opaque, CompositeSourceOver); |
278 | 279 |
279 context.setCompositeOperation(CompositeDestinationIn); | 280 context.setCompositeOperation(CompositeDestinationIn); |
280 context.beginTransparencyLayer(1); | 281 context.beginTransparencyLayer(1); |
281 | 282 |
282 OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100)); | 283 OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100)); |
| 284 EXPECT_FALSE(!alphaImage); |
283 alphaImage->context()->fillRect(IntRect(0, 0, 100, 100), alpha); | 285 alphaImage->context()->fillRect(IntRect(0, 0, 100, 100), alpha); |
284 | 286 |
285 context.setCompositeOperation(CompositeSourceOver); | 287 context.setCompositeOperation(CompositeSourceOver); |
286 context.drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10)); | 288 context.drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10)); |
287 | 289 |
288 // We can't have an opaque mask actually, but we can pretend here like it wo
uld look if we did. | 290 // We can't have an opaque mask actually, but we can pretend here like it wo
uld look if we did. |
289 context.fillRect(FloatRect(12, 12, 3, 3), opaque, CompositeSourceOver); | 291 context.fillRect(FloatRect(12, 12, 3, 3), opaque, CompositeSourceOver); |
290 | 292 |
291 context.endLayer(); | 293 context.endLayer(); |
292 context.endLayer(); | 294 context.endLayer(); |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 // endRecording finally makes the picture accessible | 1182 // endRecording finally makes the picture accessible |
1181 RefPtr<DisplayList> dl = context.endRecording(); | 1183 RefPtr<DisplayList> dl = context.endRecording(); |
1182 SkPicture* pic = dl->picture(); | 1184 SkPicture* pic = dl->picture(); |
1183 EXPECT_TRUE(pic); | 1185 EXPECT_TRUE(pic); |
1184 EXPECT_EQ(1, pic->getRefCnt()); | 1186 EXPECT_EQ(1, pic->getRefCnt()); |
1185 | 1187 |
1186 context.endRecording(); | 1188 context.endRecording(); |
1187 } | 1189 } |
1188 | 1190 |
1189 } // namespace | 1191 } // namespace |
OLD | NEW |