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

Unified Diff: src/core/SkPicturePlayback.cpp

Issue 155863005: Adding release method to SkWriter32 and using it to not copy the ops data from SkPictureRecord to S… (Closed) Base URL: https://skia.googlesource.com/skia.git@array_growth
Patch Set: Created 6 years, 10 months 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
Index: src/core/SkPicturePlayback.cpp
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index e71a17fda51095ec44fa49d4e4aa6f81b2493b0b..bedc733f8c7c4ca47bbc4693bbeca8fdf2ea2df3 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -28,7 +28,7 @@ SkPicturePlayback::SkPicturePlayback() {
this->init();
}
-SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record, bool deepCopy) {
+SkPicturePlayback::SkPicturePlayback(SkPictureRecord& record, bool deepCopy) {
#ifdef SK_DEBUG_SIZE
size_t overallBytes, bitmapBytes, matricesBytes,
paintBytes, pathBytes, pictureBytes, regionBytes;
@@ -67,7 +67,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record, bool deepCop
#endif
record.validate(record.writeStream().bytesWritten(), 0);
- const SkWriter32& writer = record.writeStream();
+ SkWriter32& writer = record.writeStream();
init();
if (writer.bytesWritten() == 0) {
fOpData = SkData::NewEmpty();
@@ -85,11 +85,8 @@ SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record, bool deepCop
}
{
- size_t size = writer.bytesWritten();
- void* buffer = sk_malloc_throw(size);
- writer.flatten(buffer);
SkASSERT(!fOpData);
- fOpData = SkData::NewFromMalloc(buffer, size);
+ fOpData = writer.release();
}
// copy over the refcnt dictionary to our reader

Powered by Google App Engine
This is Rietveld 408576698