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" |
11 #include "SkPictureData.h" | 11 #include "SkPictureData.h" |
12 #include "SkPicturePlayback.h" | 12 #include "SkPicturePlayback.h" |
13 #include "SkPictureRecord.h" | 13 #include "SkPictureRecord.h" |
14 #include "SkPictureRecorder.h" | 14 #include "SkPictureRecorder.h" |
15 | 15 |
16 #include "SkBitmapDevice.h" | 16 #include "SkBitmapDevice.h" |
17 #include "SkCanvas.h" | 17 #include "SkCanvas.h" |
18 #include "SkChunkAlloc.h" | 18 #include "SkChunkAlloc.h" |
19 #include "SkDrawPictureCallback.h" | 19 #include "SkDrawPictureCallback.h" |
| 20 #include "SkMessageBus.h" |
20 #include "SkPaintPriv.h" | 21 #include "SkPaintPriv.h" |
21 #include "SkPathEffect.h" | 22 #include "SkPathEffect.h" |
22 #include "SkPicture.h" | 23 #include "SkPicture.h" |
23 #include "SkRegion.h" | 24 #include "SkRegion.h" |
24 #include "SkShader.h" | 25 #include "SkShader.h" |
25 #include "SkStream.h" | 26 #include "SkStream.h" |
26 #include "SkTDArray.h" | 27 #include "SkTDArray.h" |
27 #include "SkTLogic.h" | 28 #include "SkTLogic.h" |
28 #include "SkTSearch.h" | 29 #include "SkTSearch.h" |
29 #include "SkTime.h" | 30 #include "SkTime.h" |
30 | 31 |
31 #include "SkReader32.h" | 32 #include "SkReader32.h" |
32 #include "SkWriter32.h" | 33 #include "SkWriter32.h" |
33 #include "SkRTree.h" | 34 #include "SkRTree.h" |
34 | 35 |
35 #if SK_SUPPORT_GPU | 36 #if SK_SUPPORT_GPU |
36 #include "GrContext.h" | 37 #include "GrContext.h" |
37 #endif | 38 #endif |
38 | 39 |
39 #include "SkRecord.h" | 40 #include "SkRecord.h" |
40 #include "SkRecordDraw.h" | 41 #include "SkRecordDraw.h" |
41 #include "SkRecordOpts.h" | 42 #include "SkRecordOpts.h" |
42 #include "SkRecorder.h" | 43 #include "SkRecorder.h" |
43 | 44 |
| 45 DECLARE_SKMESSAGEBUS_MESSAGE(SkPicture::DeletionMessage); |
| 46 |
44 template <typename T> int SafeCount(const T* obj) { | 47 template <typename T> int SafeCount(const T* obj) { |
45 return obj ? obj->count() : 0; | 48 return obj ? obj->count() : 0; |
46 } | 49 } |
47 | 50 |
48 static int32_t gPictureGenerationID; | 51 static int32_t gPictureGenerationID; |
49 | 52 |
50 // never returns a 0 | 53 // never returns a 0 |
51 static int32_t next_picture_generation_id() { | 54 static int32_t next_picture_generation_id() { |
52 // Loop in case our global wraps around. | 55 // Loop in case our global wraps around. |
53 int32_t genID; | 56 int32_t genID; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 274 |
272 int SkPicture::drawableCount() const { | 275 int SkPicture::drawableCount() const { |
273 return fDrawablePicts.get() ? fDrawablePicts->count() : 0; | 276 return fDrawablePicts.get() ? fDrawablePicts->count() : 0; |
274 } | 277 } |
275 | 278 |
276 SkPicture const* const* SkPicture::drawablePicts() const { | 279 SkPicture const* const* SkPicture::drawablePicts() const { |
277 return fDrawablePicts.get() ? fDrawablePicts->begin() : NULL; | 280 return fDrawablePicts.get() ? fDrawablePicts->begin() : NULL; |
278 } | 281 } |
279 | 282 |
280 SkPicture::~SkPicture() { | 283 SkPicture::~SkPicture() { |
281 this->callDeletionListeners(); | 284 SkPicture::DeletionMessage msg; |
| 285 msg.fUniqueID = this->uniqueID(); |
| 286 SkMessageBus<SkPicture::DeletionMessage>::Post(msg); |
282 } | 287 } |
283 | 288 |
284 void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) cons
t { | 289 void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) cons
t { |
285 fAccelData.reset(SkRef(data)); | 290 fAccelData.reset(SkRef(data)); |
286 } | 291 } |
287 | 292 |
288 const SkPicture::AccelData* SkPicture::EXPERIMENTAL_getAccelData( | 293 const SkPicture::AccelData* SkPicture::EXPERIMENTAL_getAccelData( |
289 SkPicture::AccelData::Key key) const { | 294 SkPicture::AccelData::Key key) const { |
290 if (fAccelData.get() && fAccelData->getKey() == key) { | 295 if (fAccelData.get() && fAccelData->getKey() == key) { |
291 return fAccelData.get(); | 296 return fAccelData.get(); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 | 524 |
520 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr
awablePicts, | 525 SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr
awablePicts, |
521 SkBBoxHierarchy* bbh) | 526 SkBBoxHierarchy* bbh) |
522 : fUniqueID(next_picture_generation_id()) | 527 : fUniqueID(next_picture_generation_id()) |
523 , fCullRect(cullRect) | 528 , fCullRect(cullRect) |
524 , fRecord(record) | 529 , fRecord(record) |
525 , fBBH(SkSafeRef(bbh)) | 530 , fBBH(SkSafeRef(bbh)) |
526 , fDrawablePicts(drawablePicts) | 531 , fDrawablePicts(drawablePicts) |
527 , fAnalysis(*fRecord) | 532 , fAnalysis(*fRecord) |
528 {} | 533 {} |
529 | |
530 // Note that we are assuming that this entry point will only be called from | |
531 // one thread. Currently the only client of this method is | |
532 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single | |
533 // thread. | |
534 void SkPicture::addDeletionListener(DeletionListener* listener) const { | |
535 SkASSERT(listener); | |
536 | |
537 *fDeletionListeners.append() = SkRef(listener); | |
538 } | |
539 | |
540 void SkPicture::callDeletionListeners() { | |
541 for (int i = 0; i < fDeletionListeners.count(); ++i) { | |
542 fDeletionListeners[i]->onDeletion(this->uniqueID()); | |
543 } | |
544 | |
545 fDeletionListeners.unrefAll(); | |
546 } | |
OLD | NEW |