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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 /* Description: 8 /* Description:
9 * This test defines a series of elementatry test steps that perform 9 * This test defines a series of elementatry test steps that perform
10 * a single or a small group of canvas API calls. Each test step is 10 * a single or a small group of canvas API calls. Each test step is
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 canvas.restore(); 771 canvas.restore();
772 canvas.save(); 772 canvas.save();
773 path.moveTo(5, 5); 773 path.moveTo(5, 5);
774 canvas.clipPath(path); 774 canvas.clipPath(path);
775 canvas.restore(); 775 canvas.restore();
776 canvas.save(); 776 canvas.save();
777 path.moveTo(7, 7); 777 path.moveTo(7, 7);
778 canvas.clipPath(path); // should not assert here 778 canvas.clipPath(path); // should not assert here
779 canvas.restore(); 779 canvas.restore();
780 } 780 }
781 781
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
782 class SkTestCanvas : public SkCanvas {
783 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.
784 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.
785 // set some depths (with picture enabled), then check them as they get s et
786
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.
787 REPORTER_ASSERT(reporter, getZ() == 0);
788 translateZ(-10);
789 REPORTER_ASSERT(reporter, getZ() == -10);
790
791 save();
792 translateZ(20);
793 REPORTER_ASSERT(reporter, getZ() == 10);
794
795 restore();
796 REPORTER_ASSERT(reporter, getZ() == -10);
797
798 translateZ(13.14);
799 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(getZ(),3.14));
800 }
801 };
802
782 namespace { 803 namespace {
783 804
784 class MockFilterCanvas : public SkPaintFilterCanvas { 805 class MockFilterCanvas : public SkPaintFilterCanvas {
785 public: 806 public:
786 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { } 807 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { }
787 808
788 protected: 809 protected:
789 bool onFilter(SkTCopyOnFirstWrite<SkPaint>*, Type) const override { return t rue; } 810 bool onFilter(SkTCopyOnFirstWrite<SkPaint>*, Type) const override { return t rue; }
790 811
791 private: 812 private:
(...skipping 13 matching lines...) Expand all
805 MockFilterCanvas filterCanvas(&canvas); 826 MockFilterCanvas filterCanvas(&canvas);
806 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); 827 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
807 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); 828 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
808 REPORTER_ASSERT(reporter, clip1 == clip2); 829 REPORTER_ASSERT(reporter, clip1 == clip2);
809 830
810 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); 831 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100));
811 filterCanvas.scale(0.75f, 0.5f); 832 filterCanvas.scale(0.75f, 0.5f);
812 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); 833 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
813 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); 834 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
814 REPORTER_ASSERT(reporter, clip1 == clip2); 835 REPORTER_ASSERT(reporter, clip1 == clip2);
836
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
837 SkPictureRecorder recorder;
838 SkTestCanvas* tCanvas;
839
840 tCanvas = (SkTestCanvas*) recorder.beginRecording(SkRect::MakeIWH(100, 100)) ;
841 tCanvas->test_updatedepth(reporter);
842 recorder.finishRecordingAsPicture();
815 } 843 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698