| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 fUniqueID = src.uniqueID(); // need to call method to ensure != 0 | 184 fUniqueID = src.uniqueID(); // need to call method to ensure != 0 |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 // fRecord OK | 188 // fRecord OK |
| 189 SkPicture::~SkPicture() {} | 189 SkPicture::~SkPicture() {} |
| 190 | 190 |
| 191 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE | 191 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE |
| 192 // fRecord TODO, fix by deleting this method | 192 // fRecord TODO, fix by deleting this method |
| 193 SkPicture* SkPicture::clone() const { | 193 SkPicture* SkPicture::clone() const { |
| 194 SkPicture* clonedPicture; | 194 SkPicture* clonedPicture = SkNEW(SkPicture); |
| 195 this->clone(&clonedPicture, 1); | 195 this->clone(clonedPicture, 1); |
| 196 return clonedPicture; | 196 return clonedPicture; |
| 197 } | 197 } |
| 198 | 198 |
| 199 // fRecord TODO, fix by deleting this method | 199 // fRecord TODO, fix by deleting this method |
| 200 void SkPicture::clone(SkPicture* pictures, int count) const { | 200 void SkPicture::clone(SkPicture* pictures, int count) const { |
| 201 SkPictCopyInfo copyInfo; | 201 SkPictCopyInfo copyInfo; |
| 202 | 202 |
| 203 for (int i = 0; i < count; i++) { | 203 for (int i = 0; i < count; i++) { |
| 204 SkPicture* clone = &pictures[i]; | 204 SkPicture* clone = &pictures[i]; |
| 205 | 205 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // needed to create typeface playback | 254 // needed to create typeface playback |
| 255 copyInfo.controller.setupPlaybacks(); | 255 copyInfo.controller.setupPlaybacks(); |
| 256 copyInfo.initialized = true; | 256 copyInfo.initialized = true; |
| 257 } | 257 } |
| 258 | 258 |
| 259 clone->fData.reset(SkNEW_ARGS(SkPictureData, (*fData, ©Info))); | 259 clone->fData.reset(SkNEW_ARGS(SkPictureData, (*fData, ©Info))); |
| 260 clone->fUniqueID = this->uniqueID(); // need to call method to ensur
e != 0 | 260 clone->fUniqueID = this->uniqueID(); // need to call method to ensur
e != 0 |
| 261 } | 261 } |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 | |
| 265 // fRecord TODO, fix by deleting this method | |
| 266 void SkPicture::clone(SkPicture* pictures[], int count) const { | |
| 267 SkPictCopyInfo copyInfo; | |
| 268 | |
| 269 for (int i = 0; i < count; i++) { | |
| 270 SkPicture* clone = pictures[i] = SkNEW(SkPicture); | |
| 271 | |
| 272 clone->needsNewGenID(); | |
| 273 clone->fWidth = fWidth; | |
| 274 clone->fHeight = fHeight; | |
| 275 clone->fData.reset(NULL); | |
| 276 clone->fRecordWillPlayBackBitmaps = fRecordWillPlayBackBitmaps; | |
| 277 | |
| 278 /* We want to copy the src's playback. However, if that hasn't been bui
lt | |
| 279 yet, we need to fake a call to endRecording() without actually calli
ng | |
| 280 it (since it is destructive, and we don't want to change src). | |
| 281 */ | |
| 282 if (fData.get()) { | |
| 283 if (!copyInfo.initialized) { | |
| 284 int paintCount = SafeCount(fData->fPaints); | |
| 285 | |
| 286 /* The alternative to doing this is to have a clone method on th
e paint and have it | |
| 287 * make the deep copy of its internal structures as needed. The
holdup to doing | |
| 288 * that is at this point we would need to pass the SkBitmapHeap
so that we don't | |
| 289 * unnecessarily flatten the pixels in a bitmap shader. | |
| 290 */ | |
| 291 copyInfo.paintData.setCount(paintCount); | |
| 292 | |
| 293 /* Use an SkBitmapHeap to avoid flattening bitmaps in shaders. I
f there already is | |
| 294 * one, use it. If this SkPictureData was created from a stream,
fBitmapHeap | |
| 295 * will be NULL, so create a new one. | |
| 296 */ | |
| 297 if (fData->fBitmapHeap.get() == NULL) { | |
| 298 // FIXME: Put this on the stack inside SkPicture::clone. | |
| 299 SkBitmapHeap* heap = SkNEW(SkBitmapHeap); | |
| 300 copyInfo.controller.setBitmapStorage(heap); | |
| 301 heap->unref(); | |
| 302 } else { | |
| 303 copyInfo.controller.setBitmapStorage(fData->fBitmapHeap); | |
| 304 } | |
| 305 | |
| 306 SkDEBUGCODE(int heapSize = SafeCount(fData->fBitmapHeap.get());) | |
| 307 for (int i = 0; i < paintCount; i++) { | |
| 308 if (NeedsDeepCopy(fData->fPaints->at(i))) { | |
| 309 copyInfo.paintData[i] = | |
| 310 SkFlatData::Create<SkPaint::FlatteningTraits>(©I
nfo.controller, | |
| 311 fData->fPaints->at
(i), 0); | |
| 312 | |
| 313 } else { | |
| 314 // this is our sentinel, which we use in the unflatten l
oop | |
| 315 copyInfo.paintData[i] = NULL; | |
| 316 } | |
| 317 } | |
| 318 SkASSERT(SafeCount(fData->fBitmapHeap.get()) == heapSize); | |
| 319 | |
| 320 // needed to create typeface playback | |
| 321 copyInfo.controller.setupPlaybacks(); | |
| 322 copyInfo.initialized = true; | |
| 323 } | |
| 324 | |
| 325 clone->fData.reset(SkNEW_ARGS(SkPictureData, (*fData, ©Info))); | |
| 326 clone->fUniqueID = this->uniqueID(); // need to call method to ensur
e != 0 | |
| 327 } | |
| 328 } | |
| 329 } | |
| 330 #endif//SK_SUPPORT_LEGACY_PICTURE_CLONE | 264 #endif//SK_SUPPORT_LEGACY_PICTURE_CLONE |
| 331 | 265 |
| 332 // fRecord OK | 266 // fRecord OK |
| 333 void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) cons
t { | 267 void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) cons
t { |
| 334 fAccelData.reset(SkRef(data)); | 268 fAccelData.reset(SkRef(data)); |
| 335 } | 269 } |
| 336 | 270 |
| 337 // fRecord OK | 271 // fRecord OK |
| 338 const SkPicture::AccelData* SkPicture::EXPERIMENTAL_getAccelData( | 272 const SkPicture::AccelData* SkPicture::EXPERIMENTAL_getAccelData( |
| 339 SkPicture::AccelData::Key key) const { | 273 SkPicture::AccelData::Key key) const { |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 } | 543 } |
| 610 | 544 |
| 611 // fRecord OK | 545 // fRecord OK |
| 612 SkPicture::SkPicture(int width, int height, SkRecord* record) | 546 SkPicture::SkPicture(int width, int height, SkRecord* record) |
| 613 : fWidth(width) | 547 : fWidth(width) |
| 614 , fHeight(height) | 548 , fHeight(height) |
| 615 , fRecord(record) | 549 , fRecord(record) |
| 616 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) { | 550 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) { |
| 617 this->needsNewGenID(); | 551 this->needsNewGenID(); |
| 618 } | 552 } |
| OLD | NEW |