Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Unified Diff: src/gpu/gl/GrGLProgramDesc.cpp

Issue 600483002: Use uniform color/coverage inputs when path rendering. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add assert Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLProgramDesc.cpp
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 5339937c1a8e0be49b32e02c2e3193ab6d8e40de..b7e03cad9f597e899034607deebddaa41da08c23 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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698