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 #include "SkPictureStateTree.h" | 15 #include "SkPictureStateTree.h" |
16 | 16 |
17 #include "SkBBHFactory.h" | |
18 #include "SkBitmapDevice.h" | 17 #include "SkBitmapDevice.h" |
19 #include "SkCanvas.h" | 18 #include "SkCanvas.h" |
20 #include "SkChunkAlloc.h" | 19 #include "SkChunkAlloc.h" |
21 #include "SkDrawPictureCallback.h" | 20 #include "SkDrawPictureCallback.h" |
22 #include "SkPaintPriv.h" | 21 #include "SkPaintPriv.h" |
23 #include "SkPicture.h" | 22 #include "SkPicture.h" |
24 #include "SkRecordAnalysis.h" | 23 #include "SkRecordAnalysis.h" |
25 #include "SkRegion.h" | 24 #include "SkRegion.h" |
26 #include "SkStream.h" | 25 #include "SkStream.h" |
27 #include "SkTDArray.h" | 26 #include "SkTDArray.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 131 |
133 SkPictInfo info; | 132 SkPictInfo info; |
134 this->createHeader(&info); | 133 this->createHeader(&info); |
135 fData.reset(SkNEW_ARGS(SkPictureData, (record, info, deepCopyOps))); | 134 fData.reset(SkNEW_ARGS(SkPictureData, (record, info, deepCopyOps))); |
136 } | 135 } |
137 | 136 |
138 // Create an SkPictureData-backed SkPicture from an SkRecord. | 137 // Create an SkPictureData-backed SkPicture from an SkRecord. |
139 // This for compatibility with serialization code only. This is not cheap. | 138 // This for compatibility with serialization code only. This is not cheap. |
140 static SkPicture* backport(const SkRecord& src, int width, int height) { | 139 static SkPicture* backport(const SkRecord& src, int width, int height) { |
141 SkPictureRecorder recorder; | 140 SkPictureRecorder recorder; |
142 SkRecordDraw(src, recorder.beginRecording(width, height)); | 141 SkRecordDraw(src, recorder.beginRecording(width, height), NULL/*bbh*/, NULL/
*callback*/); |
143 return recorder.endRecording(); | 142 return recorder.endRecording(); |
144 } | 143 } |
145 | 144 |
146 // fRecord OK | 145 // fRecord OK |
147 SkPicture::~SkPicture() { | 146 SkPicture::~SkPicture() { |
148 this->callDeletionListeners(); | 147 this->callDeletionListeners(); |
149 } | 148 } |
150 | 149 |
151 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE | 150 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE |
152 // fRecord TODO, fix by deleting this method | 151 // fRecord TODO, fix by deleting this method |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 // fRecord OK | 259 // fRecord OK |
261 void SkPicture::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) const { | 260 void SkPicture::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) const { |
262 SkASSERT(NULL != canvas); | 261 SkASSERT(NULL != canvas); |
263 SkASSERT(NULL != fData.get() || NULL != fRecord.get()); | 262 SkASSERT(NULL != fData.get() || NULL != fRecord.get()); |
264 | 263 |
265 if (NULL != fData.get()) { | 264 if (NULL != fData.get()) { |
266 SkPicturePlayback playback(this); | 265 SkPicturePlayback playback(this); |
267 playback.draw(canvas, callback); | 266 playback.draw(canvas, callback); |
268 } | 267 } |
269 if (NULL != fRecord.get()) { | 268 if (NULL != fRecord.get()) { |
270 SkRecordDraw(*fRecord, canvas, callback); | 269 SkRecordDraw(*fRecord, canvas, fBBH.get(), callback); |
271 } | 270 } |
272 } | 271 } |
273 | 272 |
274 /////////////////////////////////////////////////////////////////////////////// | 273 /////////////////////////////////////////////////////////////////////////////// |
275 | 274 |
276 #include "SkStream.h" | 275 #include "SkStream.h" |
277 | 276 |
278 static const char kMagic[] = { 's', 'k', 'i', 'a', 'p', 'i', 'c', 't' }; | 277 static const char kMagic[] = { 's', 'k', 'i', 'a', 'p', 'i', 'c', 't' }; |
279 | 278 |
280 // fRecord OK | 279 // fRecord OK |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 482 |
484 // fRecord OK | 483 // fRecord OK |
485 uint32_t SkPicture::uniqueID() const { | 484 uint32_t SkPicture::uniqueID() const { |
486 if (SK_InvalidGenID == fUniqueID) { | 485 if (SK_InvalidGenID == fUniqueID) { |
487 fUniqueID = next_picture_generation_id(); | 486 fUniqueID = next_picture_generation_id(); |
488 } | 487 } |
489 return fUniqueID; | 488 return fUniqueID; |
490 } | 489 } |
491 | 490 |
492 // fRecord OK | 491 // fRecord OK |
493 SkPicture::SkPicture(int width, int height, SkRecord* record) | 492 SkPicture::SkPicture(int width, int height, SkRecord* record, SkBBoxHierarchy* b
bh) |
494 : fWidth(width) | 493 : fWidth(width) |
495 , fHeight(height) | 494 , fHeight(height) |
496 , fRecord(record) | 495 , fRecord(record) |
| 496 , fBBH(SkSafeRef(bbh)) |
497 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) { | 497 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) { |
| 498 // TODO: delay as much of this work until just before first playback? |
| 499 if (fBBH.get()) { |
| 500 SkRecordFillBounds(*record, fBBH.get()); |
| 501 } |
498 this->needsNewGenID(); | 502 this->needsNewGenID(); |
499 } | 503 } |
500 | 504 |
501 // Note that we are assuming that this entry point will only be called from | 505 // Note that we are assuming that this entry point will only be called from |
502 // one thread. Currently the only client of this method is | 506 // one thread. Currently the only client of this method is |
503 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single | 507 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single |
504 // thread. | 508 // thread. |
505 void SkPicture::addDeletionListener(DeletionListener* listener) const { | 509 void SkPicture::addDeletionListener(DeletionListener* listener) const { |
506 SkASSERT(NULL != listener); | 510 SkASSERT(NULL != listener); |
507 | 511 |
508 *fDeletionListeners.append() = SkRef(listener); | 512 *fDeletionListeners.append() = SkRef(listener); |
509 } | 513 } |
510 | 514 |
511 void SkPicture::callDeletionListeners() { | 515 void SkPicture::callDeletionListeners() { |
512 for (int i = 0; i < fDeletionListeners.count(); ++i) { | 516 for (int i = 0; i < fDeletionListeners.count(); ++i) { |
513 fDeletionListeners[i]->onDeletion(this->uniqueID()); | 517 fDeletionListeners[i]->onDeletion(this->uniqueID()); |
514 } | 518 } |
515 | 519 |
516 fDeletionListeners.unrefAll(); | 520 fDeletionListeners.unrefAll(); |
517 } | 521 } |
OLD | NEW |