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

Unified Diff: sky/engine/platform/graphics/GraphicsContextTest.cpp

Issue 1017593005: Add a basic custom painting facility to Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Add missing files Created 5 years, 9 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: sky/engine/platform/graphics/GraphicsContextTest.cpp
diff --git a/sky/engine/platform/graphics/GraphicsContextTest.cpp b/sky/engine/platform/graphics/GraphicsContextTest.cpp
index f8f6c2580a6f4f7b973938a7a0e431c70a0e66c8..0d99ea3cb95986112c0dc7590b7edec95e9f46f3 100644
--- a/sky/engine/platform/graphics/GraphicsContextTest.cpp
+++ b/sky/engine/platform/graphics/GraphicsContextTest.cpp
@@ -1117,82 +1117,4 @@ TEST(GraphicsContextTest, OpaqueRegionForLayerWithRectDeviceClip)
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);
-
-TEST(GraphicsContextTest, RecordingTotalMatrix)
-{
- SkBitmap bitmap;
- bitmap.allocN32Pixels(400, 400);
- bitmap.eraseColor(0);
- SkCanvas canvas(bitmap);
- GraphicsContext context(&canvas);
-
- SkCanvas controlCanvas(400, 400);
- GraphicsContext controlContext(&controlCanvas);
-
- EXPECT_EQ(context.getCTM(), controlContext.getCTM());
- DISPATCH2(context, controlContext, scale, 2, 2);
- EXPECT_EQ(context.getCTM(), controlContext.getCTM());
-
- controlContext.save();
- context.beginRecording(FloatRect(0, 0, 200, 200));
- DISPATCH2(context, controlContext, translate, 10, 10);
- EXPECT_EQ(context.getCTM(), controlContext.getCTM());
-
- controlContext.save();
- context.beginRecording(FloatRect(10, 10, 100, 100));
- DISPATCH1(context, controlContext, rotate, 45);
- EXPECT_EQ(context.getCTM(), controlContext.getCTM());
-
- controlContext.restore();
- context.endRecording();
- EXPECT_EQ(context.getCTM(), controlContext.getCTM());
-
- controlContext.restore();
- context.endRecording();
- EXPECT_EQ(context.getCTM(), controlContext.getCTM());
-}
-
-TEST(GraphicsContextTest, DisplayList)
-{
- FloatRect rect(0, 0, 1, 1);
- RefPtr<DisplayList> dl = adoptRef(new DisplayList(rect));
-
- // picture() returns 0 initially
- SkPicture* pic = dl->picture();
- EXPECT_FALSE(pic);
-
- // endRecording without a beginRecording does nothing
- dl->endRecording();
- pic = dl->picture();
- EXPECT_FALSE(pic);
-
- // Two beginRecordings in a row generate two canvases.
- // Unfortunately the new one could be allocated in the same
- // spot as the old one so ref the first one to prolong its life.
- IntSize size(1, 1);
- SkCanvas* canvas1 = dl->beginRecording(size);
- EXPECT_TRUE(canvas1);
- canvas1->ref();
- SkCanvas* canvas2 = dl->beginRecording(size);
- EXPECT_TRUE(canvas2);
-
- EXPECT_NE(canvas1, canvas2);
- EXPECT_TRUE(canvas1->unique());
- canvas1->unref();
-
- EXPECT_TRUE(dl->isRecording());
-
- // picture() returns 0 during recording
- pic = dl->picture();
- EXPECT_FALSE(pic);
-
- // endRecording finally makes the picture accessible
- dl->endRecording();
- pic = dl->picture();
- EXPECT_TRUE(pic);
- EXPECT_TRUE(pic->unique());
-}
-
} // namespace

Powered by Google App Engine
This is Rietveld 408576698