Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1858)

Unified Diff: src/core/SkPictureRecord.cpp

Issue 715413002: More cleanup: streamline paths and bitmaps. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureRecord.cpp
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 00c51ac3051c873e3ab453fa52d34d6c485e4188..af1b8ffbc2134d0aa937c49429f61163e550d806 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -31,16 +31,12 @@ static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect
SkPictureRecord::SkPictureRecord(const SkISize& dimensions, uint32_t flags)
: INHERITED(dimensions.width(), dimensions.height())
- , fRecordFlags(flags) {
-
- fBitmapHeap = SkNEW(SkBitmapHeap);
-
- fFirstSavedLayerIndex = kNoSavedLayerIndex;
- fInitialSaveCount = kNoInitialSave;
+ , fFirstSavedLayerIndex(kNoSavedLayerIndex)
+ , fRecordFlags(flags)
+ , fInitialSaveCount(kNoInitialSave) {
}
SkPictureRecord::~SkPictureRecord() {
- SkSafeUnref(fBitmapHeap);
fPictureRefs.unrefAll();
fTextBlobRefs.unrefAll();
}
@@ -905,13 +901,16 @@ SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfac
}
int SkPictureRecord::addBitmap(const SkBitmap& bitmap) {
- const int index = fBitmapHeap->insert(bitmap);
- // In debug builds, a bad return value from insert() will crash, allowing for debugging. In
- // release builds, the invalid value will be recorded so that the reader will know that there
- // was a problem.
- SkASSERT(index != SkBitmapHeap::INVALID_SLOT);
- this->addInt(index);
- return index;
+ if (bitmap.isImmutable()) {
+ fBitmaps.push_back(bitmap);
+ } else {
+ SkBitmap copy;
+ bitmap.copyTo(&copy);
+ copy.setImmutable();
+ fBitmaps.push_back(copy);
+ }
+ this->addInt(fBitmaps.count()-1); // Unlike the rest, bitmap indicies are 0-based.
+ return fBitmaps.count();
}
void SkPictureRecord::addMatrix(const SkMatrix& matrix) {
@@ -930,14 +929,8 @@ void SkPictureRecord::addPaintPtr(const SkPaint* paint) {
}
int SkPictureRecord::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
+ fPaths.push_back(path);
+ return fPaths.count();
}
void SkPictureRecord::addPath(const SkPath& path) {
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698