Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: src/gpu/effects/GrCustomXfermode.cpp

Issue 1210573002: Alter shader code for soft light to avoid driver bug. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "effects/GrCustomXfermode.h" 8 #include "effects/GrCustomXfermode.h"
9 #include "effects/GrCustomXfermodePriv.h" 9 #include "effects/GrCustomXfermodePriv.h"
10 10
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // else if (4D < Da) 148 // else if (4D < Da)
149 fsBuilder->codeAppendf("} else if (4.0 * %s.%c <= %s.a) {", 149 fsBuilder->codeAppendf("} else if (4.0 * %s.%c <= %s.a) {",
150 dst, component, dst); 150 dst, component, dst);
151 fsBuilder->codeAppendf("float DSqd = %s.%c * %s.%c;", 151 fsBuilder->codeAppendf("float DSqd = %s.%c * %s.%c;",
152 dst, component, dst, component); 152 dst, component, dst, component);
153 fsBuilder->codeAppendf("float DCub = DSqd * %s.%c;", dst, component); 153 fsBuilder->codeAppendf("float DCub = DSqd * %s.%c;", dst, component);
154 fsBuilder->codeAppendf("float DaSqd = %s.a * %s.a;", dst, dst); 154 fsBuilder->codeAppendf("float DaSqd = %s.a * %s.a;", dst, dst);
155 fsBuilder->codeAppendf("float DaCub = DaSqd * %s.a;", dst); 155 fsBuilder->codeAppendf("float DaCub = DaSqd * %s.a;", dst);
156 // (Da^3 (-S)+Da^2 (S-D (3 Sa-6 S-1))+12 Da D^2 (Sa-2 S)-16 D^3 (Sa-2 S))/Da ^2 156 // (Da^3 (-S)+Da^2 (S-D (3 Sa-6 S-1))+12 Da D^2 (Sa-2 S)-16 D^3 (Sa-2 S))/Da ^2
157 fsBuilder->codeAppendf("%s.%c =" 157 fsBuilder->codeAppendf("%s.%c ="
158 "(-DaCub*%s.%c + DaSqd*(%s.%c - %s.%c * (3.0*%s.a - 6 .0*%s.%c - 1.0)) +" 158 "(DaSqd*(%s.%c - %s.%c * (3.0*%s.a - 6.0*%s.%c - 1.0) ) +"
159 " 12.0*%s.a*DSqd*(%s.a - 2.0*%s.%c) - 16.0*DCub * (%s .a - 2.0*%s.%c)) /" 159 " 12.0*%s.a*DSqd*(%s.a - 2.0*%s.%c) - 16.0*DCub * (%s .a - 2.0*%s.%c) -"
160 "DaSqd;", 160 " DaCub*%s.%c) / DaSqd;",
161 final, component, src, component, src, component, dst , component, 161 final, component, src, component, dst, component,
162 src, src, component, dst, src, src, component, src, s rc, 162 src, src, component, dst, src, src, component, src, s rc,
163 component); 163 component, src, component);
164 fsBuilder->codeAppendf("} else {"); 164 fsBuilder->codeAppendf("} else {");
165 // -sqrt(Da * D) (Sa-2 S)-Da S+D (Sa-2 S+1)+S 165 // -sqrt(Da * D) (Sa-2 S)-Da S+D (Sa-2 S+1)+S
166 fsBuilder->codeAppendf("%s.%c = -sqrt(%s.a*%s.%c)*(%s.a - 2.0*%s.%c) - %s.a* %s.%c +" 166 fsBuilder->codeAppendf("%s.%c = %s.%c*(%s.a - 2.0*%s.%c + 1.0) + %s.%c -"
167 "%s.%c*(%s.a - 2.0*%s.%c + 1.0) + %s.%c;", 167 " sqrt(%s.a*%s.%c)*(%s.a - 2.0*%s.%c) - %s.a*%s.%c;",
168 final, component, dst, dst, component, src, src, comp onent, dst, 168 final, component, dst, component, src, src, component , src, component,
169 src, component, dst, component, src, src, component, src, 169 dst, dst, component, src, src, component, dst, src, c omponent);
170 component);
171 fsBuilder->codeAppendf("}"); 170 fsBuilder->codeAppendf("}");
172 } 171 }
173 172
174 // Adds a function that takes two colors and an alpha as input. It produces a co lor with the 173 // Adds a function that takes two colors and an alpha as input. It produces a co lor with the
175 // hue and saturation of the first color, the luminosity of the second color, an d the input 174 // hue and saturation of the first color, the luminosity of the second color, an d the input
176 // alpha. It has this signature: 175 // alpha. It has this signature:
177 // vec3 set_luminance(vec3 hueSatColor, float alpha, vec3 lumColor). 176 // vec3 set_luminance(vec3 hueSatColor, float alpha, vec3 lumColor).
178 static void add_lum_function(GrGLFragmentBuilder* fsBuilder, SkString* setLumFun ction) { 177 static void add_lum_function(GrGLFragmentBuilder* fsBuilder, SkString* setLumFun ction) {
179 // Emit a helper that gets the luminance of a color. 178 // Emit a helper that gets the luminance of a color.
180 SkString getFunction; 179 SkString getFunction;
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); 815 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory);
817 GrXPFactory* GrCustomXPFactory::TestCreate(SkRandom* rand, 816 GrXPFactory* GrCustomXPFactory::TestCreate(SkRandom* rand,
818 GrContext*, 817 GrContext*,
819 const GrCaps&, 818 const GrCaps&,
820 GrTexture*[]) { 819 GrTexture*[]) {
821 int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLas tSeparableMode); 820 int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLas tSeparableMode);
822 821
823 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); 822 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode)));
824 } 823 }
825 824
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698