From: bsalomon Date: Tue, 18 Aug 2015 17:33:30 +0000 (-0700) Subject: ClearStencilClip in GrBatch X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~1209 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5ea0363bf12495412649fa11b62e1a6caa71c093;p=platform%2Fupstream%2FlibSkiaSharp.git ClearStencilClip in GrBatch Review URL: https://codereview.chromium.org/1288963004 --- diff --git a/src/core/SkStringUtils.cpp b/src/core/SkStringUtils.cpp index 35e5557..6f5699c 100644 --- a/src/core/SkStringUtils.cpp +++ b/src/core/SkStringUtils.cpp @@ -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; } diff --git a/src/gpu/GrBufferedDrawTarget.cpp b/src/gpu/GrBufferedDrawTarget.cpp index c59d035..4959ddc 100644 --- a/src/gpu/GrBufferedDrawTarget.cpp +++ b/src/gpu/GrBufferedDrawTarget.cpp @@ -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(); diff --git a/src/gpu/GrBufferedDrawTarget.h b/src/gpu/GrBufferedDrawTarget.h index e764512..962385e 100644 --- a/src/gpu/GrBufferedDrawTarget.h +++ b/src/gpu/GrBufferedDrawTarget.h @@ -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*, diff --git a/src/gpu/GrCommandBuilder.cpp b/src/gpu/GrCommandBuilder.cpp index 86c1668..2d86c1e 100644 --- a/src/gpu/GrCommandBuilder.cpp +++ b/src/gpu/GrCommandBuilder.cpp @@ -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, diff --git a/src/gpu/GrCommandBuilder.h b/src/gpu/GrCommandBuilder.h index b50a6bb..473e0bf 100644 --- a/src/gpu/GrCommandBuilder.h +++ b/src/gpu/GrCommandBuilder.h @@ -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() {} diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index d2c258d..3926739 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -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(); +} diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index 1890883..b2d4aa5 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -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 diff --git a/src/gpu/GrImmediateDrawTarget.cpp b/src/gpu/GrImmediateDrawTarget.cpp index 55af985..dee30d2 100644 --- a/src/gpu/GrImmediateDrawTarget.cpp +++ b/src/gpu/GrImmediateDrawTarget.cpp @@ -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() { diff --git a/src/gpu/GrImmediateDrawTarget.h b/src/gpu/GrImmediateDrawTarget.h index 10b7e24..e1baebe 100644 --- a/src/gpu/GrImmediateDrawTarget.h +++ b/src/gpu/GrImmediateDrawTarget.h @@ -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*, diff --git a/src/gpu/GrTargetCommands.cpp b/src/gpu/GrTargetCommands.cpp index 7a75661..befee79 100644 --- a/src/gpu/GrTargetCommands.cpp +++ b/src/gpu/GrTargetCommands.cpp @@ -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); } diff --git a/src/gpu/GrTargetCommands.h b/src/gpu/GrTargetCommands.h index cf3054d..39199f3 100644 --- a/src/gpu/GrTargetCommands.h +++ b/src/gpu/GrTargetCommands.h @@ -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 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 fRenderTarget; - }; - struct CopySurface : public Cmd { CopySurface(GrSurface* dst, GrSurface* src) : Cmd(kCopySurface_CmdType) diff --git a/src/gpu/batches/GrClearBatch.h b/src/gpu/batches/GrClearBatch.h index 0a2153f..f13b073 100644 --- a/src/gpu/batches/GrClearBatch.h +++ b/src/gpu/batches/GrClearBatch.h @@ -52,4 +52,40 @@ private: GrPendingIOResource fRenderTarget; }; +class GrClearStencilClipBatch final : public GrBatch { +public: + GrClearStencilClipBatch(const SkIRect& rect, bool insideClip, GrRenderTarget* rt) + : fRect(rect) + , fInsideClip(insideClip) + , fRenderTarget(rt) { + this->initClassID(); + 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 fRenderTarget; +}; + #endif