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

Unified Diff: tests/CanvasTest.cpp

Issue 2127233002: Added the framework for having canvas/recorder/picture record depth_set's. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Made setZ translateZ Created 4 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: tests/CanvasTest.cpp
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 70c2c04ffabf511239239fe8fe3cf91ab78582af..c8d8119d457542f626811164df4f04b411f4427b 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -779,6 +779,27 @@ DEF_TEST(Canvas_ClipEmptyPath, reporter) {
canvas.restore();
}
robertphillips 2016/07/12 15:34:32 This is kind of strange ...
vjiaoblack 2016/07/12 16:03:33 Since we made getZ a protected method, I now know
+class SkTestCanvas : public SkCanvas {
+public:
robertphillips 2016/07/12 15:34:32 If you want this to be a member function it should
vjiaoblack 2016/07/12 16:03:33 Done.
+ void test_updatedepth(skiatest::Reporter* reporter) {
robertphillips 2016/07/12 15:34:32 This comment shouldn't mention picture anymore
vjiaoblack 2016/07/12 16:03:33 Done.
+ // set some depths (with picture enabled), then check them as they get set
+
robertphillips 2016/07/12 15:34:32 If you want this to be a member function all the c
vjiaoblack 2016/07/12 16:03:33 Done.
+ REPORTER_ASSERT(reporter, getZ() == 0);
+ translateZ(-10);
+ REPORTER_ASSERT(reporter, getZ() == -10);
+
+ save();
+ translateZ(20);
+ REPORTER_ASSERT(reporter, getZ() == 10);
+
+ restore();
+ REPORTER_ASSERT(reporter, getZ() == -10);
+
+ translateZ(13.14);
+ REPORTER_ASSERT(reporter, SkScalarNearlyEqual(getZ(),3.14));
+ }
+};
+
namespace {
class MockFilterCanvas : public SkPaintFilterCanvas {
@@ -812,4 +833,11 @@ DEF_TEST(PaintFilterCanvas_ConsistentState, reporter) {
REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMatrix());
REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getClipBounds(&clip2));
REPORTER_ASSERT(reporter, clip1 == clip2);
+
robertphillips 2016/07/12 15:34:32 Can you not just do: { SkCanvas testCanvas(100
vjiaoblack 2016/07/12 16:03:33 Uh. Oh. pfft, right. I'll do that. *tried to do
+ SkPictureRecorder recorder;
+ SkTestCanvas* tCanvas;
+
+ tCanvas = (SkTestCanvas*) recorder.beginRecording(SkRect::MakeIWH(100, 100));
+ tCanvas->test_updatedepth(reporter);
+ recorder.finishRecordingAsPicture();
}

Powered by Google App Engine
This is Rietveld 408576698