Revert r3054 for failing tests
git-svn-id: http://skia.googlecode.com/svn/trunk@3055 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index c736f1e..b8417ba 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -70,7 +70,6 @@
// memset exceptions
fColor = 0xffffffff;
- fCoverage = 0xffffffff;
fFirstCoverageStage = kNumStages;
fColorFilterMode = SkXfermode::kDst_Mode;
fSrcBlend = kOne_BlendCoeff;
@@ -79,9 +78,9 @@
// ensure values that will be memcmp'ed in == but not memset in reset()
// are tightly packed
- GrAssert(kMemsetSize + sizeof(fColor) + sizeof(fCoverage) +
- sizeof(fFirstCoverageStage) + sizeof(fColorFilterMode) +
- sizeof(fSrcBlend) + sizeof(fDstBlend) + sizeof(GrMatrix) ==
+ GrAssert(kMemsetSize + sizeof(fColor) + sizeof(fFirstCoverageStage) +
+ sizeof(fColorFilterMode) + sizeof(fSrcBlend) +
+ sizeof(fDstBlend) + sizeof(GrMatrix) ==
reinterpret_cast<intptr_t>(&fEdgeAANumEdges) -
reinterpret_cast<intptr_t>(this));
@@ -126,33 +125,6 @@
/// @}
///////////////////////////////////////////////////////////////////////////
- /// @name Coverage
- ////
-
- /**
- * Sets a constant fractional coverage to be applied to the draw. The
- * initial value (after construction or reset()) is 0xff. The constant
- * coverage is ignored when per-vertex coverage is provided.
- */
- void setCoverage(uint8_t coverage) {
- fCoverage = GrColorPackRGBA(coverage, coverage, coverage, coverage);
- }
-
- /**
- * Version of above that specifies 4 channel per-vertex color. The value
- * should be premultiplied.
- */
- void setCoverage4(GrColor coverage) {
- fCoverage = coverage;
- }
-
- GrColor getCoverage() const {
- return fCoverage;
- }
-
- /// @}
-
- ///////////////////////////////////////////////////////////////////////////
/// @name Textures
////
@@ -781,7 +753,6 @@
// @{ Initialized to values other than zero
GrColor fColor;
- GrColor fCoverage;
int fFirstCoverageStage;
SkXfermode::Mode fColorFilterMode;
GrBlendCoeff fSrcBlend;
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index fa266d1..be6bd0a 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -885,10 +885,8 @@
// When coeffs are (0,1) there is no reason to draw at all, unless
// stenciling is enabled. Having color writes disabled is effectively
- // (0,1). The same applies when coverage is known to be 0.
- if ((kZero_BlendCoeff == *srcCoeff && dstCoeffIsOne) ||
- (!(layout & kCoverage_VertexLayoutBit) &&
- 0 == drawState.getCoverage())) {
+ // (0,1).
+ if ((kZero_BlendCoeff == *srcCoeff && dstCoeffIsOne)) {
if (drawState.getStencil().doesWrite()) {
return kDisableBlend_BlendOptFlag |
kEmitTransBlack_BlendOptFlag;
@@ -897,10 +895,8 @@
}
}
- // check for coverage due to constant coverage, per-vertex coverage,
- // edge aa or coverage texture stage
+ // check for coverage due to edge aa or coverage texture stage
bool hasCoverage = forceCoverage ||
- 0xffffffff != drawState.getCoverage() ||
drawState.getNumAAEdges() > 0 ||
(layout & kCoverage_VertexLayoutBit) ||
(layout & kEdge_VertexLayoutBit);
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 5fc420d..2635ddd 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -239,7 +239,8 @@
enum VertexLayoutBits {
/* vertices have colors (GrColor) */
kColor_VertexLayoutBit = 1 << (STAGE_BIT_CNT + 0),
- /* vertices have coverage (GrColor)
+ /* vertices have coverage (GrColor where all channels should have the
+ * same value)
*/
kCoverage_VertexLayoutBit = 1 << (STAGE_BIT_CNT + 1),
/* Use text vertices. (Pos and tex coords may be a different type for
diff --git a/src/gpu/GrGLProgram.cpp b/src/gpu/GrGLProgram.cpp
index 7acdd29..d159f5a 100644
--- a/src/gpu/GrGLProgram.cpp
+++ b/src/gpu/GrGLProgram.cpp
@@ -92,7 +92,6 @@
#define COV_ATTR_NAME "aCoverage"
#define EDGE_ATTR_NAME "aEdge"
#define COL_UNI_NAME "uColor"
-#define COV_UNI_NAME "uCoverage"
#define EDGES_UNI_NAME "uEdges"
#define COL_FILTER_UNI_NAME "uColorFilter"
#define COL_MATRIX_UNI_NAME "uColorMatrix"
@@ -612,37 +611,21 @@
}
}
-void genAttributeCoverage(ShaderCodeSegments* segments,
- GrStringBuilder* inOutCoverage) {
- segments->fVSAttrs.push_back().set(GrGLShaderVar::kVec4f_Type,
+void genPerVertexCoverage(ShaderCodeSegments* segments,
+ GrStringBuilder* inCoverage) {
+ segments->fVSAttrs.push_back().set(GrGLShaderVar::kFloat_Type,
GrGLShaderVar::kAttribute_TypeModifier,
COV_ATTR_NAME);
const char *vsName, *fsName;
- append_varying(GrGLShaderVar::kVec4f_Type, "Coverage",
+ append_varying(GrGLShaderVar::kFloat_Type, "Coverage",
segments, &vsName, &fsName);
segments->fVSCode.appendf("\t%s = " COV_ATTR_NAME ";\n", vsName);
- if (inOutCoverage->size()) {
- segments->fFSCode.appendf("\tvec4 attrCoverage = %s * %s;\n",
- fsName, inOutCoverage->c_str());
- *inOutCoverage = "attrCoverage";
+ if (inCoverage->size()) {
+ segments->fFSCode.appendf("\tfloat edgeAndAttrCov = %s * %s;\n",
+ fsName, inCoverage->c_str());
+ *inCoverage = "edgeAndAttrCov";
} else {
- *inOutCoverage = fsName;
- }
-}
-
-void genUniformCoverage(ShaderCodeSegments* segments,
- GrGLProgram::CachedData* programData,
- GrStringBuilder* inOutCoverage) {
- segments->fFSUnis.push_back().set(GrGLShaderVar::kVec4f_Type,
- GrGLShaderVar::kUniform_TypeModifier,
- COV_UNI_NAME);
- programData->fUniLocations.fCoverageUni = kUseUniform;
- if (inOutCoverage->size()) {
- segments->fFSCode.appendf("\tvec4 uniCoverage = %s * %s;\n",
- COV_UNI_NAME, inOutCoverage->c_str());
- *inOutCoverage = "uniCoverage";
- } else {
- *inOutCoverage = COV_UNI_NAME;
+ *inCoverage = fsName;
}
}
@@ -704,7 +687,6 @@
#endif
SkXfermode::Coeff colorCoeff, uniformCoeff;
- bool applyColorMatrix = SkToBool(fProgramDesc.fColorMatrixEnabled);
// The rest of transfer mode color filters have not been implemented
if (fProgramDesc.fColorFilterXfermode < SkXfermode::kCoeffModesCnt) {
GR_DEBUGCODE(bool success =)
@@ -717,13 +699,6 @@
uniformCoeff = SkXfermode::kZero_Coeff;
}
- // no need to do the color filter / matrix at all if coverage is 0
- if (ProgramDesc::kTransBlack_ColorInput == fProgramDesc.fCoverageInput) {
- colorCoeff = SkXfermode::kZero_Coeff;
- uniformCoeff = SkXfermode::kZero_Coeff;
- applyColorMatrix = false;
- }
-
// If we know the final color is going to be all zeros then we can
// simplify the color filter coeffecients. needComputedColor will then
// come out false below.
@@ -857,7 +832,7 @@
bool wroteFragColorZero = false;
if (SkXfermode::kZero_Coeff == uniformCoeff &&
SkXfermode::kZero_Coeff == colorCoeff &&
- !applyColorMatrix) {
+ !fProgramDesc.fColorMatrixEnabled) {
segments.fFSCode.appendf("\t%s = %s;\n",
fsColorOutput,
all_zeros_vec(4));
@@ -869,7 +844,7 @@
colorCoeff, color);
inColor = "filteredColor";
}
- if (applyColorMatrix) {
+ if (fProgramDesc.fColorMatrixEnabled) {
segments.fFSUnis.push_back().set(GrGLShaderVar::kMat44f_Type,
GrGLShaderVar::kUniform_TypeModifier,
COL_MATRIX_UNI_NAME);
@@ -897,20 +872,9 @@
// get edge AA coverage and use it as inCoverage to first coverage stage
this->genEdgeCoverage(gl, layout, programData, &inCoverage, &segments);
- switch (fProgramDesc.fCoverageInput) {
- case ProgramDesc::kSolidWhite_ColorInput:
- // empty string implies solid white
- break;
- case ProgramDesc::kTransBlack_ColorInput:
- GrCrash("We should have already written 0 as the frag output.");
- case ProgramDesc::kAttribute_ColorInput:
- genAttributeCoverage(&segments, &inCoverage);
- break;
- case ProgramDesc::kUniform_ColorInput:
- genUniformCoverage(&segments, programData, &inCoverage);
- break;
- default:
- GrCrash("Unexpected input coverage.");
+ // include explicit per-vertex coverage if we have it
+ if (GrDrawTarget::kCoverage_VertexLayoutBit & layout) {
+ genPerVertexCoverage(&segments, &inCoverage);
}
GrStringBuilder outCoverage;
@@ -1324,11 +1288,6 @@
GR_GL_CALL_RET(gl, programData->fUniLocations.fColorMatrixVecUni,
GetUniformLocation(progID, COL_MATRIX_VEC_UNI_NAME));
}
- if (kUseUniform == programData->fUniLocations.fCoverageUni) {
- GR_GL_CALL_RET(gl, programData->fUniLocations.fCoverageUni,
- GetUniformLocation(progID, COV_UNI_NAME));
- GrAssert(kUnusedUniform != programData->fUniLocations.fCoverageUni);
- }
if (kUseUniform == programData->fUniLocations.fEdgesUni) {
GR_GL_CALL_RET(gl, programData->fUniLocations.fEdgesUni,
diff --git a/src/gpu/GrGLProgram.h b/src/gpu/GrGLProgram.h
index 4d80f50..b4ad4af 100644
--- a/src/gpu/GrGLProgram.h
+++ b/src/gpu/GrGLProgram.h
@@ -211,7 +211,6 @@
#endif
uint8_t fColorInput; // casts to enum ColorInput
- uint8_t fCoverageInput; // casts to enum CoverageInput
uint8_t fOutputPM; // cases to enum OutputPM
uint8_t fDualSrcOutput; // casts to enum DualSrcOutput
int8_t fFirstCoverageStage;
@@ -262,7 +261,6 @@
struct UniLocations {
GrGLint fViewMatrixUni;
GrGLint fColorUni;
- GrGLint fCoverageUni;
GrGLint fEdgesUni;
GrGLint fColorFilterUni;
GrGLint fColorMatrixUni;
@@ -271,7 +269,6 @@
void reset() {
fViewMatrixUni = kUnusedUniform;
fColorUni = kUnusedUniform;
- fCoverageUni = kUnusedUniform;
fEdgesUni = kUnusedUniform;
fColorFilterUni = kUnusedUniform;
fColorMatrixUni = kUnusedUniform;
@@ -309,7 +306,6 @@
// these reflect the current values of uniforms
// (GL uniform values travel with program)
GrColor fColor;
- GrColor fCoverage;
GrColor fColorFilterColor;
GrMatrix fTextureMatrices[GrDrawState::kNumStages];
// width and height used for normalized texel size
diff --git a/src/gpu/GrGpuGLShaders.cpp b/src/gpu/GrGpuGLShaders.cpp
index b8e0999a..251fc41 100644
--- a/src/gpu/GrGpuGLShaders.cpp
+++ b/src/gpu/GrGpuGLShaders.cpp
@@ -198,7 +198,6 @@
pdesc.fVertexLayout = 0;
pdesc.fEmitsPointSize = random.nextF() > .5f;
pdesc.fColorInput = random_int(&random, ProgramDesc::kColorInputCnt);
- pdesc.fCoverageInput = random_int(&random, ProgramDesc::kColorInputCnt);
pdesc.fColorFilterXfermode = random_int(&random, SkXfermode::kCoeffModesCnt);
@@ -654,8 +653,7 @@
switch (desc.fColorInput) {
case ProgramDesc::kAttribute_ColorInput:
if (fHWDrawState.getColor() != color) {
- // OpenGL ES only supports the float varieties of
- // glVertexAttrib
+ // OpenGL ES only supports the float varities of glVertexAttrib
float c[] = GR_COLOR_TO_VEC4(color);
GL_CALL(VertexAttrib4fv(GrGLProgram::ColorAttributeIdx(),
c));
@@ -664,8 +662,7 @@
break;
case ProgramDesc::kUniform_ColorInput:
if (fProgramData->fColor != color) {
- // OpenGL ES doesn't support unsigned byte varieties of
- // glUniform
+ // OpenGL ES only supports the float varities of glVertexAttrib
float c[] = GR_COLOR_TO_VEC4(color);
GrAssert(GrGLProgram::kUnusedUniform !=
fProgramData->fUniLocations.fColorUni);
@@ -691,47 +688,6 @@
}
}
-void GrGpuGLShaders::flushCoverage(GrColor coverage) {
- const ProgramDesc& desc = fCurrentProgram.getDesc();
- const GrDrawState& drawState = this->getDrawState();
-
-
- if (this->getGeomSrc().fVertexLayout & kCoverage_VertexLayoutBit) {
- // coverage will be specified per-vertex as an attribute
- // invalidate the const vertex attrib coverage
- fHWDrawState.setCoverage4(GrColor_ILLEGAL);
- } else {
- switch (desc.fCoverageInput) {
- case ProgramDesc::kAttribute_ColorInput:
- if (fHWDrawState.getCoverage() != coverage) {
- // OpenGL ES only supports the float varieties of
- // glVertexAttrib
- float c[] = GR_COLOR_TO_VEC4(coverage);
- GL_CALL(VertexAttrib4fv(GrGLProgram::CoverageAttributeIdx(),
- c));
- fHWDrawState.setCoverage(coverage);
- }
- break;
- case ProgramDesc::kUniform_ColorInput:
- if (fProgramData->fCoverage != coverage) {
- // OpenGL ES doesn't support unsigned byte varieties of
- // glUniform
- float c[] = GR_COLOR_TO_VEC4(coverage);
- GrAssert(GrGLProgram::kUnusedUniform !=
- fProgramData->fUniLocations.fCoverageUni);
- GL_CALL(Uniform4fv(fProgramData->fUniLocations.fCoverageUni,
- 1, c));
- fProgramData->fCoverage = coverage;
- }
- break;
- case ProgramDesc::kSolidWhite_ColorInput:
- case ProgramDesc::kTransBlack_ColorInput:
- break;
- default:
- GrCrash("Unknown coverage type.");
- }
- }
-}
bool GrGpuGLShaders::flushGraphicsState(GrPrimitiveType type) {
if (!flushGLStateCommon(type)) {
@@ -770,19 +726,14 @@
this->flushBlend(type, srcCoeff, dstCoeff);
GrColor color;
- GrColor coverage;
if (blendOpts & kEmitTransBlack_BlendOptFlag) {
color = 0;
- coverage = 0;
} else if (blendOpts & kEmitCoverage_BlendOptFlag) {
color = 0xffffffff;
- coverage = drawState.getCoverage();
} else {
color = drawState.getColor();
- coverage = drawState.getCoverage();
}
this->flushColor(color);
- this->flushCoverage(coverage);
this->flushViewMatrix();
@@ -911,14 +862,15 @@
}
if (newCoverageOffset > 0) {
+ // bind a single channel, they should all have the same value.
GrGLvoid* coverageOffset = (int8_t*)(vertexOffset + newCoverageOffset);
int idx = GrGLProgram::CoverageAttributeIdx();
if (oldCoverageOffset <= 0) {
GL_CALL(EnableVertexAttribArray(idx));
- GL_CALL(VertexAttribPointer(idx, 4, GR_GL_UNSIGNED_BYTE,
+ GL_CALL(VertexAttribPointer(idx, 1, GR_GL_UNSIGNED_BYTE,
true, newStride, coverageOffset));
} else if (allOffsetsChange || newCoverageOffset != oldCoverageOffset) {
- GL_CALL(VertexAttribPointer(idx, 4, GR_GL_UNSIGNED_BYTE,
+ GL_CALL(VertexAttribPointer(idx, 1, GR_GL_UNSIGNED_BYTE,
true, newStride, coverageOffset));
}
} else if (oldCoverageOffset > 0) {
@@ -970,14 +922,10 @@
bool requiresAttributeColors =
!skipColor && SkToBool(desc.fVertexLayout & kColor_VertexLayoutBit);
- bool requiresAttributeCoverage =
- !skipCoverage && SkToBool(desc.fVertexLayout &
- kCoverage_VertexLayoutBit);
-
- // fColorInput/fCoverageInput records how colors are specified for the.
- // program. So we strip the bits from the layout to avoid false negatives
- // when searching for an existing program in the cache.
- desc.fVertexLayout &= ~(kColor_VertexLayoutBit | kCoverage_VertexLayoutBit);
+ // fColorInput records how colors are specified for the program. Strip
+ // the bit from the layout to avoid false negatives when searching for an
+ // existing program in the cache.
+ desc.fVertexLayout &= ~(kColor_VertexLayoutBit);
desc.fColorFilterXfermode = skipColor ?
SkXfermode::kDst_Mode :
@@ -1005,19 +953,6 @@
} else {
desc.fColorInput = ProgramDesc::kAttribute_ColorInput;
}
-
- bool covIsSolidWhite = !requiresAttributeCoverage &&
- 0xffffffff == drawState.getCoverage();
-
- if (skipCoverage) {
- desc.fCoverageInput = ProgramDesc::kTransBlack_ColorInput;
- } else if (covIsSolidWhite) {
- desc.fCoverageInput = ProgramDesc::kSolidWhite_ColorInput;
- } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresAttributeCoverage) {
- desc.fCoverageInput = ProgramDesc::kUniform_ColorInput;
- } else {
- desc.fCoverageInput = ProgramDesc::kAttribute_ColorInput;
- }
desc.fEdgeAANumEdges = skipCoverage ? 0 : drawState.getNumAAEdges();
desc.fEdgeAAConcave = desc.fEdgeAANumEdges > 0 &&
@@ -1166,7 +1101,7 @@
if (!hasCoverage) {
hasCoverage =
desc.fEdgeAANumEdges ||
- requiresAttributeCoverage ||
+ (desc.fVertexLayout & GrDrawTarget::kCoverage_VertexLayoutBit) ||
(desc.fVertexLayout & GrDrawTarget::kEdge_VertexLayoutBit);
}
diff --git a/src/gpu/GrGpuGLShaders.h b/src/gpu/GrGpuGLShaders.h
index d875fe9..4b972b5 100644
--- a/src/gpu/GrGpuGLShaders.h
+++ b/src/gpu/GrGpuGLShaders.h
@@ -57,12 +57,9 @@
// sets the texture domain uniform for currently bound program
void flushTextureDomain(int stage);
- // sets the color specified by GrDrawState::setColor()
+ // sets the color specified by GrDrawTarget::setColor()
void flushColor(GrColor color);
- // sets the color specified by GrDrawState::setCoverage()
- void flushCoverage(GrColor color);
-
// sets the MVP matrix uniform for currently bound program
void flushViewMatrix();