| 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 "SkPictureRecord.h" | 13 #include "SkPictureRecord.h" |
| 13 #include "SkPictureRecorder.h" | 14 #include "SkPictureRecorder.h" |
| 14 | 15 |
| 15 #include "SkBBHFactory.h" | 16 #include "SkBBHFactory.h" |
| 16 #include "SkBitmapDevice.h" | 17 #include "SkBitmapDevice.h" |
| 17 #include "SkCanvas.h" | 18 #include "SkCanvas.h" |
| 18 #include "SkChunkAlloc.h" | 19 #include "SkChunkAlloc.h" |
| 19 #include "SkDrawPictureCallback.h" | 20 #include "SkDrawPictureCallback.h" |
| 20 #include "SkPaintPriv.h" | 21 #include "SkPaintPriv.h" |
| 21 #include "SkPicture.h" | 22 #include "SkPicture.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 int32_t id = sk_atomic_inc(&gNextID); | 286 int32_t id = sk_atomic_inc(&gNextID); |
| 286 if (id >= 1 << (8 * sizeof(Domain))) { | 287 if (id >= 1 << (8 * sizeof(Domain))) { |
| 287 SK_CRASH(); | 288 SK_CRASH(); |
| 288 } | 289 } |
| 289 | 290 |
| 290 return static_cast<Domain>(id); | 291 return static_cast<Domain>(id); |
| 291 } | 292 } |
| 292 | 293 |
| 293 /////////////////////////////////////////////////////////////////////////////// | 294 /////////////////////////////////////////////////////////////////////////////// |
| 294 | 295 |
| 295 // fRecord OK | |
| 296 const SkPicture::OperationList& SkPicture::OperationList::InvalidList() { | |
| 297 static OperationList gInvalid; | |
| 298 return gInvalid; | |
| 299 } | |
| 300 | |
| 301 // fRecord TODO | 296 // fRecord TODO |
| 302 const SkPicture::OperationList& SkPicture::EXPERIMENTAL_getActiveOps(const SkIRe
ct& queryRect) const { | 297 const SkPicture::OperationList* SkPicture::EXPERIMENTAL_getActiveOps(const SkIRe
ct& queryRect) const { |
| 303 SkASSERT(NULL != fData.get()); | 298 SkASSERT(NULL != fData.get()); |
| 304 if (NULL != fData.get()) { | 299 if (NULL != fData.get()) { |
| 305 return fData->getActiveOps(queryRect); | 300 return fData->getActiveOps(queryRect); |
| 306 } | 301 } |
| 307 return OperationList::InvalidList(); | 302 return NULL; |
| 308 } | |
| 309 | |
| 310 // fRecord TODO | |
| 311 size_t SkPicture::EXPERIMENTAL_curOpID() const { | |
| 312 if (NULL != fData.get()) { | |
| 313 return fData->curOpID(); | |
| 314 } | |
| 315 return 0; | |
| 316 } | 303 } |
| 317 | 304 |
| 318 // fRecord OK | 305 // fRecord OK |
| 319 void SkPicture::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) const { | 306 void SkPicture::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) const { |
| 320 SkASSERT(NULL != canvas); | 307 SkASSERT(NULL != canvas); |
| 321 SkASSERT(NULL != fData.get() || NULL != fRecord.get()); | 308 SkASSERT(NULL != fData.get() || NULL != fRecord.get()); |
| 322 | 309 |
| 323 if (NULL != fData.get()) { | 310 if (NULL != fData.get()) { |
| 324 fData->draw(*canvas, callback); | 311 SkPicturePlayback playback(this); |
| 312 playback.draw(canvas, callback); |
| 325 } | 313 } |
| 326 if (NULL != fRecord.get()) { | 314 if (NULL != fRecord.get()) { |
| 327 SkRecordDraw(*fRecord, canvas, callback); | 315 SkRecordDraw(*fRecord, canvas, callback); |
| 328 } | 316 } |
| 329 } | 317 } |
| 330 | 318 |
| 331 /////////////////////////////////////////////////////////////////////////////// | 319 /////////////////////////////////////////////////////////////////////////////// |
| 332 | 320 |
| 333 #include "SkStream.h" | 321 #include "SkStream.h" |
| 334 | 322 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 bool SkPicture::willPlayBackBitmaps() const { | 519 bool SkPicture::willPlayBackBitmaps() const { |
| 532 if (fRecord.get()) { | 520 if (fRecord.get()) { |
| 533 return fRecordWillPlayBackBitmaps; | 521 return fRecordWillPlayBackBitmaps; |
| 534 } | 522 } |
| 535 if (!fData.get()) { | 523 if (!fData.get()) { |
| 536 return false; | 524 return false; |
| 537 } | 525 } |
| 538 return fData->containsBitmaps(); | 526 return fData->containsBitmaps(); |
| 539 } | 527 } |
| 540 | 528 |
| 541 #ifdef SK_BUILD_FOR_ANDROID | |
| 542 // fRecord TODO, fix by switching Android to SkDrawPictureCallback, then deletin
g this method | |
| 543 void SkPicture::abortPlayback() { | |
| 544 if (NULL == fData.get()) { | |
| 545 return; | |
| 546 } | |
| 547 fData->abort(); | |
| 548 } | |
| 549 #endif | |
| 550 | |
| 551 // fRecord OK | 529 // fRecord OK |
| 552 static int32_t next_picture_generation_id() { | 530 static int32_t next_picture_generation_id() { |
| 553 static int32_t gPictureGenerationID = 0; | 531 static int32_t gPictureGenerationID = 0; |
| 554 // do a loop in case our global wraps around, as we never want to | 532 // do a loop in case our global wraps around, as we never want to |
| 555 // return a 0 | 533 // return a 0 |
| 556 int32_t genID; | 534 int32_t genID; |
| 557 do { | 535 do { |
| 558 genID = sk_atomic_inc(&gPictureGenerationID) + 1; | 536 genID = sk_atomic_inc(&gPictureGenerationID) + 1; |
| 559 } while (SK_InvalidGenID == genID); | 537 } while (SK_InvalidGenID == genID); |
| 560 return genID; | 538 return genID; |
| 561 } | 539 } |
| 562 | 540 |
| 563 // fRecord OK | 541 // fRecord OK |
| 564 uint32_t SkPicture::uniqueID() const { | 542 uint32_t SkPicture::uniqueID() const { |
| 565 if (SK_InvalidGenID == fUniqueID) { | 543 if (SK_InvalidGenID == fUniqueID) { |
| 566 fUniqueID = next_picture_generation_id(); | 544 fUniqueID = next_picture_generation_id(); |
| 567 } | 545 } |
| 568 return fUniqueID; | 546 return fUniqueID; |
| 569 } | 547 } |
| 570 | 548 |
| 571 // fRecord OK | 549 // fRecord OK |
| 572 SkPicture::SkPicture(int width, int height, SkRecord* record) | 550 SkPicture::SkPicture(int width, int height, SkRecord* record) |
| 573 : fWidth(width) | 551 : fWidth(width) |
| 574 , fHeight(height) | 552 , fHeight(height) |
| 575 , fRecord(record) | 553 , fRecord(record) |
| 576 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) { | 554 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) { |
| 577 this->needsNewGenID(); | 555 this->needsNewGenID(); |
| 578 } | 556 } |
| OLD | NEW |