Index: include/gpu/GrTypes.h |
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h |
index dbcb9a6583321d715a437a9982c7da7b5521066e..23abad8be077fefb7330c88a280e9b941bf458f6 100644 |
--- a/include/gpu/GrTypes.h |
+++ b/include/gpu/GrTypes.h |
@@ -409,6 +409,37 @@ enum GrSurfaceFlags { |
GR_MAKE_BITFIELD_OPS(GrSurfaceFlags) |
+// opaque type for 3D API object handles |
+typedef intptr_t GrBackendObject; |
+ |
+/** |
+ * An abstract base class which consumers of Skia can subclass and pass to Skia |
+ * to use custom storage allocation in place of TexImage2D. |
bsalomon
2016/01/26 22:20:54
Maybe say "in place of backend API texture creatio
erikchen
2016/01/27 21:55:14
Done.
|
+ */ |
+class TextureStorageAllocator { |
bsalomon
2016/01/26 22:20:54
Should be GrTextureStorageAllocator
erikchen
2016/01/27 21:55:15
Done.
|
+ public: |
+ /* |
bsalomon
2016/01/26 22:20:54
nit, we use four space indents.
erikchen
2016/01/27 21:55:14
Done.
|
+ * The required bind target for any texture with custom storage. |
+ */ |
+ virtual unsigned textureStorageTarget() = 0; |
+ /* |
+ * Generates and binds a texture to |textureStorageTarget()|. Allocates |
+ * storage for the texture. |
+ * |
+ * The MIN and MAX filters for the created texture must be GL_LINEAR. The |
+ * WRAP_S and WRAP_T must be GL_CLAMP_TO_EDGE. |
+ */ |
+ virtual bool allocateTextureStorage(GrBackendObject texture, unsigned width, |
bsalomon
2016/01/26 22:20:54
Don't we also need to somehow tell the allocator t
erikchen
2016/01/27 21:55:14
CHROMIUM_image on Mac supports very few pixel form
|
+ unsigned height) = 0; |
+ /* |
+ * Deallocate the storage for the given texture. |
+ */ |
+ virtual void deallocateTextureStorage(GrBackendObject texture) = 0; |
bsalomon
2016/01/26 22:20:54
We have a method on GrContext called abandonContex
erikchen
2016/01/27 21:55:15
The consumer of Skia will be responsible for destr
|
+ |
+ protected: |
+ ~TextureStorageAllocator() {} |
bsalomon
2016/01/26 22:20:54
Who deletes the allocator, Skia? Should this be vi
erikchen
2016/01/27 21:55:14
Skia does not delete the allocator, but this shoul
|
+}; |
+ |
/** |
* Some textures will be stored such that the upper and left edges of the content meet at the |
* the origin (in texture coord space) and for other textures the lower and left edges meet at |
@@ -432,7 +463,8 @@ struct GrSurfaceDesc { |
, fWidth(0) |
, fHeight(0) |
, fConfig(kUnknown_GrPixelConfig) |
- , fSampleCnt(0) { |
+ , fSampleCnt(0) |
+ , fTextureStorageAllocator(nullptr) { |
} |
GrSurfaceFlags fFlags; //!< bitfield of TextureFlags |
@@ -454,6 +486,13 @@ struct GrSurfaceDesc { |
* max supported count. |
*/ |
int fSampleCnt; |
+ |
+ /** |
+ * A custom platform-specific allocator to use in place of TexImage2D. All |
+ * surfaces derived from the original surface will have the same value for |
+ * fTextureStorageAllocator. |
+ */ |
+ TextureStorageAllocator* fTextureStorageAllocator; |
}; |
// Legacy alias |
@@ -469,9 +508,6 @@ enum GrClipType { |
/////////////////////////////////////////////////////////////////////////////// |
-// opaque type for 3D API object handles |
-typedef intptr_t GrBackendObject; |
- |
/** Ownership rules for external GPU resources imported into Skia. */ |
enum GrWrapOwnership { |