Index: Source/platform/graphics/GraphicsContextTest.cpp |
diff --git a/Source/platform/graphics/GraphicsContextTest.cpp b/Source/platform/graphics/GraphicsContextTest.cpp |
index fd4a9588621b018e68224fc9756d57c97ef4e61d..dde8fcd56cfc6d3c3bc366e3d52e258694579cff 100644 |
--- a/Source/platform/graphics/GraphicsContextTest.cpp |
+++ b/Source/platform/graphics/GraphicsContextTest.cpp |
@@ -1042,6 +1042,66 @@ TEST(GraphicsContextTest, PreserveOpaqueOnlyMattersForFirstLayer) |
EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect()); |
} |
+TEST(GraphicsContextTest, OpaqueRegionForLayer) |
+{ |
+ // 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); |
+ context.clipPath(path, RULE_EVENODD); |
+ context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); |
+ |
+ Color opaque(1.0f, 0.0f, 0.0f, 1.0f); |
+ |
+ context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver); |
danakj
2014/08/05 15:26:54
Can you EXPECT_EQ the opaqueRegion after this, and
sohanjg
2014/08/06 05:56:21
Done.
|
+ 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.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver); |
+ context.setCompositeOperation(CompositeSourceOver); |
+ context.beginTransparencyLayer(0.5); |
+ |
+ context.endLayer(); |
+ EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); |
+ |
+ SkBitmap bitmap; |
+ ASSERT_TRUE(bitmap.allocN32Pixels(400, 400)); |
+ bitmap.eraseColor(0); |
+ SkCanvas canvas2(bitmap); |
+ |
+ GraphicsContext context2(&canvas2); |
+ context2.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); |
+ |
+ // For non-opaque preserving mode and deviceClip is rect |
+ // we will mark device clip rect as non opaque. |
+ context2.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver); |
danakj
2014/08/05 15:26:54
Can you EXPECT_EQ the opaqueRegion after this, and
sohanjg
2014/08/05 16:48:12
this part has device clip as 'rect', we would need
danakj
2014/08/05 17:18:34
Oh, this is a different context, i missed that "2"
sohanjg
2014/08/06 05:56:21
Done.
|
+ context2.setCompositeOperation(CompositeSourceOut); |
+ context2.beginTransparencyLayer(0.5); |
+ |
+ context2.endLayer(); |
+ EXPECT_EQ_RECT(IntRect(), context2.opaqueRegion().asRect()); |
+ EXPECT_PIXELS_MATCH(bitmap, context2.opaqueRegion().asRect()); |
+ |
+ // For opaque preserving mode and deviceClip is rect |
+ // we will intersect device clip rect with src opaque rect. |
+ context2.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver); |
+ context2.setCompositeOperation(CompositeSourceOver); |
+ context2.beginTransparencyLayer(0.5); |
+ |
+ context2.endLayer(); |
+ EXPECT_EQ_RECT(IntRect(30, 30, 90, 90), context2.opaqueRegion().asRect()); |
+ EXPECT_PIXELS_MATCH(bitmap, context2.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); |