diff options
author | joshualitt <joshualitt@chromium.org> | 2015-01-21 11:52:36 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-21 11:52:36 -0800 |
commit | 17e7314e0e3085ec6021997d7c0593c339ba6a2e (patch) | |
tree | d6711e665e1d309d3790dcfc6c7058bbf93f54d8 | |
parent | d4742fa550bafce5225cd267437eadef177c5945 (diff) |
remove drawtype
BUG=skia:
Review URL: https://codereview.chromium.org/862933005
-rw-r--r-- | src/gpu/GrGeometryProcessor.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrGeometryProcessor.h | 11 | ||||
-rw-r--r-- | src/gpu/GrGpu.h | 37 | ||||
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.cpp | 23 | ||||
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.h | 8 | ||||
-rw-r--r-- | src/gpu/GrTest.cpp | 1 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 14 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 5 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramDesc.cpp | 1 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramDesc.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.h | 1 | ||||
-rw-r--r-- | tests/GLProgramsTest.cpp | 7 |
13 files changed, 34 insertions, 82 deletions
diff --git a/src/gpu/GrGeometryProcessor.cpp b/src/gpu/GrGeometryProcessor.cpp index 3980767b1b..75e6ed8166 100644 --- a/src/gpu/GrGeometryProcessor.cpp +++ b/src/gpu/GrGeometryProcessor.cpp @@ -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>(); } diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h index 97271b94d3..c55b9afc79 100644 --- a/src/gpu/GrGeometryProcessor.h +++ b/src/gpu/GrGeometryProcessor.h @@ -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) diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index 53ac9c3f91..5bbc3dcb05 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -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. diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index 1c7cb25271..5b1f00891e 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -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) && diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h index d94b3111ec..ea1279bc57 100644 --- a/src/gpu/GrInOrderDrawBuffer.h +++ b/src/gpu/GrInOrderDrawBuffer.h @@ -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. diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp index 3acf27ec2a..5ec4dcfa4f 100644 --- a/src/gpu/GrTest.cpp +++ b/src/gpu/GrTest.cpp @@ -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 {} diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index f489d03334..b28c32e68c 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -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, diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index d63c10500f..0173a23c48 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -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 diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp index 243be01acd..a89941c884 100644 --- a/src/gpu/gl/GrGLProgramDesc.cpp +++ b/src/gpu/gl/GrGLProgramDesc.cpp @@ -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 diff --git a/src/gpu/gl/GrGLProgramDesc.h b/src/gpu/gl/GrGLProgramDesc.h index 3b8093d53d..0584082a83 100644 --- a/src/gpu/gl/GrGLProgramDesc.h +++ b/src/gpu/gl/GrGLProgramDesc.h @@ -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&); }; diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index c26a72ec50..9fbb4c1953 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -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); diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h index 37cd57f164..612791e078 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.h +++ b/src/gpu/gl/builders/GrGLProgramBuilder.h @@ -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 diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 3d1f5e24f2..638e229caf 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -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()) { |