Chromium Code Reviews| Index: include/gpu/GrTypes.h |
| diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h |
| index dbcb9a6583321d715a437a9982c7da7b5521066e..ed017c019316eaff059c3f8f636ba0cf1dc04807 100644 |
| --- a/include/gpu/GrTypes.h |
| +++ b/include/gpu/GrTypes.h |
| @@ -409,6 +409,61 @@ enum GrSurfaceFlags { |
| GR_MAKE_BITFIELD_OPS(GrSurfaceFlags) |
| +// opaque type for 3D API object handles |
| +typedef intptr_t GrBackendObject; |
| + |
| +/** |
| + * An container of function pointers which consumers of Skia can fill in and |
| + * pass to Skia. Skia will use these function pointers in place of its backend |
| + * API texture creation function. Either all of the function pointers should be |
| + * filled in, or they should all be nullptr. |
| + */ |
| +struct GrTextureStorageAllocator { |
| + GrTextureStorageAllocator() |
| + : fAllocateTextureStorage(nullptr) |
| + , fDeallocateTextureStorage(nullptr) { |
| + } |
| + |
| + enum class Result { |
| + kSucceededAndUploaded, |
| + kSucceededWithoutUpload, |
| + kFailed |
| + }; |
| + typedef Result (*AllocateTextureStorageProc)( |
| + void* ctx, GrBackendObject texture, unsigned width, |
| + unsigned height, GrPixelConfig config, const void* srcData); |
| + typedef void (*DeallocateTextureStorageProc)(void* ctx, GrBackendObject texture); |
| + |
| + /* |
| + * 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 |
|
bsalomon
2016/02/01 14:54:42
In OpenGL, ...
erikchen
2016/02/01 22:58:32
Done.
|
| + * WRAP_S and WRAP_T must be GL_CLAMP_TO_EDGE. |
| + * |
| + * If |srcData| is not nullptr, then the implementation of this function |
|
bsalomon
2016/02/01 14:54:42
I think we need an origin param as well. Also, may
erikchen
2016/02/01 22:58:32
Done and done.
|
| + * should attempt to upload the data into the texture. On successful upload, |
| + * or if |srcData| is nullptr, returns kSucceededAndUploaded. |
| + */ |
| + AllocateTextureStorageProc fAllocateTextureStorage; |
| + |
| + /* |
| + * 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. |
| + */ |
| + DeallocateTextureStorageProc fDeallocateTextureStorage; |
| + |
| + /* |
| + * The context to use when invoking fAllocateTextureStorage and |
| + * fDeallocateTextureStorage. |
| + */ |
| + void* fCtx; |
| +}; |
| + |
| /** |
| * 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 |
| @@ -454,6 +509,13 @@ struct GrSurfaceDesc { |
| * max supported count. |
| */ |
| int fSampleCnt; |
| + |
| + /** |
| + * A custom platform-specific allocator to use in place of TexImage2D. All |
|
bsalomon
2016/02/01 14:54:42
...in place of the backend APIs usual texture crea
erikchen
2016/02/01 22:58:32
Done.
|
| + * surfaces derived from the original surface will have the same value for |
|
bsalomon
2016/02/01 14:54:42
What exactly is meant here by surfaces derived fro
erikchen
2016/02/01 22:58:32
I was referring to RenderTargets created by copy-o
|
| + * fTextureStorageAllocator. |
| + */ |
| + GrTextureStorageAllocator fTextureStorageAllocator; |
| }; |
| // Legacy alias |
| @@ -469,9 +531,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 { |