Chromium Code Reviews| Index: include/gpu/GrTypes.h |
| diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h |
| index dbcb9a6583321d715a437a9982c7da7b5521066e..ffc5bf1e37a01a50bb8befbcd4a823c8251c7d72 100644 |
| --- a/include/gpu/GrTypes.h |
| +++ b/include/gpu/GrTypes.h |
| @@ -410,6 +410,30 @@ enum GrSurfaceFlags { |
| GR_MAKE_BITFIELD_OPS(GrSurfaceFlags) |
| /** |
| + * An abstract base class which consumers of Skia can subclass and pass to Skia |
| + * to use custom storage allocation in place of TexImage2D. |
| + */ |
| +class TextureStorageAllocator { |
| + public: |
| + /* |
| + * The required bind target for any texture with custom storage. |
| + */ |
| + virtual unsigned textureStorageTarget() = 0; |
| + /* |
| + * Allocates storage for the texture. |textureId| must already be bound to |
| + * |TextureTarget()|. |
| + */ |
| + virtual bool allocateTextureStorage(unsigned textureId, unsigned width, unsigned height) = 0; |
|
bsalomon
2016/01/25 20:51:09
What do you think about
virtual bool allocateText
erikchen
2016/01/26 18:36:16
I went with your suggested API for allocateTexture
|
| + /* |
| + * Deallocate the storage for the given texture. |
| + */ |
| + virtual void deallocateTextureStorage(unsigned textureId) = 0; |
| + |
| + protected: |
| + ~TextureStorageAllocator() {} |
| +}; |
| + |
| +/** |
| * 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 |
| * the origin. kDefault_GrSurfaceOrigin sets textures to TopLeft, and render targets |
| @@ -432,7 +456,8 @@ struct GrSurfaceDesc { |
| , fWidth(0) |
| , fHeight(0) |
| , fConfig(kUnknown_GrPixelConfig) |
| - , fSampleCnt(0) { |
| + , fSampleCnt(0) |
| + , fTextureStorageAllocator(nullptr) { |
| } |
| GrSurfaceFlags fFlags; //!< bitfield of TextureFlags |
| @@ -454,6 +479,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 |
| @@ -533,6 +565,10 @@ struct GrBackendTextureDesc { |
| * OpenGL: Texture ID. |
| */ |
| GrBackendObject fTextureHandle; |
| + /** |
| + * The custom allocator to use in place of TexImage2D. |
| + */ |
| + TextureStorageAllocator* fTextureStorageAllocator; |
|
bsalomon
2016/01/25 20:51:09
We shouldn't need this here. This is used to impor
erikchen
2016/01/26 18:36:16
Done.
|
| }; |
| /////////////////////////////////////////////////////////////////////////////// |