summaryrefslogtreecommitdiffstats
path: root/gfx/canvas_direct2d_unittest.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-21 18:28:20 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-21 18:28:20 +0000
commitf286f77eec2281993efe4dd408448903334d55eb (patch)
treef6d1a521ae0842a8313880bbb1436fef2c3ee497 /gfx/canvas_direct2d_unittest.cc
parent0940ddebe40365351c6fc53bfaf39bd7cd176249 (diff)
downloadchromium_src-f286f77eec2281993efe4dd408448903334d55eb.zip
chromium_src-f286f77eec2281993efe4dd408448903334d55eb.tar.gz
chromium_src-f286f77eec2281993efe4dd408448903334d55eb.tar.bz2
Implement initial ClipRect.
Move IntersectsClipRectInt and GetClipRect functions to CanvasSkia private, since they are only used internally. BUG=none TEST=see unittest. Review URL: http://codereview.chromium.org/2959014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53218 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx/canvas_direct2d_unittest.cc')
-rw-r--r--gfx/canvas_direct2d_unittest.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/gfx/canvas_direct2d_unittest.cc b/gfx/canvas_direct2d_unittest.cc
index 0b5ce0f..7e2c734 100644
--- a/gfx/canvas_direct2d_unittest.cc
+++ b/gfx/canvas_direct2d_unittest.cc
@@ -154,3 +154,30 @@ TEST(CanvasDirect2D, PlatformPainting) {
canvas.EndPlatformPaint();
}
+TEST(CanvasDirect2D, ClipRect) {
+ TestWindow window;
+ gfx::CanvasDirect2D canvas(window.rt());
+
+ canvas.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500);
+ canvas.ClipRectInt(20, 20, 120, 120);
+ canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500);
+}
+
+TEST(CanvasDirect2D, ClipRectWithTranslate) {
+ TestWindow window;
+ gfx::CanvasDirect2D canvas(window.rt());
+
+ // Repeat the same rendering as in ClipRect...
+ canvas.Save();
+ canvas.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500);
+ canvas.ClipRectInt(20, 20, 120, 120);
+ canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500);
+ canvas.Restore();
+
+ // ... then translate, clip and fill again relative to the new origin.
+ canvas.Save();
+ canvas.TranslateInt(150, 150);
+ canvas.ClipRectInt(10, 10, 110, 110);
+ canvas.FillRectInt(SK_ColorRED, 0, 0, 500, 500);
+ canvas.Restore();
+}