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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 // Create an SkPictureData-backed SkPicture from an SkRecord. | 138 // Create an SkPictureData-backed SkPicture from an SkRecord. |
139 // This for compatibility with serialization code only. This is not cheap. | 139 // This for compatibility with serialization code only. This is not cheap. |
140 static SkPicture* backport(const SkRecord& src, int width, int height) { | 140 static SkPicture* backport(const SkRecord& src, int width, int height) { |
141 SkPictureRecorder recorder; | 141 SkPictureRecorder recorder; |
142 SkRecordDraw(src, recorder.beginRecording(width, height)); | 142 SkRecordDraw(src, recorder.beginRecording(width, height)); |
143 return recorder.endRecording(); | 143 return recorder.endRecording(); |
144 } | 144 } |
145 | 145 |
146 // fRecord OK | 146 // fRecord OK |
147 SkPicture::~SkPicture() {} | 147 SkPicture::~SkPicture() { |
| 148 this->callDeletionListeners(); |
| 149 } |
148 | 150 |
149 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE | 151 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE |
150 // fRecord TODO, fix by deleting this method | 152 // fRecord TODO, fix by deleting this method |
151 SkPicture* SkPicture::clone() const { | 153 SkPicture* SkPicture::clone() const { |
152 | 154 |
153 SkAutoTDelete<SkPictureData> newData; | 155 SkAutoTDelete<SkPictureData> newData; |
154 | 156 |
155 if (fData.get()) { | 157 if (fData.get()) { |
156 SkPictCopyInfo copyInfo; | 158 SkPictCopyInfo copyInfo; |
157 | 159 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 } | 487 } |
486 | 488 |
487 // fRecord OK | 489 // fRecord OK |
488 SkPicture::SkPicture(int width, int height, SkRecord* record) | 490 SkPicture::SkPicture(int width, int height, SkRecord* record) |
489 : fWidth(width) | 491 : fWidth(width) |
490 , fHeight(height) | 492 , fHeight(height) |
491 , fRecord(record) | 493 , fRecord(record) |
492 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) { | 494 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) { |
493 this->needsNewGenID(); | 495 this->needsNewGenID(); |
494 } | 496 } |
| 497 |
| 498 // 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 |
| 500 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single |
| 501 // thread. |
| 502 void SkPicture::addDeletionListener(DeletionListener* listener) const { |
| 503 SkASSERT(NULL != listener); |
| 504 |
| 505 *fDeletionListeners.append() = SkRef(listener); |
| 506 } |
| 507 |
| 508 void SkPicture::callDeletionListeners() { |
| 509 for (int i = 0; i < fDeletionListeners.count(); ++i) { |
| 510 fDeletionListeners[i]->onDeletion(this->uniqueID()); |
| 511 } |
| 512 |
| 513 fDeletionListeners.unrefAll(); |
| 514 } |
OLD | NEW |