OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkXfermode.h" | 10 #include "SkXfermode.h" |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1088 getLumBody.c_str(), | 1088 getLumBody.c_str(), |
1089 &getFunction); | 1089 &getFunction); |
1090 | 1090 |
1091 // Emit the set luminance function. | 1091 // Emit the set luminance function. |
1092 GrGLShaderVar setLumArgs[] = { | 1092 GrGLShaderVar setLumArgs[] = { |
1093 GrGLShaderVar("hueSat", kVec3f_GrSLType), | 1093 GrGLShaderVar("hueSat", kVec3f_GrSLType), |
1094 GrGLShaderVar("alpha", kFloat_GrSLType), | 1094 GrGLShaderVar("alpha", kFloat_GrSLType), |
1095 GrGLShaderVar("lumColor", kVec3f_GrSLType), | 1095 GrGLShaderVar("lumColor", kVec3f_GrSLType), |
1096 }; | 1096 }; |
1097 SkString setLumBody; | 1097 SkString setLumBody; |
1098 setLumBody.printf("\tfloat diff = %s(lumColor - hueSat);\n", getFunc tion.c_str()); | 1098 setLumBody.printf("\tfloat diff = %s(lumColor - hueSat);\n", getFunc tion.c_str()); |
egdaniel
2014/10/21 14:24:39
Side note: This line looks like it does diff = Lum
egdaniel
2014/10/21 14:36:25
Disregard this. It seems like the software/gpu jus
| |
1099 setLumBody.append("\tvec3 outColor = hueSat + diff;\n"); | 1099 setLumBody.append("\tvec3 outColor = hueSat + diff;\n"); |
1100 setLumBody.appendf("\tfloat outLum = %s(outColor);\n", getFunction.c _str()); | 1100 setLumBody.appendf("\tfloat outLum = %s(outColor);\n", getFunction.c _str()); |
1101 setLumBody.append("\tfloat minComp = min(min(outColor.r, outColor.g) , outColor.b);\n" | 1101 setLumBody.append("\tfloat minComp = min(min(outColor.r, outColor.g) , outColor.b);\n" |
1102 "\tfloat maxComp = max(max(outColor.r, outColor.g) , outColor.b);\n" | 1102 "\tfloat maxComp = max(max(outColor.r, outColor.g) , outColor.b);\n" |
1103 "\tif (minComp < 0.0) {\n" | 1103 "\tif (minComp < 0.0 && outLum != minComp) {\n" |
1104 "\t\toutColor = outLum + ((outColor - vec3(outLum, outLum, outLum)) * outLum) / (outLum - minComp);\n" | 1104 "\t\toutColor = outLum + ((outColor - vec3(outLum, outLum, outLum)) * outLum) / (outLum - minComp);\n" |
1105 "\t}\n" | 1105 "\t}\n" |
1106 "\tif (maxComp > alpha) {\n" | 1106 "\tif (maxComp > alpha && maxComp != outLum) {\n" |
1107 "\t\toutColor = outLum + ((outColor - vec3(outLum, outLum, outLum)) * (alpha - outLum)) / (maxComp - outLum);\n" | 1107 "\t\toutColor = outLum + ((outColor - vec3(outLum, outLum, outLum)) * (alpha - outLum)) / (maxComp - outLum);\n" |
1108 "\t}\n" | 1108 "\t}\n" |
1109 "\treturn outColor;\n"); | 1109 "\treturn outColor;\n"); |
1110 fsBuilder->emitFunction(kVec3f_GrSLType, | 1110 fsBuilder->emitFunction(kVec3f_GrSLType, |
1111 "set_luminance", | 1111 "set_luminance", |
1112 SK_ARRAY_COUNT(setLumArgs), setLumArgs, | 1112 SK_ARRAY_COUNT(setLumArgs), setLumArgs, |
1113 setLumBody.c_str(), | 1113 setLumBody.c_str(), |
1114 setLumFunction); | 1114 setLumFunction); |
1115 } | 1115 } |
1116 | 1116 |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1953 } else { | 1953 } else { |
1954 proc16 = rec.fProc16_General; | 1954 proc16 = rec.fProc16_General; |
1955 } | 1955 } |
1956 } | 1956 } |
1957 return proc16; | 1957 return proc16; |
1958 } | 1958 } |
1959 | 1959 |
1960 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1960 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
1961 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1961 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
1962 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1962 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |