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

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

Issue 679363002: Revert of Patch to remove constant attributes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLProgram.cpp
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index bfa5f3cbc155e7f18581e361933653d40bdaf357..2d9b569333a03c7ac11f13c9f8606074b9dcc677 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -129,12 +129,13 @@
void GrGLProgram::setData(const GrOptDrawState& optState,
GrGpu::DrawType drawType,
- const GrDeviceCoordTexture* dstCopy) {
+ const GrDeviceCoordTexture* dstCopy,
+ SharedGLState* sharedState) {
GrColor color = optState.getColor();
GrColor coverage = optState.getCoverageColor();
- this->setColor(optState, color);
- this->setCoverage(optState, coverage);
+ this->setColor(optState, color, sharedState);
+ this->setCoverage(optState, coverage, sharedState);
this->setMatrixAndRenderTargetHeight(drawType, optState);
if (dstCopy) {
@@ -200,49 +201,80 @@
SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType));
}
-void GrGLProgram::setColor(const GrOptDrawState& optState, GrColor color) {
+void GrGLProgram::setColor(const GrOptDrawState& optState,
+ GrColor color,
+ SharedGLState* sharedState) {
const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader();
- switch (header.fColorInput) {
- case GrGLProgramDesc::kAttribute_ColorInput:
- // Attribute case is handled in GrGpuGL::setupGeometry
- break;
- case GrGLProgramDesc::kUniform_ColorInput:
- if (fColor != color && fBuiltinUniformHandles.fColorUni.isValid()) {
- // OpenGL ES doesn't support unsigned byte varieties of glUniform
- GrGLfloat c[4];
- GrColorToRGBAFloat(color, c);
- fProgramDataManager.set4fv(fBuiltinUniformHandles.fColorUni, 1, c);
- fColor = color;
- }
- break;
- case GrGLProgramDesc::kAllOnes_ColorInput:
- // Handled by shader creation
- break;
- default:
- SkFAIL("Unexpected color type.");
- }
-}
-
-void GrGLProgram::setCoverage(const GrOptDrawState& optState, GrColor coverage) {
+ if (!optState.hasColorVertexAttribute()) {
+ switch (header.fColorInput) {
+ case GrGLProgramDesc::kAttribute_ColorInput:
+ SkASSERT(-1 != header.fColorAttributeIndex);
+ if (sharedState->fConstAttribColor != color ||
+ sharedState->fConstAttribColorIndex != header.fColorAttributeIndex) {
+ // OpenGL ES only supports the float varieties of glVertexAttrib
+ GrGLfloat c[4];
+ GrColorToRGBAFloat(color, c);
+ GL_CALL(VertexAttrib4fv(header.fColorAttributeIndex, c));
+ sharedState->fConstAttribColor = color;
+ sharedState->fConstAttribColorIndex = header.fColorAttributeIndex;
+ }
+ break;
+ case GrGLProgramDesc::kUniform_ColorInput:
+ if (fColor != color && fBuiltinUniformHandles.fColorUni.isValid()) {
+ // OpenGL ES doesn't support unsigned byte varieties of glUniform
+ GrGLfloat c[4];
+ GrColorToRGBAFloat(color, c);
+ fProgramDataManager.set4fv(fBuiltinUniformHandles.fColorUni, 1, c);
+ fColor = color;
+ }
+ sharedState->fConstAttribColorIndex = -1;
+ break;
+ case GrGLProgramDesc::kAllOnes_ColorInput:
+ sharedState->fConstAttribColorIndex = -1;
+ break;
+ default:
+ SkFAIL("Unexpected color type.");
+ }
+ } else {
+ sharedState->fConstAttribColorIndex = -1;
+ }
+}
+
+void GrGLProgram::setCoverage(const GrOptDrawState& optState,
+ GrColor coverage,
+ SharedGLState* sharedState) {
const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader();
- switch (header.fCoverageInput) {
- case GrGLProgramDesc::kAttribute_ColorInput:
- // Attribute case is handled in GrGpuGL::setupGeometry
- break;
- case GrGLProgramDesc::kUniform_ColorInput:
- if (fCoverage != coverage) {
- // OpenGL ES doesn't support unsigned byte varieties of glUniform
- GrGLfloat c[4];
- GrColorToRGBAFloat(coverage, c);
- fProgramDataManager.set4fv(fBuiltinUniformHandles.fCoverageUni, 1, c);
- fCoverage = coverage;
- }
- break;
- case GrGLProgramDesc::kAllOnes_ColorInput:
- // Handled by shader creation
- break;
- default:
- SkFAIL("Unexpected coverage type.");
+ if (!optState.hasCoverageVertexAttribute()) {
+ switch (header.fCoverageInput) {
+ case GrGLProgramDesc::kAttribute_ColorInput:
+ if (sharedState->fConstAttribCoverage != coverage ||
+ sharedState->fConstAttribCoverageIndex != header.fCoverageAttributeIndex) {
+ // OpenGL ES only supports the float varieties of glVertexAttrib
+ GrGLfloat c[4];
+ GrColorToRGBAFloat(coverage, c);
+ GL_CALL(VertexAttrib4fv(header.fCoverageAttributeIndex, c));
+ sharedState->fConstAttribCoverage = coverage;
+ sharedState->fConstAttribCoverageIndex = header.fCoverageAttributeIndex;
+ }
+ break;
+ case GrGLProgramDesc::kUniform_ColorInput:
+ if (fCoverage != coverage) {
+ // OpenGL ES doesn't support unsigned byte varieties of glUniform
+ GrGLfloat c[4];
+ GrColorToRGBAFloat(coverage, c);
+ fProgramDataManager.set4fv(fBuiltinUniformHandles.fCoverageUni, 1, c);
+ fCoverage = coverage;
+ }
+ sharedState->fConstAttribCoverageIndex = -1;
+ break;
+ case GrGLProgramDesc::kAllOnes_ColorInput:
+ sharedState->fConstAttribCoverageIndex = -1;
+ break;
+ default:
+ SkFAIL("Unexpected coverage type.");
+ }
+ } else {
+ sharedState->fConstAttribCoverageIndex = -1;
}
}
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698