| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 144 } |
| 145 | 145 |
| 146 // fRecord OK | 146 // fRecord OK |
| 147 SkPicture::~SkPicture() { | 147 SkPicture::~SkPicture() { |
| 148 this->callDeletionListeners(); | 148 this->callDeletionListeners(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE | 151 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE |
| 152 // fRecord TODO, fix by deleting this method | 152 // fRecord TODO, fix by deleting this method |
| 153 SkPicture* SkPicture::clone() const { | 153 SkPicture* SkPicture::clone() const { |
| 154 | 154 #ifdef SK_PICTURE_CLONE_NOOP |
| 155 return SkRef(const_cast<SkPicture*>(this)); |
| 156 #else |
| 155 SkAutoTDelete<SkPictureData> newData; | 157 SkAutoTDelete<SkPictureData> newData; |
| 156 | 158 |
| 157 if (fData.get()) { | 159 if (fData.get()) { |
| 158 SkPictCopyInfo copyInfo; | 160 SkPictCopyInfo copyInfo; |
| 159 | 161 |
| 160 int paintCount = SafeCount(fData->fPaints); | 162 int paintCount = SafeCount(fData->fPaints); |
| 161 | 163 |
| 162 /* The alternative to doing this is to have a clone method on the paint
and have it | 164 /* The alternative to doing this is to have a clone method on the paint
and have it |
| 163 * make the deep copy of its internal structures as needed. The holdup t
o doing | 165 * make the deep copy of its internal structures as needed. The holdup t
o doing |
| 164 * that is at this point we would need to pass the SkBitmapHeap so that
we don't | 166 * that is at this point we would need to pass the SkBitmapHeap so that
we don't |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 copyInfo.controller.setupPlaybacks(); | 199 copyInfo.controller.setupPlaybacks(); |
| 198 | 200 |
| 199 newData.reset(SkNEW_ARGS(SkPictureData, (*fData, ©Info))); | 201 newData.reset(SkNEW_ARGS(SkPictureData, (*fData, ©Info))); |
| 200 } | 202 } |
| 201 | 203 |
| 202 SkPicture* clone = SkNEW_ARGS(SkPicture, (newData.detach(), fWidth, fHeight)
); | 204 SkPicture* clone = SkNEW_ARGS(SkPicture, (newData.detach(), fWidth, fHeight)
); |
| 203 clone->fRecordWillPlayBackBitmaps = fRecordWillPlayBackBitmaps; | 205 clone->fRecordWillPlayBackBitmaps = fRecordWillPlayBackBitmaps; |
| 204 clone->fUniqueID = this->uniqueID(); // need to call method to ensure != 0 | 206 clone->fUniqueID = this->uniqueID(); // need to call method to ensure != 0 |
| 205 | 207 |
| 206 return clone; | 208 return clone; |
| 209 #endif |
| 207 } | 210 } |
| 208 #endif//SK_SUPPORT_LEGACY_PICTURE_CLONE | 211 #endif//SK_SUPPORT_LEGACY_PICTURE_CLONE |
| 209 | 212 |
| 210 // fRecord OK | 213 // fRecord OK |
| 211 void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) cons
t { | 214 void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) cons
t { |
| 212 fAccelData.reset(SkRef(data)); | 215 fAccelData.reset(SkRef(data)); |
| 213 } | 216 } |
| 214 | 217 |
| 215 // fRecord OK | 218 // fRecord OK |
| 216 const SkPicture::AccelData* SkPicture::EXPERIMENTAL_getAccelData( | 219 const SkPicture::AccelData* SkPicture::EXPERIMENTAL_getAccelData( |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 // fRecord OK | 492 // fRecord OK |
| 490 SkPicture::SkPicture(int width, int height, SkRecord* record) | 493 SkPicture::SkPicture(int width, int height, SkRecord* record) |
| 491 : fWidth(width) | 494 : fWidth(width) |
| 492 , fHeight(height) | 495 , fHeight(height) |
| 493 , fRecord(record) | 496 , fRecord(record) |
| 494 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) { | 497 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) { |
| 495 this->needsNewGenID(); | 498 this->needsNewGenID(); |
| 496 } | 499 } |
| 497 | 500 |
| 498 // Note that we are assuming that this entry point will only be called from | 501 // Note that we are assuming that this entry point will only be called from |
| 499 // one thread. Currently the only client of this method is | 502 // one thread. Currently the only client of this method is |
| 500 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single | 503 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single |
| 501 // thread. | 504 // thread. |
| 502 void SkPicture::addDeletionListener(DeletionListener* listener) const { | 505 void SkPicture::addDeletionListener(DeletionListener* listener) const { |
| 503 SkASSERT(NULL != listener); | 506 SkASSERT(NULL != listener); |
| 504 | 507 |
| 505 *fDeletionListeners.append() = SkRef(listener); | 508 *fDeletionListeners.append() = SkRef(listener); |
| 506 } | 509 } |
| 507 | 510 |
| 508 void SkPicture::callDeletionListeners() { | 511 void SkPicture::callDeletionListeners() { |
| 509 for (int i = 0; i < fDeletionListeners.count(); ++i) { | 512 for (int i = 0; i < fDeletionListeners.count(); ++i) { |
| 510 fDeletionListeners[i]->onDeletion(this->uniqueID()); | 513 fDeletionListeners[i]->onDeletion(this->uniqueID()); |
| 511 } | 514 } |
| 512 | 515 |
| 513 fDeletionListeners.unrefAll(); | 516 fDeletionListeners.unrefAll(); |
| 514 } | 517 } |
| OLD | NEW |