OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkPictureFlat.h" | 10 #include "SkPictureFlat.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 } | 157 } |
158 | 158 |
159 void SkPicture::clone(SkPicture* pictures, int count) const { | 159 void SkPicture::clone(SkPicture* pictures, int count) const { |
160 SkPictCopyInfo copyInfo; | 160 SkPictCopyInfo copyInfo; |
161 | 161 |
162 for (int i = 0; i < count; i++) { | 162 for (int i = 0; i < count; i++) { |
163 SkPicture* clone = &pictures[i]; | 163 SkPicture* clone = &pictures[i]; |
164 | 164 |
165 clone->fWidth = fWidth; | 165 clone->fWidth = fWidth; |
166 clone->fHeight = fHeight; | 166 clone->fHeight = fHeight; |
167 clone->fRecord = NULL; | 167 SkSafeSetNull(clone->fRecord); |
scroggo
2014/02/14 15:07:40
SkSafeSetNull seems like a bad name to me - it's n
| |
168 | |
169 if (NULL != clone->fRecord) { | |
170 clone->fRecord->unref(); | |
171 clone->fRecord = NULL; | |
172 } | |
173 SkDELETE(clone->fPlayback); | 168 SkDELETE(clone->fPlayback); |
174 | 169 |
175 /* We want to copy the src's playback. However, if that hasn't been bui lt | 170 /* We want to copy the src's playback. However, if that hasn't been bui lt |
176 yet, we need to fake a call to endRecording() without actually calli ng | 171 yet, we need to fake a call to endRecording() without actually calli ng |
177 it (since it is destructive, and we don't want to change src). | 172 it (since it is destructive, and we don't want to change src). |
178 */ | 173 */ |
179 if (fPlayback) { | 174 if (fPlayback) { |
180 clone->fPlayback = SkNEW_ARGS(SkPicturePlayback, (*fPlayback, ©I nfo)); | 175 clone->fPlayback = SkNEW_ARGS(SkPicturePlayback, (*fPlayback, ©I nfo)); |
181 } else if (fRecord) { | 176 } else if (fRecord) { |
182 // here we do a fake src.endRecording() | 177 // here we do a fake src.endRecording() |
183 clone->fPlayback = SkNEW_ARGS(SkPicturePlayback, (*fRecord, true)); | 178 clone->fPlayback = SkNEW_ARGS(SkPicturePlayback, (*fRecord, true)); |
184 } else { | 179 } else { |
185 clone->fPlayback = NULL; | 180 clone->fPlayback = NULL; |
186 } | 181 } |
187 } | 182 } |
188 } | 183 } |
189 | 184 |
190 /////////////////////////////////////////////////////////////////////////////// | 185 /////////////////////////////////////////////////////////////////////////////// |
191 | 186 |
192 SkCanvas* SkPicture::beginRecording(int width, int height, | 187 SkCanvas* SkPicture::beginRecording(int width, int height, |
193 uint32_t recordingFlags) { | 188 uint32_t recordingFlags) { |
194 if (fPlayback) { | 189 if (fPlayback) { |
195 SkDELETE(fPlayback); | 190 SkDELETE(fPlayback); |
196 fPlayback = NULL; | 191 fPlayback = NULL; |
197 } | 192 } |
198 | 193 |
199 if (NULL != fRecord) { | 194 SkSafeSetNull(fRecord); |
200 fRecord->unref(); | |
201 fRecord = NULL; | |
202 } | |
203 | 195 |
204 SkBitmap bm; | 196 SkBitmap bm; |
205 bm.setConfig(SkBitmap::kNo_Config, width, height); | 197 bm.setConfig(SkBitmap::kNo_Config, width, height); |
206 SkAutoTUnref<SkBaseDevice> dev(SkNEW_ARGS(SkBitmapDevice, (bm))); | 198 SkAutoTUnref<SkBaseDevice> dev(SkNEW_ARGS(SkBitmapDevice, (bm))); |
207 | 199 |
208 // Must be set before calling createBBoxHierarchy | 200 // Must be set before calling createBBoxHierarchy |
209 fWidth = width; | 201 fWidth = width; |
210 fHeight = height; | 202 fHeight = height; |
211 | 203 |
212 if (recordingFlags & kOptimizeForClippedPlayback_RecordingFlag) { | 204 if (recordingFlags & kOptimizeForClippedPlayback_RecordingFlag) { |
(...skipping 26 matching lines...) Expand all Loading... | |
239 SkCanvas* SkPicture::getRecordingCanvas() const { | 231 SkCanvas* SkPicture::getRecordingCanvas() const { |
240 // will be null if we are not recording | 232 // will be null if we are not recording |
241 return fRecord; | 233 return fRecord; |
242 } | 234 } |
243 | 235 |
244 void SkPicture::endRecording() { | 236 void SkPicture::endRecording() { |
245 if (NULL == fPlayback) { | 237 if (NULL == fPlayback) { |
246 if (NULL != fRecord) { | 238 if (NULL != fRecord) { |
247 fRecord->endRecording(); | 239 fRecord->endRecording(); |
248 fPlayback = SkNEW_ARGS(SkPicturePlayback, (*fRecord)); | 240 fPlayback = SkNEW_ARGS(SkPicturePlayback, (*fRecord)); |
249 fRecord->unref(); | 241 SkSafeSetNull(fRecord); |
250 fRecord = NULL; | |
251 } | 242 } |
252 } | 243 } |
253 SkASSERT(NULL == fRecord); | 244 SkASSERT(NULL == fRecord); |
254 } | 245 } |
255 | 246 |
256 void SkPicture::draw(SkCanvas* surface, SkDrawPictureCallback* callback) { | 247 void SkPicture::draw(SkCanvas* surface, SkDrawPictureCallback* callback) { |
257 this->endRecording(); | 248 this->endRecording(); |
258 if (fPlayback) { | 249 if (fPlayback) { |
259 fPlayback->draw(*surface, callback); | 250 fPlayback->draw(*surface, callback); |
260 } | 251 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 } | 426 } |
436 | 427 |
437 #ifdef SK_BUILD_FOR_ANDROID | 428 #ifdef SK_BUILD_FOR_ANDROID |
438 void SkPicture::abortPlayback() { | 429 void SkPicture::abortPlayback() { |
439 if (NULL == fPlayback) { | 430 if (NULL == fPlayback) { |
440 return; | 431 return; |
441 } | 432 } |
442 fPlayback->abort(); | 433 fPlayback->abort(); |
443 } | 434 } |
444 #endif | 435 #endif |
OLD | NEW |