Move some of the adding stencil attachment logic of Gpu and into Render Target.
The new flow of calls for attaching a Stencil looks like:
Client
rt->attachStencilAttachment()
gpu->getStencilAttachment()
glgpu->createStencilAttachment()
glrt->completeStencilAttachment() //actually attaches
BUG=skia:
Review URL: https://codereview.chromium.org/1333383002
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 73a5264..d8e5681 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -369,8 +369,14 @@
virtual bool isTestingOnlyBackendTexture(GrBackendObject id) const = 0;
virtual void deleteTestingOnlyBackendTexture(GrBackendObject id) const = 0;
- // Given a rt, find or create a stencil buffer and attach it
- bool attachStencilAttachmentToRenderTarget(GrRenderTarget* target);
+ // width and height may be larger than rt (if underlying API allows it).
+ // Returns nullptr if compatible sb could not be created, otherwise the caller owns the ref on
+ // the GrStencilAttachment.
+ virtual GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget*,
+ int width,
+ int height) = 0;
+ // clears target's entire stencil buffer to 0
+ virtual void clearStencil(GrRenderTarget* target) = 0;
// This is only to be used in GL-specific tests.
virtual const GrGLContext* glContextForTesting() const { return nullptr; }
@@ -466,17 +472,6 @@
const SkIRect& srcRect,
const SkIPoint& dstPoint) = 0;
- // width and height may be larger than rt (if underlying API allows it).
- // Should attach the SB to the RT. Returns false if compatible sb could
- // not be created.
- virtual bool createStencilAttachmentForRenderTarget(GrRenderTarget*, int width, int height) = 0;
-
- // attaches an existing SB to an existing RT.
- virtual bool attachStencilAttachmentToRenderTarget(GrStencilAttachment*, GrRenderTarget*) = 0;
-
- // clears target's entire stencil buffer to 0
- virtual void clearStencil(GrRenderTarget* target) = 0;
-
void resetContext() {
this->onResetContext(fResetBits);
fResetBits = 0;