add callbacks to Images that wrap client-provided content
BUG=skia:
Review URL: https://codereview.chromium.org/1169553003
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 281f762..973f4ba 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -115,7 +115,9 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
static SkImage* new_wrapped_texture_common(GrContext* ctx, const GrBackendTextureDesc& desc,
- SkAlphaType at, GrWrapOwnership ownership) {
+ SkAlphaType at, GrWrapOwnership ownership,
+ SkImage::TextureReleaseProc releaseProc,
+ SkImage::ReleaseContext releaseCtx) {
if (desc.fWidth <= 0 || desc.fHeight <= 0) {
return NULL;
}
@@ -123,18 +125,23 @@
if (!tex) {
return NULL;
}
+ if (releaseProc) {
+ tex->setRelease(releaseProc, releaseCtx);
+ }
+
const SkSurface::Budgeted budgeted = SkSurface::kNo_Budgeted;
return SkNEW_ARGS(SkImage_Gpu, (desc.fWidth, desc.fHeight, at, tex, 0, budgeted));
}
-SkImage* SkImage::NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc, SkAlphaType at) {
- return new_wrapped_texture_common(ctx, desc, at, kBorrow_GrWrapOwnership);
+SkImage* SkImage::NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc, SkAlphaType at,
+ TextureReleaseProc releaseP, ReleaseContext releaseC) {
+ return new_wrapped_texture_common(ctx, desc, at, kBorrow_GrWrapOwnership, releaseP, releaseC);
}
SkImage* SkImage::NewFromAdoptedTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
SkAlphaType at) {
- return new_wrapped_texture_common(ctx, desc, at, kAdopt_GrWrapOwnership);
+ return new_wrapped_texture_common(ctx, desc, at, kAdopt_GrWrapOwnership, NULL, NULL);
}
SkImage* SkImage::NewFromTextureCopy(GrContext* ctx, const GrBackendTextureDesc& srcDesc,