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 27 matching lines...) Expand all Loading... |
38 * of a single canvas API call. | 38 * of a single canvas API call. |
39 * | 39 * |
40 * SIMPLE_TEST_STEP(MytestStep, someCanvasAPIMethod()); | 40 * SIMPLE_TEST_STEP(MytestStep, someCanvasAPIMethod()); |
41 * | 41 * |
42 * There is another macro called SIMPLE_TEST_STEP_WITH_ASSERT that | 42 * There is another macro called SIMPLE_TEST_STEP_WITH_ASSERT that |
43 * works the same way as SIMPLE_TEST_STEP, and additionally verifies | 43 * works the same way as SIMPLE_TEST_STEP, and additionally verifies |
44 * that the invoked method returns a non-zero value. | 44 * that the invoked method returns a non-zero value. |
45 */ | 45 */ |
46 #include "SkBitmap.h" | 46 #include "SkBitmap.h" |
47 #include "SkCanvas.h" | 47 #include "SkCanvas.h" |
| 48 #include "SkClipStack.h" |
48 #include "SkDeferredCanvas.h" | 49 #include "SkDeferredCanvas.h" |
49 #include "SkDevice.h" | 50 #include "SkDevice.h" |
50 #include "SkDocument.h" | 51 #include "SkDocument.h" |
51 #include "SkMatrix.h" | 52 #include "SkMatrix.h" |
52 #include "SkNWayCanvas.h" | 53 #include "SkNWayCanvas.h" |
53 #include "SkPaint.h" | 54 #include "SkPaint.h" |
54 #include "SkPath.h" | 55 #include "SkPath.h" |
55 #include "SkPicture.h" | 56 #include "SkPicture.h" |
56 #include "SkPictureRecord.h" | 57 #include "SkPictureRecord.h" |
57 #include "SkPictureRecorder.h" | 58 #include "SkPictureRecorder.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 SkBitmap bm; | 211 SkBitmap bm; |
211 bm.setInfo(SkImageInfo::MakeN32Premul(size.width(), size.height())); | 212 bm.setInfo(SkImageInfo::MakeN32Premul(size.width(), size.height())); |
212 SkCanvas c(bm); | 213 SkCanvas c(bm); |
213 | 214 |
214 Canvas2CanvasClipVisitor visitor(&c); | 215 Canvas2CanvasClipVisitor visitor(&c); |
215 canvas->replayClips(&visitor); | 216 canvas->replayClips(&visitor); |
216 | 217 |
217 REPORTER_ASSERT(reporter, equal_clips(c, *canvas)); | 218 REPORTER_ASSERT(reporter, equal_clips(c, *canvas)); |
218 } | 219 } |
219 | 220 |
| 221 static void test_clipstack(skiatest::Reporter* reporter) { |
| 222 // The clipstack is refcounted, and needs to be able to out-live the canvas
if a client has |
| 223 // ref'd it. |
| 224 const SkClipStack* cs = NULL; |
| 225 { |
| 226 SkCanvas canvas(10, 10); |
| 227 cs = SkRef(canvas.getClipStack()); |
| 228 } |
| 229 REPORTER_ASSERT(reporter, cs->unique()); |
| 230 cs->unref(); |
| 231 } |
| 232 |
220 // Format strings that describe the test context. The %s token is where | 233 // Format strings that describe the test context. The %s token is where |
221 // the name of the test step is inserted. The context is required for | 234 // the name of the test step is inserted. The context is required for |
222 // disambiguating the error in the case of failures that are reported in | 235 // disambiguating the error in the case of failures that are reported in |
223 // functions that are called multiple times in different contexts (test | 236 // functions that are called multiple times in different contexts (test |
224 // cases and test steps). | 237 // cases and test steps). |
225 static const char* const kDefaultAssertMessageFormat = "%s"; | 238 static const char* const kDefaultAssertMessageFormat = "%s"; |
226 static const char* const kCanvasDrawAssertMessageFormat = | 239 static const char* const kCanvasDrawAssertMessageFormat = |
227 "Drawing test step %s with SkCanvas"; | 240 "Drawing test step %s with SkCanvas"; |
228 static const char* const kDeferredDrawAssertMessageFormat = | 241 static const char* const kDeferredDrawAssertMessageFormat = |
229 "Drawing test step %s with SkDeferredCanvas"; | 242 "Drawing test step %s with SkDeferredCanvas"; |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 // report correct clipping and device bounds information | 677 // report correct clipping and device bounds information |
665 // Issue: http://code.google.com/p/skia/issues/detail?id=501 | 678 // Issue: http://code.google.com/p/skia/issues/detail?id=501 |
666 | 679 |
667 if (false) { // avoid bit rot, suppress warning | 680 if (false) { // avoid bit rot, suppress warning |
668 TestNWayCanvasStateConsistency(reporter, d, testStep, referenceCanvas); | 681 TestNWayCanvasStateConsistency(reporter, d, testStep, referenceCanvas); |
669 } | 682 } |
670 | 683 |
671 if (false) { // avoid bit rot, suppress warning | 684 if (false) { // avoid bit rot, suppress warning |
672 test_clipVisitor(reporter, &referenceCanvas); | 685 test_clipVisitor(reporter, &referenceCanvas); |
673 } | 686 } |
| 687 test_clipstack(reporter); |
674 } | 688 } |
675 | 689 |
676 static void test_newraster(skiatest::Reporter* reporter) { | 690 static void test_newraster(skiatest::Reporter* reporter) { |
677 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); | 691 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); |
678 const size_t minRowBytes = info.minRowBytes(); | 692 const size_t minRowBytes = info.minRowBytes(); |
679 const size_t size = info.getSafeSize(minRowBytes); | 693 const size_t size = info.getSafeSize(minRowBytes); |
680 SkAutoMalloc storage(size); | 694 SkAutoMalloc storage(size); |
681 SkPMColor* baseAddr = static_cast<SkPMColor*>(storage.get()); | 695 SkPMColor* baseAddr = static_cast<SkPMColor*>(storage.get()); |
682 sk_bzero(baseAddr, size); | 696 sk_bzero(baseAddr, size); |
683 | 697 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 canvas.restore(); | 770 canvas.restore(); |
757 canvas.save(); | 771 canvas.save(); |
758 path.moveTo(5, 5); | 772 path.moveTo(5, 5); |
759 canvas.clipPath(path); | 773 canvas.clipPath(path); |
760 canvas.restore(); | 774 canvas.restore(); |
761 canvas.save(); | 775 canvas.save(); |
762 path.moveTo(7, 7); | 776 path.moveTo(7, 7); |
763 canvas.clipPath(path); // should not assert here | 777 canvas.clipPath(path); // should not assert here |
764 canvas.restore(); | 778 canvas.restore(); |
765 } | 779 } |
OLD | NEW |