Path stenciling in GrBatch
Review URL: https://codereview.chromium.org/1293973003
This commit is contained in:
parent
b32758a72f
commit
a44919ea27
@ -241,6 +241,7 @@
|
||||
'<(skia_src_path)/gpu/batches/GrRectBatchFactory.cpp',
|
||||
'<(skia_src_path)/gpu/batches/GrStrokeRectBatch.cpp',
|
||||
'<(skia_src_path)/gpu/batches/GrStrokeRectBatch.h',
|
||||
'<(skia_src_path)/gpu/batches/GrStencilPathBatch.h',
|
||||
'<(skia_src_path)/gpu/batches/GrTInstanceBatch.h',
|
||||
'<(skia_src_path)/gpu/batches/GrVertexBatch.cpp',
|
||||
'<(skia_src_path)/gpu/batches/GrVertexBatch.h',
|
||||
|
@ -30,14 +30,6 @@ void GrBufferedDrawTarget::onDrawBatch(GrBatch* batch) {
|
||||
fCommands->recordDrawBatch(batch, *this->caps());
|
||||
}
|
||||
|
||||
void GrBufferedDrawTarget::onStencilPath(const GrPipelineBuilder& pipelineBuilder,
|
||||
const GrPathProcessor* pathProc,
|
||||
const GrPath* path,
|
||||
const GrScissorState& scissorState,
|
||||
const GrStencilSettings& stencilSettings) {
|
||||
fCommands->recordStencilPath(pipelineBuilder, pathProc, path, scissorState, stencilSettings);
|
||||
}
|
||||
|
||||
void GrBufferedDrawTarget::onDrawPath(const GrPathProcessor* pathProc,
|
||||
const GrPath* path,
|
||||
const GrStencilSettings& stencilSettings,
|
||||
|
@ -73,11 +73,6 @@ private:
|
||||
void onReset() override;
|
||||
void onFlush() override;
|
||||
|
||||
void onStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrScissorState&,
|
||||
const GrStencilSettings&) override;
|
||||
void onDrawPath(const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrStencilSettings&,
|
||||
|
@ -27,11 +27,6 @@ public:
|
||||
void flush(GrGpu* gpu, GrResourceProvider* rp) { fCommands.flush(gpu, rp); }
|
||||
|
||||
virtual Cmd* recordDrawBatch(GrBatch*, const GrCaps&) = 0;
|
||||
virtual Cmd* recordStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrScissorState&,
|
||||
const GrStencilSettings&) = 0;
|
||||
virtual Cmd* recordDrawPath(State*,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
@ -50,7 +45,6 @@ public:
|
||||
|
||||
protected:
|
||||
typedef GrTargetCommands::DrawBatch DrawBatch;
|
||||
typedef GrTargetCommands::StencilPath StencilPath;
|
||||
typedef GrTargetCommands::DrawPath DrawPath;
|
||||
typedef GrTargetCommands::DrawPaths DrawPaths;
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "batches/GrDiscardBatch.h"
|
||||
#include "batches/GrDrawBatch.h"
|
||||
#include "batches/GrRectBatchFactory.h"
|
||||
#include "batches/GrStencilPathBatch.h"
|
||||
|
||||
#include "SkStrokeRec.h"
|
||||
|
||||
@ -212,7 +213,13 @@ void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder,
|
||||
GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
|
||||
this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
|
||||
|
||||
this->onStencilPath(pipelineBuilder, pathProc, path, scissorState, stencilSettings);
|
||||
GrBatch* batch = GrStencilPathBatch::Create(pathProc->viewMatrix(),
|
||||
pipelineBuilder.isHWAntialias(),
|
||||
stencilSettings, scissorState,
|
||||
pipelineBuilder.getRenderTarget(),
|
||||
path);
|
||||
this->onDrawBatch(batch);
|
||||
batch->unref();
|
||||
}
|
||||
|
||||
void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder,
|
||||
|
@ -243,11 +243,6 @@ private:
|
||||
|
||||
virtual void onFlush() = 0;
|
||||
|
||||
virtual void onStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrScissorState&,
|
||||
const GrStencilSettings&) = 0;
|
||||
virtual void onDrawPath(const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrStencilSettings&,
|
||||
|
@ -33,13 +33,6 @@ private:
|
||||
void onReset() override;
|
||||
void onFlush() override;
|
||||
|
||||
void onStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrScissorState&,
|
||||
const GrStencilSettings&) override {
|
||||
SkFAIL("Only batch implemented\n");
|
||||
}
|
||||
void onDrawPath(const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrStencilSettings&,
|
||||
|
@ -41,22 +41,6 @@ GrTargetCommands::Cmd* GrInOrderCommandBuilder::recordDrawBatch(GrBatch* batch,
|
||||
return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (batch));
|
||||
}
|
||||
|
||||
GrTargetCommands::Cmd*
|
||||
GrInOrderCommandBuilder::recordStencilPath(const GrPipelineBuilder& pipelineBuilder,
|
||||
const GrPathProcessor* pathProc,
|
||||
const GrPath* path,
|
||||
const GrScissorState& scissorState,
|
||||
const GrStencilSettings& stencilSettings) {
|
||||
StencilPath* sp = GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), StencilPath,
|
||||
(path, pipelineBuilder.getRenderTarget()));
|
||||
|
||||
sp->fScissor = scissorState;
|
||||
sp->fUseHWAA = pipelineBuilder.isHWAntialias();
|
||||
sp->fViewMatrix = pathProc->viewMatrix();
|
||||
sp->fStencil = stencilSettings;
|
||||
return sp;
|
||||
}
|
||||
|
||||
GrTargetCommands::Cmd*
|
||||
GrInOrderCommandBuilder::recordDrawPath(State* state,
|
||||
const GrPathProcessor* pathProc,
|
||||
|
@ -18,11 +18,6 @@ public:
|
||||
GrInOrderCommandBuilder() : INHERITED() { }
|
||||
|
||||
Cmd* recordDrawBatch(GrBatch*, const GrCaps&) override;
|
||||
Cmd* recordStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrScissorState&,
|
||||
const GrStencilSettings&) override;
|
||||
Cmd* recordDrawPath(State*,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
|
@ -18,14 +18,6 @@ public:
|
||||
GrReorderCommandBuilder() : INHERITED() {}
|
||||
|
||||
Cmd* recordDrawBatch(GrBatch*, const GrCaps&) override;
|
||||
Cmd* recordStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrScissorState&,
|
||||
const GrStencilSettings&) override {
|
||||
SkFAIL("Unsupported\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Cmd* recordDrawPath(State*,
|
||||
const GrPathProcessor*,
|
||||
|
@ -43,12 +43,6 @@ void GrTargetCommands::flush(GrGpu* gpu, GrResourceProvider* resourceProvider) {
|
||||
fLastFlushToken = flushState.lastFlushedToken();
|
||||
}
|
||||
|
||||
void GrTargetCommands::StencilPath::execute(GrBatchFlushState* state) {
|
||||
GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fViewMatrix, &fScissor,
|
||||
&fStencil);
|
||||
state->gpu()->pathRendering()->stencilPath(args, this->path());
|
||||
}
|
||||
|
||||
void GrTargetCommands::DrawPath::execute(GrBatchFlushState* state) {
|
||||
if (!fState->fCompiled) {
|
||||
state->gpu()->buildProgramDesc(&fState->fDesc, *fState->fPrimitiveProcessor,
|
||||
|
@ -30,7 +30,6 @@ public:
|
||||
class Cmd : ::SkNoncopyable {
|
||||
public:
|
||||
enum CmdType {
|
||||
kStencilPath_CmdType = 1,
|
||||
kDrawPath_CmdType = 2,
|
||||
kDrawPaths_CmdType = 3,
|
||||
kDrawBatch_CmdType = 4,
|
||||
@ -118,25 +117,6 @@ private:
|
||||
// TODO remove this when State is just a pipeline
|
||||
friend SkNVRefCnt<StateForPathDraw>;
|
||||
|
||||
struct StencilPath : public Cmd {
|
||||
StencilPath(const GrPath* path, GrRenderTarget* rt)
|
||||
: Cmd(kStencilPath_CmdType)
|
||||
, fRenderTarget(rt)
|
||||
, fPath(path) {}
|
||||
|
||||
const GrPath* path() const { return fPath.get(); }
|
||||
|
||||
void execute(GrBatchFlushState*) override;
|
||||
|
||||
SkMatrix fViewMatrix;
|
||||
bool fUseHWAA;
|
||||
GrStencilSettings fStencil;
|
||||
GrScissorState fScissor;
|
||||
private:
|
||||
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
|
||||
GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
|
||||
};
|
||||
|
||||
struct DrawPath : public Cmd {
|
||||
DrawPath(StateForPathDraw* state, const GrPath* path)
|
||||
: Cmd(kDrawPath_CmdType)
|
||||
|
72
src/gpu/batches/GrStencilPathBatch.h
Normal file
72
src/gpu/batches/GrStencilPathBatch.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrStencilPathBatch_DEFINED
|
||||
#define GrStencilPathBatch_DEFINED
|
||||
|
||||
#include "GrBatch.h"
|
||||
#include "GrBatchFlushState.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrPath.h"
|
||||
#include "GrPathRendering.h"
|
||||
#include "GrRenderTarget.h"
|
||||
|
||||
class GrStencilPathBatch final : public GrBatch {
|
||||
public:
|
||||
static GrBatch* Create(const SkMatrix& viewMatrix,
|
||||
bool useHWAA,
|
||||
const GrStencilSettings& stencil,
|
||||
const GrScissorState& scissor,
|
||||
GrRenderTarget* renderTarget,
|
||||
const GrPath* path) {
|
||||
return SkNEW_ARGS(GrStencilPathBatch, (viewMatrix, useHWAA, stencil, scissor, renderTarget,
|
||||
path));
|
||||
}
|
||||
|
||||
const char* name() const override { return "StencilPath"; }
|
||||
|
||||
uint32_t renderTargetUniqueID() const { return fRenderTarget.get()->getUniqueID(); }
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
string.printf("PATH: 0x%p, AA:%d", fPath.get(), fUseHWAA);
|
||||
return string;
|
||||
}
|
||||
|
||||
private:
|
||||
GrStencilPathBatch(const SkMatrix& viewMatrix,
|
||||
bool useHWAA,
|
||||
const GrStencilSettings& stencil,
|
||||
const GrScissorState& scissor,
|
||||
GrRenderTarget* renderTarget,
|
||||
const GrPath* path)
|
||||
: fViewMatrix(viewMatrix)
|
||||
, fUseHWAA(useHWAA)
|
||||
, fStencil(stencil)
|
||||
, fScissor(scissor)
|
||||
, fRenderTarget(renderTarget)
|
||||
, fPath(path) {}
|
||||
|
||||
bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return false; }
|
||||
|
||||
void onPrepare(GrBatchFlushState*) override {}
|
||||
|
||||
void onDraw(GrBatchFlushState* state) override {
|
||||
GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fViewMatrix,
|
||||
&fScissor, &fStencil);
|
||||
state->gpu()->pathRendering()->stencilPath(args, fPath.get());
|
||||
}
|
||||
|
||||
SkMatrix fViewMatrix;
|
||||
bool fUseHWAA;
|
||||
GrStencilSettings fStencil;
|
||||
GrScissorState fScissor;
|
||||
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
|
||||
GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user