Refactor GrColorSpaceXformHelper
Nonlinear blending mode is going to (sometimes) require additional
uniforms and shader code for color space transformation.
This change just alters the usage of the helper struct so that we can
hide any new logic (without having to change all the FPs that use it).
BUG=skia:
Change-Id: I913478a387973f5bad5aa09a29f85d21daacab94
Reviewed-on: https://skia-review.googlesource.com/9414
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 5f06fc1..ec7ad79 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -32,7 +32,7 @@
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
UniformHandle fImageIncrementUni;
- UniformHandle fColorSpaceXformUni;
+ GrGLSLColorSpaceXformHelper fColorSpaceHelper;
GrTextureDomain::GLDomain fDomain;
typedef GrGLSLFragmentProcessor INHERITED;
@@ -48,8 +48,7 @@
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
- GrGLSLColorSpaceXformHelper colorSpaceHelper(uniformHandler, bicubicEffect.colorSpaceXform(),
- &fColorSpaceXformUni);
+ fColorSpaceHelper.emitCode(uniformHandler, bicubicEffect.colorSpaceXform());
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
@@ -107,9 +106,9 @@
y);
}
SkString bicubicColor("(wy.x * s0 + wy.y * s1 + wy.z * s2 + wy.w * s3)");
- if (colorSpaceHelper.getXformMatrix()) {
+ if (fColorSpaceHelper.isValid()) {
SkString xformedColor;
- fragBuilder->appendColorGamutXform(&xformedColor, bicubicColor.c_str(), &colorSpaceHelper);
+ fragBuilder->appendColorGamutXform(&xformedColor, bicubicColor.c_str(), &fColorSpaceHelper);
bicubicColor.swap(xformedColor);
}
fragBuilder->codeAppendf("%s = %s;",
@@ -127,7 +126,7 @@
pdman.set2fv(fImageIncrementUni, 1, imageIncrement);
fDomain.setData(pdman, bicubicEffect.domain(), texture);
if (SkToBool(bicubicEffect.colorSpaceXform())) {
- pdman.setSkMatrix44(fColorSpaceXformUni, bicubicEffect.colorSpaceXform()->srcToDst());
+ fColorSpaceHelper.setData(pdman, bicubicEffect.colorSpaceXform());
}
}