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

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

Issue 12462008: Add GrEllipseEdgeEffect (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 10 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
« src/gpu/effects/GrEllipseEdgeEffect.cpp ('K') | « src/gpu/gl/GrGLProgram.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLProgram.cpp
===================================================================
--- src/gpu/gl/GrGLProgram.cpp (revision 7952)
+++ src/gpu/gl/GrGLProgram.cpp (working copy)
@@ -125,6 +125,7 @@
desc->fDiscardIfOutsideEdge = false;
}
+ desc->fEffectAttributes.reset();
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
bool skip = s < drawState.getFirstCoverageStage() ? skipColor : skipCoverage;
@@ -133,6 +134,14 @@
const GrEffectRef& effect = *drawState.getStage(s).getEffect();
const GrBackendEffectFactory& factory = effect->getFactory();
desc->fEffectKeys[s] = factory.glEffectKey(drawState.getStage(s), gpu->glCaps());
+ int attrCount = drawState.getStage(s).getVertexAttribIndexCount();
+ GrAssert(attrCount == effect.get()->numVertexAttribs());
+ for (int i = 0; i < attrCount; ++i) {
+ Desc::AttribPair pair;
+ pair.fIndex = drawState.getStage(s).getVertexAttribIndices()[i];
+ pair.fName = effect.get()->vertexAttribName(i);
+ desc->fEffectAttributes.push_back(pair);
+ }
} else {
desc->fEffectKeys[s] = 0;
}
@@ -462,13 +471,6 @@
builder->fFSCode.appendf("\tfloat innerAlpha = %s.w == 0.0 ? 1.0 : smoothstep(%s.w - 0.5, %s.w + 0.5, d);\n", fsName, fsName, fsName);
builder->fFSCode.append("\tedgeAlpha = outerAlpha * innerAlpha;\n");
break;
- case GrDrawState::kEllipse_EdgeType:
- builder->fFSCode.append("\tfloat edgeAlpha;\n");
- builder->fFSCode.appendf("\tvec2 offset = (%s.xy - %s.xy);\n", builder->fragmentPosition(), fsName);
- builder->fFSCode.appendf("\toffset.y *= %s.w;\n", fsName);
- builder->fFSCode.append("\tfloat d = length(offset);\n");
- builder->fFSCode.appendf("\tedgeAlpha = smoothstep(d - 0.5, d + 0.5, %s.z);\n", fsName);
- break;
default:
GrCrash("Unknown Edge Type!");
break;
@@ -914,6 +916,11 @@
inCoverage = outCoverage;
}
}
+
+ // discard if coverage is zero
+ if (fDesc.fDiscardIfOutsideEdge && !outCoverage.isEmpty()) {
+ builder.fFSCode.appendf("\tif (all(lessThan(%s, vec4(0.0))) {\n\t\tdiscard;\n\t}\n", outCoverage.c_str());
+ }
}
if (Desc::kNone_DualSrcOutput != fDesc.fDualSrcOutput) {
@@ -1023,6 +1030,13 @@
GL_CALL(BindAttribLocation(fProgramID, fDesc.fTexCoordAttributeIndex, TEX_ATTR_NAME));
}
+ const Desc::AttribPair* attribEnd = fDesc.fEffectAttributes.end();
+ for (const Desc::AttribPair* attrib = fDesc.fEffectAttributes.begin();
+ attrib != attribEnd;
+ ++attrib) {
+ GL_CALL(BindAttribLocation(fProgramID, attrib->fIndex, attrib->fName));
+ }
+
GL_CALL(LinkProgram(fProgramID));
GrGLint linked = GR_GL_INIT_ZERO;
« src/gpu/effects/GrEllipseEdgeEffect.cpp ('K') | « src/gpu/gl/GrGLProgram.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698