Chromium Code Reviews| Index: src/core/SkPicture.cpp |
| diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp |
| index 9b7177870dad9a2beb8a9c61a0640966a34e9ddd..76c2b9def9c1d248a3e002577fc3728647830a44 100644 |
| --- a/src/core/SkPicture.cpp |
| +++ b/src/core/SkPicture.cpp |
| @@ -131,18 +131,16 @@ SkPicture::SkPicture() |
| } |
| SkPicture::SkPicture(int width, int height, |
| - SkPictureRecord& record, |
| + const SkPictureRecord& record, |
| bool deepCopyOps) |
| : fWidth(width) |
| , fHeight(height) |
| , fAccelData(NULL) { |
| this->needsNewGenID(); |
| - fPathHeap.reset(SkSafeRef(record.pathHeap())); |
| - |
| SkPictInfo info; |
| this->createHeader(&info); |
| - fPlayback = SkNEW_ARGS(SkPicturePlayback, (this, record, info, deepCopyOps)); |
| + fPlayback = SkNEW_ARGS(SkPicturePlayback, (record, info, deepCopyOps)); |
| } |
| SkPicture::SkPicture(const SkPicture& src) |
| @@ -152,47 +150,12 @@ SkPicture::SkPicture(const SkPicture& src) |
| fWidth = src.fWidth; |
| fHeight = src.fHeight; |
| - /* We want to copy the src's playback. However, if that hasn't been built |
| - yet, we need to fake a call to endRecording() without actually calling |
| - it (since it is destructive, and we don't want to change src). |
| - */ |
| if (src.fPlayback) { |
| - fPlayback = SkNEW_ARGS(SkPicturePlayback, (this, *src.fPlayback)); |
| + fPlayback = SkNEW_ARGS(SkPicturePlayback, (*src.fPlayback)); |
| fUniqueID = src.uniqueID(); // need to call method to ensure != 0 |
| } else { |
| fPlayback = NULL; |
| } |
| - |
| - fPathHeap.reset(SkSafeRef(src.fPathHeap.get())); |
| -} |
| - |
| -const SkPath& SkPicture::getPath(int index) const { |
| - return (*fPathHeap.get())[index]; |
| -} |
| - |
| -int SkPicture::addPathToHeap(const SkPath& path) { |
| - if (NULL == fPathHeap) { |
| - fPathHeap.reset(SkNEW(SkPathHeap)); |
| - } |
| -#ifdef SK_DEDUP_PICTURE_PATHS |
| - return fPathHeap->insert(path); |
| -#else |
| - return fPathHeap->append(path); |
| -#endif |
| -} |
| - |
| -void SkPicture::initForPlayback() const { |
| - // ensure that the paths bounds are pre-computed |
| - if (NULL != fPathHeap.get()) { |
| - for (int i = 0; i < fPathHeap->count(); i++) { |
| - (*fPathHeap.get())[i].updateBoundsCache(); |
| - } |
| - } |
| -} |
| - |
| -void SkPicture::dumpSize() const { |
| - SkDebugf("--- picture size: paths=%d\n", |
| - SafeCount(fPathHeap.get())); |
| } |
| SkPicture::~SkPicture() { |
| @@ -206,7 +169,6 @@ void SkPicture::swap(SkPicture& other) { |
| SkTSwap(fAccelData, other.fAccelData); |
| SkTSwap(fWidth, other.fWidth); |
| SkTSwap(fHeight, other.fHeight); |
| - fPathHeap.swap(&other.fPathHeap); |
| } |
| SkPicture* SkPicture::clone() const { |
| @@ -273,13 +235,11 @@ void SkPicture::clone(SkPicture* pictures, int count) const { |
| copyInfo.initialized = true; |
| } |
| - clone->fPlayback = SkNEW_ARGS(SkPicturePlayback, (clone, *fPlayback, ©Info)); |
| + clone->fPlayback = SkNEW_ARGS(SkPicturePlayback, (*fPlayback, ©Info)); |
| clone->fUniqueID = this->uniqueID(); // need to call method to ensure != 0 |
| } else { |
| clone->fPlayback = NULL; |
| } |
| - |
| - clone->fPathHeap.reset(SkSafeRef(fPathHeap.get())); |
| } |
| } |
| @@ -389,20 +349,17 @@ SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc pro |
| return NULL; |
| } |
| - SkPicture* newPict = SkNEW_ARGS(SkPicture, (NULL, info.fWidth, info.fHeight)); |
| - |
| // Check to see if there is a playback to recreate. |
| if (stream->readBool()) { |
| - SkPicturePlayback* playback = SkPicturePlayback::CreateFromStream(newPict, stream, |
| - info, proc); |
| + SkPicturePlayback* playback = SkPicturePlayback::CreateFromStream(stream, info, proc); |
| if (NULL == playback) { |
| - SkDELETE(newPict); |
| return NULL; |
| } |
| - newPict->fPlayback = playback; |
| + |
| + return SkNEW_ARGS(SkPicture, (playback, info.fWidth, info.fHeight)); |
| } |
| - return newPict; |
| + return NULL; |
|
mtklein
2014/06/11 21:12:58
Same deal?
|
| } |
| SkPicture* SkPicture::CreateFromBuffer(SkReadBuffer& buffer) { |
| @@ -412,19 +369,17 @@ SkPicture* SkPicture::CreateFromBuffer(SkReadBuffer& buffer) { |
| return NULL; |
| } |
| - SkPicture* newPict = SkNEW_ARGS(SkPicture, (NULL, info.fWidth, info.fHeight)); |
| - |
| // Check to see if there is a playback to recreate. |
| if (buffer.readBool()) { |
| - SkPicturePlayback* playback = SkPicturePlayback::CreateFromBuffer(newPict, buffer, info); |
| + SkPicturePlayback* playback = SkPicturePlayback::CreateFromBuffer(buffer, info); |
| if (NULL == playback) { |
| - SkDELETE(newPict); |
| return NULL; |
| } |
| - newPict->fPlayback = playback; |
| + |
| + return SkNEW_ARGS(SkPicture, (playback, info.fWidth, info.fHeight)); |
| } |
| - return newPict; |
| + return NULL; |
| } |
| void SkPicture::createHeader(SkPictInfo* info) const { |
| @@ -474,32 +429,6 @@ void SkPicture::WriteTagSize(SkWStream* stream, uint32_t tag, size_t size) { |
| stream->write32(SkToU32(size)); |
| } |
| -bool SkPicture::parseBufferTag(SkReadBuffer& buffer, |
| - uint32_t tag, |
| - uint32_t size) { |
| - switch (tag) { |
| - case SK_PICT_PATH_BUFFER_TAG: |
| - if (size > 0) { |
| - fPathHeap.reset(SkNEW_ARGS(SkPathHeap, (buffer))); |
| - } |
| - break; |
| - default: |
| - // The tag was invalid. |
| - return false; |
| - } |
| - |
| - return true; // success |
| -} |
| - |
| -void SkPicture::flattenToBuffer(SkWriteBuffer& buffer) const { |
| - int n; |
| - |
| - if ((n = SafeCount(fPathHeap.get())) > 0) { |
| - WriteTagSize(buffer, SK_PICT_PATH_BUFFER_TAG, n); |
| - fPathHeap->flatten(buffer); |
| - } |
| -} |
| - |
| void SkPicture::flatten(SkWriteBuffer& buffer) const { |
| SkPicturePlayback* playback = fPlayback; |