diff options
author | ericrk <ericrk@chromium.org> | 2016-02-24 14:49:51 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-24 14:49:52 -0800 |
commit | f7b8b8affec91fcfab0d79199e466c16c254fe56 (patch) | |
tree | 295ca66ae496d202d9005b40f08b1832ad476068 /include/core | |
parent | 0cc2f85a19d50b45573d71d8c9d6ee1292c9fd3a (diff) |
Add wrapBackendTextureAsRenderTarget API
Skia's GrTextureProvider currently exposes two APIs for wrapping backend
objects:
* wrapBackendTexture - wraps a texture into a GrTexture. Depending on
flags, this GrTexture can be converted to a GrRenderTarget. Skia
manages the render target objects it may create to provide a render
target for the texture. This allows Skia to create stencil buffers
if needed and manager MSAA resolves.
* wrapBackendRenderTarget - wraps a FBO into a GrRenderTarget. This
object cannot be converted to a GrTexture. Skia does not manage
the render target objects for such a GrRenderTarget, and as such
cannot attach stencil buffers or perform MSAA resolves on the
created GrRenderTarget.
Given these two options, wrapBackendTexture provides more versatility
and allows Skia more room for optimization. Chrome currently uses
wrapBackendTexture for this reason.
While these two functions cover most cases, they do not provide a way
for Skia to wrap a texture into a render target (and gain the MSAA and
stencil buffer management), without also creating a GrTexture. This is
problematic in cases where a texture can be bound to a render target,
but cannot be textured from, as is the case in Chrome's limited support
for GL_TEXTURE_RECTANGLE.
To address this, a new function is created:
* wrapBackendTextureAsRenderTarget - wraps a texture into a
GrRenderTarget. As with wrapBackendTexture, the created render
target objects are fully managed by Skia. Unlike wrapBackendTexture
no GrTexture is created, and the created object will never be
textured from.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1709163003
Review URL: https://codereview.chromium.org/1709163003
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkSurface.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h index d5a66b4bb7..975c80e3f0 100644 --- a/include/core/SkSurface.h +++ b/include/core/SkSurface.h @@ -108,7 +108,6 @@ public: return NewFromBackendTexture(ctx, desc, props); } - /** * Used to wrap a pre-existing 3D API rendering target as a SkSurface. Skia will not assume * ownership of the render target and the client must ensure the render target is valid for the @@ -118,6 +117,17 @@ public: const SkSurfaceProps*); /** + * Used to wrap a pre-existing 3D API texture as a SkSurface. Skia will treat the texture as + * a rendering target only, but unlike NewFromBackendRenderTarget, Skia will manage and own + * the associated render target objects (but not the provided texture). The kRenderTarget flag + * must be set on GrBackendTextureDesc for this to succeed. Skia will not assume ownership + * of the texture and the client must ensure the texture is valid for the lifetime of the + * SkSurface. + */ + static SkSurface* NewFromBackendTextureAsRenderTarget( + GrContext*, const GrBackendTextureDesc&, const SkSurfaceProps*); + + /** * Return a new surface whose contents will be drawn to an offscreen * render target, allocated by the surface. * @@ -292,6 +302,11 @@ public: const SkSurfaceProps& props() const { return fProps; } + /** + * Issue any pending surface IO to the current backend 3D API and resolve any surface MSAA. + */ + void prepareForExternalIO(); + protected: SkSurface(int width, int height, const SkSurfaceProps*); SkSurface(const SkImageInfo&, const SkSurfaceProps*); |