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

Unified Diff: src/core/SkRecorder.cpp

Issue 746553002: SkData -> SkPicture::SnapshotArray (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ctor 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/SkRecorder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRecorder.cpp
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index 33d89d90794c26ca2bdfc78ad8d4c72e47651205..3fbe1c95c685830fcd2c48f4047a6021ec14856a 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -5,7 +5,6 @@
* found in the LICENSE file.
*/
-#include "SkData.h"
#include "SkRecorder.h"
#include "SkPatchUtils.h"
#include "SkPicture.h"
@@ -30,42 +29,17 @@ void SkRecorder::forgetRecord() {
fRecord = NULL;
}
-// ReleaseProc for SkData, assuming the data was allocated via sk_malloc, and its contents are an
-// array of SkPicture* which need to be unref'd.
-//
-static void unref_all_malloc_releaseProc(const void* ptr, size_t length, void* context) {
- SkASSERT(ptr == context); // our context is our ptr, allocated via sk_malloc
- int count = SkToInt(length / sizeof(SkPicture*));
- SkASSERT(count * sizeof(SkPicture*) == length); // our length is snug for the array
-
- SkPicture* const* array = reinterpret_cast<SkPicture* const*>(ptr);
- for (int i = 0; i < count; ++i) {
- SkSafeUnref(array[i]);
- }
- sk_free(context);
-}
-
-// Return an uninitialized SkData sized for "count" SkPicture pointers. They will be unref'd when
-// the SkData is destroyed.
-//
-static SkData* new_uninitialized_picture_ptrs(int count) {
- size_t length = count * sizeof(SkPicture*);
- void* array = sk_malloc_throw(length);
- void* context = array;
- return SkData::NewWithProc(array, length, unref_all_malloc_releaseProc, context);
-}
-
-SkData* SkRecorder::newDrawableSnapshot(SkBBHFactory* factory, uint32_t recordFlags) {
+SkPicture::SnapshotArray* SkRecorder::newDrawableSnapshot(SkBBHFactory* factory,
+ uint32_t recordFlags) {
const int count = fDrawableList.count();
if (0 == count) {
return NULL;
}
- SkData* data = new_uninitialized_picture_ptrs(count);
- SkPicture** pics = reinterpret_cast<SkPicture**>(data->writable_data());
+ SkAutoTMalloc<const SkPicture*> pics(count);
for (int i = 0; i < count; ++i) {
pics[i] = fDrawableList[i]->newPictureSnapshot(factory, recordFlags);
}
- return data;
+ return SkNEW_ARGS(SkPicture::SnapshotArray, (pics.detach(), count));
}
// To make appending to fRecord a little less verbose.
« no previous file with comments | « src/core/SkRecorder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698