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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 */ | 45 */ |
46 #include "SkBitmap.h" | 46 #include "SkBitmap.h" |
47 #include "SkCanvas.h" | 47 #include "SkCanvas.h" |
48 #include "SkClipStack.h" | 48 #include "SkClipStack.h" |
49 #include "SkDeferredCanvas.h" | 49 #include "SkDeferredCanvas.h" |
50 #include "SkDevice.h" | 50 #include "SkDevice.h" |
51 #include "SkDocument.h" | 51 #include "SkDocument.h" |
52 #include "SkMatrix.h" | 52 #include "SkMatrix.h" |
53 #include "SkNWayCanvas.h" | 53 #include "SkNWayCanvas.h" |
54 #include "SkPaint.h" | 54 #include "SkPaint.h" |
| 55 #include "SkPaintFilterCanvas.h" |
55 #include "SkPath.h" | 56 #include "SkPath.h" |
56 #include "SkPicture.h" | 57 #include "SkPicture.h" |
57 #include "SkPictureRecord.h" | 58 #include "SkPictureRecord.h" |
58 #include "SkPictureRecorder.h" | 59 #include "SkPictureRecorder.h" |
59 #include "SkRect.h" | 60 #include "SkRect.h" |
60 #include "SkRegion.h" | 61 #include "SkRegion.h" |
61 #include "SkShader.h" | 62 #include "SkShader.h" |
62 #include "SkStream.h" | 63 #include "SkStream.h" |
63 #include "SkSurface.h" | 64 #include "SkSurface.h" |
64 #include "SkTDArray.h" | 65 #include "SkTDArray.h" |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 canvas.restore(); | 776 canvas.restore(); |
776 canvas.save(); | 777 canvas.save(); |
777 path.moveTo(5, 5); | 778 path.moveTo(5, 5); |
778 canvas.clipPath(path); | 779 canvas.clipPath(path); |
779 canvas.restore(); | 780 canvas.restore(); |
780 canvas.save(); | 781 canvas.save(); |
781 path.moveTo(7, 7); | 782 path.moveTo(7, 7); |
782 canvas.clipPath(path); // should not assert here | 783 canvas.clipPath(path); // should not assert here |
783 canvas.restore(); | 784 canvas.restore(); |
784 } | 785 } |
| 786 |
| 787 namespace { |
| 788 |
| 789 class MockFilterCanvas : public SkPaintFilterCanvas { |
| 790 public: |
| 791 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { } |
| 792 |
| 793 protected: |
| 794 void onFilterPaint(SkPaint *paint, Type type) const override { } |
| 795 |
| 796 private: |
| 797 typedef SkPaintFilterCanvas INHERITED; |
| 798 }; |
| 799 |
| 800 } // anonymous namespace |
| 801 |
| 802 // SkPaintFilterCanvas should inherit the initial target canvas state. |
| 803 DEF_TEST(PaintFilterCanvas_ConsistentState, reporter) { |
| 804 SkCanvas canvas(100, 100); |
| 805 canvas.clipRect(SkRect::MakeXYWH(12.7f, 12.7f, 75, 75)); |
| 806 canvas.scale(0.5f, 0.75f); |
| 807 |
| 808 SkRect clip1, clip2; |
| 809 |
| 810 MockFilterCanvas filterCanvas(&canvas); |
| 811 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa
trix()); |
| 812 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl
ipBounds(&clip2)); |
| 813 REPORTER_ASSERT(reporter, clip1 == clip2); |
| 814 |
| 815 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); |
| 816 filterCanvas.scale(0.75f, 0.5f); |
| 817 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa
trix()); |
| 818 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl
ipBounds(&clip2)); |
| 819 REPORTER_ASSERT(reporter, clip1 == clip2); |
| 820 } |
OLD | NEW |