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

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: Tests Updated. 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 fd4a9588621b018e68224fc9756d57c97ef4e61d..3b8b330631bab15276ec5862d2b2bb16b35a5393 100644
--- a/Source/platform/graphics/GraphicsContextTest.cpp
+++ b/Source/platform/graphics/GraphicsContextTest.cpp
@@ -1042,6 +1042,59 @@ TEST(GraphicsContextTest, PreserveOpaqueOnlyMattersForFirstLayer)
EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect());
}
+TEST(GraphicsContextTest, OpaqueRegionForLayer)
+{
+ // Set non-rect device clip.
+ Path path;
+ path.moveTo(FloatPoint(0, 0));
+ path.addLineTo(FloatPoint(50, 50));
+
+ SkCanvas canvas(50, 50);
danakj 2014/08/05 13:53:28 can you make the canvas bigger than the path's bou
sohanjg 2014/08/05 15:23:21 Done.
+ GraphicsContext context(&canvas);
+ context.clipPath(path, RULE_EVENODD);
+ context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque);
+
+ Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+
+ // Set Opaque Rect.
danakj 2014/08/05 13:53:28 Say why not what, all of these comments just say w
sohanjg 2014/08/05 15:23:20 Done.
+ context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver);
danakj 2014/08/05 13:53:28 isn't this outside the bounds of the canvas?
sohanjg 2014/08/05 15:23:21 Done. I was trying to avoid markRectAsNonOpaque ea
+ // Begin non-opaque-preserving layer.
+ context.setCompositeOperation(CompositeSourceOut);
+ context.beginTransparencyLayer(0.5);
+
+ context.endLayer();
+ EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
+
+ // Set rect device clip.
+ SkBitmap bitmap;
+ ASSERT_TRUE(bitmap.allocN32Pixels(50, 50));
+ bitmap.eraseColor(0);
+ SkCanvas canvas2(bitmap);
+
+ GraphicsContext context2(&canvas2);
+ context2.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque);
+
+ // Set Opaque Rect.
+ context2.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver);
+ // Begin non-opaque-preserving layer.
+ context2.setCompositeOperation(CompositeSourceOut);
+ context2.beginTransparencyLayer(0.5);
+
+ context2.endLayer();
+ EXPECT_EQ_RECT(IntRect(), context2.opaqueRegion().asRect());
+ EXPECT_PIXELS_MATCH(bitmap, context2.opaqueRegion().asRect());
+
+ // Set Opaque Rect.
+ context2.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver);
+ // Begin opaque-preserving layer.
+ context2.setCompositeOperation(CompositeSourceOver);
+ context2.beginTransparencyLayer(0.5);
+
+ context2.endLayer();
+ EXPECT_EQ_RECT(IntRect(30, 30, 20, 20), 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') | Source/platform/graphics/RegionTracker.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698