OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrDistanceFieldGeoProc.h" | 8 #include "GrDistanceFieldGeoProc.h" |
9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
10 #include "GrTexture.h" | 10 #include "GrTexture.h" |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 | 713 |
714 // this gives us a smooth step across approximately one fragment | 714 // this gives us a smooth step across approximately one fragment |
715 fragBuilder->codeAppend("afwidth = " SK_DistanceFieldAAFactor "*leng
th(grad);"); | 715 fragBuilder->codeAppend("afwidth = " SK_DistanceFieldAAFactor "*leng
th(grad);"); |
716 } | 716 } |
717 | 717 |
718 // The smoothstep falloff compensates for the non-linear sRGB response c
urve. If we are | 718 // The smoothstep falloff compensates for the non-linear sRGB response c
urve. If we are |
719 // doing gamma-correct rendering (to an sRGB or F16 buffer), then we act
ually want distance | 719 // doing gamma-correct rendering (to an sRGB or F16 buffer), then we act
ually want distance |
720 // mapped linearly to coverage, so use a linear step: | 720 // mapped linearly to coverage, so use a linear step: |
721 if (isGammaCorrect) { | 721 if (isGammaCorrect) { |
722 fragBuilder->codeAppend("vec4 val = " | 722 fragBuilder->codeAppend("vec4 val = " |
723 "vec4(clamp(distance + vec3(afwidth) / vec3(2.0 * afwidth), 0.0,
1.0), 1.0f);"); | 723 "vec4(clamp(distance + vec3(afwidth) / vec3(2.0 * afwidth), 0.0,
1.0), 1.0);"); |
724 } else { | 724 } else { |
725 fragBuilder->codeAppend( | 725 fragBuilder->codeAppend( |
726 "vec4 val = vec4(smoothstep(vec3(-afwidth), vec3(afwidth), dista
nce), 1.0);"); | 726 "vec4 val = vec4(smoothstep(vec3(-afwidth), vec3(afwidth), dista
nce), 1.0);"); |
727 } | 727 } |
728 | 728 |
729 // set alpha to be max of rgb coverage | 729 // set alpha to be max of rgb coverage |
730 fragBuilder->codeAppend("val.a = max(max(val.r, val.g), val.b);"); | 730 fragBuilder->codeAppend("val.a = max(max(val.r, val.g), val.b);"); |
731 | 731 |
732 fragBuilder->codeAppendf("%s = val;", args.fOutputCoverage); | 732 fragBuilder->codeAppendf("%s = val;", args.fOutputCoverage); |
733 } | 733 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0
; | 839 flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0
; |
840 } | 840 } |
841 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 841 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
842 return GrDistanceFieldLCDTextGeoProc::Make(GrRandomColor(d->fRandom), | 842 return GrDistanceFieldLCDTextGeoProc::Make(GrRandomColor(d->fRandom), |
843 GrTest::TestMatrix(d->fRandom), | 843 GrTest::TestMatrix(d->fRandom), |
844 d->fTextures[texIdx], params, | 844 d->fTextures[texIdx], params, |
845 wa, | 845 wa, |
846 flags, | 846 flags, |
847 d->fRandom->nextBool()); | 847 d->fRandom->nextBool()); |
848 } | 848 } |
OLD | NEW |