Fix to allow ovals GM to finish on N7
R=jvanverth@google.com, robertphillips@google.com
Author: bsalomon@google.com
Review URL: https://chromiumcodereview.appspot.com/23477079
git-svn-id: http://skia.googlecode.com/svn/trunk@11340 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 16a3640..be6fdb0 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -980,9 +980,20 @@
} else if (GrGradientEffect::kThree_ColorType == ColorTypeFromKey(key)){
builder->fsCodeAppendf("\tfloat oneMinus2t = 1.0 - (2.0 * (%s));\n",
gradientTValue);
- builder->fsCodeAppendf("\tvec4 colorTemp = clamp(oneMinus2t, 0.0, 1.0) * %s +(1.0 - min(abs(oneMinus2t), 1.0)) * %s + clamp(-oneMinus2t, 0.0, 1.0) * %s;\n",
- builder->getUniformVariable(fColorStartUni).c_str(),
- builder->getUniformVariable(fColorMidUni).c_str(),
+ builder->fsCodeAppendf("\tvec4 colorTemp = clamp(oneMinus2t, 0.0, 1.0) * %s;\n",
+ builder->getUniformVariable(fColorStartUni).c_str());
+ if (kTegra3_GrGLRenderer == builder->ctxInfo().renderer()) {
+ // The Tegra3 compiler will sometimes never return if we have
+ // min(abs(oneMinus2t), 1.0), or do the abs first in a separate expression.
+ builder->fsCodeAppend("\tfloat minAbs = abs(oneMinus2t);\n");
+ builder->fsCodeAppend("\tminAbs = minAbs > 1.0 ? 1.0 : minAbs;\n");
+ builder->fsCodeAppendf("\tcolorTemp += (1.0 - minAbs) * %s;\n",
+ builder->getUniformVariable(fColorMidUni).c_str());
+ } else {
+ builder->fsCodeAppendf("\tcolorTemp += (1.0 - min(abs(oneMinus2t), 1.0)) * %s;\n",
+ builder->getUniformVariable(fColorMidUni).c_str());
+ }
+ builder->fsCodeAppendf("\tcolorTemp += clamp(-oneMinus2t, 0.0, 1.0) * %s;\n",
builder->getUniformVariable(fColorEndUni).c_str());
if (GrGradientEffect::kAfterInterp_PremulType == PremulTypeFromKey(key)) {
builder->fsCodeAppend("\tcolorTemp.rgb *= colorTemp.a;\n");
diff --git a/src/gpu/gl/GrGLContext.cpp b/src/gpu/gl/GrGLContext.cpp
index 93f3691..097fce2 100644
--- a/src/gpu/gl/GrGLContext.cpp
+++ b/src/gpu/gl/GrGLContext.cpp
@@ -13,6 +13,7 @@
fGLVersion = ctxInfo.fGLVersion;
fGLSLGeneration = ctxInfo.fGLSLGeneration;
fVendor = ctxInfo.fVendor;
+ fRenderer = ctxInfo.fRenderer;
fExtensions = ctxInfo.fExtensions;
fIsMesa = ctxInfo.fIsMesa;
*fGLCaps = *ctxInfo.fGLCaps.get();
@@ -38,6 +39,8 @@
fVendor = GrGLGetVendor(interface);
+ fRenderer = GrGLGetRenderer(interface);
+
fIsMesa = GrGLIsMesaFromVersionString(ver);
fGLCaps->init(*this, interface);
@@ -56,6 +59,7 @@
fGLVersion = GR_GL_VER(0, 0);
fGLSLGeneration = static_cast<GrGLSLGeneration>(0);
fVendor = kOther_GrGLVendor;
+ fRenderer = kOther_GrGLRenderer;
fIsMesa = false;
fExtensions.reset();
fGLCaps->reset();
diff --git a/src/gpu/gl/GrGLContext.h b/src/gpu/gl/GrGLContext.h
index ac9e9ed..b6e1ab3 100644
--- a/src/gpu/gl/GrGLContext.h
+++ b/src/gpu/gl/GrGLContext.h
@@ -47,6 +47,7 @@
GrGLVersion version() const { return fGLVersion; }
GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; }
GrGLVendor vendor() const { return fVendor; }
+ GrGLRenderer renderer() const { return fRenderer; }
/** Is this a mesa-based driver. Does not mean it is the osmesa software rasterizer. */
bool isMesa() const { return fIsMesa; }
const GrGLCaps* caps() const { return fGLCaps.get(); }
@@ -74,6 +75,7 @@
GrGLVersion fGLVersion;
GrGLSLGeneration fGLSLGeneration;
GrGLVendor fVendor;
+ GrGLRenderer fRenderer;
GrGLExtensions fExtensions;
bool fIsMesa;
SkAutoTUnref<GrGLCaps> fGLCaps;
diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp
index d6f5820..0e3d2a3 100644
--- a/src/gpu/gl/GrGLUtil.cpp
+++ b/src/gpu/gl/GrGLUtil.cpp
@@ -214,6 +214,15 @@
return kOther_GrGLVendor;
}
+GrGLRenderer GrGLGetRendererFromString(const char* rendererString) {
+ if (NULL != rendererString) {
+ if (0 == strcmp(rendererString, "NVIDIA Tegra 3")) {
+ return kTegra3_GrGLRenderer;
+ }
+ }
+ return kOther_GrGLRenderer;
+}
+
GrGLBinding GrGLGetBindingInUse(const GrGLInterface* gl) {
const GrGLubyte* v;
GR_GL_CALL_RET(gl, v, GetString(GR_GL_VERSION));
@@ -238,6 +247,12 @@
return GrGLGetVendorFromString((const char*) v);
}
+GrGLRenderer GrGLGetRenderer(const GrGLInterface* gl) {
+ const GrGLubyte* v;
+ GR_GL_CALL_RET(gl, v, GetString(GR_GL_RENDERER));
+ return GrGLGetRendererFromString((const char*) v);
+}
+
template<> void GrGLGetMatrix<3>(GrGLfloat* dest, const SkMatrix& src) {
// Col 0
dest[0] = SkScalarToFloat(src[SkMatrix::kMScaleX]);
diff --git a/src/gpu/gl/GrGLUtil.h b/src/gpu/gl/GrGLUtil.h
index 686943b..5bcf2f3 100644
--- a/src/gpu/gl/GrGLUtil.h
+++ b/src/gpu/gl/GrGLUtil.h
@@ -19,7 +19,7 @@
typedef uint32_t GrGLSLVersion;
/**
- * This list is lazily updated as required.
+ * The Vendor and Renderer enum values are lazily updated as required.
*/
enum GrGLVendor {
kARM_GrGLVendor,
@@ -30,6 +30,12 @@
kOther_GrGLVendor
};
+enum GrGLRenderer {
+ kTegra3_GrGLRenderer,
+
+ kOther_GrGLRenderer
+};
+
#define GR_GL_VER(major, minor) ((static_cast<int>(major) << 16) | \
static_cast<int>(minor))
#define GR_GLSL_VER(major, minor) ((static_cast<int>(major) << 16) | \
@@ -76,12 +82,14 @@
GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString);
bool GrGLIsMesaFromVersionString(const char* versionString);
GrGLVendor GrGLGetVendorFromString(const char* vendorString);
+GrGLRenderer GrGLGetRendererFromString(const char* rendererString);
// these variants call glGetString()
GrGLBinding GrGLGetBindingInUse(const GrGLInterface*);
GrGLVersion GrGLGetVersion(const GrGLInterface*);
GrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface*);
GrGLVendor GrGLGetVendor(const GrGLInterface*);
+GrGLRenderer GrGLGetRenderer(const GrGLInterface*);
/**
* Helpers for glGetError()