Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: Source/platform/graphics/GraphicsContextTest.cpp

Issue 417153002: Avoid passing uninitialized value to markRectAsNonOpaque. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: review comments + test Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
« no previous file with comments | « no previous file | Source/platform/graphics/skia/OpaqueRegionSkia.cpp » ('j') | Source/platform/graphics/skia/OpaqueRegionSkia.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698