Chromium Code Reviews| Index: include/gpu/GrTypes.h |
| diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h |
| index dbcb9a6583321d715a437a9982c7da7b5521066e..c8f4ae377f645a965060f780084456eef9e0e67b 100644 |
| --- a/include/gpu/GrTypes.h |
| +++ b/include/gpu/GrTypes.h |
| @@ -409,6 +409,45 @@ 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. |
| + * Skia will use this object in place of its backend API texture creation |
| + * function. |
| + */ |
| +class GrTextureStorageAllocator { |
| +public: |
| + /* |
| + * Whether a texture can be created with the given pixel config. |
| + */ |
| + virtual bool supportsPixelConfig(GrPixelConfig config) = 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. |
| + * |
| + * The internal format must be GL_RGBA. |
|
bsalomon
2016/01/29 16:57:38
I'm not crazy about this restriction. I get that t
erikchen
2016/01/29 20:32:25
I added two more parameters: GrPixelConfig and a c
|
| + */ |
| + virtual bool allocateTextureStorage(GrBackendObject texture, unsigned width, |
| + unsigned height) = 0; |
| + /* |
| + * Deallocate the storage for the given texture. |
| + * |
| + * Skia does not always destroy its outstanding textures. See |
| + * GrContext::abandonContext() for more details. The consumer of Skia is |
| + * responsible for making sure that all textures are destroyed, even if this |
| + * callback is not invoked. |
| + */ |
| + virtual void deallocateTextureStorage(GrBackendObject texture) = 0; |
| + |
| +protected: |
| + virtual ~GrTextureStorageAllocator() {} |
| +}; |
| + |
| /** |
| * 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 +471,8 @@ struct GrSurfaceDesc { |
| , fWidth(0) |
| , fHeight(0) |
| , fConfig(kUnknown_GrPixelConfig) |
| - , fSampleCnt(0) { |
| + , fSampleCnt(0) |
| + , fTextureStorageAllocator(nullptr) { |
| } |
| GrSurfaceFlags fFlags; //!< bitfield of TextureFlags |
| @@ -454,6 +494,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. |
| + */ |
| + GrTextureStorageAllocator* fTextureStorageAllocator; |
| }; |
| // Legacy alias |
| @@ -469,9 +516,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 { |