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

Unified Diff: include/core/SkImage.h

Issue 1776693002: Add deferred texture upload API. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase on pixmap change Created 4 years, 9 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/SkPixmap.h » ('j') | src/image/SkImage_Gpu.cpp » ('J')
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 0474195ae2f1ad2d69bf9494f1111afff570eb7f..27b1a023f1ef97a665afc19db57dbf4a3a22dae3 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -25,6 +25,7 @@ class SkPixelSerializer;
class SkString;
class SkSurface;
class GrContext;
+class GrContextThreadSafeProxy;
class GrTexture;
/**
@@ -316,6 +317,46 @@ public:
*/
SkImage* newTextureImage(GrContext*) const;
+ /** Drawing params for which a deferred texture image data should be optimized. */
+ struct DeferredTextureImageUsageParams {
+ SkMatrix fViewMatrix;
reed1 2016/03/09 18:28:41 ViewMatrix is not really a term we use in the skia
bsalomon 2016/03/09 18:35:21 Sure, "CTM" or "CanvasMatrix" would work.
+ SkFilterQuality fQuality;
+ SkRect fSrcRect;
+ SkRect fDstRect;
+ };
+
+ /**
+ * This method allows clients to capture the data necessary to turn a SkImage into a texture-
+ * backed image. If the original image is codec-backed this will decode into a format optimized
+ * for the context represented by the proxy. This method is thread safe with respect to the
+ * GrContext whence the proxy came. Clients allocate and manage the storage of the deferred
+ * texture data and control its lifetime. No cleanup is required, thus it is safe to simply free
+ * the memory out from under the data.
+ *
robertphillips 2016/03/09 18:54:16 to for -> for ?
bsalomon 2016/03/10 15:30:07 Done.
+ * The same method is used to for both getting the size necessary for pre-uploaded texture data
+ * and to retrieve the data. The params array represents the set of draws over which to optimize
+ * the pre-upload data.
+ *
+ * When called with a null buffer this returns the size that the client must allocate in order
+ * to create deferred texture data for this image (or zero if this is an inappropriate
+ * candidate). The buffer allocated by the client should be 8 byte aligned.
+ *
+ * When buffer is not null this fills in the deferred texture data for this image in the
+ * provided buffer (assuming this is an appropriate candidate image and the buffer is
+ * appropriately aligned). Upon success the size written is returned, otherwise 0.
+ */
+ size_t getDeferredTextureImageData(const GrContextThreadSafeProxy&,
+ const DeferredTextureImageUsageParams[],
+ int paramCnt,
+ void* buffer) const;
+
+ /**
robertphillips 2016/03/09 18:54:16 produce -> produced ?
bsalomon 2016/03/10 15:30:07 Done.
+ * Returns a texture-backed image from data produce in SkImage::getDeferredTextureImageData.
+ * The context must be the context that provided the proxy passed to
+ * getDeferredTextureImageData.
+ */
+ static SkImage* NewFromDeferredTextureImageData(GrContext*, const void*, SkBudgeted);
+
// Helper functions to convert to SkBitmap
enum LegacyBitmapMode {
« no previous file with comments | « no previous file | include/core/SkPixmap.h » ('j') | src/image/SkImage_Gpu.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698