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 class SkTestCanvas : public SkCanvas { |
| 783 public: |
| 784 void testUpdateDepth(skiatest::Reporter* reporter) { |
| 785 // set some depths (with picture enabled), then check them as they get s
et |
| 786 |
| 787 REPORTER_ASSERT(reporter, this->getZ() == 0); |
| 788 this->translateZ(-10); |
| 789 REPORTER_ASSERT(reporter, this->getZ() == -10); |
| 790 |
| 791 this->save(); |
| 792 this->translateZ(20); |
| 793 REPORTER_ASSERT(reporter, this->getZ() == 10); |
| 794 |
| 795 this->restore(); |
| 796 REPORTER_ASSERT(reporter, this->getZ() == -10); |
| 797 |
| 798 this->translateZ(13.14f); |
| 799 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(this->getZ(),3.14f)); |
| 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 Loading... |
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 |
| 837 SkTestCanvas* tCanvas; |
| 838 |
| 839 tCanvas = (SkTestCanvas*) new SkCanvas(100,100); |
| 840 tCanvas->testUpdateDepth(reporter); |
815 } | 841 } |
OLD | NEW |