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

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

Issue 14034018: Some fixes for saturation computation XferEffect. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 GrGLShaderVar("sat", kFloat_GrSLType), 1298 GrGLShaderVar("sat", kFloat_GrSLType),
1299 }; 1299 };
1300 helperArgs[0].setTypeModifier(GrGLShaderVar::kInOut_TypeModifier); 1300 helperArgs[0].setTypeModifier(GrGLShaderVar::kInOut_TypeModifier);
1301 helperArgs[1].setTypeModifier(GrGLShaderVar::kInOut_TypeModifier); 1301 helperArgs[1].setTypeModifier(GrGLShaderVar::kInOut_TypeModifier);
1302 helperArgs[2].setTypeModifier(GrGLShaderVar::kInOut_TypeModifier); 1302 helperArgs[2].setTypeModifier(GrGLShaderVar::kInOut_TypeModifier);
1303 SkString helperBody; 1303 SkString helperBody;
1304 helperBody.append("\tif (minComp < maxComp) {\n" 1304 helperBody.append("\tif (minComp < maxComp) {\n"
1305 "\t\tmidComp = sat * (midComp - minComp) / (maxCom p - minComp);\n" 1305 "\t\tmidComp = sat * (midComp - minComp) / (maxCom p - minComp);\n"
1306 "\t\tmaxComp = sat;\n" 1306 "\t\tmaxComp = sat;\n"
1307 "\t} else {\n" 1307 "\t} else {\n"
1308 "\t\tmidComp = midComp = 0.0;\n" 1308 "\t\tmidComp = maxComp = 0.0;\n"
1309 "\t}\n" 1309 "\t}\n"
1310 "\tminComp = 0.0;\n"); 1310 "\tminComp = 0.0;\n");
1311 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, 1311 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType,
1312 kVoid_GrSLType, 1312 kVoid_GrSLType,
1313 "set_saturation_helper", 1313 "set_saturation_helper",
1314 SK_ARRAY_COUNT(helperArgs), helperArgs, 1314 SK_ARRAY_COUNT(helperArgs), helperArgs,
1315 helperBody.c_str(), 1315 helperBody.c_str(),
1316 &helperFunction); 1316 &helperFunction);
1317 1317
1318 GrGLShaderVar setSatArgs[] = { 1318 GrGLShaderVar setSatArgs[] = {
1319 GrGLShaderVar("hueLumColor", kVec3f_GrSLType), 1319 GrGLShaderVar("hueLumColor", kVec3f_GrSLType),
1320 GrGLShaderVar("satColor", kVec3f_GrSLType), 1320 GrGLShaderVar("satColor", kVec3f_GrSLType),
1321 }; 1321 };
1322 const char* helpFunc = helperFunction.c_str(); 1322 const char* helpFunc = helperFunction.c_str();
1323 SkString setSatBody; 1323 SkString setSatBody;
1324 setSatBody.appendf("\tfloat sat = %s(satColor);\n" 1324 setSatBody.appendf("\tfloat sat = %s(satColor);\n"
1325 "\tif (hueLumColor.r <= hueLumColor.g) {\n" 1325 "\tif (hueLumColor.r <= hueLumColor.g) {\n"
1326 "\t\tif (hueLumColor.g <= hueLumColor.b) {\n" 1326 "\t\tif (hueLumColor.g <= hueLumColor.b) {\n"
1327 "\t\t\t%s(hueLumColor.r, hueLumColor.g, hueLumCol or.b, sat);\n" 1327 "\t\t\t%s(hueLumColor.r, hueLumColor.g, hueLumCol or.b, sat);\n"
1328 "\t\t} else if (hueLumColor.r <= hueLumColor.b) { \n"
1329 "\t\t\t%s(hueLumColor.r, hueLumColor.b, hueLumCol or.g, sat);\n"
1328 "\t\t} else {\n" 1330 "\t\t} else {\n"
1329 "\t\t\t%s(hueLumColor.r, hueLumColor.b, hueLumCol or.g, sat);\n" 1331 "\t\t\t%s(hueLumColor.b, hueLumColor.r, hueLumCol or.g, sat);\n"
1330 "\t\t}\n" 1332 "\t\t}\n"
1331 "\t} else if (hueLumColor.r <= hueLumColor.b) {\n " 1333 "\t} else if (hueLumColor.r <= hueLumColor.b) {\n "
1332 "\t\t%s(hueLumColor.g, hueLumColor.r, hueLumColor .b, sat);\n" 1334 "\t\t%s(hueLumColor.g, hueLumColor.r, hueLumColor .b, sat);\n"
1333 "\t} else if (hueLumColor.g <= hueLumColor.b) {\n " 1335 "\t} else if (hueLumColor.g <= hueLumColor.b) {\n "
1334 "\t\t%s(hueLumColor.g, hueLumColor.b, hueLumColor .r, sat);\n" 1336 "\t\t%s(hueLumColor.g, hueLumColor.b, hueLumColor .r, sat);\n"
1335 "\t} else {\n" 1337 "\t} else {\n"
1336 "\t\t%s(hueLumColor.b, hueLumColor.g, hueLumColor .r, sat);\n" 1338 "\t\t%s(hueLumColor.b, hueLumColor.g, hueLumColor .r, sat);\n"
1337 "\t}\n" 1339 "\t}\n"
1338 "\treturn hueLumColor;", 1340 "\treturn hueLumColor;",
1339 getFunction.c_str(), helpFunc, helpFunc, helpFunc , helpFunc,\ 1341 getFunction.c_str(), helpFunc, helpFunc, helpFunc , helpFunc,
1340 helpFunc); 1342 helpFunc, helpFunc);
1341 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, 1343 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType,
1342 kVec3f_GrSLType, 1344 kVec3f_GrSLType,
1343 "set_saturation", 1345 "set_saturation",
1344 SK_ARRAY_COUNT(setSatArgs), setSatArgs, 1346 SK_ARRAY_COUNT(setSatArgs), setSatArgs,
1345 setSatBody.c_str(), 1347 setSatBody.c_str(),
1346 setSatFunction); 1348 setSatFunction);
1347 1349
1348 } 1350 }
1349 1351
1350 typedef GrGLEffect INHERITED; 1352 typedef GrGLEffect INHERITED;
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 return proc16; 1966 return proc16;
1965 } 1967 }
1966 1968
1967 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1969 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1968 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1970 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1969 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) 1971 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode)
1970 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) 1972 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode)
1971 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) 1973 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode)
1972 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) 1974 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode)
1973 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1975 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