Chromium Code Reviews| Index: src/gpu/gl/GrGpuGL_program.cpp |
| diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp |
| index be21abf3e9817a14a5722ac3dc62a7c91e7e36f0..04152c86677d8831316be2a08ee5962b494b0ab8 100644 |
| --- a/src/gpu/gl/GrGpuGL_program.cpp |
| +++ b/src/gpu/gl/GrGpuGL_program.cpp |
| @@ -9,8 +9,9 @@ |
| #include "GrEffect.h" |
| #include "GrGLEffect.h" |
| -#include "SkRTConf.h" |
| #include "GrGLPathRendering.h" |
| +#include "GrOptDrawState.h" |
| +#include "SkRTConf.h" |
| #include "SkTSearch.h" |
| #ifdef PROGRAM_CACHE_STATS |
| @@ -204,23 +205,26 @@ GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc, |
| #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) |
| bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstCopy) { |
| - const GrDrawState& drawState = this->getDrawState(); |
| + const GrOptDrawState& optState = *this->getDrawState().createOptState(); |
| + optState.unref(); |
|
bsalomon
2014/09/15 14:04:34
This seems really dangerous... it is assuming an i
egdaniel
2014/09/15 17:51:35
Done.
|
| // GrGpu::setupClipAndFlushState should have already checked this and bailed if not true. |
| - SkASSERT(drawState.getRenderTarget()); |
| + SkASSERT(optState.getRenderTarget()); |
| if (kStencilPath_DrawType == type) { |
| - const GrRenderTarget* rt = this->getDrawState().getRenderTarget(); |
| + const GrRenderTarget* rt = optState.getRenderTarget(); |
| SkISize size; |
| size.set(rt->width(), rt->height()); |
| - this->glPathRendering()->setProjectionMatrix(drawState.getViewMatrix(), size, rt->origin()); |
| + this->glPathRendering()->setProjectionMatrix(optState.getViewMatrix(), size, rt->origin()); |
| } else { |
| this->flushMiscFixedFunctionState(); |
| - GrBlendCoeff srcCoeff; |
| - GrBlendCoeff dstCoeff; |
| - GrDrawState::BlendOptFlags blendOpts = drawState.getBlendOpts(false, &srcCoeff, &dstCoeff); |
| - if (GrDrawState::kSkipDraw_BlendOptFlag & blendOpts) { |
| + GrBlendCoeff srcCoeff = optState.getSrcBlendCoeff(); |
| + GrBlendCoeff dstCoeff = optState.getDstBlendCoeff(); |
| + |
| + // In these blend coeff's we end up drawing nothing so we can skip draw all together |
| + if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff && |
| + !optState.getStencil().doesWrite()) { |
| return false; |
| } |
| @@ -228,9 +232,8 @@ bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC |
| SkSTArray<8, const GrEffectStage*, true> colorStages; |
| SkSTArray<8, const GrEffectStage*, true> coverageStages; |
| GrGLProgramDesc desc; |
| - if (!GrGLProgramDesc::Build(this->getDrawState(), |
| + if (!GrGLProgramDesc::Build(optState, |
| type, |
| - blendOpts, |
| srcCoeff, |
| dstCoeff, |
| this, |
| @@ -263,8 +266,8 @@ bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC |
| fCurrentProgram->overrideBlend(&srcCoeff, &dstCoeff); |
| this->flushBlend(kDrawLines_DrawType == type, srcCoeff, dstCoeff); |
| - fCurrentProgram->setData(type, |
| - blendOpts, |
| + fCurrentProgram->setData(optState, |
| + type, |
| geometryProcessor, |
| colorStages.begin(), |
| coverageStages.begin(), |
| @@ -272,15 +275,15 @@ bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC |
| &fSharedGLProgramState); |
| } |
| - GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(drawState.getRenderTarget()); |
| + GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTarget()); |
| this->flushStencil(type); |
| this->flushScissor(glRT->getViewport(), glRT->origin()); |
| this->flushAAState(type); |
| SkIRect* devRect = NULL; |
| SkIRect devClipBounds; |
| - if (drawState.isClipState()) { |
| - this->getClip()->getConservativeBounds(drawState.getRenderTarget(), &devClipBounds); |
| + if (optState.isClipState()) { |
| + this->getClip()->getConservativeBounds(optState.getRenderTarget(), &devClipBounds); |
| devRect = &devClipBounds; |
| } |
| // This must come after textures are flushed because a texture may need |
| @@ -292,7 +295,10 @@ bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC |
| void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) { |
| - GrGLsizei stride = static_cast<GrGLsizei>(this->getDrawState().getVertexStride()); |
| + const GrOptDrawState& optState = *this->getDrawState().createOptState(); |
| + optState.unref(); |
|
bsalomon
2014/09/15 14:04:34
ditto
egdaniel
2014/09/15 17:51:35
Done.
|
| + |
| + GrGLsizei stride = static_cast<GrGLsizei>(optState.getVertexStride()); |
| size_t vertexOffsetInBytes = stride * info.startVertex(); |
| @@ -346,16 +352,12 @@ void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) { |
| fHWGeometryState.bindArrayAndBuffersToDraw(this, vbuf, ibuf); |
| if (fCurrentProgram->hasVertexShader()) { |
| - int vertexAttribCount = this->getDrawState().getVertexAttribCount(); |
| + int vertexAttribCount = optState.getVertexAttribCount(); |
| uint32_t usedAttribArraysMask = 0; |
| - const GrVertexAttrib* vertexAttrib = this->getDrawState().getVertexAttribs(); |
| - |
| - bool canIgnoreColorAttrib = this->getDrawState().canIgnoreColorAttribute(); |
| + const GrVertexAttrib* vertexAttrib = optState.getVertexAttribs(); |
| for (int vertexAttribIndex = 0; vertexAttribIndex < vertexAttribCount; |
| ++vertexAttribIndex, ++vertexAttrib) { |
| - |
| - if (kColor_GrVertexAttribBinding != vertexAttrib->fBinding || !canIgnoreColorAttrib) { |
| usedAttribArraysMask |= (1 << vertexAttribIndex); |
| GrVertexAttribType attribType = vertexAttrib->fType; |
| attribState->set(this, |
| @@ -367,7 +369,6 @@ void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) { |
| stride, |
| reinterpret_cast<GrGLvoid*>( |
| vertexOffsetInBytes + vertexAttrib->fOffset)); |
| - } |
| } |
| attribState->disableUnusedArrays(this, usedAttribArraysMask); |
| } |