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

Side by Side Diff: src/core/SkXfermode.cpp

Issue 666043003: Preventing division by 0 in non-separable blend mode shaders. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 /* 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
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
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
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