aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-18 13:00:28 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-18 13:00:28 +0000
commit0694ea7f6a16e946972b9c625f434e80eb42bb5f (patch)
tree8a93916e28e1954fc631258bfb2715707fef958c
parent688d362b4545e1beadebb7ba5886813d7038883c (diff)
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
-rw-r--r--src/effects/gradients/SkGradientShader.cpp17
-rw-r--r--src/gpu/gl/GrGLContext.cpp4
-rw-r--r--src/gpu/gl/GrGLContext.h2
-rw-r--r--src/gpu/gl/GrGLUtil.cpp15
-rw-r--r--src/gpu/gl/GrGLUtil.h10
5 files changed, 44 insertions, 4 deletions
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 16a3640e29..be6fdb036d 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -980,9 +980,20 @@ void GrGLGradientEffect::emitColor(GrGLShaderBuilder* builder,
} 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 93f369109a..097fce23e2 100644
--- a/src/gpu/gl/GrGLContext.cpp
+++ b/src/gpu/gl/GrGLContext.cpp
@@ -13,6 +13,7 @@ GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& ctxInfo) {
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 @@ bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
fVendor = GrGLGetVendor(interface);
+ fRenderer = GrGLGetRenderer(interface);
+
fIsMesa = GrGLIsMesaFromVersionString(ver);
fGLCaps->init(*this, interface);
@@ -56,6 +59,7 @@ void GrGLContextInfo::reset() {
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 ac9e9ed900..b6e1ab3942 100644
--- a/src/gpu/gl/GrGLContext.h
+++ b/src/gpu/gl/GrGLContext.h
@@ -47,6 +47,7 @@ public:
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 @@ private:
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 d6f5820781..0e3d2a3f7b 100644
--- a/src/gpu/gl/GrGLUtil.cpp
+++ b/src/gpu/gl/GrGLUtil.cpp
@@ -214,6 +214,15 @@ GrGLVendor GrGLGetVendorFromString(const char* vendorString) {
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 @@ GrGLVendor GrGLGetVendor(const GrGLInterface* gl) {
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 686943bdce..5bcf2f324c 100644
--- a/src/gpu/gl/GrGLUtil.h
+++ b/src/gpu/gl/GrGLUtil.h
@@ -19,7 +19,7 @@ typedef uint32_t GrGLVersion;
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 @@ enum GrGLVendor {
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 @@ GrGLBinding GrGLGetBindingInUseFromString(const char* versionString);
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()