}
if (*input != '\0') {
result.append(tabs);
+ result.append(input);
}
- result.append(input);
return result;
}
opts);
}
-void GrBufferedDrawTarget::clearStencilClip(const SkIRect& rect,
- bool insideClip,
- GrRenderTarget* renderTarget) {
- fCommands->recordClearStencilClip(rect, insideClip, renderTarget);
-}
-
void GrBufferedDrawTarget::onReset() {
fCommands->reset();
fPathIndexBuffer.rewind();
~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,
}
}
+ void onDrawBatch(GrBatch*) override;
+
private:
friend class GrInOrderCommandBuilder;
friend class GrTargetCommands;
void onReset() override;
void onFlush() override;
- // overrides from GrDrawTarget
- void onDrawBatch(GrBatch*) override;
void onStencilPath(const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,
}
}
-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,
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*,
typedef GrTargetCommands::StencilPath StencilPath;
typedef GrTargetCommands::DrawPath DrawPath;
typedef GrTargetCommands::DrawPaths DrawPaths;
- typedef GrTargetCommands::ClearStencilClip ClearStencilClip;
typedef GrTargetCommands::CopySurface CopySurface;
GrCommandBuilder() {}
// 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();
+}
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*,
* 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
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() {
~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*,
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);
}
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)
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)
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