OLD | NEW |
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 "SkArithmeticMode_gpu.h" | 8 #include "SkArithmeticMode_gpu.h" |
9 | 9 |
10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
11 #include "GrContext.h" | 11 #include "GrContext.h" |
12 #include "GrFragmentProcessor.h" | 12 #include "GrFragmentProcessor.h" |
13 #include "GrInvariantOutput.h" | 13 #include "GrInvariantOutput.h" |
14 #include "GrProcessor.h" | 14 #include "GrProcessor.h" |
15 #include "GrTexture.h" | 15 #include "GrTexture.h" |
16 #include "gl/GrGLCaps.h" | 16 #include "gl/GrGLCaps.h" |
17 #include "gl/GrGLFragmentProcessor.h" | 17 #include "gl/GrGLFragmentProcessor.h" |
18 #include "gl/GrGLProgramDataManager.h" | 18 #include "gl/GrGLProgramDataManager.h" |
19 #include "gl/builders/GrGLProgramBuilder.h" | 19 #include "gl/builders/GrGLProgramBuilder.h" |
20 | 20 |
21 static const bool gUseUnpremul = false; | 21 static const bool gUseUnpremul = false; |
22 | 22 |
23 static void add_arithmetic_code(GrGLFragmentBuilder* fsBuilder, | 23 static void add_arithmetic_code(GrGLFragmentBuilder* fsBuilder, |
24 const char* inputColor, | 24 const char* inputColor, |
25 const char* dstColor, | 25 const char* dstColor, |
26 const char* outputColor, | 26 const char* outputColor, |
27 const char* kUni, | 27 const char* kUni, |
28 bool enforcePMColor) { | 28 bool enforcePMColor) { |
29 // We don't try to optimize for this case at all | 29 // We don't try to optimize for this case at all |
30 if (NULL == inputColor) { | 30 if (nullptr == inputColor) { |
31 fsBuilder->codeAppend("const vec4 src = vec4(1);"); | 31 fsBuilder->codeAppend("const vec4 src = vec4(1);"); |
32 } else { | 32 } else { |
33 fsBuilder->codeAppendf("vec4 src = %s;", inputColor); | 33 fsBuilder->codeAppendf("vec4 src = %s;", inputColor); |
34 if (gUseUnpremul) { | 34 if (gUseUnpremul) { |
35 fsBuilder->codeAppend("src.rgb = clamp(src.rgb / src.a, 0.0, 1.0);")
; | 35 fsBuilder->codeAppend("src.rgb = clamp(src.rgb / src.a, 0.0, 1.0);")
; |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 fsBuilder->codeAppendf("vec4 dst = %s;", dstColor); | 39 fsBuilder->codeAppendf("vec4 dst = %s;", dstColor); |
40 if (gUseUnpremul) { | 40 if (gUseUnpremul) { |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 float k1 = d->fRandom->nextF(); | 299 float k1 = d->fRandom->nextF(); |
300 float k2 = d->fRandom->nextF(); | 300 float k2 = d->fRandom->nextF(); |
301 float k3 = d->fRandom->nextF(); | 301 float k3 = d->fRandom->nextF(); |
302 float k4 = d->fRandom->nextF(); | 302 float k4 = d->fRandom->nextF(); |
303 bool enforcePMColor = d->fRandom->nextBool(); | 303 bool enforcePMColor = d->fRandom->nextBool(); |
304 | 304 |
305 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); | 305 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); |
306 } | 306 } |
307 | 307 |
308 #endif | 308 #endif |
OLD | NEW |