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

Unified Diff: include/core/SkImage.h

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. 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 | include/core/SkImageInfo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkImage.h
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index e2757b9af5cad8d2e2ac1cdf3173a2aeb31a1578..9d1c546ef5158eed0ae0794c9d1c5de70b22e1d1 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -44,10 +44,23 @@ public:
SK_DECLARE_INST_COUNT(SkImage)
typedef SkImageInfo Info;
+ typedef void* ReleaseContext;
static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowBytes);
static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes);
+ typedef void (*RasterReleaseProc)(const void* pixels, ReleaseContext);
+
+ /**
+ * Return a new Image referencing the specified pixels. These must remain valid and unchanged
+ * until the specified release-proc is called, indicating that Skia no longer has a reference
+ * to the pixels.
+ *
+ * Returns NULL if the requested Info is unsupported.
+ */
+ static SkImage* NewFromRaster(const Info&, const void* pixels, size_t rowBytes,
+ RasterReleaseProc, ReleaseContext);
+
/**
* Construct a new SkImage based on the given ImageGenerator.
* This function will always take ownership of the passed
@@ -70,8 +83,25 @@ public:
*
* Will return NULL if the specified descriptor is unsupported.
*/
- static SkImage* NewFromTexture(GrContext*, const GrBackendTextureDesc&,
- SkAlphaType = kPremul_SkAlphaType);
+ static SkImage* NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc) {
+ return NewFromTexture(ctx, desc, kPremul_SkAlphaType, NULL, NULL);
+ }
+
+ static SkImage* NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& de, SkAlphaType at) {
+ return NewFromTexture(ctx, de, at, NULL, NULL);
+ }
+
+ typedef void (*TextureReleaseProc)(ReleaseContext);
+
+ /**
+ * Create a new image from the specified descriptor. The underlying platform texture must stay
+ * valid and unaltered until the specified release-proc is invoked, indicating that Skia
+ * nolonger is holding a reference to it.
+ *
+ * Will return NULL if the specified descriptor is unsupported.
+ */
+ static SkImage* NewFromTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType,
+ TextureReleaseProc, ReleaseContext);
/**
* Create a new image from the specified descriptor. Note - Skia will delete or recycle the
« no previous file with comments | « no previous file | include/core/SkImageInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698