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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
| 782 |
| 783 void test_updatedepth(skiatest::Reporter* reporter) { |
| 784 // set some depths (with picture enabled), then check them as they get set |
| 785 SkPictureRecorder recorder; |
| 786 SkCanvas* canvas; |
| 787 sk_sp<SkPicture> picture; |
| 788 |
| 789 canvas = recorder.beginRecording(SkRect::MakeIWH(100, 100)); |
| 790 |
| 791 canvas->setZ(-10); |
| 792 REPORTER_ASSERT(reporter, canvas->getZ() == -10); |
| 793 |
| 794 canvas->save(); |
| 795 canvas->setZ(10); |
| 796 REPORTER_ASSERT(reporter, canvas->getZ() == 10); |
| 797 |
| 798 canvas->restore(); |
| 799 REPORTER_ASSERT(reporter, canvas->getZ() == -10); |
| 800 |
| 801 canvas->setZ(3.14); |
| 802 REPORTER_ASSERT(reporter, canvas->getZ() == 3.14); |
| 803 |
| 804 recorder.finishRecordingAsPicture(); |
| 805 } |
| 806 |
782 namespace { | 807 namespace { |
783 | 808 |
784 class MockFilterCanvas : public SkPaintFilterCanvas { | 809 class MockFilterCanvas : public SkPaintFilterCanvas { |
785 public: | 810 public: |
786 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { } | 811 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { } |
787 | 812 |
788 protected: | 813 protected: |
789 bool onFilter(SkTCopyOnFirstWrite<SkPaint>*, Type) const override { return t
rue; } | 814 bool onFilter(SkTCopyOnFirstWrite<SkPaint>*, Type) const override { return t
rue; } |
790 | 815 |
791 private: | 816 private: |
(...skipping 13 matching lines...) Expand all Loading... |
805 MockFilterCanvas filterCanvas(&canvas); | 830 MockFilterCanvas filterCanvas(&canvas); |
806 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa
trix()); | 831 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa
trix()); |
807 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl
ipBounds(&clip2)); | 832 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl
ipBounds(&clip2)); |
808 REPORTER_ASSERT(reporter, clip1 == clip2); | 833 REPORTER_ASSERT(reporter, clip1 == clip2); |
809 | 834 |
810 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); | 835 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); |
811 filterCanvas.scale(0.75f, 0.5f); | 836 filterCanvas.scale(0.75f, 0.5f); |
812 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa
trix()); | 837 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa
trix()); |
813 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl
ipBounds(&clip2)); | 838 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl
ipBounds(&clip2)); |
814 REPORTER_ASSERT(reporter, clip1 == clip2); | 839 REPORTER_ASSERT(reporter, clip1 == clip2); |
| 840 |
| 841 test_updatedepth(reporter); |
815 } | 842 } |
OLD | NEW |