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..476f174cdc8e542ccfa579b153b450d826138143 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,25 @@ 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(); |
+ SkAutoTUnref<GrOptDrawState> optState(this->getDrawState().createOptState()); |
// 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 +231,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.get(), |
type, |
- blendOpts, |
srcCoeff, |
dstCoeff, |
this, |
@@ -263,8 +265,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.get(), |
+ type, |
geometryProcessor, |
colorStages.begin(), |
coverageStages.begin(), |
@@ -272,15 +274,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 |
@@ -291,8 +293,9 @@ bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC |
} |
void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) { |
+ SkAutoTUnref<GrOptDrawState> optState(this->getDrawState().createOptState()); |
- GrGLsizei stride = static_cast<GrGLsizei>(this->getDrawState().getVertexStride()); |
+ GrGLsizei stride = static_cast<GrGLsizei>(optState->getVertexStride()); |
size_t vertexOffsetInBytes = stride * info.startVertex(); |
@@ -346,16 +349,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 +366,6 @@ void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) { |
stride, |
reinterpret_cast<GrGLvoid*>( |
vertexOffsetInBytes + vertexAttrib->fOffset)); |
- } |
} |
attribState->disableUnusedArrays(this, usedAttribArraysMask); |
} |