ClearStencilClip in GrBatch
Review URL: https://codereview.chromium.org/1288963004
This commit is contained in:
parent
2ad37be2b1
commit
5ea0363bf1
@ -57,7 +57,7 @@ SkString SkTabString(const SkString& string, int tabCnt) {
|
||||
}
|
||||
if (*input != '\0') {
|
||||
result.append(tabs);
|
||||
result.append(input);
|
||||
}
|
||||
result.append(input);
|
||||
return result;
|
||||
}
|
||||
|
@ -69,12 +69,6 @@ void GrBufferedDrawTarget::onDrawPaths(const GrPathProcessor* pathProc,
|
||||
opts);
|
||||
}
|
||||
|
||||
void GrBufferedDrawTarget::clearStencilClip(const SkIRect& rect,
|
||||
bool insideClip,
|
||||
GrRenderTarget* renderTarget) {
|
||||
fCommands->recordClearStencilClip(rect, insideClip, renderTarget);
|
||||
}
|
||||
|
||||
void GrBufferedDrawTarget::onReset() {
|
||||
fCommands->reset();
|
||||
fPathIndexBuffer.rewind();
|
||||
|
@ -30,10 +30,6 @@ public:
|
||||
|
||||
~GrBufferedDrawTarget() override;
|
||||
|
||||
void clearStencilClip(const SkIRect& rect,
|
||||
bool insideClip,
|
||||
GrRenderTarget* renderTarget) override;
|
||||
|
||||
protected:
|
||||
void appendIndicesAndTransforms(const void* indexValues, PathIndexType indexType,
|
||||
const float* transformValues, PathTransformType transformType,
|
||||
@ -55,6 +51,8 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
void onDrawBatch(GrBatch*) override;
|
||||
|
||||
private:
|
||||
friend class GrInOrderCommandBuilder;
|
||||
friend class GrTargetCommands;
|
||||
@ -75,8 +73,6 @@ private:
|
||||
void onReset() override;
|
||||
void onFlush() override;
|
||||
|
||||
// overrides from GrDrawTarget
|
||||
void onDrawBatch(GrBatch*) override;
|
||||
void onStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
|
@ -18,20 +18,6 @@ GrCommandBuilder* GrCommandBuilder::Create(GrGpu* gpu, bool reorder) {
|
||||
}
|
||||
}
|
||||
|
||||
GrTargetCommands::Cmd* GrCommandBuilder::recordClearStencilClip(const SkIRect& rect,
|
||||
bool insideClip,
|
||||
GrRenderTarget* renderTarget) {
|
||||
SkASSERT(renderTarget);
|
||||
|
||||
ClearStencilClip* clr = GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(),
|
||||
ClearStencilClip,
|
||||
(renderTarget));
|
||||
clr->fRect = rect;
|
||||
clr->fInsideClip = insideClip;
|
||||
GrBATCH_INFO("Recording clear stencil clip %d\n", clr->uniqueID());
|
||||
return clr;
|
||||
}
|
||||
|
||||
GrTargetCommands::Cmd* GrCommandBuilder::recordCopySurface(GrSurface* dst,
|
||||
GrSurface* src,
|
||||
const SkIRect& srcRect,
|
||||
|
@ -26,9 +26,6 @@ public:
|
||||
void reset() { fCommands.reset(); }
|
||||
void flush(GrGpu* gpu, GrResourceProvider* rp) { fCommands.flush(gpu, rp); }
|
||||
|
||||
virtual Cmd* recordClearStencilClip(const SkIRect& rect,
|
||||
bool insideClip,
|
||||
GrRenderTarget* renderTarget);
|
||||
virtual Cmd* recordDrawBatch(GrBatch*, const GrCaps&) = 0;
|
||||
virtual Cmd* recordStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
@ -60,7 +57,6 @@ protected:
|
||||
typedef GrTargetCommands::StencilPath StencilPath;
|
||||
typedef GrTargetCommands::DrawPath DrawPath;
|
||||
typedef GrTargetCommands::DrawPaths DrawPaths;
|
||||
typedef GrTargetCommands::ClearStencilClip ClearStencilClip;
|
||||
typedef GrTargetCommands::CopySurface CopySurface;
|
||||
|
||||
GrCommandBuilder() {}
|
||||
|
@ -532,3 +532,9 @@ void GrClipTarget::purgeResources() {
|
||||
// get rid of them all.
|
||||
fClipMaskManager->purgeResources();
|
||||
};
|
||||
|
||||
void GrClipTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* rt) {
|
||||
GrBatch* batch = SkNEW_ARGS(GrClearStencilClipBatch, (rect, insideClip, rt));
|
||||
this->onDrawBatch(batch);
|
||||
batch->unref();
|
||||
}
|
||||
|
@ -236,12 +236,13 @@ protected:
|
||||
GrXferProcessor::DstTexture*,
|
||||
const SkRect* drawBounds);
|
||||
|
||||
virtual void onDrawBatch(GrBatch*) = 0;
|
||||
|
||||
private:
|
||||
virtual void onReset() = 0;
|
||||
|
||||
virtual void onFlush() = 0;
|
||||
|
||||
virtual void onDrawBatch(GrBatch*) = 0;
|
||||
virtual void onStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
@ -311,7 +312,7 @@ public:
|
||||
* is free to clear the remaining bits to zero if masked clears are more
|
||||
* expensive than clearing all bits.
|
||||
*/
|
||||
virtual void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* = NULL) = 0;
|
||||
void clearStencilClip(const SkIRect&, bool insideClip, GrRenderTarget*);
|
||||
|
||||
/**
|
||||
* Release any resources that are cached but not currently in use. This
|
||||
|
@ -47,12 +47,6 @@ void GrImmediateDrawTarget::onCopySurface(GrSurface* dst,
|
||||
this->getGpu()->copySurface(dst, src, srcRect, dstPoint);
|
||||
}
|
||||
|
||||
void GrImmediateDrawTarget::clearStencilClip(const SkIRect& rect,
|
||||
bool insideClip,
|
||||
GrRenderTarget* renderTarget) {
|
||||
this->getGpu()->clearStencilClip(rect, insideClip, renderTarget);
|
||||
}
|
||||
|
||||
void GrImmediateDrawTarget::onReset() {}
|
||||
|
||||
void GrImmediateDrawTarget::onFlush() {
|
||||
|
@ -26,16 +26,13 @@ public:
|
||||
|
||||
~GrImmediateDrawTarget() override;
|
||||
|
||||
void clearStencilClip(const SkIRect& rect,
|
||||
bool insideClip,
|
||||
GrRenderTarget* renderTarget) override;
|
||||
protected:
|
||||
void onDrawBatch(GrBatch*) override;
|
||||
|
||||
private:
|
||||
void onReset() override;
|
||||
void onFlush() override;
|
||||
|
||||
// overrides from GrDrawTarget
|
||||
void onDrawBatch(GrBatch*) override;
|
||||
void onStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
|
@ -76,10 +76,6 @@ void GrTargetCommands::DrawBatch::execute(GrBatchFlushState* state) {
|
||||
fBatch->draw(state);
|
||||
}
|
||||
|
||||
void GrTargetCommands::ClearStencilClip::execute(GrBatchFlushState* state) {
|
||||
state->gpu()->clearStencilClip(fRect, fInsideClip, this->renderTarget());
|
||||
}
|
||||
|
||||
void GrTargetCommands::CopySurface::execute(GrBatchFlushState* state) {
|
||||
state->gpu()->copySurface(this->dst(), this->src(), fSrcRect, fDstPoint);
|
||||
}
|
||||
|
@ -31,11 +31,10 @@ public:
|
||||
public:
|
||||
enum CmdType {
|
||||
kStencilPath_CmdType = 1,
|
||||
kClearStencil_CmdType = 2,
|
||||
kCopySurface_CmdType = 3,
|
||||
kDrawPath_CmdType = 4,
|
||||
kDrawPaths_CmdType = 5,
|
||||
kDrawBatch_CmdType = 6,
|
||||
kCopySurface_CmdType = 2,
|
||||
kDrawPath_CmdType = 3,
|
||||
kDrawPaths_CmdType = 4,
|
||||
kDrawBatch_CmdType = 5,
|
||||
};
|
||||
|
||||
Cmd(CmdType type)
|
||||
@ -177,21 +176,6 @@ private:
|
||||
GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange;
|
||||
};
|
||||
|
||||
// This command is ONLY used by the clip mask manager to clear the stencil clip bits
|
||||
struct ClearStencilClip : public Cmd {
|
||||
ClearStencilClip(GrRenderTarget* rt) : Cmd(kClearStencil_CmdType), fRenderTarget(rt) {}
|
||||
|
||||
GrRenderTarget* renderTarget() const { return fRenderTarget.get(); }
|
||||
|
||||
void execute(GrBatchFlushState*) override;
|
||||
|
||||
SkIRect fRect;
|
||||
bool fInsideClip;
|
||||
|
||||
private:
|
||||
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
|
||||
};
|
||||
|
||||
struct CopySurface : public Cmd {
|
||||
CopySurface(GrSurface* dst, GrSurface* src)
|
||||
: Cmd(kCopySurface_CmdType)
|
||||
|
@ -52,4 +52,40 @@ private:
|
||||
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
|
||||
};
|
||||
|
||||
class GrClearStencilClipBatch final : public GrBatch {
|
||||
public:
|
||||
GrClearStencilClipBatch(const SkIRect& rect, bool insideClip, GrRenderTarget* rt)
|
||||
: fRect(rect)
|
||||
, fInsideClip(insideClip)
|
||||
, fRenderTarget(rt) {
|
||||
this->initClassID<GrClearStencilClipBatch>();
|
||||
fBounds = SkRect::Make(rect);
|
||||
}
|
||||
|
||||
const char* name() const override { return "ClearStencilClip"; }
|
||||
|
||||
uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->getUniqueID(); }
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
string.printf("Rect [L: %d, T: %d, R: %d, B: %d], IC: %d, RT: 0x%p",
|
||||
fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom, fInsideClip,
|
||||
fRenderTarget.get());
|
||||
return string;
|
||||
}
|
||||
|
||||
private:
|
||||
bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return false; }
|
||||
|
||||
void onPrepare(GrBatchFlushState*) override {}
|
||||
|
||||
void onDraw(GrBatchFlushState* state) override {
|
||||
state->gpu()->clearStencilClip(fRect, fInsideClip, fRenderTarget.get());
|
||||
}
|
||||
|
||||
SkIRect fRect;
|
||||
bool fInsideClip;
|
||||
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user