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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // With an R-Tree | 42 // With an R-Tree |
43 SkRTreeFactory RTreeFactory; | 43 SkRTreeFactory RTreeFactory; |
44 this->run(&RTreeFactory, reporter); | 44 this->run(&RTreeFactory, reporter); |
45 } | 45 } |
46 | 46 |
47 private: | 47 private: |
48 void run(SkBBHFactory* factory, skiatest::Reporter* reporter) { | 48 void run(SkBBHFactory* factory, skiatest::Reporter* reporter) { |
49 SkCanvas playbackCanvas(fResultBitmap); | 49 SkCanvas playbackCanvas(fResultBitmap); |
50 playbackCanvas.clear(SK_ColorGREEN); | 50 playbackCanvas.clear(SK_ColorGREEN); |
51 SkPictureRecorder recorder; | 51 SkPictureRecorder recorder; |
52 SkCanvas* recordCanvas = recorder.beginRecording(SkIntToScalar(fPictureW
idth), SkIntToScalar(fPictureHeight), factory); | 52 SkCanvas* recordCanvas = recorder.beginRecording(SkIntToScalar(fPictureW
idth), |
| 53 SkIntToScalar(fPictureH
eight), |
| 54 factory); |
53 this->doTest(playbackCanvas, *recordCanvas); | 55 this->doTest(playbackCanvas, *recordCanvas); |
54 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 56 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
55 playbackCanvas.drawPicture(picture); | 57 playbackCanvas.drawPicture(picture); |
56 REPORTER_ASSERT(reporter, SK_ColorGREEN == fResultBitmap.getColor(0, 0))
; | 58 REPORTER_ASSERT(reporter, SK_ColorGREEN == fResultBitmap.getColor(0, 0))
; |
57 } | 59 } |
58 | 60 |
59 SkBitmap fResultBitmap; | 61 SkBitmap fResultBitmap; |
60 int fPictureWidth, fPictureHeight; | 62 int fPictureWidth, fPictureHeight; |
61 }; | 63 }; |
62 | 64 |
(...skipping 29 matching lines...) Expand all Loading... |
92 }; | 94 }; |
93 | 95 |
94 DEF_TEST(PictureBBH, reporter) { | 96 DEF_TEST(PictureBBH, reporter) { |
95 | 97 |
96 DrawEmptyPictureBBHTest emptyPictureTest; | 98 DrawEmptyPictureBBHTest emptyPictureTest; |
97 emptyPictureTest.run(reporter); | 99 emptyPictureTest.run(reporter); |
98 | 100 |
99 EmptyClipPictureBBHTest emptyClipPictureTest; | 101 EmptyClipPictureBBHTest emptyClipPictureTest; |
100 emptyClipPictureTest.run(reporter); | 102 emptyClipPictureTest.run(reporter); |
101 } | 103 } |
| 104 |
| 105 static void test_clear(skiatest::Reporter* r, SkBBHFactory* factory) { |
| 106 // Make a single red pixel. |
| 107 SkBitmap bm; |
| 108 bm.allocN32Pixels(1,1); |
| 109 SkCanvas dst(bm); |
| 110 dst.clear(SK_ColorRED); |
| 111 |
| 112 // Clip our canvas down to empty. |
| 113 dst.clipRect(SkRect::MakeWH(0,0)); |
| 114 |
| 115 // clear() should still set that pixel to true, because it ignores the clip. |
| 116 dst.clear(SK_ColorBLUE); |
| 117 REPORTER_ASSERT(r, SK_ColorBLUE == bm.getColor(0,0)); |
| 118 |
| 119 // Should also work if we do the draw via an SkPicture. |
| 120 SkPictureRecorder rec; |
| 121 SkCanvas* src = rec.beginRecording(1,1, factory); |
| 122 src->clear(SK_ColorGREEN); |
| 123 SkAutoTDelete<SkPicture> pic(rec.endRecording()); |
| 124 pic->playback(&dst); |
| 125 REPORTER_ASSERT(r, SK_ColorGREEN == bm.getColor(0,0)); |
| 126 } |
| 127 |
| 128 DEF_TEST(PictureBBH_Clear, r) { |
| 129 test_clear(r, NULL); |
| 130 |
| 131 SkTileGridFactory::TileGridInfo grid = { {1,1}, {0,0}, {0,0} }; |
| 132 SkTileGridFactory tilegrid(grid); |
| 133 test_clear(r, &tilegrid); |
| 134 |
| 135 SkRTreeFactory rtree; |
| 136 test_clear(r, &rtree); |
| 137 } |
OLD | NEW |