aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-08-18 10:33:30 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-18 10:33:30 -0700
commit5ea0363bf12495412649fa11b62e1a6caa71c093 (patch)
treeeedcf10c2ef211e0a83114d123285aed3047b1d9
parent2ad37be2b1f596a163e889ae0282227055c6b661 (diff)
ClearStencilClip in GrBatch
-rw-r--r--src/core/SkStringUtils.cpp2
-rw-r--r--src/gpu/GrBufferedDrawTarget.cpp6
-rw-r--r--src/gpu/GrBufferedDrawTarget.h8
-rw-r--r--src/gpu/GrCommandBuilder.cpp14
-rw-r--r--src/gpu/GrCommandBuilder.h4
-rw-r--r--src/gpu/GrDrawTarget.cpp6
-rw-r--r--src/gpu/GrDrawTarget.h5
-rw-r--r--src/gpu/GrImmediateDrawTarget.cpp6
-rw-r--r--src/gpu/GrImmediateDrawTarget.h7
-rw-r--r--src/gpu/GrTargetCommands.cpp4
-rw-r--r--src/gpu/GrTargetCommands.h24
-rw-r--r--src/gpu/batches/GrClearBatch.h36
12 files changed, 54 insertions, 68 deletions
diff --git a/src/core/SkStringUtils.cpp b/src/core/SkStringUtils.cpp
index 35e55570c3..6f5699c805 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 c59d035a59..4959ddce73 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 e764512f8d..962385e93b 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 86c1668ae2..2d86c1ea89 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 b50a6bbe6a..473e0bf011 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 d2c258d1d0..3926739f19 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 1890883b9a..b2d4aa506d 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 55af98511f..dee30d2629 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 10b7e24987..e1baebe5b2 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 7a7566113f..befee7971c 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 cf3054deab..39199f37ae 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<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)
diff --git a/src/gpu/batches/GrClearBatch.h b/src/gpu/batches/GrClearBatch.h
index 0a2153fbf3..f13b073d75 100644
--- a/src/gpu/batches/GrClearBatch.h
+++ b/src/gpu/batches/GrClearBatch.h
@@ -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