TEMPORARY: track stencil clip state in GrRenderTargetOpList
Tracks the stencil clip state in GrRenderTargetOpList instead of
GrStencilAttachment. This is a temporary move to unblock MDB, after
which point we will be able to overhaul clipping.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2468743002
Review-Url: https://codereview.chromium.org/2468743002
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 7afaa92..669a9c2 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -358,10 +358,7 @@
}
// use the stencil clip if we can't represent the clip as a rectangle.
- // TODO: these need to be swapped over to using a StencilAttachmentProxy
- GrStencilAttachment* stencilAttachment =
- context->resourceProvider()->attachStencilAttachment(rt);
- if (nullptr == stencilAttachment) {
+ if (!context->resourceProvider()->attachStencilAttachment(rt)) {
SkDebugf("WARNING: failed to attach stencil buffer for clip mask. Clip will be ignored.\n");
return true;
}
@@ -369,11 +366,11 @@
// This relies on the property that a reduced sub-rect of the last clip will contain all the
// relevant window rectangles that were in the last clip. This subtle requirement will go away
// after clipping is overhauled.
- if (stencilAttachment->mustRenderClip(reducedClip.elementsGenID(), reducedClip.ibounds(),
- fOrigin)) {
+ if (renderTargetContext->priv().mustRenderClip(reducedClip.elementsGenID(),
+ reducedClip.ibounds(), fOrigin)) {
reducedClip.drawStencilClipMask(context, renderTargetContext, fOrigin);
- stencilAttachment->setLastClip(reducedClip.elementsGenID(), reducedClip.ibounds(),
- fOrigin);
+ renderTargetContext->priv().setLastClip(reducedClip.elementsGenID(), reducedClip.ibounds(),
+ fOrigin);
}
out->addStencilClip();
return true;
diff --git a/src/gpu/GrRenderTargetContextPriv.h b/src/gpu/GrRenderTargetContextPriv.h
index 092fd11..83a334b 100644
--- a/src/gpu/GrRenderTargetContextPriv.h
+++ b/src/gpu/GrRenderTargetContextPriv.h
@@ -25,6 +25,28 @@
return fRenderTargetContext->getOpList()->instancedRendering();
}
+ // called to note the last clip drawn to the stencil buffer.
+ // TODO: remove after clipping overhaul.
+ void setLastClip(int32_t clipStackGenID,
+ const SkIRect& clipSpaceRect,
+ const SkIPoint clipOrigin) {
+ GrRenderTargetOpList* opList = fRenderTargetContext->getOpList();
+ opList->fLastClipStackGenID = clipStackGenID;
+ opList->fLastClipStackRect = clipSpaceRect;
+ opList->fLastClipOrigin = clipOrigin;
+ }
+
+ // called to determine if we have to render the clip into SB.
+ // TODO: remove after clipping overhaul.
+ bool mustRenderClip(int32_t clipStackGenID,
+ const SkIRect& clipSpaceRect,
+ const SkIPoint& clipOrigin) const {
+ GrRenderTargetOpList* opList = fRenderTargetContext->getOpList();
+ return opList->fLastClipStackGenID != clipStackGenID ||
+ opList->fLastClipOrigin != clipOrigin ||
+ !opList->fLastClipStackRect.contains(clipSpaceRect);
+ }
+
void clear(const GrFixedClip&, const GrColor, bool canIgnoreClip);
void clearStencilClip(const GrFixedClip&, bool insideStencilMask);
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index 33a8608..37c469a 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -52,7 +52,8 @@
: INHERITED(rtp, auditTrail)
, fLastFullClearBatch(nullptr)
, fGpu(SkRef(gpu))
- , fResourceProvider(resourceProvider) {
+ , fResourceProvider(resourceProvider)
+ , fLastClipStackGenID(SK_InvalidUniqueID) {
// TODO: Stop extracting the context (currently needed by GrClip)
fContext = fGpu->getContext();
diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h
index 2a7f1a1..e4b2bf6 100644
--- a/src/gpu/GrRenderTargetOpList.h
+++ b/src/gpu/GrRenderTargetOpList.h
@@ -131,7 +131,7 @@
SkDEBUGCODE(void dump() const override;)
private:
- friend class GrRenderTargetContextPriv; // for clearStencilClip
+ friend class GrRenderTargetContextPriv; // for clearStencilClip and stencil clip state.
// Returns the batch that the input batch was combined with or the input batch if it wasn't
// combined.
@@ -169,6 +169,10 @@
SkAutoTDelete<gr_instanced::InstancedRendering> fInstancedRendering;
+ int32_t fLastClipStackGenID;
+ SkIRect fLastClipStackRect;
+ SkIPoint fLastClipOrigin;
+
typedef GrOpList INHERITED;
};
diff --git a/src/gpu/GrStencilAttachment.h b/src/gpu/GrStencilAttachment.h
index 0ed3c8b..08d6799 100644
--- a/src/gpu/GrStencilAttachment.h
+++ b/src/gpu/GrStencilAttachment.h
@@ -28,24 +28,6 @@
int bits() const { return fBits; }
int numSamples() const { return fSampleCnt; }
- // called to note the last clip drawn to this buffer.
- void setLastClip(int32_t clipStackGenID,
- const SkIRect& clipSpaceRect,
- const SkIPoint clipOrigin) {
- fLastClipStackGenID = clipStackGenID;
- fLastClipStackRect = clipSpaceRect;
- fLastClipOrigin = clipOrigin;
- }
-
- // called to determine if we have to render the clip into SB.
- bool mustRenderClip(int32_t clipStackGenID,
- const SkIRect& clipSpaceRect,
- const SkIPoint& clipOrigin) const {
- return fLastClipStackGenID != clipStackGenID ||
- fLastClipOrigin != clipOrigin ||
- !fLastClipStackRect.contains(clipSpaceRect);
- }
-
// We create a unique stencil buffer at each width, height and sampleCnt and share it for
// all render targets that require a stencil with those params.
static void ComputeSharedStencilAttachmentKey(int width, int height, int sampleCnt,
@@ -57,9 +39,7 @@
, fWidth(width)
, fHeight(height)
, fBits(bits)
- , fSampleCnt(sampleCnt)
- , fLastClipStackGenID(SkClipStack::kInvalidGenID) {
- fLastClipStackRect.setEmpty();
+ , fSampleCnt(sampleCnt) {
}
private:
@@ -69,10 +49,6 @@
int fBits;
int fSampleCnt;
- int32_t fLastClipStackGenID;
- SkIRect fLastClipStackRect;
- SkIPoint fLastClipOrigin;
-
typedef GrGpuResource INHERITED;
};