From 4ed9ae4b230425df7735bc4a3778da00f63178de Mon Sep 17 00:00:00 2001 From: Stan Iliev Date: Tue, 25 Jul 2017 11:59:12 -0400 Subject: Improve GrGLNonlinearColorSpaceXformEffect to support scRGB Improve GrGLNonlinearColorSpaceXformEffect to correctly implement scRGB transfer function and allow for negative colors. Relax SkSurface_Gpu::Valid to allow kRGBA_half_GrPixelConfig render target without a color space needed for legacy blending on Android. Bug: b/62347704 Change-Id: Ibc6144e69c26cdbdcbf29348c4f612fb6b639e01 Reviewed-on: https://skia-review.googlesource.com/26143 Commit-Queue: Stan Iliev Reviewed-by: Brian Osman --- src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gpu/effects') diff --git a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp index bfa2ed77df..c0573e915a 100644 --- a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp +++ b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp @@ -63,7 +63,9 @@ public: transferFnBody.appendf("float E = %s[4];", coeffsName); transferFnBody.appendf("float F = %s[5];", coeffsName); transferFnBody.appendf("float G = %s[6];", coeffsName); - transferFnBody.appendf("return (x < D) ? (C * x) + F : pow(A * x + B, G) + E;"); + transferFnBody.append("float s = sign(x);"); + transferFnBody.append("x = abs(x);"); + transferFnBody.appendf("return s * ((x < D) ? (C * x) + F : pow(A * x + B, G) + E);"); fragBuilder->emitFunction(kFloat_GrSLType, fnName, SK_ARRAY_COUNT(gTransferFnFuncArgs), gTransferFnFuncArgs, transferFnBody.c_str(), &tfFuncNames[i]); } -- cgit v1.2.3