diff options
author | 2014-11-12 10:24:55 -0800 | |
---|---|---|
committer | 2014-11-12 10:24:55 -0800 | |
commit | 71a236370792416b367a7d2d6b8e471b06b331cd (patch) | |
tree | cffb97b06bce0279e7f4b62802c7559a7237a206 /src/core/SkPictureData.cpp | |
parent | 391e318b3d31669ecef5306cb279618c121e45af (diff) |
More cleanup: streamline paths and bitmaps.
SkBitmapHeap is still used---now exclusively---by pipe.
BUG=skia:
Review URL: https://codereview.chromium.org/715413002
Diffstat (limited to 'src/core/SkPictureData.cpp')
-rw-r--r-- | src/core/SkPictureData.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp index 556e2a5d90..29e4415cfa 100644 --- a/src/core/SkPictureData.cpp +++ b/src/core/SkPictureData.cpp @@ -30,10 +30,8 @@ SkPictureData::SkPictureData(const SkPictInfo& info) void SkPictureData::initForPlayback() const { // ensure that the paths bounds are pre-computed - if (fPathHeap.get()) { - for (int i = 0; i < fPathHeap->count(); i++) { - (*fPathHeap.get())[i].updateBoundsCache(); - } + for (int i = 0; i < fPaths->count(); i++) { + (*fPaths)[i].updateBoundsCache(); } } @@ -48,11 +46,9 @@ SkPictureData::SkPictureData(const SkPictureRecord& record, fContentInfo.set(record.fContentInfo); - fBitmaps = record.fBitmapHeap->extractBitmaps(); - fPaints = SkTRefArray<SkPaint>::Create(record.fPaints.begin(), record.fPaints.count()); - - fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap)); - fPathHeap.reset(SkSafeRef(record.pathHeap())); + fBitmaps = SkTRefArray<SkBitmap>::Create(record.fBitmaps.begin(), record.fBitmaps.count()); + fPaints = SkTRefArray<SkPaint> ::Create(record.fPaints .begin(), record.fPaints .count()); + fPaths = SkTRefArray<SkPath> ::Create(record.fPaths .begin(), record.fPaths .count()); this->initForPlayback(); @@ -80,6 +76,7 @@ SkPictureData::SkPictureData(const SkPictureRecord& record, void SkPictureData::init() { fBitmaps = NULL; fPaints = NULL; + fPaths = NULL; fPictureRefs = NULL; fPictureCount = 0; fTextBlobRefs = NULL; @@ -93,6 +90,7 @@ SkPictureData::~SkPictureData() { SkSafeUnref(fBitmaps); SkSafeUnref(fPaints); + SkSafeUnref(fPaths); for (int i = 0; i < fPictureCount; i++) { fPictureRefs[i]->unref(); @@ -210,9 +208,12 @@ void SkPictureData::flattenToBuffer(SkWriteBuffer& buffer) const { } } - if ((n = SafeCount(fPathHeap.get())) > 0) { + if ((n = SafeCount(fPaths)) > 0) { write_tag_size(buffer, SK_PICT_PATH_BUFFER_TAG, n); - fPathHeap->flatten(buffer); + buffer.writeInt(n); + for (int i = 0; i < n; i++) { + buffer.writePath((*fPaths)[i]); + } } if (fTextBlobCount > 0) { @@ -441,9 +442,12 @@ bool SkPictureData::parseBufferTag(SkReadBuffer& buffer, } break; case SK_PICT_PATH_BUFFER_TAG: if (size > 0) { - fPathHeap.reset(SkNEW_ARGS(SkPathHeap, (buffer))); - } - break; + const int count = buffer.readInt(); + fPaths = SkTRefArray<SkPath>::Create(count); + for (int i = 0; i < count; i++) { + buffer.readPath(&fPaths->writableAt(i)); + } + } break; case SK_PICT_TEXTBLOB_BUFFER_TAG: { if (!buffer.validate((0 == fTextBlobCount) && (NULL == fTextBlobRefs))) { return false; |