Chromium Code Reviews

Unified Diff: src/image/SkImage_Gpu.cpp

Issue 1169553003: add callbacks to Images that wrap client-provided content (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: privatize Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « src/image/SkImage.cpp ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage_Gpu.cpp
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 281f762dff37421c07a9cdfcf2b9a2f635807eea..973f4ba3041497ec60e89f325bcf4ecd1e2aee91 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -115,7 +115,9 @@ bool SkImage_Gpu::onReadPixels(const SkImageInfo& info, void* pixels, size_t row
///////////////////////////////////////////////////////////////////////////////////////////////////
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 @@ static SkImage* new_wrapped_texture_common(GrContext* ctx, const GrBackendTextur
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,
« no previous file with comments | « src/image/SkImage.cpp ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine