Clamp premul colors correctly after a gamut change

Textures that we sample on the GPU are always premul, so we should
actually clamp to alpha.

Colors that are xformed on the CPU are always unpremul, so clamping to
[0,1] is correct. Add a comment explaining that.

BUG=skia:

Change-Id: I180f2d410f24afc78bd03ab8636a83fb443d68e2
Reviewed-on: https://skia-review.googlesource.com/6581
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.cpp b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
index e2cbdee..5609a9c 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
@@ -124,8 +124,9 @@
         GrShaderVar("xform", kMat44f_GrSLType),
     };
     SkString functionBody;
-    // Gamut xform, clamp to destination gamut
-    functionBody.append("\tcolor.rgb = clamp((xform * vec4(color.rgb, 1.0)).rgb, 0.0, 1.0);\n");
+    // Gamut xform, clamp to destination gamut. We only support/have premultiplied textures, so we
+    // always just clamp to alpha.
+    functionBody.append("\tcolor.rgb = clamp((xform * vec4(color.rgb, 1.0)).rgb, 0.0, color.a);\n");
     functionBody.append("\treturn color;");
     SkString colorGamutXformFuncName;
     this->emitFunction(kVec4f_GrSLType,