Workaround Mali static analysis bug
Comment describes it: Unless we do something to confuse their optimizer,
they will (incorrectly) deduce that uniform opaque color (modulated only
by a texture fetch) is always going to remain opaque. Then they skip
inserting their shader based blending code, turning SrcOver into Src.
Doing a max against zero is enough to squelch the optimization.
Bug: skia:
Change-Id: I74676cebb0b0c8d121da868dd8a88050e0cfcc0d
Reviewed-on: https://skia-review.googlesource.com/17924
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
index f39fff2..d32766c 100644
--- a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
@@ -9,6 +9,7 @@
#include "GrCoordTransform.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLUniformHandler.h"
#include "glsl/GrGLSLVertexShaderBuilder.h"
@@ -46,6 +47,9 @@
"Color",
&stagedLocalVarName);
fragBuilder->codeAppendf("%s = %s;", outputName, stagedLocalVarName);
+ if (fragBuilder->getProgramBuilder()->shaderCaps()->mustObfuscateUniformColor()) {
+ fragBuilder->codeAppendf("%s = max(%s, vec4(0, 0, 0, 0));", outputName, outputName);
+ }
}
//////////////////////////////////////////////////////////////////////////////