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:
parent
8a8668b472
commit
7cdda99ac3
@ -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.
|
// 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
|
if (!context->resourceProvider()->attachStencilAttachment(rt)) {
|
||||||
GrStencilAttachment* stencilAttachment =
|
|
||||||
context->resourceProvider()->attachStencilAttachment(rt);
|
|
||||||
if (nullptr == stencilAttachment) {
|
|
||||||
SkDebugf("WARNING: failed to attach stencil buffer for clip mask. Clip will be ignored.\n");
|
SkDebugf("WARNING: failed to attach stencil buffer for clip mask. Clip will be ignored.\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -369,10 +366,10 @@ 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
|
// 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
|
// relevant window rectangles that were in the last clip. This subtle requirement will go away
|
||||||
// after clipping is overhauled.
|
// after clipping is overhauled.
|
||||||
if (stencilAttachment->mustRenderClip(reducedClip.elementsGenID(), reducedClip.ibounds(),
|
if (renderTargetContext->priv().mustRenderClip(reducedClip.elementsGenID(),
|
||||||
fOrigin)) {
|
reducedClip.ibounds(), fOrigin)) {
|
||||||
reducedClip.drawStencilClipMask(context, renderTargetContext, fOrigin);
|
reducedClip.drawStencilClipMask(context, renderTargetContext, fOrigin);
|
||||||
stencilAttachment->setLastClip(reducedClip.elementsGenID(), reducedClip.ibounds(),
|
renderTargetContext->priv().setLastClip(reducedClip.elementsGenID(), reducedClip.ibounds(),
|
||||||
fOrigin);
|
fOrigin);
|
||||||
}
|
}
|
||||||
out->addStencilClip();
|
out->addStencilClip();
|
||||||
|
@ -25,6 +25,28 @@ public:
|
|||||||
return fRenderTargetContext->getOpList()->instancedRendering();
|
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 clear(const GrFixedClip&, const GrColor, bool canIgnoreClip);
|
||||||
|
|
||||||
void clearStencilClip(const GrFixedClip&, bool insideStencilMask);
|
void clearStencilClip(const GrFixedClip&, bool insideStencilMask);
|
||||||
|
@ -52,7 +52,8 @@ GrRenderTargetOpList::GrRenderTargetOpList(GrRenderTargetProxy* rtp, GrGpu* gpu,
|
|||||||
: INHERITED(rtp, auditTrail)
|
: INHERITED(rtp, auditTrail)
|
||||||
, fLastFullClearBatch(nullptr)
|
, fLastFullClearBatch(nullptr)
|
||||||
, fGpu(SkRef(gpu))
|
, fGpu(SkRef(gpu))
|
||||||
, fResourceProvider(resourceProvider) {
|
, fResourceProvider(resourceProvider)
|
||||||
|
, fLastClipStackGenID(SK_InvalidUniqueID) {
|
||||||
// TODO: Stop extracting the context (currently needed by GrClip)
|
// TODO: Stop extracting the context (currently needed by GrClip)
|
||||||
fContext = fGpu->getContext();
|
fContext = fGpu->getContext();
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public:
|
|||||||
SkDEBUGCODE(void dump() const override;)
|
SkDEBUGCODE(void dump() const override;)
|
||||||
|
|
||||||
private:
|
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
|
// Returns the batch that the input batch was combined with or the input batch if it wasn't
|
||||||
// combined.
|
// combined.
|
||||||
@ -169,6 +169,10 @@ private:
|
|||||||
|
|
||||||
SkAutoTDelete<gr_instanced::InstancedRendering> fInstancedRendering;
|
SkAutoTDelete<gr_instanced::InstancedRendering> fInstancedRendering;
|
||||||
|
|
||||||
|
int32_t fLastClipStackGenID;
|
||||||
|
SkIRect fLastClipStackRect;
|
||||||
|
SkIPoint fLastClipOrigin;
|
||||||
|
|
||||||
typedef GrOpList INHERITED;
|
typedef GrOpList INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,24 +28,6 @@ public:
|
|||||||
int bits() const { return fBits; }
|
int bits() const { return fBits; }
|
||||||
int numSamples() const { return fSampleCnt; }
|
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
|
// 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.
|
// all render targets that require a stencil with those params.
|
||||||
static void ComputeSharedStencilAttachmentKey(int width, int height, int sampleCnt,
|
static void ComputeSharedStencilAttachmentKey(int width, int height, int sampleCnt,
|
||||||
@ -57,9 +39,7 @@ protected:
|
|||||||
, fWidth(width)
|
, fWidth(width)
|
||||||
, fHeight(height)
|
, fHeight(height)
|
||||||
, fBits(bits)
|
, fBits(bits)
|
||||||
, fSampleCnt(sampleCnt)
|
, fSampleCnt(sampleCnt) {
|
||||||
, fLastClipStackGenID(SkClipStack::kInvalidGenID) {
|
|
||||||
fLastClipStackRect.setEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -69,10 +49,6 @@ private:
|
|||||||
int fBits;
|
int fBits;
|
||||||
int fSampleCnt;
|
int fSampleCnt;
|
||||||
|
|
||||||
int32_t fLastClipStackGenID;
|
|
||||||
SkIRect fLastClipStackRect;
|
|
||||||
SkIPoint fLastClipOrigin;
|
|
||||||
|
|
||||||
typedef GrGpuResource INHERITED;
|
typedef GrGpuResource INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user