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

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

Issue 14535004: Remove inout params from saturation helper func in XferEffect. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« 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 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 SkString getSatBody; 1280 SkString getSatBody;
1281 getSatBody.printf("\treturn max(max(color.r, color.g), color.b) - " 1281 getSatBody.printf("\treturn max(max(color.r, color.g), color.b) - "
1282 "min(min(color.r, color.g), color.b);\n"); 1282 "min(min(color.r, color.g), color.b);\n");
1283 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, 1283 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType,
1284 kFloat_GrSLType, 1284 kFloat_GrSLType,
1285 "saturation", 1285 "saturation",
1286 SK_ARRAY_COUNT(getSatArgs), getSatArgs, 1286 SK_ARRAY_COUNT(getSatArgs), getSatArgs,
1287 getSatBody.c_str(), 1287 getSatBody.c_str(),
1288 &getFunction); 1288 &getFunction);
1289 1289
1290 // Emit a helper that sets the saturation given sorted input channel s 1290 // Emit a helper that sets the saturation given sorted input channel s. This used
1291 // to use inout params for min, mid, and max components but that see ms to cause
1292 // problems on PowerVR drivers. So instead it returns a vec3 where r , g ,b are the
1293 // adjusted min, mid, and max inputs, respectively.
1291 SkString helperFunction; 1294 SkString helperFunction;
1292 GrGLShaderVar helperArgs[] = { 1295 GrGLShaderVar helperArgs[] = {
1293 GrGLShaderVar("minComp", kFloat_GrSLType), 1296 GrGLShaderVar("minComp", kFloat_GrSLType),
1294 GrGLShaderVar("midComp", kFloat_GrSLType), 1297 GrGLShaderVar("midComp", kFloat_GrSLType),
1295 GrGLShaderVar("maxComp", kFloat_GrSLType), 1298 GrGLShaderVar("maxComp", kFloat_GrSLType),
1296 GrGLShaderVar("sat", kFloat_GrSLType), 1299 GrGLShaderVar("sat", kFloat_GrSLType),
1297 }; 1300 };
1298 helperArgs[0].setTypeModifier(GrGLShaderVar::kInOut_TypeModifier); 1301 static const char kHelperBody[] = "\tif (minComp < maxComp) {\n"
1299 helperArgs[1].setTypeModifier(GrGLShaderVar::kInOut_TypeModifier); 1302 "\t\tvec3 result;\n"
1300 helperArgs[2].setTypeModifier(GrGLShaderVar::kInOut_TypeModifier); 1303 "\t\tresult.r = 0.0;\n"
1301 SkString helperBody; 1304 "\t\tresult.g = sat * (midComp - m inComp) / (maxComp - minComp);\n"
1302 helperBody.append("\tif (minComp < maxComp) {\n" 1305 "\t\tresult.b = sat;\n"
1303 "\t\tmidComp = sat * (midComp - minComp) / (maxCom p - minComp);\n" 1306 "\t\treturn result;\n"
1304 "\t\tmaxComp = sat;\n" 1307 "\t} else {\n"
1305 "\t} else {\n" 1308 "\t\treturn vec3(0, 0, 0);\n"
1306 "\t\tmidComp = maxComp = 0.0;\n" 1309 "\t}\n";
1307 "\t}\n"
1308 "\tminComp = 0.0;\n");
1309 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, 1310 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType,
1310 kVoid_GrSLType, 1311 kVec3f_GrSLType,
1311 "set_saturation_helper", 1312 "set_saturation_helper",
1312 SK_ARRAY_COUNT(helperArgs), helperArgs, 1313 SK_ARRAY_COUNT(helperArgs), helperArgs,
1313 helperBody.c_str(), 1314 kHelperBody,
1314 &helperFunction); 1315 &helperFunction);
1315 1316
1316 GrGLShaderVar setSatArgs[] = { 1317 GrGLShaderVar setSatArgs[] = {
1317 GrGLShaderVar("hueLumColor", kVec3f_GrSLType), 1318 GrGLShaderVar("hueLumColor", kVec3f_GrSLType),
1318 GrGLShaderVar("satColor", kVec3f_GrSLType), 1319 GrGLShaderVar("satColor", kVec3f_GrSLType),
1319 }; 1320 };
1320 const char* helpFunc = helperFunction.c_str(); 1321 const char* helpFunc = helperFunction.c_str();
1321 SkString setSatBody; 1322 SkString setSatBody;
1322 setSatBody.appendf("\tfloat sat = %s(satColor);\n" 1323 setSatBody.appendf("\tfloat sat = %s(satColor);\n"
1323 "\tif (hueLumColor.r <= hueLumColor.g) {\n" 1324 "\tif (hueLumColor.r <= hueLumColor.g) {\n"
1324 "\t\tif (hueLumColor.g <= hueLumColor.b) {\n" 1325 "\t\tif (hueLumColor.g <= hueLumColor.b) {\n"
1325 "\t\t\t%s(hueLumColor.r, hueLumColor.g, hueLumCol or.b, sat);\n" 1326 "\t\t\thueLumColor.rgb = %s(hueLumColor.r, hueLum Color.g, hueLumColor.b, sat);\n"
1326 "\t\t} else if (hueLumColor.r <= hueLumColor.b) { \n" 1327 "\t\t} else if (hueLumColor.r <= hueLumColor.b) { \n"
1327 "\t\t\t%s(hueLumColor.r, hueLumColor.b, hueLumCol or.g, sat);\n" 1328 "\t\t\thueLumColor.rbg = %s(hueLumColor.r, hueLum Color.b, hueLumColor.g, sat);\n"
1328 "\t\t} else {\n" 1329 "\t\t} else {\n"
1329 "\t\t\t%s(hueLumColor.b, hueLumColor.r, hueLumCol or.g, sat);\n" 1330 "\t\t\thueLumColor.brg = %s(hueLumColor.b, hueLum Color.r, hueLumColor.g, sat);\n"
1330 "\t\t}\n" 1331 "\t\t}\n"
1331 "\t} else if (hueLumColor.r <= hueLumColor.b) {\n " 1332 "\t} else if (hueLumColor.r <= hueLumColor.b) {\n "
1332 "\t\t%s(hueLumColor.g, hueLumColor.r, hueLumColor .b, sat);\n" 1333 "\t\thueLumColor.grb = %s(hueLumColor.g, hueLumCo lor.r, hueLumColor.b, sat);\n"
1333 "\t} else if (hueLumColor.g <= hueLumColor.b) {\n " 1334 "\t} else if (hueLumColor.g <= hueLumColor.b) {\n "
1334 "\t\t%s(hueLumColor.g, hueLumColor.b, hueLumColor .r, sat);\n" 1335 "\t\thueLumColor.gbr = %s(hueLumColor.g, hueLumCo lor.b, hueLumColor.r, sat);\n"
1335 "\t} else {\n" 1336 "\t} else {\n"
1336 "\t\t%s(hueLumColor.b, hueLumColor.g, hueLumColor .r, sat);\n" 1337 "\t\thueLumColor.bgr = %s(hueLumColor.b, hueLumCo lor.g, hueLumColor.r, sat);\n"
1337 "\t}\n" 1338 "\t}\n"
1338 "\treturn hueLumColor;", 1339 "\treturn hueLumColor;\n",
1339 getFunction.c_str(), helpFunc, helpFunc, helpFunc , helpFunc, 1340 getFunction.c_str(), helpFunc, helpFunc, helpFunc , helpFunc,
1340 helpFunc, helpFunc); 1341 helpFunc, helpFunc);
1341 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, 1342 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType,
1342 kVec3f_GrSLType, 1343 kVec3f_GrSLType,
1343 "set_saturation", 1344 "set_saturation",
1344 SK_ARRAY_COUNT(setSatArgs), setSatArgs, 1345 SK_ARRAY_COUNT(setSatArgs), setSatArgs,
1345 setSatBody.c_str(), 1346 setSatBody.c_str(),
1346 setSatFunction); 1347 setSatFunction);
1347 1348
1348 } 1349 }
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 return proc16; 1969 return proc16;
1969 } 1970 }
1970 1971
1971 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1972 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1972 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1973 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1973 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) 1974 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode)
1974 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) 1975 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode)
1975 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) 1976 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode)
1976 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) 1977 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode)
1977 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1978 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