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
This commit is contained in:
csmartdalton 2016-11-01 07:03:03 -07:00 committed by Commit bot
parent 8a8668b472
commit 7cdda99ac3
5 changed files with 35 additions and 35 deletions

View File

@ -358,10 +358,7 @@ bool GrClipStackClip::apply(GrContext* context, GrRenderTargetContext* renderTar
}
// 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 @@ bool GrClipStackClip::apply(GrContext* context, GrRenderTargetContext* renderTar
// 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;

View File

@ -25,6 +25,28 @@ public:
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);

View File

@ -52,7 +52,8 @@ GrRenderTargetOpList::GrRenderTargetOpList(GrRenderTargetProxy* rtp, GrGpu* gpu,
: 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();

View File

@ -131,7 +131,7 @@ public:
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 @@ private:
SkAutoTDelete<gr_instanced::InstancedRendering> fInstancedRendering;
int32_t fLastClipStackGenID;
SkIRect fLastClipStackRect;
SkIPoint fLastClipOrigin;
typedef GrOpList INHERITED;
};

View File

@ -28,24 +28,6 @@ public:
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 @@ protected:
, fWidth(width)
, fHeight(height)
, fBits(bits)
, fSampleCnt(sampleCnt)
, fLastClipStackGenID(SkClipStack::kInvalidGenID) {
fLastClipStackRect.setEmpty();
, fSampleCnt(sampleCnt) {
}
private:
@ -69,10 +49,6 @@ private:
int fBits;
int fSampleCnt;
int32_t fLastClipStackGenID;
SkIRect fLastClipStackRect;
SkIPoint fLastClipOrigin;
typedef GrGpuResource INHERITED;
};