diff options
author | bsalomon <bsalomon@google.com> | 2014-09-23 08:19:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-23 08:19:00 -0700 |
commit | cd523ebe2be30f268cdcec2d0b59eba609b9901b (patch) | |
tree | 058676c737723a766a7ca9c24031006992cb3659 /src/gpu/gl/GrGLProgramDesc.cpp | |
parent | 033ea7f2ad65e567d1812546ef60e55a54ac88df (diff) |
Use uniform color/coverage inputs when path rendering.
BUG=skia:2954
R=egdaniel@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/600483002
Diffstat (limited to 'src/gpu/gl/GrGLProgramDesc.cpp')
-rw-r--r-- | src/gpu/gl/GrGLProgramDesc.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp index c356a8c6c2..5eef81bc3d 100644 --- a/src/gpu/gl/GrGLProgramDesc.cpp +++ b/src/gpu/gl/GrGLProgramDesc.cpp @@ -180,8 +180,6 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, // bindings in use or other descriptor field settings) it should be set // to a canonical value to avoid duplicate programs with different keys. - bool requiresColorAttrib = optState.hasColorVertexAttribute(); - bool requiresCoverageAttrib = optState.hasCoverageVertexAttribute(); bool requiresLocalCoordAttrib = optState.requiresLocalCoordAttrib(); int numStages = optState.numTotalStages(); @@ -260,10 +258,6 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, // Because header is a pointer into the dynamic array, we can't push any new data into the key // below here. - header->fUseFragShaderOnly = gpu->caps()->pathRenderingSupport() && - GrGpu::IsPathRenderingDrawType(drawType) && - gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunction_TexturingMode; - SkASSERT(!header->fUseFragShaderOnly || !optState.hasGeometryProcessor()); header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; @@ -276,26 +270,38 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, header->fExperimentalGS = false; #endif #endif - bool defaultToUniformInputs = GR_GL_NO_CONSTANT_ATTRIBUTES || header->fUseFragShaderOnly; + + if (gpu->caps()->pathRenderingSupport() && + GrGpu::IsPathRenderingDrawType(drawType) && + gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunction_TexturingMode) { + header->fUseFragShaderOnly = true; + SkASSERT(!optState.hasGeometryProcessor()); + } else { + header->fUseFragShaderOnly = false; + } + + bool defaultToUniformInputs = GrGpu::IsPathRenderingDrawType(drawType) || + GR_GL_NO_CONSTANT_ATTRIBUTES; if (!inputColorIsUsed) { header->fColorInput = kAllOnes_ColorInput; - } else if (defaultToUniformInputs && !requiresColorAttrib) { + } else if (defaultToUniformInputs && !optState.hasColorVertexAttribute()) { header->fColorInput = kUniform_ColorInput; } else { header->fColorInput = kAttribute_ColorInput; - header->fUseFragShaderOnly = false; + SkASSERT(!header->fUseFragShaderOnly); } - bool covIsSolidWhite = !requiresCoverageAttrib && 0xffffffff == optState.getCoverageColor(); + bool covIsSolidWhite = !optState.hasCoverageVertexAttribute() && + 0xffffffff == optState.getCoverageColor(); if (covIsSolidWhite || !inputCoverageIsUsed) { header->fCoverageInput = kAllOnes_ColorInput; - } else if (defaultToUniformInputs && !requiresCoverageAttrib) { + } else if (defaultToUniformInputs && !optState.hasCoverageVertexAttribute()) { header->fCoverageInput = kUniform_ColorInput; } else { header->fCoverageInput = kAttribute_ColorInput; - header->fUseFragShaderOnly = false; + SkASSERT(!header->fUseFragShaderOnly); } if (optState.readsDst()) { @@ -324,7 +330,7 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, // For constant color and coverage we need an attribute with an index beyond those already set int availableAttributeIndex = optState.getVertexAttribCount(); - if (requiresColorAttrib) { + if (optState.hasColorVertexAttribute()) { header->fColorAttributeIndex = optState.colorVertexAttributeIndex(); } else if (GrGLProgramDesc::kAttribute_ColorInput == header->fColorInput) { SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt); @@ -334,7 +340,7 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, header->fColorAttributeIndex = -1; } - if (requiresCoverageAttrib) { + if (optState.hasCoverageVertexAttribute()) { header->fCoverageAttributeIndex = optState.coverageVertexAttributeIndex(); } else if (GrGLProgramDesc::kAttribute_ColorInput == header->fCoverageInput) { SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt); |