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

Unified Diff: include/core/SkData.h

Issue 1193553002: simplify release-proc for SkData, removing unneeded size param (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | src/core/SkData.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkData.h
diff --git a/include/core/SkData.h b/include/core/SkData.h
index 0e4a474e124f443356716314f97871729c1b54ee..8a37cdee0741edf74751484fff99fde8c92bb40c 100644
--- a/include/core/SkData.h
+++ b/include/core/SkData.h
@@ -71,9 +71,9 @@ public:
/**
* Function that, if provided, will be called when the SkData goes out
- * of scope, allowing for custom allocation/freeing of the data.
+ * of scope, allowing for custom allocation/freeing of the data's contents.
*/
- typedef void (*ReleaseProc)(const void* ptr, size_t length, void* context);
+ typedef void (*ReleaseProc)(const void* ptr, void* context);
/**
* Create a new dataref by copying the specified data
@@ -95,17 +95,24 @@ public:
static SkData* NewWithCString(const char cstr[]);
/**
- * Create a new dataref, taking the data ptr as is, and using the
+ * Create a new dataref, taking the ptr as is, and using the
* releaseproc to free it. The proc may be NULL.
*/
- static SkData* NewWithProc(const void* data, size_t length, ReleaseProc proc, void* context);
+ static SkData* NewWithProc(const void* ptr, size_t length, ReleaseProc proc, void* context);
+
+#ifdef SK_SUPPORT_LEGACY_DATARELEASEPROC_PARAMS
+ // This variant is temporary.
+ // Its signature is meant to match an older version of the API
+ typedef void (*LegacyReleaseProc)(const void* ptr, size_t size, void* ctx);
+ static SkData* NewWithProc(const void* ptr, size_t length, LegacyReleaseProc proc, void* ctx);
+#endif
/**
* Call this when the data parameter is already const and will outlive the lifetime of the
* SkData. Suitable for with const globals.
*/
static SkData* NewWithoutCopy(const void* data, size_t length) {
- return NewWithProc(data, length, NULL, NULL);
+ return NewWithProc(data, length, DummyReleaseProc, NULL);
}
/**
@@ -160,11 +167,18 @@ public:
private:
ReleaseProc fReleaseProc;
void* fReleaseProcContext;
+#ifdef SK_SUPPORT_LEGACY_DATARELEASEPROC_PARAMS
+ LegacyReleaseProc fLegacyReleaseProc;
+#endif
void* fPtr;
size_t fSize;
+#ifdef SK_SUPPORT_LEGACY_DATARELEASEPROC_PARAMS
+ SkData(const void* ptr, size_t size, ReleaseProc, void* context, LegacyReleaseProc = NULL);
+#else
SkData(const void* ptr, size_t size, ReleaseProc, void* context);
+#endif
SkData(size_t size); // inplace new/delete
virtual ~SkData();
@@ -183,6 +197,8 @@ private:
// shared internal factory
static SkData* PrivateNewWithCopy(const void* srcOrNull, size_t length);
+ static void DummyReleaseProc(const void*, void*) {}
+
typedef SkRefCnt INHERITED;
};
« no previous file with comments | « no previous file | src/core/SkData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698