| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkBBoxHierarchy.h" | 9 #include "SkBBoxHierarchy.h" |
| 10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 emptyClipPictureTest.run(reporter); | 102 emptyClipPictureTest.run(reporter); |
| 103 } | 103 } |
| 104 | 104 |
| 105 static void test_clear(skiatest::Reporter* r, SkBBHFactory* factory) { | 105 static void test_clear(skiatest::Reporter* r, SkBBHFactory* factory) { |
| 106 // SkPicture should always call clear()s on the target canvas, even if its c
lip is empty. | 106 // SkPicture should always call clear()s on the target canvas, even if its c
lip is empty. |
| 107 SkPictureRecorder src, dst; | 107 SkPictureRecorder src, dst; |
| 108 | 108 |
| 109 // A picture that's just clear(). | 109 // A picture that's just clear(). |
| 110 src.beginRecording(1,1, factory) | 110 src.beginRecording(1,1, factory) |
| 111 ->clear(SK_ColorGREEN); | 111 ->clear(SK_ColorGREEN); |
| 112 SkAutoTDelete<SkPicture> srcPic(src.endRecording()); | 112 SkAutoTUnref<SkPicture> srcPic(src.endRecording()); |
| 113 | 113 |
| 114 // A target canvas with an empty clip. | 114 // A target canvas with an empty clip. |
| 115 SkCanvas* c = dst.beginRecording(1,1, NULL); | 115 SkCanvas* c = dst.beginRecording(1,1, NULL); |
| 116 c->clipRect(SkRect::MakeEmpty()); | 116 c->clipRect(SkRect::MakeEmpty()); |
| 117 srcPic->playback(c); | 117 srcPic->playback(c); |
| 118 SkAutoTDelete<SkPicture> dstPic(dst.endRecording()); | 118 SkAutoTUnref<SkPicture> dstPic(dst.endRecording()); |
| 119 | 119 |
| 120 // Should be Clip - Save - Clear - Restore. | 120 // Should be Clip - Save - Clear - Restore. |
| 121 // Buggy implementations might return 1 (just Clip) or 3 (Clip - Save - Rest
ore). | 121 // Buggy implementations might return 1 (just Clip) or 3 (Clip - Save - Rest
ore). |
| 122 REPORTER_ASSERT(r, dstPic->approximateOpCount() == 4); | 122 REPORTER_ASSERT(r, dstPic->approximateOpCount() == 4); |
| 123 } | 123 } |
| 124 | 124 |
| 125 DEF_TEST(PictureBBH_Clear, r) { | 125 DEF_TEST(PictureBBH_Clear, r) { |
| 126 test_clear(r, NULL); | 126 test_clear(r, NULL); |
| 127 | 127 |
| 128 SkTileGridFactory::TileGridInfo grid = { {1,1}, {0,0}, {0,0} }; | 128 SkTileGridFactory::TileGridInfo grid = { {1,1}, {0,0}, {0,0} }; |
| 129 SkTileGridFactory tilegrid(grid); | 129 SkTileGridFactory tilegrid(grid); |
| 130 test_clear(r, &tilegrid); | 130 test_clear(r, &tilegrid); |
| 131 | 131 |
| 132 SkRTreeFactory rtree; | 132 SkRTreeFactory rtree; |
| 133 test_clear(r, &rtree); | 133 test_clear(r, &rtree); |
| 134 } | 134 } |
| OLD | NEW |