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 "Test.h" | 8 #include "Test.h" |
9 | 9 |
10 #include "SkPictureRecorder.h" | 10 #include "SkPictureRecorder.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 SkRecord record; | 118 SkRecord record; |
119 SkRecorder recorder(&record, 100, 100); | 119 SkRecorder recorder(&record, 100, 100); |
120 recorder.drawPicture(pic); | 120 recorder.drawPicture(pic); |
121 // the recorder should now also be an owner | 121 // the recorder should now also be an owner |
122 REPORTER_ASSERT(r, !pic->unique()); | 122 REPORTER_ASSERT(r, !pic->unique()); |
123 } | 123 } |
124 // the recorder destructor should have released us (back to unique) | 124 // the recorder destructor should have released us (back to unique) |
125 REPORTER_ASSERT(r, pic->unique()); | 125 REPORTER_ASSERT(r, pic->unique()); |
126 } | 126 } |
127 | 127 |
128 DEF_TEST(Recorder_IsDrawingToLayer, r) { | |
129 SkRecord record; | |
130 SkRecorder recorder(&record, 100, 100); | |
131 | |
132 // We'll save, saveLayer, save, and saveLayer, then restore them all, | |
133 // checking that isDrawingToLayer() is correct at each step. | |
134 | |
135 REPORTER_ASSERT(r, !recorder.isDrawingToLayer()); | |
136 recorder.save(); | |
137 REPORTER_ASSERT(r, !recorder.isDrawingToLayer()); | |
138 recorder.saveLayer(NULL, NULL); | |
139 REPORTER_ASSERT(r, recorder.isDrawingToLayer()); | |
140 recorder.save(); | |
141 REPORTER_ASSERT(r, recorder.isDrawingToLayer()); | |
142 recorder.saveLayer(NULL, NULL); | |
143 REPORTER_ASSERT(r, recorder.isDrawingToLayer()); | |
144 recorder.restore(); | |
145 REPORTER_ASSERT(r, recorder.isDrawingToLayer()); | |
146 recorder.restore(); | |
147 REPORTER_ASSERT(r, recorder.isDrawingToLayer()); | |
148 recorder.restore(); | |
149 REPORTER_ASSERT(r, !recorder.isDrawingToLayer()); | |
150 recorder.restore(); | |
151 REPORTER_ASSERT(r, !recorder.isDrawingToLayer()); | |
152 } | |
153 | |
154 DEF_TEST(Recorder_drawImage_takeReference, reporter) { | 128 DEF_TEST(Recorder_drawImage_takeReference, reporter) { |
155 | 129 |
156 SkAutoTUnref<SkImage> image; | 130 SkAutoTUnref<SkImage> image; |
157 { | 131 { |
158 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100))
; | 132 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100))
; |
159 surface->getCanvas()->clear(SK_ColorGREEN); | 133 surface->getCanvas()->clear(SK_ColorGREEN); |
160 image.reset(surface->newImageSnapshot()); | 134 image.reset(surface->newImageSnapshot()); |
161 } | 135 } |
162 { | 136 { |
163 SkRecord record; | 137 SkRecord record; |
(...skipping 18 matching lines...) Expand all Loading... |
182 recorder.drawImageRect(image.get(), 0, SkRect::MakeWH(100, 100)); | 156 recorder.drawImageRect(image.get(), 0, SkRect::MakeWH(100, 100)); |
183 REPORTER_ASSERT(reporter, !image->unique()); | 157 REPORTER_ASSERT(reporter, !image->unique()); |
184 | 158 |
185 Tally tally; | 159 Tally tally; |
186 tally.apply(record); | 160 tally.apply(record); |
187 | 161 |
188 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); | 162 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); |
189 } | 163 } |
190 REPORTER_ASSERT(reporter, image->unique()); | 164 REPORTER_ASSERT(reporter, image->unique()); |
191 } | 165 } |
OLD | NEW |