Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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/11 19:24:52
My suggestion here is to ditch the SkCanvasDrawDep
vjiaoblack
2016/07/11 19:48:13
Done.
| |
| 782 class SkCanvasDrawDepthTester { | |
| 783 public: | |
|
robertphillips
2016/07/11 19:24:53
kCanvasWidth & kCanvasHeight
Also, these don't ap
vjiaoblack
2016/07/11 19:48:13
Done.
| |
| 784 const static int canvasWidth = 100; | |
| 785 const static int canvasHeight = 100; | |
| 786 | |
| 787 SkCanvasDrawDepthTester(skiatest::Reporter* reporter) { | |
|
robertphillips
2016/07/11 19:24:53
Don't need "this->" here
vjiaoblack
2016/07/11 19:48:13
Done.
| |
| 788 this->fReporter = reporter; | |
| 789 } | |
| 790 | |
| 791 void runTests() { | |
|
robertphillips
2016/07/11 19:24:53
testUpdateDepth. The '_' form is for static local
vjiaoblack
2016/07/11 19:48:13
Done.
| |
| 792 this->test_updatedepth(this->fReporter); | |
| 793 } | |
| 794 | |
| 795 private: | |
| 796 skiatest::Reporter* fReporter; | |
| 797 | |
| 798 void test_updatedepth(skiatest::Reporter* reporter) { | |
|
robertphillips
2016/07/11 19:24:52
I don't know what recording into a picture is givi
vjiaoblack
2016/07/11 19:48:13
Done.
| |
| 799 // set some depths (with picture enabled), then check them as they get s et | |
| 800 SkPictureRecorder recorder; | |
| 801 SkCanvas* canvas; | |
| 802 sk_sp<SkPicture> picture; | |
| 803 | |
|
robertphillips
2016/07/11 19:24:52
You could use kCanvasWidth & kCanvasHeight here in
vjiaoblack
2016/07/11 19:48:13
Done.
| |
| 804 canvas = recorder.beginRecording(SkRect::MakeIWH(100, 100)); | |
| 805 | |
| 806 canvas->setZ(-10); | |
|
robertphillips
2016/07/11 19:24:53
REPORTER_ASSERT(reporter, canvas->getZ() == -10);
vjiaoblack
2016/07/11 19:48:13
Done.
| |
| 807 canvas->save(); | |
| 808 canvas->setZ(10); | |
| 809 REPORTER_ASSERT(reporter, canvas->getZ() == 10); | |
| 810 | |
| 811 canvas->restore(); | |
| 812 REPORTER_ASSERT(reporter, canvas->getZ() == -10); | |
| 813 | |
| 814 canvas->setZ(3.14); | |
| 815 REPORTER_ASSERT(reporter, canvas->getZ() == 3.14); | |
| 816 | |
| 817 picture = recorder.finishRecordingAsPicture(); | |
| 818 } | |
| 819 }; | |
| 820 | |
| 782 namespace { | 821 namespace { |
| 783 | 822 |
| 784 class MockFilterCanvas : public SkPaintFilterCanvas { | 823 class MockFilterCanvas : public SkPaintFilterCanvas { |
| 785 public: | 824 public: |
| 786 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { } | 825 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { } |
| 787 | 826 |
| 788 protected: | 827 protected: |
| 789 bool onFilter(SkTCopyOnFirstWrite<SkPaint>*, Type) const override { return t rue; } | 828 bool onFilter(SkTCopyOnFirstWrite<SkPaint>*, Type) const override { return t rue; } |
| 790 | 829 |
| 791 private: | 830 private: |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 805 MockFilterCanvas filterCanvas(&canvas); | 844 MockFilterCanvas filterCanvas(&canvas); |
| 806 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); | 845 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); |
| 807 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); | 846 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); |
| 808 REPORTER_ASSERT(reporter, clip1 == clip2); | 847 REPORTER_ASSERT(reporter, clip1 == clip2); |
| 809 | 848 |
| 810 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); | 849 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); |
| 811 filterCanvas.scale(0.75f, 0.5f); | 850 filterCanvas.scale(0.75f, 0.5f); |
| 812 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); | 851 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); |
| 813 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); | 852 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); |
| 814 REPORTER_ASSERT(reporter, clip1 == clip2); | 853 REPORTER_ASSERT(reporter, clip1 == clip2); |
| 854 | |
| 855 SkCanvasDrawDepthTester depthTester(reporter); | |
| 856 depthTester.runTests(); | |
| 815 } | 857 } |
| OLD | NEW |