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..7af99ec87fef43d973d0732af841fd1853d6fbfc 100644 |
| --- a/Source/platform/graphics/GraphicsContextTest.cpp |
| +++ b/Source/platform/graphics/GraphicsContextTest.cpp |
| @@ -1042,6 +1042,77 @@ TEST(GraphicsContextTest, PreserveOpaqueOnlyMattersForFirstLayer) |
| EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect()); |
| } |
| +TEST(GraphicsContextTest, OpaqueRegionForLayerWithNonRectDeviceClip) |
| +{ |
| + // For non-opaque preserving mode and deviceClip is not rect |
| + // we will mark opaque rect as empty. |
| + Path path; |
| + path.moveTo(FloatPoint(0, 0)); |
| + path.addLineTo(FloatPoint(50, 50)); |
| + |
| + SkCanvas canvas(400, 400); |
| + GraphicsContext context(&canvas); |
| + |
| + Color opaque(1.0f, 0.0f, 0.0f, 1.0f); |
| + |
| + context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); |
| + |
| + context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver); |
| + EXPECT_EQ_RECT(IntRect(30, 30, 90, 90), context.opaqueRegion().asRect()); |
| + |
| + context.clipPath(path, RULE_EVENODD); |
| + context.setCompositeOperation(CompositeSourceOut); |
| + context.beginTransparencyLayer(0.5); |
| + |
| + context.endLayer(); |
| + EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); |
| + |
| + // For opaque preserving mode and deviceClip is not rect |
| + // we will not alter opaque rect. |
| + context.setCompositeOperation(CompositeSourceOver); |
| + context.beginTransparencyLayer(0.5); |
| + |
|
danakj
2014/08/06 13:53:34
If the clip was a rect, what about this begin/end
sohanjg
2014/08/06 14:09:26
yes, for rect clip, we would have got a non-empty
danakj
2014/08/06 14:17:28
I don't understand, the opaque rect is non-empty?
sohanjg
2014/08/06 14:30:07
hmm..once we set context.clipPath, it seems we can
danakj
2014/08/06 14:32:10
You can clipRect with kReplace_Op for instance?
sohanjg
2014/08/07 08:07:46
I have updated the test and used rect device clip
|
| + context.endLayer(); |
| + EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); |
| +} |
| + |
| +TEST(GraphicsContextTest, OpaqueRegionForLayerWithRectDeviceClip) |
| +{ |
| + |
| + SkBitmap bitmap; |
| + ASSERT_TRUE(bitmap.allocN32Pixels(400, 400)); |
| + 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, 90, 90), 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); |
| + |
| + context.endLayer(); |
| + EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); |
| + EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect()); |
| + |
| + context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver); |
| + |
| + // For opaque preserving mode and deviceClip is rect |
| + // we will intersect device clip rect with src opaque rect. |
|
danakj
2014/08/06 13:53:33
Can you change the inputs so that we see the inter
sohanjg
2014/08/07 08:07:46
Done.
|
| + context.setCompositeOperation(CompositeSourceOver); |
| + context.beginTransparencyLayer(0.5); |
| + |
| + context.endLayer(); |
| + EXPECT_EQ_RECT(IntRect(30, 30, 90, 90), 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); |