Index: Source/platform/graphics/GraphicsContextTest.cpp |
diff --git a/Source/platform/graphics/GraphicsContextTest.cpp b/Source/platform/graphics/GraphicsContextTest.cpp |
index 8a76411d237a15b582ddd7cff8e05f0add7e1aec..739f1a91b7dc1d1813efc5883767d7c0bdd70918 100644 |
--- a/Source/platform/graphics/GraphicsContextTest.cpp |
+++ b/Source/platform/graphics/GraphicsContextTest.cpp |
@@ -1042,6 +1042,40 @@ TEST(GraphicsContextTest, PreserveOpaqueOnlyMattersForFirstLayer) |
EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect()); |
} |
+TEST(GraphicsContextTest, OpaqueRegionForLayer) |
+{ |
+ SkBitmap bitmap; |
danakj
2014/07/30 13:31:25
What makes the device clip not a Rect in this test
sohanjg
2014/07/30 13:41:54
This is still a Rect, i wonder how can we set devi
sohanjg
2014/07/31 15:44:34
Done.
|
+ ASSERT_TRUE(bitmap.allocN32Pixels(100, 100)); |
+ bitmap.eraseColor(0); |
+ SkCanvas canvas(bitmap); |
+ |
+ GraphicsContext context(&canvas); |
+ context.setTrackOpaqueRegion(true); |
+ |
+ Path path; |
+ Color opaque(1.0f, 0.0f, 0.0f, 1.0f); |
+ |
+ // Set Opaque Rect. |
+ context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver); |
+ // Begin non-opaque-preserving layer. |
+ context.setCompositeOperation(CompositeSourceOut); |
+ context.beginTransparencyLayer(0.5); |
+ |
+ context.endLayer(); |
+ EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); |
+ EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect()); |
+ |
+ // Set Opaque Rect. |
+ context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver); |
+ // Begin opaque-preserving layer. |
+ context.setCompositeOperation(CompositeSourceOver); |
+ context.beginTransparencyLayer(0.5); |
+ |
+ 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); |