Example #1
0
/**
 * Adds a line to the fragment shader code which modifies the color by
 * the specified color filter.
 */
static void addColorFilter(GrStringBuilder* fsCode, const char * outputVar,
                           SkXfermode::Coeff uniformCoeff,
                           SkXfermode::Coeff colorCoeff,
                           const char* inColor) {
    GrStringBuilder colorStr, constStr;
    blendTermString(&colorStr, colorCoeff, COL_FILTER_UNI_NAME,
                    inColor, inColor);
    blendTermString(&constStr, uniformCoeff, COL_FILTER_UNI_NAME,
                    inColor, COL_FILTER_UNI_NAME);

    add_helper(outputVar, colorStr.c_str(), constStr.c_str(), fsCode);
}
/**
 * Adds a line to the fragment shader code which modifies the color by
 * the specified color filter.
 */
static void addColorFilter(SkString* fsCode, const char * outputVar,
                           SkXfermode::Coeff uniformCoeff,
                           SkXfermode::Coeff colorCoeff,
                           const char* filterColor,
                           const char* inColor) {
    SkString colorStr, constStr;
    blendTermString(&colorStr, colorCoeff, filterColor, inColor, inColor);
    blendTermString(&constStr, uniformCoeff, filterColor, inColor, filterColor);

    fsCode->appendf("\t%s = ", outputVar);
    GrGLSLAdd4f(fsCode, colorStr.c_str(), constStr.c_str());
    fsCode->append(";\n");
}