| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 , fAnalysis() { | 257 , fAnalysis() { |
| 258 this->needsNewGenID(); | 258 this->needsNewGenID(); |
| 259 | 259 |
| 260 SkPictInfo info; | 260 SkPictInfo info; |
| 261 this->createHeader(&info); | 261 this->createHeader(&info); |
| 262 fData.reset(SkNEW_ARGS(SkPictureData, (record, info, deepCopyOps))); | 262 fData.reset(SkNEW_ARGS(SkPictureData, (record, info, deepCopyOps))); |
| 263 } | 263 } |
| 264 | 264 |
| 265 // Create an SkPictureData-backed SkPicture from an SkRecord. | 265 // Create an SkPictureData-backed SkPicture from an SkRecord. |
| 266 // This for compatibility with serialization code only. This is not cheap. | 266 // This for compatibility with serialization code only. This is not cheap. |
| 267 static SkPicture* backport(const SkRecord& src, const SkRect& cullRect) { | 267 SkPicture* SkPicture::Backport(const SkRecord& src, const SkRect& cullRect) { |
| 268 SkPictureRecorder recorder; | 268 SkPictureRecord rec(SkISize::Make(cullRect.width(), cullRect.height()), 0/*f
lags*/); |
| 269 SkRecordDraw(src, | 269 rec.beginRecording(); |
| 270 recorder.DEPRECATED_beginRecording(cullRect.width(), cullRect.h
eight()), | 270 SkRecordDraw(src, &rec, NULL/*bbh*/, NULL/*callback*/); |
| 271 NULL/*bbh*/, NULL/*callback*/); | 271 rec.endRecording(); |
| 272 return recorder.endRecording(); | 272 return SkNEW_ARGS(SkPicture, (cullRect.width(), cullRect.height(), rec, fals
e/*deepCopyOps*/)); |
| 273 } | 273 } |
| 274 | 274 |
| 275 // fRecord OK | 275 // fRecord OK |
| 276 SkPicture::~SkPicture() { | 276 SkPicture::~SkPicture() { |
| 277 this->callDeletionListeners(); | 277 this->callDeletionListeners(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 // fRecord OK | 280 // fRecord OK |
| 281 void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) cons
t { | 281 void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) cons
t { |
| 282 fAccelData.reset(SkRef(data)); | 282 fAccelData.reset(SkRef(data)); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 } | 503 } |
| 504 } | 504 } |
| 505 | 505 |
| 506 // fRecord OK | 506 // fRecord OK |
| 507 void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const { | 507 void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const { |
| 508 const SkPictureData* data = fData.get(); | 508 const SkPictureData* data = fData.get(); |
| 509 | 509 |
| 510 // If we're a new-format picture, backport to old format for serialization. | 510 // If we're a new-format picture, backport to old format for serialization. |
| 511 SkAutoTDelete<SkPicture> oldFormat; | 511 SkAutoTDelete<SkPicture> oldFormat; |
| 512 if (NULL == data && fRecord.get()) { | 512 if (NULL == data && fRecord.get()) { |
| 513 oldFormat.reset(backport(*fRecord, this->cullRect())); | 513 oldFormat.reset(Backport(*fRecord, this->cullRect())); |
| 514 data = oldFormat->fData.get(); | 514 data = oldFormat->fData.get(); |
| 515 SkASSERT(data); | 515 SkASSERT(data); |
| 516 } | 516 } |
| 517 | 517 |
| 518 SkPictInfo info; | 518 SkPictInfo info; |
| 519 this->createHeader(&info); | 519 this->createHeader(&info); |
| 520 SkASSERT(sizeof(SkPictInfo) == 32); | 520 SkASSERT(sizeof(SkPictInfo) == 32); |
| 521 stream->write(&info, sizeof(info)); | 521 stream->write(&info, sizeof(info)); |
| 522 | 522 |
| 523 if (data) { | 523 if (data) { |
| 524 stream->writeBool(true); | 524 stream->writeBool(true); |
| 525 data->serialize(stream, encoder); | 525 data->serialize(stream, encoder); |
| 526 } else { | 526 } else { |
| 527 stream->writeBool(false); | 527 stream->writeBool(false); |
| 528 } | 528 } |
| 529 } | 529 } |
| 530 | 530 |
| 531 // fRecord OK | 531 // fRecord OK |
| 532 void SkPicture::flatten(SkWriteBuffer& buffer) const { | 532 void SkPicture::flatten(SkWriteBuffer& buffer) const { |
| 533 const SkPictureData* data = fData.get(); | 533 const SkPictureData* data = fData.get(); |
| 534 | 534 |
| 535 // If we're a new-format picture, backport to old format for serialization. | 535 // If we're a new-format picture, backport to old format for serialization. |
| 536 SkAutoTDelete<SkPicture> oldFormat; | 536 SkAutoTDelete<SkPicture> oldFormat; |
| 537 if (NULL == data && fRecord.get()) { | 537 if (NULL == data && fRecord.get()) { |
| 538 oldFormat.reset(backport(*fRecord, this->cullRect())); | 538 oldFormat.reset(Backport(*fRecord, this->cullRect())); |
| 539 data = oldFormat->fData.get(); | 539 data = oldFormat->fData.get(); |
| 540 SkASSERT(data); | 540 SkASSERT(data); |
| 541 } | 541 } |
| 542 | 542 |
| 543 SkPictInfo info; | 543 SkPictInfo info; |
| 544 this->createHeader(&info); | 544 this->createHeader(&info); |
| 545 buffer.writeByteArray(&info.fMagic, sizeof(info.fMagic)); | 545 buffer.writeByteArray(&info.fMagic, sizeof(info.fMagic)); |
| 546 buffer.writeUInt(info.fVersion); | 546 buffer.writeUInt(info.fVersion); |
| 547 buffer.writeRect(info.fCullRect); | 547 buffer.writeRect(info.fCullRect); |
| 548 buffer.writeUInt(info.fFlags); | 548 buffer.writeUInt(info.fFlags); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 int SkPicture::approximateOpCount() const { | 658 int SkPicture::approximateOpCount() const { |
| 659 SkASSERT(fRecord.get() || fData.get()); | 659 SkASSERT(fRecord.get() || fData.get()); |
| 660 if (fRecord.get()) { | 660 if (fRecord.get()) { |
| 661 return fRecord->count(); | 661 return fRecord->count(); |
| 662 } | 662 } |
| 663 if (fData.get()) { | 663 if (fData.get()) { |
| 664 return fData->opCount(); | 664 return fData->opCount(); |
| 665 } | 665 } |
| 666 return 0; | 666 return 0; |
| 667 } | 667 } |
| OLD | NEW |