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 class SkDrawDepthTester { | |
| 783 public: | |
|
robertphillips
2016/07/11 18:39:35
kCanvas* ?
vjiaoblack
2016/07/11 18:58:03
Done.
| |
| 784 const static int canvasWidth = 100; | |
| 785 const static int canvasHeight = 100; | |
| 786 | |
| 787 SkDrawDepthTester(skiatest::Reporter* reporter) { | |
|
robertphillips
2016/07/11 18:39:35
It doesn't look like you are saving off the report
vjiaoblack
2016/07/11 18:58:03
Done.
| |
| 788 } | |
| 789 | |
| 790 void runTests() { | |
| 791 this->test_updatedepth(this->_reporter); | |
| 792 } | |
| 793 | |
| 794 private: | |
|
robertphillips
2016/07/11 18:39:35
Member variables are prefixed with 'f' not '_'
vjiaoblack
2016/07/11 18:58:03
Done.
| |
| 795 skiatest::Reporter* _reporter; | |
| 796 | |
|
robertphillips
2016/07/11 18:39:35
The SkPictureRecorder should just be on the stack
vjiaoblack
2016/07/11 18:58:03
Done.
| |
| 797 SkPictureRecorder _recorder; | |
|
robertphillips
2016/07/11 18:39:35
Why do you need to store _canvas & _picture ?
vjiaoblack
2016/07/11 18:58:03
Done.
| |
| 798 sk_sp<SkPicture> _picture; | |
| 799 SkCanvas* _canvas; | |
|
robertphillips
2016/07/11 18:39:35
Do you use paint at all ?
vjiaoblack
2016/07/11 18:58:03
Done.
| |
| 800 SkPaint paint; | |
| 801 | |
| 802 void test_updatedepth(skiatest::Reporter* reporter) { | |
| 803 // set some depths (with picture enabled), then check them as they get s et | |
| 804 this->_canvas = this->_recorder.beginRecording(SkRect::MakeIWH(100, 100) ); | |
| 805 | |
| 806 this->_canvas->setZ(-10); | |
| 807 this->_canvas->save(); | |
| 808 this->_canvas->setZ(10); | |
| 809 REPORTER_ASSERT(reporter, this->_canvas->getZ() == 10); | |
| 810 | |
| 811 this->_canvas->restore(); | |
| 812 REPORTER_ASSERT(reporter, this->_canvas->getZ() == -10); | |
| 813 | |
| 814 this->_canvas->setZ(3.14); | |
| 815 REPORTER_ASSERT(reporter, this->_canvas->getZ() == 3.14); | |
| 816 | |
| 817 this->_picture = this->_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 SkDrawDepthTester depthTester(reporter); | |
| 856 depthTester.runTests(); | |
| 815 } | 857 } |
|
robertphillips
2016/07/11 18:39:35
What's with all these lines ?
vjiaoblack
2016/07/11 18:58:03
Done.
| |
| 858 | |
| 859 | |
| 860 | |
| 861 | |
| 862 | |
| 863 | |
| 864 | |
| 865 | |
| 866 | |
| 867 | |
| 868 | |
| 869 | |
| 870 | |
| 871 | |
| 872 | |
| 873 | |
| 874 | |
| 875 | |
| 876 | |
| 877 | |
| 878 | |
| 879 | |
| 880 | |
| 881 | |
| 882 | |
| 883 | |
| 884 | |
| 885 | |
| 886 | |
| 887 | |
| 888 | |
| 889 | |
| 890 | |
| 891 | |
| 892 | |
| 893 | |
| 894 | |
| 895 | |
| 896 | |
| 897 | |
| 898 | |
| 899 | |
| 900 | |
| 901 | |
| 902 | |
| 903 | |
| 904 | |
| 905 | |
| 906 | |
| 907 | |
| 908 | |
| 909 | |
| 910 | |
| 911 | |
| 912 | |
| 913 | |
| 914 | |
| 915 | |
| 916 | |
| 917 | |
| 918 | |
| 919 | |
| 920 | |
| 921 | |
| 922 | |
| 923 | |
| 924 | |
| 925 | |
| 926 | |
| 927 | |
| 928 | |
| 929 | |
| 930 | |
| 931 | |
| 932 | |
| 933 | |
| 934 | |
| 935 | |
| OLD | NEW |