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

Unified Diff: src/ports/SkImageDecoder_CG.cpp

Issue 1604963002: SkStream/Priv cleanups (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update header description Created 4 years, 11 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
« no previous file with comments | « src/images/SkImageDecoder_pkm.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkImageDecoder_CG.cpp
diff --git a/src/ports/SkImageDecoder_CG.cpp b/src/ports/SkImageDecoder_CG.cpp
index 4be58742537341affaf83155143dfa38f46ac159..2deaf21d76cad5006cc556b6cedded38701a7b97 100644
--- a/src/ports/SkImageDecoder_CG.cpp
+++ b/src/ports/SkImageDecoder_CG.cpp
@@ -10,6 +10,7 @@
#include "SkCGUtils.h"
#include "SkColorPriv.h"
+#include "SkData.h"
#include "SkImageDecoder.h"
#include "SkImageEncoder.h"
#include "SkMovie.h"
@@ -28,17 +29,19 @@
#include <MobileCoreServices/MobileCoreServices.h>
#endif
-static void malloc_release_proc(void* info, const void* data, size_t size) {
- sk_free(info);
+static void data_unref_proc(void* skdata, const void*, size_t) {
+ SkASSERT(skdata);
+ static_cast<SkData*>(skdata)->unref();
}
static CGDataProviderRef SkStreamToDataProvider(SkStream* stream) {
// TODO: use callbacks, so we don't have to load all the data into RAM
- SkAutoMalloc storage;
- const size_t len = SkCopyStreamToStorage(&storage, stream);
- void* data = storage.detach();
+ SkData* skdata = SkCopyStreamToData(stream);
+ if (!skdata) {
+ return nullptr;
+ }
- return CGDataProviderCreateWithData(data, data, len, malloc_release_proc);
+ return CGDataProviderCreateWithData(skdata, skdata->data(), skdata->size(), data_unref_proc);
}
static CGImageSourceRef SkStreamToCGImageSource(SkStream* stream) {
« no previous file with comments | « src/images/SkImageDecoder_pkm.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698