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

Unified Diff: Source/WebKit/chromium/tests/TransparencyWinTest.cpp

Issue 10254020: Merge 114791 - [chromium] Clip TransparencyWin to prevent OOM from large Skia canvas (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1084/
Patch Set: Created 8 years, 8 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 | « Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebKit/chromium/tests/TransparencyWinTest.cpp
===================================================================
--- Source/WebKit/chromium/tests/TransparencyWinTest.cpp (revision 115490)
+++ Source/WebKit/chromium/tests/TransparencyWinTest.cpp (working copy)
@@ -395,6 +395,66 @@
EXPECT_EQ(green, getPixelAt(src->context(), 15, 7));
}
+static void testClippedLayerKeepTransform(TransparencyWin::LayerMode layerMode)
+{
+ // Fill with white.
+ OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), 1, ColorSpaceDeviceRGB));
+ Color white(0xFFFFFFFF);
+ FloatRect fullRect(0, 0, 16, 16);
+ src->context()->fillRect(fullRect, white, ColorSpaceDeviceRGB);
+
+ IntRect clipRect(IntPoint(11, 5), IntSize(1, 1));
+ src->context()->clip(clipRect);
+
+ // Scroll down by 6 (coordinate system goes up).
+ src->context()->save();
+ src->context()->translate(0, -6);
+
+ Color red(0xFFFF0000);
+ Color green(0xFF00FF00);
+ {
+ // The transparency layer after translation will be @ (0, -6) with
+ // a size that would be too large to handle unclipped.
+ TransparencyWin helper;
+ helper.init(src->context(),
+ layerMode,
+ TransparencyWin::KeepTransform,
+ IntRect(0, 0, INT_MAX, INT_MAX));
+
+ // Draw a green pixel at (11, 11). This should be within the clip rect
+ // and at (11, 5) after the transform.
+ FloatRect greenRect(11, 11, 1, 1);
+ helper.context()->fillRect(greenRect, green, ColorSpaceDeviceRGB);
+
+ // Draw a red pixel at (9, 9). This should be outside the clip rect
+ // and not drawn.
+ FloatRect redRect(9, 9, 1, 1);
+ helper.context()->fillRect(redRect, red, ColorSpaceDeviceRGB);
+ helper.composite();
+ }
+
+ src->context()->restore();
+
+ // Verify green pixel got drawn in clip rect and red pixel got clipped.
+ EXPECT_EQ(green, getPixelAt(src->context(), 11, 5));
+ EXPECT_EQ(white, getPixelAt(src->context(), 9, 3));
+}
+
+TEST(TransparencyWin, ClippedKeepTransformNoLayer)
+{
+ testClippedLayerKeepTransform(TransparencyWin::NoLayer);
+}
+
+TEST(TransparencyWin, ClippedKeepTransformOpaqueCompositeLayer)
+{
+ testClippedLayerKeepTransform(TransparencyWin::OpaqueCompositeLayer);
+}
+
+TEST(TransparencyWin, ClippedKeepTransformWhiteLayer)
+{
+ testClippedLayerKeepTransform(TransparencyWin::WhiteLayer);
+}
+
// Same as OpaqueCompositeLayer, but the canvas has a rotation applied. This
// tests that the propert transform is applied to the copied layer.
TEST(TransparencyWin, RotateOpaqueCompositeLayer)
« no previous file with comments | « Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698