GrColor4f GrColorSpaceXform::apply(const GrColor4f& srcColor) {
GrColor4f result;
fSrcToDst.mapScalars(srcColor.fRGBA, result.fRGBA);
+ // We always operate on unpremul colors, so clamp to [0,1].
for (int i = 0; i < 4; ++i) {
result.fRGBA[i] = SkTPin(result.fRGBA[i], 0.0f, 1.0f);
}
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,