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

Unified Diff: src/image/SkSurface_Raster.cpp

Issue 351373005: add SkSurface::NewRasterDirectReleaseProc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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/SkSurface.h ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkSurface_Raster.cpp
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index 0b6efe19fe67b23870dd6596bbd808bd261173e3..986994ab8f83afc46d780752e86756ea0a587d36 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -17,7 +17,8 @@ class SkSurface_Raster : public SkSurface_Base {
public:
static bool Valid(const SkImageInfo&, size_t rb = kIgnoreRowBytesValue);
- SkSurface_Raster(const SkImageInfo&, void*, size_t rb);
+ SkSurface_Raster(const SkImageInfo&, void*, size_t rb,
+ void (*releaseProc)(void* pixels, void* context), void* context);
SkSurface_Raster(SkPixelRef*);
virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
@@ -76,10 +77,11 @@ bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) {
return true;
}
-SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t rb)
+SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t rb,
+ void (*releaseProc)(void* pixels, void* context), void* context)
: INHERITED(info)
{
- fBitmap.installPixels(info, pixels, rb);
+ fBitmap.installPixels(info, pixels, rb, NULL, releaseProc, context);
fWeOwnThePixels = false; // We are "Direct"
}
@@ -136,15 +138,24 @@ void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) {
///////////////////////////////////////////////////////////////////////////////
-SkSurface* SkSurface::NewRasterDirect(const SkImageInfo& info, void* pixels, size_t rowBytes) {
- if (!SkSurface_Raster::Valid(info, rowBytes)) {
+SkSurface* SkSurface::NewRasterDirectReleaseProc(const SkImageInfo& info, void* pixels, size_t rb,
+ void (*releaseProc)(void* pixels, void* context),
+ void* context) {
+ if (NULL == releaseProc) {
+ context = NULL;
+ }
+ if (!SkSurface_Raster::Valid(info, rb)) {
return NULL;
}
if (NULL == pixels) {
return NULL;
}
+
+ return SkNEW_ARGS(SkSurface_Raster, (info, pixels, rb, releaseProc, context));
+}
- return SkNEW_ARGS(SkSurface_Raster, (info, pixels, rowBytes));
+SkSurface* SkSurface::NewRasterDirect(const SkImageInfo& info, void* pixels, size_t rowBytes) {
+ return NewRasterDirectReleaseProc(info, pixels, rowBytes, NULL, NULL);
}
SkSurface* SkSurface::NewRaster(const SkImageInfo& info) {
« no previous file with comments | « include/core/SkSurface.h ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698