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

Unified Diff: src/core/SkData.cpp

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 | « include/core/SkData.h ('k') | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkData.cpp
diff --git a/src/core/SkData.cpp b/src/core/SkData.cpp
index ad79ce05350064b128a4e210f7b4ef135ee896af..09d7a5de98d8d4bbacbe9a4677a7ce59cb229d09 100644
--- a/src/core/SkData.cpp
+++ b/src/core/SkData.cpp
@@ -12,11 +12,19 @@
#include "SkStream.h"
#include "SkWriteBuffer.h"
+#ifdef SK_SUPPORT_LEGACY_DATARELEASEPROC_PARAMS
+SkData::SkData(const void* ptr, size_t size, ReleaseProc proc, void* context,
+ LegacyReleaseProc legacyProc) {
+#else
SkData::SkData(const void* ptr, size_t size, ReleaseProc proc, void* context) {
+#endif
fPtr = const_cast<void*>(ptr);
fSize = size;
fReleaseProc = proc;
fReleaseProcContext = context;
+#ifdef SK_SUPPORT_LEGACY_DATARELEASEPROC_PARAMS
+ fLegacyReleaseProc = legacyProc;
+#endif
}
// This constructor means we are inline with our fPtr's contents. Thus we set fPtr
@@ -28,12 +36,20 @@ SkData::SkData(size_t size) {
fSize = size;
fReleaseProc = NULL;
fReleaseProcContext = NULL;
+#ifdef SK_SUPPORT_LEGACY_DATARELEASEPROC_PARAMS
+ fLegacyReleaseProc = NULL;
+#endif
}
SkData::~SkData() {
if (fReleaseProc) {
- fReleaseProc(fPtr, fSize, fReleaseProcContext);
+ fReleaseProc(fPtr, fReleaseProcContext);
}
+#ifdef SK_SUPPORT_LEGACY_DATARELEASEPROC_PARAMS
+ if (fLegacyReleaseProc) {
+ fLegacyReleaseProc(fPtr, fSize, fReleaseProcContext);
+ }
+#endif
}
bool SkData::equals(const SkData* other) const {
@@ -91,7 +107,7 @@ SkData* SkData::NewEmpty() {
}
// assumes fPtr was allocated via sk_malloc
-static void sk_free_releaseproc(const void* ptr, size_t, void*) {
+static void sk_free_releaseproc(const void* ptr, void*) {
sk_free((void*)ptr);
}
@@ -108,13 +124,19 @@ SkData* SkData::NewUninitialized(size_t length) {
return PrivateNewWithCopy(NULL, length);
}
-SkData* SkData::NewWithProc(const void* data, size_t length,
- ReleaseProc proc, void* context) {
- return new SkData(data, length, proc, context);
+SkData* SkData::NewWithProc(const void* ptr, size_t length, ReleaseProc proc, void* context) {
+ return new SkData(ptr, length, proc, context);
+}
+
+#ifdef SK_SUPPORT_LEGACY_DATARELEASEPROC_PARAMS
+SkData* SkData::NewWithProc(const void* ptr, size_t length, LegacyReleaseProc proc, void* ctx) {
+ return new SkData(ptr, length, NULL, ctx, proc);
}
+#endif
// assumes fPtr was allocated with sk_fmmap
-static void sk_mmap_releaseproc(const void* addr, size_t length, void*) {
+static void sk_mmap_releaseproc(const void* addr, void* ctx) {
+ size_t length = reinterpret_cast<size_t>(ctx);
sk_fmunmap(addr, length);
}
@@ -125,7 +147,7 @@ SkData* SkData::NewFromFILE(SkFILE* f) {
return NULL;
}
- return SkData::NewWithProc(addr, size, sk_mmap_releaseproc, NULL);
+ return SkData::NewWithProc(addr, size, sk_mmap_releaseproc, reinterpret_cast<void*>(size));
}
SkData* SkData::NewFromFileName(const char path[]) {
@@ -149,7 +171,7 @@ SkData* SkData::NewFromFD(int fd) {
}
// assumes context is a SkData
-static void sk_dataref_releaseproc(const void*, size_t, void* context) {
+static void sk_dataref_releaseproc(const void*, void* context) {
SkData* src = reinterpret_cast<SkData*>(context);
src->unref();
}
« no previous file with comments | « include/core/SkData.h ('k') | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698