SkColorFilter* SkColorFilter::CreateLightingFilter(SkColor mul, SkColor add) { SkColorMatrix matrix; matrix.setScale(byte_to_scale(SkColorGetR(mul)), byte_to_scale(SkColorGetG(mul)), byte_to_scale(SkColorGetB(mul)), 1); matrix.postTranslate(SkIntToScalar(SkColorGetR(add)), SkIntToScalar(SkColorGetG(add)), SkIntToScalar(SkColorGetB(add)), 0); return SkColorMatrixFilter::Create(matrix); }
static SkColorFilter* make_cf1() { SkColorMatrix cm; cm.setSaturation(0.75f); SkAutoTUnref<SkColorFilter> a(SkColorMatrixFilter::Create(cm)); // CreateComposedFilter will try to concat these two matrices, resulting in a single // filter (which is good for speed). For this test, we want to force a real compose of // these two, so our inner filter has a scale-up, which disables the optimization of // combining the two matrices. cm.setScale(1.1f, 0.9f, 1); SkAutoTUnref<SkColorFilter> b(SkColorMatrixFilter::Create(cm)); return SkColorFilter::CreateComposeFilter(a, b); }