remove drawtype
BUG=skia: Review URL: https://codereview.chromium.org/862933005
This commit is contained in:
parent
d4742fa550
commit
17e7314e0e
@ -503,7 +503,7 @@ private:
|
||||
GrPathProcessor::GrPathProcessor(GrColor color,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix& localMatrix)
|
||||
: INHERITED(viewMatrix, localMatrix)
|
||||
: INHERITED(viewMatrix, localMatrix, true)
|
||||
, fColor(color) {
|
||||
this->initClassID<GrPathProcessor>();
|
||||
}
|
||||
|
@ -169,12 +169,16 @@ public:
|
||||
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
|
||||
const GrGLCaps& caps) const = 0;
|
||||
|
||||
bool isPathRendering() const { return fIsPathRendering; }
|
||||
|
||||
protected:
|
||||
GrPrimitiveProcessor(const SkMatrix& viewMatrix, const SkMatrix& localMatrix)
|
||||
GrPrimitiveProcessor(const SkMatrix& viewMatrix, const SkMatrix& localMatrix,
|
||||
bool isPathRendering)
|
||||
: fNumAttribs(0)
|
||||
, fVertexStride(0)
|
||||
, fViewMatrix(viewMatrix)
|
||||
, fLocalMatrix(localMatrix) {}
|
||||
, fLocalMatrix(localMatrix)
|
||||
, fIsPathRendering(isPathRendering) {}
|
||||
|
||||
/*
|
||||
* CanCombineOutput will return true if two draws are 'batchable' from a color perspective.
|
||||
@ -215,6 +219,7 @@ private:
|
||||
|
||||
const SkMatrix fViewMatrix;
|
||||
SkMatrix fLocalMatrix;
|
||||
bool fIsPathRendering;
|
||||
|
||||
typedef GrProcessor INHERITED;
|
||||
};
|
||||
@ -234,7 +239,7 @@ public:
|
||||
const SkMatrix& viewMatrix = SkMatrix::I(),
|
||||
const SkMatrix& localMatrix = SkMatrix::I(),
|
||||
bool opaqueVertexColors = false)
|
||||
: INHERITED(viewMatrix, localMatrix)
|
||||
: INHERITED(viewMatrix, localMatrix, false)
|
||||
, fColor(color)
|
||||
, fOpaqueVertexColors(opaqueVertexColors)
|
||||
, fWillUseGeoShader(false)
|
||||
|
@ -302,25 +302,12 @@ public:
|
||||
// is dirty.
|
||||
ResetTimestamp getResetTimestamp() const { return fResetTimestamp; }
|
||||
|
||||
enum DrawType {
|
||||
kDrawPoints_DrawType,
|
||||
kDrawLines_DrawType,
|
||||
kDrawTriangles_DrawType,
|
||||
kDrawPath_DrawType,
|
||||
kDrawPaths_DrawType,
|
||||
};
|
||||
|
||||
static bool IsPathRenderingDrawType(DrawType type) {
|
||||
return kDrawPath_DrawType == type || kDrawPaths_DrawType == type;
|
||||
}
|
||||
|
||||
GrContext::GPUStats* gpuStats() { return &fGPUStats; }
|
||||
|
||||
virtual void buildProgramDesc(GrProgramDesc*,
|
||||
const GrPrimitiveProcessor&,
|
||||
const GrOptDrawState&,
|
||||
const GrProgramDesc::DescInfo&,
|
||||
GrGpu::DrawType,
|
||||
const GrBatchTracker&) const = 0;
|
||||
|
||||
/**
|
||||
@ -366,20 +353,17 @@ public:
|
||||
DrawArgs(const GrPrimitiveProcessor* primProc,
|
||||
const GrOptDrawState* optState,
|
||||
const GrProgramDesc* desc,
|
||||
const GrBatchTracker* batchTracker,
|
||||
DrawType drawType)
|
||||
const GrBatchTracker* batchTracker)
|
||||
: fPrimitiveProcessor(primProc)
|
||||
, fOptState(optState)
|
||||
, fDesc(desc)
|
||||
, fBatchTracker(batchTracker)
|
||||
, fDrawType(drawType) {
|
||||
, fBatchTracker(batchTracker) {
|
||||
SkASSERT(primProc && optState && desc && batchTracker);
|
||||
}
|
||||
const GrPrimitiveProcessor* fPrimitiveProcessor;
|
||||
const GrOptDrawState* fOptState;
|
||||
const GrProgramDesc* fDesc;
|
||||
const GrBatchTracker* fBatchTracker;
|
||||
DrawType fDrawType;
|
||||
};
|
||||
|
||||
void draw(const DrawArgs&, const GrDrawTarget::DrawInfo&);
|
||||
@ -405,23 +389,6 @@ public:
|
||||
int count,
|
||||
const GrStencilSettings&);
|
||||
|
||||
static DrawType PrimTypeToDrawType(GrPrimitiveType type) {
|
||||
switch (type) {
|
||||
case kTriangles_GrPrimitiveType:
|
||||
case kTriangleStrip_GrPrimitiveType:
|
||||
case kTriangleFan_GrPrimitiveType:
|
||||
return kDrawTriangles_DrawType;
|
||||
case kPoints_GrPrimitiveType:
|
||||
return kDrawPoints_DrawType;
|
||||
case kLines_GrPrimitiveType:
|
||||
case kLineStrip_GrPrimitiveType:
|
||||
return kDrawLines_DrawType;
|
||||
default:
|
||||
SkFAIL("Unexpected primitive type");
|
||||
return kDrawTriangles_DrawType;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
// Functions used to map clip-respecting stencil tests into normal
|
||||
// stencil funcs supported by GPUs.
|
||||
|
@ -245,9 +245,7 @@ void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds,
|
||||
const GrDeviceCoordTexture* dstCopy) {
|
||||
SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer()));
|
||||
|
||||
if (!this->recordStateAndShouldDraw(ds, gp,
|
||||
GrGpu::PrimTypeToDrawType(info.primitiveType()),
|
||||
scissorState, dstCopy)) {
|
||||
if (!this->recordStateAndShouldDraw(ds, gp, scissorState, dstCopy)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -287,8 +285,7 @@ void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds,
|
||||
const GrStencilSettings& stencilSettings,
|
||||
const GrDeviceCoordTexture* dstCopy) {
|
||||
// TODO: Only compare the subset of GrDrawState relevant to path covering?
|
||||
if (!this->recordStateAndShouldDraw(ds, pathProc, GrGpu::kDrawPath_DrawType,
|
||||
scissorState, dstCopy)) {
|
||||
if (!this->recordStateAndShouldDraw(ds, pathProc, scissorState, dstCopy)) {
|
||||
return;
|
||||
}
|
||||
DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path));
|
||||
@ -311,8 +308,7 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds,
|
||||
SkASSERT(indices);
|
||||
SkASSERT(transformValues);
|
||||
|
||||
if (!this->recordStateAndShouldDraw(ds, pathProc, GrGpu::kDrawPath_DrawType, scissorState,
|
||||
dstCopy)) {
|
||||
if (!this->recordStateAndShouldDraw(ds, pathProc, scissorState, dstCopy)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -435,8 +431,7 @@ void GrInOrderDrawBuffer::onFlush() {
|
||||
SetState* ss = reinterpret_cast<SetState*>(iter.get());
|
||||
|
||||
this->getGpu()->buildProgramDesc(&ss->fDesc, *ss->fPrimitiveProcessor, ss->fState,
|
||||
ss->fState.descInfo(), ss->fDrawType,
|
||||
ss->fBatchTracker);
|
||||
ss->fState.descInfo(), ss->fBatchTracker);
|
||||
currentState = ss;
|
||||
|
||||
} else {
|
||||
@ -455,7 +450,7 @@ void GrInOrderDrawBuffer::onFlush() {
|
||||
void GrInOrderDrawBuffer::Draw::execute(GrInOrderDrawBuffer* buf, const SetState* state) {
|
||||
SkASSERT(state);
|
||||
DrawArgs args(state->fPrimitiveProcessor.get(), &state->fState, &state->fDesc,
|
||||
&state->fBatchTracker, state->fDrawType);
|
||||
&state->fBatchTracker);
|
||||
buf->getGpu()->draw(args, fInfo);
|
||||
}
|
||||
|
||||
@ -473,14 +468,14 @@ void GrInOrderDrawBuffer::StencilPath::execute(GrInOrderDrawBuffer* buf, const S
|
||||
void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf, const SetState* state) {
|
||||
SkASSERT(state);
|
||||
DrawArgs args(state->fPrimitiveProcessor.get(), &state->fState, &state->fDesc,
|
||||
&state->fBatchTracker, state->fDrawType);
|
||||
&state->fBatchTracker);
|
||||
buf->getGpu()->drawPath(args, this->path(), fStencilSettings);
|
||||
}
|
||||
|
||||
void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf, const SetState* state) {
|
||||
SkASSERT(state);
|
||||
DrawArgs args(state->fPrimitiveProcessor.get(), &state->fState, &state->fDesc,
|
||||
&state->fBatchTracker, state->fDrawType);
|
||||
&state->fBatchTracker);
|
||||
buf->getGpu()->drawPaths(args, this->pathRange(),
|
||||
&buf->fPathIndexBuffer[fIndicesLocation], fIndexType,
|
||||
&buf->fPathTransformBuffer[fTransformsLocation], fTransformType,
|
||||
@ -521,12 +516,11 @@ bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst,
|
||||
|
||||
bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds,
|
||||
const GrPrimitiveProcessor* primProc,
|
||||
GrGpu::DrawType drawType,
|
||||
const GrScissorState& scissor,
|
||||
const GrDeviceCoordTexture* dstCopy) {
|
||||
SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState,
|
||||
(ds, primProc, *this->getGpu()->caps(), scissor,
|
||||
dstCopy, drawType));
|
||||
dstCopy));
|
||||
if (ss->fState.mustSkip()) {
|
||||
fCmdBuffer.pop_back();
|
||||
return false;
|
||||
@ -536,7 +530,6 @@ bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds,
|
||||
ss->fState.getInitBatchTracker());
|
||||
|
||||
if (fPrevState &&
|
||||
fPrevState->fDrawType == ss->fDrawType &&
|
||||
fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker,
|
||||
*ss->fPrimitiveProcessor,
|
||||
ss->fBatchTracker) &&
|
||||
|
@ -181,12 +181,10 @@ private:
|
||||
struct SetState : public Cmd {
|
||||
SetState(const GrDrawState& drawState, const GrPrimitiveProcessor* primProc,
|
||||
const GrDrawTargetCaps& caps,
|
||||
const GrScissorState& scissor, const GrDeviceCoordTexture* dstCopy,
|
||||
GrGpu::DrawType drawType)
|
||||
const GrScissorState& scissor, const GrDeviceCoordTexture* dstCopy)
|
||||
: Cmd(kSetState_Cmd)
|
||||
, fPrimitiveProcessor(primProc)
|
||||
, fState(drawState, primProc, caps, scissor, dstCopy)
|
||||
, fDrawType(drawType) {}
|
||||
, fState(drawState, primProc, caps, scissor, dstCopy) {}
|
||||
|
||||
void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE;
|
||||
|
||||
@ -195,7 +193,6 @@ private:
|
||||
const GrOptDrawState fState;
|
||||
GrProgramDesc fDesc;
|
||||
GrBatchTracker fBatchTracker;
|
||||
GrGpu::DrawType fDrawType;
|
||||
};
|
||||
|
||||
typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
|
||||
@ -257,7 +254,6 @@ private:
|
||||
// recorded.
|
||||
bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&,
|
||||
const GrPrimitiveProcessor*,
|
||||
GrGpu::DrawType,
|
||||
const GrScissorState&,
|
||||
const GrDeviceCoordTexture*);
|
||||
// We lazily record clip changes in order to skip clips that have no effect.
|
||||
|
@ -66,7 +66,6 @@ public:
|
||||
void buildProgramDesc(GrProgramDesc*,const GrPrimitiveProcessor&,
|
||||
const GrOptDrawState&,
|
||||
const GrProgramDesc::DescInfo&,
|
||||
GrGpu::DrawType,
|
||||
const GrBatchTracker&) const SK_OVERRIDE {}
|
||||
|
||||
void discard(GrRenderTarget*) SK_OVERRIDE {}
|
||||
|
@ -1336,7 +1336,7 @@ void GrGLGpu::flushScissor(const GrScissorState& scissorState,
|
||||
this->disableScissor();
|
||||
}
|
||||
|
||||
bool GrGLGpu::flushGLState(const DrawArgs& args) {
|
||||
bool GrGLGpu::flushGLState(const DrawArgs& args, bool isLineDraw) {
|
||||
GrXferProcessor::BlendInfo blendInfo;
|
||||
const GrOptDrawState& optState = *args.fOptState;
|
||||
args.fOptState->getXferProcessor()->getBlendInfo(&blendInfo);
|
||||
@ -1368,8 +1368,7 @@ bool GrGLGpu::flushGLState(const DrawArgs& args) {
|
||||
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTarget());
|
||||
this->flushStencil(optState.getStencil());
|
||||
this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->origin());
|
||||
this->flushHWAAState(glRT, optState.isHWAntialiasState(),
|
||||
kDrawLines_DrawType == args.fDrawType);
|
||||
this->flushHWAAState(glRT, optState.isHWAntialiasState(), isLineDraw);
|
||||
|
||||
// This must come after textures are flushed because a texture may need
|
||||
// to be msaa-resolved (which will modify bound FBO state).
|
||||
@ -1435,9 +1434,8 @@ void GrGLGpu::buildProgramDesc(GrProgramDesc* desc,
|
||||
const GrPrimitiveProcessor& primProc,
|
||||
const GrOptDrawState& optState,
|
||||
const GrProgramDesc::DescInfo& descInfo,
|
||||
GrGpu::DrawType drawType,
|
||||
const GrBatchTracker& batchTracker) const {
|
||||
if (!GrGLProgramDescBuilder::Build(desc, primProc, optState, descInfo, drawType, this,
|
||||
if (!GrGLProgramDescBuilder::Build(desc, primProc, optState, descInfo, this,
|
||||
batchTracker)) {
|
||||
SkDEBUGFAIL("Failed to generate GL program descriptor");
|
||||
}
|
||||
@ -1827,7 +1825,7 @@ GrGLenum gPrimitiveType2GLMode[] = {
|
||||
#endif
|
||||
|
||||
void GrGLGpu::onDraw(const DrawArgs& args, const GrDrawTarget::DrawInfo& info) {
|
||||
if (!this->flushGLState(args)) {
|
||||
if (!this->flushGLState(args, GrIsPrimTypeLines(info.primitiveType()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1880,7 +1878,7 @@ void GrGLGpu::onStencilPath(const GrPath* path, const StencilPathState& state) {
|
||||
|
||||
void GrGLGpu::onDrawPath(const DrawArgs& args, const GrPath* path,
|
||||
const GrStencilSettings& stencil) {
|
||||
if (!this->flushGLState(args)) {
|
||||
if (!this->flushGLState(args, false)) {
|
||||
return;
|
||||
}
|
||||
fPathRendering->drawPath(path, stencil);
|
||||
@ -1894,7 +1892,7 @@ void GrGLGpu::onDrawPaths(const DrawArgs& args,
|
||||
GrDrawTarget::PathTransformType transformType,
|
||||
int count,
|
||||
const GrStencilSettings& stencil) {
|
||||
if (!this->flushGLState(args)) {
|
||||
if (!this->flushGLState(args, false)) {
|
||||
return;
|
||||
}
|
||||
fPathRendering->drawPaths(pathRange, indices, indexType, transformValues,
|
||||
|
@ -108,7 +108,6 @@ public:
|
||||
const GrPrimitiveProcessor&,
|
||||
const GrOptDrawState&,
|
||||
const GrProgramDesc::DescInfo&,
|
||||
GrGpu::DrawType,
|
||||
const GrBatchTracker&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
@ -168,7 +167,9 @@ private:
|
||||
void setTextureUnit(int unitIdx);
|
||||
|
||||
// Flushes state from GrOptDrawState to GL. Returns false if the state couldn't be set.
|
||||
bool flushGLState(const DrawArgs&);
|
||||
// TODO we only have need to know if this is a line draw for flushing AA state on some buggy
|
||||
// hardware. Evaluate if this is really necessary anymore
|
||||
bool flushGLState(const DrawArgs&, bool isLineDraw);
|
||||
|
||||
// Sets up vertex attribute pointers and strides. On return indexOffsetInBytes gives the offset
|
||||
// an into the index buffer. It does not account for drawInfo.startIndex() but rather the start
|
||||
|
@ -90,7 +90,6 @@ bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
|
||||
const GrPrimitiveProcessor& primProc,
|
||||
const GrOptDrawState& optState,
|
||||
const GrProgramDesc::DescInfo& descInfo,
|
||||
GrGpu::DrawType drawType,
|
||||
const GrGLGpu* gpu,
|
||||
const GrBatchTracker& batchTracker) {
|
||||
// The descriptor is used as a cache key. Thus when a field of the
|
||||
|
@ -49,7 +49,6 @@ public:
|
||||
* this optstate.
|
||||
* @param DescInfo A descriptor info struct, generated by the optstate, which contains a number
|
||||
* of important facts about the program the built descriptor will represent
|
||||
* @param DrawType
|
||||
* @param GrGLGpu A GL Gpu, the caps and Gpu object are used to output processor specific
|
||||
* parts of the descriptor.
|
||||
* @param GrDeviceCoordTexture A dstCopy texture, which may be null if frame buffer fetch is
|
||||
@ -60,7 +59,6 @@ public:
|
||||
const GrPrimitiveProcessor&,
|
||||
const GrOptDrawState&,
|
||||
const GrProgramDesc::DescInfo&,
|
||||
GrGpu::DrawType,
|
||||
const GrGLGpu*,
|
||||
const GrBatchTracker&);
|
||||
};
|
||||
|
@ -74,7 +74,7 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const DrawArgs& args, GrGLGpu* gp
|
||||
|
||||
GrGLProgramBuilder* GrGLProgramBuilder::CreateProgramBuilder(const DrawArgs& args,
|
||||
GrGLGpu* gpu) {
|
||||
if (GrGpu::IsPathRenderingDrawType(args.fDrawType)) {
|
||||
if (args.fPrimitiveProcessor->isPathRendering()) {
|
||||
SkASSERT(gpu->glCaps().pathRenderingSupport() &&
|
||||
!args.fPrimitiveProcessor->willUseGeoShader() &&
|
||||
args.fPrimitiveProcessor->numAttribs() == 0);
|
||||
@ -396,7 +396,7 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
|
||||
|
||||
// Legacy nvpr will not compile with a vertex shader, but newer nvpr requires a dummy vertex
|
||||
// shader
|
||||
bool useNvpr = GrGpu::IsPathRenderingDrawType(this->drawType());
|
||||
bool useNvpr = primitiveProcessor().isPathRendering();
|
||||
if (!(useNvpr && fGpu->glCaps().nvprSupport() == GrGLCaps::kLegacy_NvprSupport)) {
|
||||
if (!fVS.compileAndAttachShaders(programID, &shadersToDelete)) {
|
||||
this->cleanupProgram(programID, shadersToDelete);
|
||||
|
@ -287,7 +287,6 @@ protected:
|
||||
const GrProgramDesc& desc() const { return *fArgs.fDesc; }
|
||||
const GrBatchTracker& batchTracker() const { return *fArgs.fBatchTracker; }
|
||||
const GrProgramDesc::KeyHeader& header() const { return fArgs.fDesc->header(); }
|
||||
GrGpu::DrawType drawType() const { return fArgs.fDrawType; }
|
||||
|
||||
// Generates a name for a variable. The generated string will be name prefixed by the prefix
|
||||
// char (unless the prefix is '\0'). It also mangles the name to be stage-specific if we're
|
||||
|
@ -272,9 +272,6 @@ bool GrDrawTarget::programUnitTest(int maxStages) {
|
||||
// if path rendering we have to setup a couple of things like the draw type
|
||||
bool usePathRendering = gpu->glCaps().pathRenderingSupport() && random.nextBool();
|
||||
|
||||
GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType :
|
||||
GrGpu::kDrawPoints_DrawType;
|
||||
|
||||
// twiddle drawstate knobs randomly
|
||||
bool hasGeometryProcessor = !usePathRendering;
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp;
|
||||
@ -320,9 +317,9 @@ bool GrDrawTarget::programUnitTest(int maxStages) {
|
||||
primProc->initBatchTracker(&bt, ods.getInitBatchTracker());
|
||||
|
||||
GrProgramDesc desc;
|
||||
gpu->buildProgramDesc(&desc, *primProc, ods, ods.descInfo(), drawType, bt);
|
||||
gpu->buildProgramDesc(&desc, *primProc, ods, ods.descInfo(), bt);
|
||||
|
||||
GrGpu::DrawArgs args(primProc, &ods, &desc, &bt, drawType);
|
||||
GrGpu::DrawArgs args(primProc, &ods, &desc, &bt);
|
||||
SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(args, gpu));
|
||||
|
||||
if (NULL == program.get()) {
|
||||
|
Loading…
Reference in New Issue
Block a user