avoid illegal enum values in GrGLGpu
This tracks the state of the blend equation and coefficients using an out-of-band bool rather than an illegal enum value. This was caught by -fsanitize=enum. This CL doesn't change the size of fHWBlendState. Change-Id: I8dbc8aaaa07e82186c148ceb19590390051eb296 Reviewed-on: https://skia-review.googlesource.com/146962 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
ed5e73cdf1
commit
7ca217b3b2
@ -2639,9 +2639,10 @@ void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo, const GrSw
|
||||
fHWBlendState.fEnabled = kYes_TriState;
|
||||
}
|
||||
|
||||
if (fHWBlendState.fEquation != equation) {
|
||||
if (!fHWBlendState.fEquationValid || fHWBlendState.fEquation != equation) {
|
||||
GL_CALL(BlendEquation(gXfermodeEquation2Blend[equation]));
|
||||
fHWBlendState.fEquation = equation;
|
||||
fHWBlendState.fEquationValid = true;
|
||||
}
|
||||
|
||||
if (GrBlendEquationIsAdvanced(equation)) {
|
||||
@ -2650,11 +2651,13 @@ void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo, const GrSw
|
||||
return;
|
||||
}
|
||||
|
||||
if (fHWBlendState.fSrcCoeff != srcCoeff || fHWBlendState.fDstCoeff != dstCoeff) {
|
||||
if (!fHWBlendState.fCoeffsValid || fHWBlendState.fSrcCoeff != srcCoeff
|
||||
|| fHWBlendState.fDstCoeff != dstCoeff) {
|
||||
GL_CALL(BlendFunc(gXfermodeCoeff2Blend[srcCoeff],
|
||||
gXfermodeCoeff2Blend[dstCoeff]));
|
||||
fHWBlendState.fSrcCoeff = srcCoeff;
|
||||
fHWBlendState.fDstCoeff = dstCoeff;
|
||||
fHWBlendState.fCoeffsValid = true;
|
||||
}
|
||||
|
||||
if ((BlendCoeffReferencesConstant(srcCoeff) || BlendCoeffReferencesConstant(dstCoeff))) {
|
||||
|
@ -558,13 +558,17 @@ private:
|
||||
GrBlendCoeff fSrcCoeff;
|
||||
GrBlendCoeff fDstCoeff;
|
||||
GrColor fConstColor;
|
||||
|
||||
bool fEquationValid;
|
||||
bool fCoeffsValid;
|
||||
bool fConstColorValid;
|
||||
/* there's a spare byte here */
|
||||
|
||||
TriState fEnabled;
|
||||
|
||||
void invalidate() {
|
||||
fEquation = static_cast<GrBlendEquation>(-1);
|
||||
fSrcCoeff = static_cast<GrBlendCoeff>(-1);
|
||||
fDstCoeff = static_cast<GrBlendCoeff>(-1);
|
||||
fEquationValid = false;
|
||||
fCoeffsValid = false;
|
||||
fConstColorValid = false;
|
||||
fEnabled = kUnknown_TriState;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user