Bug Fix for Intel atan on gpu sweep gradient
BUG=skia:2164
R=bsalomon@google.com
Author: egdaniel@google.com
Review URL: https://codereview.chromium.org/152233006
git-svn-id: http://skia.googlecode.com/svn/trunk@13456 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 494569d..cb9d276 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -249,8 +249,18 @@
const TextureSamplerArray& samplers) {
this->emitUniforms(builder, key);
SkString coords2D = builder->ensureFSCoords2D(coords, 0);
+ const GrGLContextInfo ctxInfo = builder->ctxInfo();
SkString t;
- t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", coords2D.c_str(), coords2D.c_str());
+ // 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi]
+ // On Intel GPU there is an issue where it reads the second arguement to atan "- %s.x" as an int
+ // thus must us -1.0 * %s.x to work correctly
+ if (kIntel_GrGLVendor != ctxInfo.vendor()){
+ t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5",
+ coords2D.c_str(), coords2D.c_str());
+ } else {
+ t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5",
+ coords2D.c_str(), coords2D.c_str());
+ }
this->emitColor(builder, t.c_str(), key,
outputColor, inputColor, samplers);
}