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

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 addressed. Created 6 years, 4 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
« no previous file with comments | « no previous file | Source/platform/graphics/RegionTracker.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | Source/platform/graphics/RegionTracker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698