| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 context.restore(); | 208 context.restore(); |
| 209 | 209 |
| 210 // Another non-rectangular clip. | 210 // Another non-rectangular clip. |
| 211 context.save(); | 211 context.save(); |
| 212 context.clip(IntRect(30, 30, 20, 20)); | 212 context.clip(IntRect(30, 30, 20, 20)); |
| 213 context.clipOut(IntRect(30, 30, 10, 10)); | 213 context.clipOut(IntRect(30, 30, 10, 10)); |
| 214 context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver); | 214 context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver); |
| 215 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); | 215 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); |
| 216 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect()); | 216 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect()); |
| 217 context.restore(); | 217 context.restore(); |
| 218 | |
| 219 OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100)); | |
| 220 alphaImage->context()->fillRect(IntRect(0, 0, 100, 100), alpha); | |
| 221 | |
| 222 // Clipping with a non-opaque Image (there is no way to mark an ImageBuffer
as opaque today). | |
| 223 context.save(); | |
| 224 context.clipToImageBuffer(alphaImage.get(), FloatRect(30, 30, 10, 10)); | |
| 225 context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver); | |
| 226 context.restore(); | |
| 227 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); | |
| 228 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect()); | |
| 229 } | 218 } |
| 230 | 219 |
| 231 TEST(GraphicsContextTest, trackImageMask) | 220 TEST(GraphicsContextTest, trackImageMask) |
| 232 { | 221 { |
| 233 SkBitmap bitmap; | 222 SkBitmap bitmap; |
| 234 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400); | 223 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400); |
| 235 bitmap.allocPixels(); | 224 bitmap.allocPixels(); |
| 236 bitmap.eraseColor(0); | 225 bitmap.eraseColor(0); |
| 237 SkCanvas canvas(bitmap); | 226 SkCanvas canvas(bitmap); |
| 238 | 227 |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 path.moveTo(FloatPoint(10, 10)); | 1082 path.moveTo(FloatPoint(10, 10)); |
| 1094 path.addLineTo(FloatPoint(40, 40)); | 1083 path.addLineTo(FloatPoint(40, 40)); |
| 1095 context.strokePath(path); | 1084 context.strokePath(path); |
| 1096 | 1085 |
| 1097 context.endTransparencyLayer(); | 1086 context.endTransparencyLayer(); |
| 1098 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); | 1087 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); |
| 1099 EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect()); | 1088 EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect()); |
| 1100 } | 1089 } |
| 1101 | 1090 |
| 1102 } // namespace | 1091 } // namespace |
| OLD | NEW |