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

Unified Diff: src/utils/mac/SkStream_mac.cpp

Issue 849103004: Make SkStream *not* ref counted. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase, just in case. Created 5 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/utils/SkPDFRasterizer.cpp ('k') | src/utils/win/SkDWriteFontFileStream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/mac/SkStream_mac.cpp
diff --git a/src/utils/mac/SkStream_mac.cpp b/src/utils/mac/SkStream_mac.cpp
index 64d2dbb2cae1767d1195487601145e5cb6638ab9..26884711ed3976621c6beefe00291f63b94e19bd 100644
--- a/src/utils/mac/SkStream_mac.cpp
+++ b/src/utils/mac/SkStream_mac.cpp
@@ -8,13 +8,21 @@
#include "SkCGUtils.h"
#include "SkStream.h"
-// This is used by CGDataProviderCreateWithData
+// These are used by CGDataProviderCreateWithData
static void unref_proc(void* info, const void* addr, size_t size) {
SkASSERT(info);
((SkRefCnt*)info)->unref();
}
+static void delete_stream_proc(void* info, const void* addr, size_t size) {
+ SkASSERT(info);
+ SkStream* stream = (SkStream*)info;
+ SkASSERT(stream->getMemoryBase() == addr);
+ SkASSERT(stream->getLength() == size);
+ SkDELETE(stream);
+}
+
// These are used by CGDataProviderSequentialCallbacks
static size_t get_bytes_proc(void* info, void* buffer, size_t bytes) {
@@ -31,19 +39,20 @@ static void rewind_proc(void* info) {
((SkStream*)info)->rewind();
}
+// Used when info is an SkStream.
static void release_info_proc(void* info) {
SkASSERT(info);
- ((SkStream*)info)->unref();
+ SkDELETE((SkStream*)info);
}
CGDataProviderRef SkCreateDataProviderFromStream(SkStream* stream) {
- stream->ref(); // unref will be called when the provider is deleted
-
+ // TODO: Replace with SkStream::getData() when that is added. Then we only
+ // have one version of CGDataProviderCreateWithData (i.e. same release proc)
const void* addr = stream->getMemoryBase();
if (addr) {
// special-case when the stream is just a block of ram
return CGDataProviderCreateWithData(stream, addr, stream->getLength(),
- unref_proc);
+ delete_stream_proc);
}
CGDataProviderSequentialCallbacks rec;
« no previous file with comments | « src/utils/SkPDFRasterizer.cpp ('k') | src/utils/win/SkDWriteFontFileStream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698