diff options
Diffstat (limited to 'src/gpu/effects/GrDitherEffect.cpp')
-rw-r--r-- | src/gpu/effects/GrDitherEffect.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp index 6f5266e738..d78af4ee5a 100644 --- a/src/gpu/effects/GrDitherEffect.cpp +++ b/src/gpu/effects/GrDitherEffect.cpp @@ -24,22 +24,21 @@ public: const GrDitherEffect& _outer = args.fFp.cast<GrDitherEffect>(); (void)_outer; fragBuilder->codeAppendf( - "half value;\nhalf range;\n@switch (%d) {\n case 0:\n range = " + "float value;\nfloat range;\n@switch (%d) {\n case 0:\n range = " "0.0039215686274509803;\n break;\n case 1:\n range = " "0.015873015873015872;\n break;\n default:\n range = " "0.066666666666666666;\n break;\n}\n@if (sk_Caps.integerSupport) {\n " "uint x = uint(sk_FragCoord.x);\n uint y = uint(sk_FragCoord.y);\n uint m = " "(((((y & 1) << 5 | (x & 1) << 4) | (y & 2) << 2) | (x & 2) << 1) | (y & 4) >> 1) " - "| (x & 4) >> 2;\n value = highfloat(highfloat(half(m)) / 64.0) - 0.4921875;\n} " - "else {\n half4 modValues = half4(mod(sk_FragCoord.xyxy, highfloat4(half4(2.0, " - "2.0, 4.0, 4.0))));\n half4 stepValues = half4(step(highfloat4(modValues), " - "highfloat4(half4(1.0, 1.0, 2.0, 2.0))));\n value = highfloat(dot(stepValues, " - "half4(0.5, 0.25, 0.125, 0.0625))) - 0.46875;\n}\n%s = " - "half4(clamp(highfloat3(%s.xyz + value * range), 0.0, highfloat(%s.w)), %s.w);\n", + "| (x & 4) >> 2;\n value = float(m) / 64.0 - 0.4921875;\n} else {\n float4 " + "modValues = mod(sk_FragCoord.xyxy, float4(2.0, 2.0, 4.0, 4.0));\n float4 " + "stepValues = step(modValues, float4(1.0, 1.0, 2.0, 2.0));\n value = " + "dot(stepValues, float4(0.5, 0.25, 0.125, 0.0625)) - 0.46875;\n}\n%s = " + "float4(clamp(%s.xyz + value * range, 0.0, %s.w), %s.w);\n", _outer.rangeType(), args.fOutputColor, - args.fInputColor ? args.fInputColor : "half4(1)", - args.fInputColor ? args.fInputColor : "half4(1)", - args.fInputColor ? args.fInputColor : "half4(1)"); + args.fInputColor ? args.fInputColor : "float4(1)", + args.fInputColor ? args.fInputColor : "float4(1)", + args.fInputColor ? args.fInputColor : "float4(1)"); } private: |