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 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 | |
|
robertphillips
2016/07/11 20:57:26
static
vjiaoblack
2016/07/12 13:14:22
Done.
| |
| 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; | |
|
robertphillips
2016/07/11 20:57:26
picture isn't used
vjiaoblack
2016/07/12 13:14:22
Done.
| |
| 787 sk_sp<SkPicture> picture; | |
| 788 | |
| 789 canvas = recorder.beginRecording(SkRect::MakeIWH(100, 100)); | |
| 790 REPORTER_ASSERT(reporter, canvas->getZ() == 0); | |
| 791 | |
| 792 canvas->setZ(-10); | |
| 793 REPORTER_ASSERT(reporter, canvas->getZ() == -10); | |
| 794 | |
| 795 canvas->save(); | |
| 796 canvas->setZ(10); | |
| 797 REPORTER_ASSERT(reporter, canvas->getZ() == 10); | |
| 798 | |
| 799 canvas->restore(); | |
| 800 REPORTER_ASSERT(reporter, canvas->getZ() == -10); | |
| 801 | |
| 802 canvas->setZ(3.14); | |
| 803 REPORTER_ASSERT(reporter, canvas->getZ() == 3.14); | |
| 804 | |
| 805 recorder.finishRecordingAsPicture(); | |
| 806 } | |
| 807 | |
| 782 namespace { | 808 namespace { |
| 783 | 809 |
| 784 class MockFilterCanvas : public SkPaintFilterCanvas { | 810 class MockFilterCanvas : public SkPaintFilterCanvas { |
| 785 public: | 811 public: |
| 786 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { } | 812 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { } |
| 787 | 813 |
| 788 protected: | 814 protected: |
| 789 bool onFilter(SkTCopyOnFirstWrite<SkPaint>*, Type) const override { return t rue; } | 815 bool onFilter(SkTCopyOnFirstWrite<SkPaint>*, Type) const override { return t rue; } |
| 790 | 816 |
| 791 private: | 817 private: |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 805 MockFilterCanvas filterCanvas(&canvas); | 831 MockFilterCanvas filterCanvas(&canvas); |
| 806 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); | 832 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); |
| 807 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); | 833 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); |
| 808 REPORTER_ASSERT(reporter, clip1 == clip2); | 834 REPORTER_ASSERT(reporter, clip1 == clip2); |
| 809 | 835 |
| 810 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); | 836 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); |
| 811 filterCanvas.scale(0.75f, 0.5f); | 837 filterCanvas.scale(0.75f, 0.5f); |
| 812 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); | 838 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); |
| 813 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); | 839 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); |
| 814 REPORTER_ASSERT(reporter, clip1 == clip2); | 840 REPORTER_ASSERT(reporter, clip1 == clip2); |
| 841 | |
| 842 test_updatedepth(reporter); | |
| 815 } | 843 } |
| OLD | NEW |