remove drawType from optState
BUG=skia: Review URL: https://codereview.chromium.org/864853002
This commit is contained in:
parent
fb62b3d423
commit
b77e4b6bf0
@ -366,17 +366,20 @@ public:
|
||||
DrawArgs(const GrPrimitiveProcessor* primProc,
|
||||
const GrOptDrawState* optState,
|
||||
const GrProgramDesc* desc,
|
||||
const GrBatchTracker* batchTracker)
|
||||
const GrBatchTracker* batchTracker,
|
||||
DrawType drawType)
|
||||
: fPrimitiveProcessor(primProc)
|
||||
, fOptState(optState)
|
||||
, fDesc(desc)
|
||||
, fBatchTracker(batchTracker) {
|
||||
, fBatchTracker(batchTracker)
|
||||
, fDrawType(drawType) {
|
||||
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&);
|
||||
|
@ -435,7 +435,7 @@ void GrInOrderDrawBuffer::onFlush() {
|
||||
SetState* ss = reinterpret_cast<SetState*>(iter.get());
|
||||
|
||||
this->getGpu()->buildProgramDesc(&ss->fDesc, *ss->fPrimitiveProcessor, ss->fState,
|
||||
ss->fState.descInfo(), ss->fState.drawType(),
|
||||
ss->fState.descInfo(), ss->fDrawType,
|
||||
ss->fBatchTracker);
|
||||
currentState = ss;
|
||||
|
||||
@ -455,7 +455,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->fBatchTracker, state->fDrawType);
|
||||
buf->getGpu()->draw(args, fInfo);
|
||||
}
|
||||
|
||||
@ -473,14 +473,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->fBatchTracker, state->fDrawType);
|
||||
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->fBatchTracker, state->fDrawType);
|
||||
buf->getGpu()->drawPaths(args, this->pathRange(),
|
||||
&buf->fPathIndexBuffer[fIndicesLocation], fIndexType,
|
||||
&buf->fPathTransformBuffer[fTransformsLocation], fTransformType,
|
||||
@ -536,6 +536,7 @@ bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds,
|
||||
ss->fState.getInitBatchTracker());
|
||||
|
||||
if (fPrevState &&
|
||||
fPrevState->fDrawType == ss->fDrawType &&
|
||||
fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker,
|
||||
*ss->fPrimitiveProcessor,
|
||||
ss->fBatchTracker) &&
|
||||
|
@ -185,7 +185,8 @@ private:
|
||||
GrGpu::DrawType drawType)
|
||||
: Cmd(kSetState_Cmd)
|
||||
, fPrimitiveProcessor(primProc)
|
||||
, fState(drawState, primProc, caps, scissor, dstCopy, drawType) {}
|
||||
, fState(drawState, primProc, caps, scissor, dstCopy)
|
||||
, fDrawType(drawType) {}
|
||||
|
||||
void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE;
|
||||
|
||||
@ -194,6 +195,7 @@ 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.
|
||||
|
@ -17,10 +17,7 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
|
||||
const GrPrimitiveProcessor* primProc,
|
||||
const GrDrawTargetCaps& caps,
|
||||
const GrScissorState& scissorState,
|
||||
const GrDeviceCoordTexture* dstCopy,
|
||||
GrGpu::DrawType drawType) {
|
||||
fDrawType = drawType;
|
||||
|
||||
const GrDeviceCoordTexture* dstCopy) {
|
||||
const GrProcOptInfo& colorPOI = drawState.colorProcInfo(primProc);
|
||||
const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(primProc);
|
||||
|
||||
@ -145,7 +142,6 @@ bool GrOptDrawState::isEqual(const GrOptDrawState& that) const {
|
||||
this->fFragmentStages.count() != that.fFragmentStages.count() ||
|
||||
this->fNumColorStages != that.fNumColorStages ||
|
||||
this->fScissorState != that.fScissorState ||
|
||||
this->fDrawType != that.fDrawType ||
|
||||
this->fFlags != that.fFlags ||
|
||||
this->fStencilSettings != that.fStencilSettings ||
|
||||
this->fDrawFace != that.fDrawFace ||
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
|
||||
GrOptDrawState(const GrDrawState& drawState, const GrPrimitiveProcessor*,
|
||||
const GrDrawTargetCaps&, const GrScissorState&,
|
||||
const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType);
|
||||
const GrDeviceCoordTexture* dstCopy);
|
||||
|
||||
/*
|
||||
* Returns true if it is possible to combine the two GrOptDrawStates and it will update 'this'
|
||||
@ -128,8 +128,6 @@ public:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGpu::DrawType drawType() const { return fDrawType; }
|
||||
|
||||
const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ? &fDstCopy : NULL; }
|
||||
|
||||
const GrProgramDesc::DescInfo& descInfo() const { return fDescInfo; }
|
||||
@ -171,7 +169,6 @@ private:
|
||||
uint32_t fFlags;
|
||||
ProgramXferProcessor fXferProcessor;
|
||||
FragmentStageArray fFragmentStages;
|
||||
GrGpu::DrawType fDrawType;
|
||||
GrProgramDesc::DescInfo fDescInfo;
|
||||
GrGeometryProcessor::InitBT fInitBT;
|
||||
|
||||
|
@ -1369,7 +1369,7 @@ bool GrGLGpu::flushGLState(const DrawArgs& args) {
|
||||
this->flushStencil(optState.getStencil());
|
||||
this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->origin());
|
||||
this->flushHWAAState(glRT, optState.isHWAntialiasState(),
|
||||
kDrawLines_DrawType == optState.drawType());
|
||||
kDrawLines_DrawType == args.fDrawType);
|
||||
|
||||
// This must come after textures are flushed because a texture may need
|
||||
// to be msaa-resolved (which will modify bound FBO state).
|
||||
|
@ -142,7 +142,7 @@ void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrOptDrawS
|
||||
this->setFragmentData(primProc, optState);
|
||||
|
||||
// Some of GrGLProgram subclasses need to update state here
|
||||
this->didSetData(optState.drawType());
|
||||
this->didSetData();
|
||||
}
|
||||
|
||||
void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc,
|
||||
@ -169,10 +169,6 @@ void GrGLProgram::setTransformData(const GrPrimitiveProcessor& primProc,
|
||||
processor.processor()->coordTransforms());
|
||||
}
|
||||
|
||||
void GrGLProgram::didSetData(GrGpu::DrawType drawType) {
|
||||
SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType));
|
||||
}
|
||||
|
||||
void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
|
||||
const GrOptDrawState& optState) {
|
||||
// Load the RT height uniform if it is needed to y-flip gl_FragCoord.
|
||||
@ -215,8 +211,7 @@ GrGLNvprProgram::GrGLNvprProgram(GrGLGpu* gpu,
|
||||
: INHERITED(gpu, desc, builtinUniforms, programID, uniforms, primProc,
|
||||
xferProcessor, fragmentProcessors) {
|
||||
}
|
||||
void GrGLNvprProgram::didSetData(GrGpu::DrawType drawType) {
|
||||
SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
|
||||
void GrGLNvprProgram::didSetData() {
|
||||
GrGLPathProcessor* pathProc =
|
||||
static_cast<GrGLPathProcessor*>(fGeometryProcessor.get()->fGLProc.get());
|
||||
pathProc->didSetData(fGpu->glPathRendering());
|
||||
@ -234,8 +229,7 @@ void GrGLNvprProgram::setTransformData(const GrPrimitiveProcessor& primProc,
|
||||
|
||||
void GrGLNvprProgram::onSetRenderTargetState(const GrPrimitiveProcessor& primProc,
|
||||
const GrOptDrawState& optState) {
|
||||
SkASSERT(GrGpu::IsPathRenderingDrawType(optState.drawType()) &&
|
||||
!primProc.willUseGeoShader() && primProc.numAttribs() == 0);
|
||||
SkASSERT(!primProc.willUseGeoShader() && primProc.numAttribs() == 0);
|
||||
const GrRenderTarget* rt = optState.getRenderTarget();
|
||||
SkISize size;
|
||||
size.set(rt->width(), rt->height());
|
||||
|
@ -128,7 +128,7 @@ protected:
|
||||
* Legacy NVPR needs a hook here to flush path tex gen settings.
|
||||
* TODO when legacy nvpr is removed, remove this call.
|
||||
*/
|
||||
virtual void didSetData(GrGpu::DrawType);
|
||||
virtual void didSetData() {}
|
||||
|
||||
// Helper for setData() that sets the view matrix and loads the render target height uniform
|
||||
void setRenderTargetState(const GrPrimitiveProcessor&, const GrOptDrawState&);
|
||||
@ -175,7 +175,7 @@ protected:
|
||||
GrGLInstalledFragProcs* fragmentProcessors);
|
||||
|
||||
private:
|
||||
void didSetData(GrGpu::DrawType) SK_OVERRIDE;
|
||||
void didSetData() SK_OVERRIDE;
|
||||
virtual void setTransformData(const GrPrimitiveProcessor&,
|
||||
const GrPendingFragmentStage&,
|
||||
int index,
|
||||
|
@ -74,7 +74,7 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const DrawArgs& args, GrGLGpu* gp
|
||||
|
||||
GrGLProgramBuilder* GrGLProgramBuilder::CreateProgramBuilder(const DrawArgs& args,
|
||||
GrGLGpu* gpu) {
|
||||
if (GrGpu::IsPathRenderingDrawType(args.fOptState->drawType())) {
|
||||
if (GrGpu::IsPathRenderingDrawType(args.fDrawType)) {
|
||||
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->optState().drawType());
|
||||
bool useNvpr = GrGpu::IsPathRenderingDrawType(this->drawType());
|
||||
if (!(useNvpr && fGpu->glCaps().nvprSupport() == GrGLCaps::kLegacy_NvprSupport)) {
|
||||
if (!fVS.compileAndAttachShaders(programID, &shadersToDelete)) {
|
||||
this->cleanupProgram(programID, shadersToDelete);
|
||||
|
@ -287,6 +287,7 @@ 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
|
||||
|
@ -312,7 +312,7 @@ bool GrDrawTarget::programUnitTest(int maxStages) {
|
||||
|
||||
// create optimized draw state, setup readDst texture if required, and build a descriptor
|
||||
// and program. ODS creation can fail, so we have to check
|
||||
GrOptDrawState ods(ds, primProc, *gpu->caps(), scissor, &dstCopy, drawType);
|
||||
GrOptDrawState ods(ds, primProc, *gpu->caps(), scissor, &dstCopy);
|
||||
if (ods.mustSkip()) {
|
||||
continue;
|
||||
}
|
||||
@ -320,9 +320,9 @@ bool GrDrawTarget::programUnitTest(int maxStages) {
|
||||
primProc->initBatchTracker(&bt, ods.getInitBatchTracker());
|
||||
|
||||
GrProgramDesc desc;
|
||||
gpu->buildProgramDesc(&desc, *primProc, ods, ods.descInfo(), ods.drawType(), bt);
|
||||
gpu->buildProgramDesc(&desc, *primProc, ods, ods.descInfo(), drawType, bt);
|
||||
|
||||
GrGpu::DrawArgs args(primProc, &ods, &desc, &bt);
|
||||
GrGpu::DrawArgs args(primProc, &ods, &desc, &bt, drawType);
|
||||
SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(args, gpu));
|
||||
|
||||
if (NULL == program.get()) {
|
||||
|
Loading…
Reference in New Issue
Block a user