Chromium Code Reviews| Index: Source/platform/graphics/GraphicsContextTest.cpp |
| diff --git a/Source/platform/graphics/GraphicsContextTest.cpp b/Source/platform/graphics/GraphicsContextTest.cpp |
| index fd4a9588621b018e68224fc9756d57c97ef4e61d..a117f0b92b4bc574bc0bb740b30960590b8bfcd0 100644 |
| --- a/Source/platform/graphics/GraphicsContextTest.cpp |
| +++ b/Source/platform/graphics/GraphicsContextTest.cpp |
| @@ -1042,6 +1042,85 @@ TEST(GraphicsContextTest, PreserveOpaqueOnlyMattersForFirstLayer) |
| EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect()); |
| } |
| +TEST(GraphicsContextTest, OpaqueRegionForLayerWithNonRectDeviceClip) |
| +{ |
| + SkBitmap bitmap; |
| + ASSERT_TRUE(bitmap.allocN32Pixels(100, 100)); |
| + bitmap.eraseColor(0); |
| + SkCanvas canvas(bitmap); |
| + |
| + GraphicsContext context(&canvas); |
| + context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); |
| + Color opaque(1.0f, 0.0f, 0.0f, 1.0f); |
| + |
| + context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver); |
| + |
| + context.setCompositeOperation(CompositeSourceOver); |
| + context.beginTransparencyLayer(0.5); |
| + |
|
danakj
2014/08/07 12:49:55
nit: rm extra whitespace here
sohanjg
2014/08/07 14:05:20
Done.
|
| + context.endLayer(); |
| + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), context.opaqueRegion().asRect()); |
| + |
| + Path path; |
| + path.moveTo(FloatPoint(0, 0)); |
| + path.addLineTo(FloatPoint(50, 50)); |
| + |
| + // For opaque preserving mode and deviceClip is not rect |
| + // we will not alter opaque rect. |
| + context.clipPath(path, RULE_EVENODD); |
| + |
| + context.setCompositeOperation(CompositeSourceOver); |
| + context.beginTransparencyLayer(0.5); |
| + |
|
danakj
2014/08/07 12:49:55
nit: rm extra whitespace here
sohanjg
2014/08/07 14:05:20
Done.
|
| + context.endLayer(); |
| + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), context.opaqueRegion().asRect()); |
| + |
| + // For non-opaque preserving mode and deviceClip is not rect |
| + // we will mark opaque rect as empty. |
| + context.setCompositeOperation(CompositeSourceOut); |
| + context.beginTransparencyLayer(0.5); |
| + |
| + context.endLayer(); |
| + EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); |
| +} |
| + |
| +TEST(GraphicsContextTest, OpaqueRegionForLayerWithRectDeviceClip) |
| +{ |
| + |
| + SkBitmap bitmap; |
| + ASSERT_TRUE(bitmap.allocN32Pixels(100, 100)); |
| + bitmap.eraseColor(0); |
| + SkCanvas canvas(bitmap); |
| + |
| + Color opaque(1.0f, 0.0f, 0.0f, 1.0f); |
| + |
| + GraphicsContext context(&canvas); |
| + context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); |
| + |
| + context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver); |
| + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), context.opaqueRegion().asRect()); |
| + |
| + // For non-opaque preserving mode and deviceClip is rect |
| + // we will mark device clip rect as non opaque. |
| + context.setCompositeOperation(CompositeSourceOut); |
| + context.beginTransparencyLayer(0.5); |
| + |
|
danakj
2014/08/07 12:49:55
nit: rm extra whitespace here
sohanjg
2014/08/07 14:05:20
Done.
|
| + context.endLayer(); |
| + EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); |
| + EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect()); |
| + |
| + context.fillRect(FloatRect(30, 30, 100, 100), opaque, CompositeSourceOver); |
| + |
| + // For opaque preserving mode and deviceClip is rect |
| + // we will intersect device clip rect with src opaque rect. |
|
danakj
2014/08/07 12:49:56
You didn't set any device clip rect in this test,
sohanjg
2014/08/07 14:05:20
Done.
|
| + context.setCompositeOperation(CompositeSourceOver); |
| + context.beginTransparencyLayer(0.5); |
| + |
|
danakj
2014/08/07 12:49:55
nit: rm extra whitespace here
sohanjg
2014/08/07 14:05:20
Done.
|
| + context.endLayer(); |
| + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), context.opaqueRegion().asRect()); |
| + EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect()); |
| +} |
| + |
| #define DISPATCH1(c1, c2, op, param1) do { c1.op(param1); c2.op(param1); } while (0); |
| #define DISPATCH2(c1, c2, op, param1, param2) do { c1.op(param1, param2); c2.op(param1, param2); } while (0); |