Introduce new factory for SkColorFilters
Idea: transition callers to this, so we can later typedef SkColorFilter and SkShader to the same thing. Bug: skia:8937 Change-Id: I000c882e11622091aa44c141aa6ddd1216414f46 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206685 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
c19cf51df4
commit
b286bc2da8
@ -50,8 +50,7 @@ public:
|
||||
SkPaint* paint = looperBuilder.addLayerOnTop(info);
|
||||
paint->setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(0.5)));
|
||||
paint->setColorFilter(SkColorFilter::MakeModeFilter(SK_ColorLTGRAY,
|
||||
SkBlendMode::kSrcIn));
|
||||
paint->setColorFilter(SkColorFilters::Blend(SK_ColorLTGRAY, SkBlendMode::kSrcIn));
|
||||
paint->setColor(SK_ColorGRAY);
|
||||
}
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ static sk_sp<SkImageFilter> make_brightness(float amount, sk_sp<SkImageFilter> i
|
||||
0, 1, 0, 0, amount255,
|
||||
0, 0, 1, 0, amount255,
|
||||
0, 0, 0, 1, 0 };
|
||||
sk_sp<SkColorFilter> filter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
|
||||
sk_sp<SkColorFilter> filter(SkColorFilters::MatrixRowMajor255(matrix));
|
||||
return SkColorFilterImageFilter::Make(std::move(filter), std::move(input));
|
||||
}
|
||||
|
||||
@ -32,12 +32,12 @@ static sk_sp<SkImageFilter> make_grayscale(sk_sp<SkImageFilter> input) {
|
||||
matrix[1] = matrix[6] = matrix[11] = 0.7152f;
|
||||
matrix[2] = matrix[7] = matrix[12] = 0.0722f;
|
||||
matrix[18] = 1.0f;
|
||||
sk_sp<SkColorFilter> filter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
|
||||
sk_sp<SkColorFilter> filter(SkColorFilters::MatrixRowMajor255(matrix));
|
||||
return SkColorFilterImageFilter::Make(std::move(filter), std::move(input));
|
||||
}
|
||||
|
||||
static sk_sp<SkImageFilter> make_mode_blue(sk_sp<SkImageFilter> input) {
|
||||
sk_sp<SkColorFilter> filter(SkColorFilter::MakeModeFilter(SK_ColorBLUE, SkBlendMode::kSrcIn));
|
||||
sk_sp<SkColorFilter> filter(SkColorFilters::Blend(SK_ColorBLUE, SkBlendMode::kSrcIn));
|
||||
return SkColorFilterImageFilter::Make(std::move(filter), std::move(input));
|
||||
}
|
||||
|
||||
@ -310,8 +310,8 @@ protected:
|
||||
img = img->makeRasterImage();
|
||||
}
|
||||
fShader = img->makeShader();
|
||||
auto cf0 = SkColorFilter::MakeModeFilter(0x88FF3366, SkBlendMode::kDstIn);
|
||||
auto cf1 = SkColorFilter::MakeModeFilter(0x88FF3366, SkBlendMode::kDstATop);
|
||||
auto cf0 = SkColorFilters::Blend(0x88FF3366, SkBlendMode::kDstIn);
|
||||
auto cf1 = SkColorFilters::Blend(0x88FF3366, SkBlendMode::kDstATop);
|
||||
auto mx = SkMixer::MakeLerp(0.5f);
|
||||
if (!(fFlags & kUseCF0)) {
|
||||
cf0 = nullptr;
|
||||
@ -319,7 +319,7 @@ protected:
|
||||
if (!(fFlags & kUseCF1)) {
|
||||
cf1 = nullptr;
|
||||
}
|
||||
fFilter = SkColorFilter::MakeMixer(cf0, cf1, mx);
|
||||
fFilter = SkColorFilters::Mixer(mx, cf0, cf1);
|
||||
}
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
SkRect r = SkRect::MakeWH(256, 256);
|
||||
|
@ -103,7 +103,7 @@ static sk_sp<SkColorFilter> make_brightness(float amount) {
|
||||
0, 1, 0, 0, amount255,
|
||||
0, 0, 1, 0, amount255,
|
||||
0, 0, 0, 1, 0 };
|
||||
return SkColorFilter::MakeMatrixFilterRowMajor255(matrix);
|
||||
return SkColorFilters::MatrixRowMajor255(matrix);
|
||||
}
|
||||
|
||||
static sk_sp<SkColorFilter> make_grayscale() {
|
||||
@ -113,7 +113,7 @@ static sk_sp<SkColorFilter> make_grayscale() {
|
||||
matrix[1] = matrix[6] = matrix[11] = 0.7152f;
|
||||
matrix[2] = matrix[7] = matrix[12] = 0.0722f;
|
||||
matrix[18] = 1.0f;
|
||||
return SkColorFilter::MakeMatrixFilterRowMajor255(matrix);
|
||||
return SkColorFilters::MatrixRowMajor255(matrix);
|
||||
}
|
||||
|
||||
class MatrixCollapseBench: public BaseImageFilterCollapseBench {
|
||||
|
@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) {
|
||||
SkPaint paint;
|
||||
canvas->scale(4, 4);
|
||||
for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) {
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(color, SkBlendMode::kPlus));
|
||||
paint.setColorFilter(SkColorFilters::Blend(color, SkBlendMode::kPlus));
|
||||
canvas->drawBitmapRect(bitmap, SkRect::MakeWH(8, 8), &paint);
|
||||
canvas->translate(8, 0);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) {
|
||||
SkPaint paint;
|
||||
canvas->scale(4, 4);
|
||||
for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) {
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(color, SkBlendMode::kPlus));
|
||||
paint.setColorFilter(SkColorFilters::Blend(color, SkBlendMode::kPlus));
|
||||
canvas->drawImageRect(image, SkIRect::MakeWH(2, 2), SkRect::MakeWH(8, 8), &paint);
|
||||
canvas->translate(8, 0);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) {
|
||||
SkPaint paint;
|
||||
canvas->scale(4, 4);
|
||||
for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) {
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(color, SkBlendMode::kPlus));
|
||||
paint.setColorFilter(SkColorFilters::Blend(color, SkBlendMode::kPlus));
|
||||
canvas->drawImageRect(image, SkRect::MakeWH(8, 8), &paint);
|
||||
canvas->translate(8, 0);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ REG_FIDDLE(Paint_getColorFilter, 256, 256, true, 0) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkPaint paint;
|
||||
SkDebugf("nullptr %c= color filter\n", paint.getColorFilter() ? '!' : '=');
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(SK_ColorLTGRAY, SkBlendMode::kSrcIn));
|
||||
paint.setColorFilter(SkColorFilters::Blend(SK_ColorLTGRAY, SkBlendMode::kSrcIn));
|
||||
SkDebugf("nullptr %c= color filter\n", paint.getColorFilter() ? '!' : '=');
|
||||
}
|
||||
} // END FIDDLE
|
||||
|
@ -5,7 +5,7 @@
|
||||
REG_FIDDLE(Paint_refColorFilter, 256, 256, true, 0) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkPaint paint1, paint2;
|
||||
paint1.setColorFilter(SkColorFilter::MakeModeFilter(0xFFFF0000, SkBlendMode::kSrcATop));
|
||||
paint1.setColorFilter(SkColorFilters::Blend(0xFFFF0000, SkBlendMode::kSrcATop));
|
||||
SkDebugf("color filter unique: %s\n", paint1.getColorFilter()->unique() ? "true" : "false");
|
||||
paint2.setColorFilter(paint1.refColorFilter());
|
||||
SkDebugf("color filter unique: %s\n", paint1.getColorFilter()->unique() ? "true" : "false");
|
||||
|
@ -5,7 +5,7 @@
|
||||
REG_FIDDLE(Paint_setColorFilter, 256, 64, false, 0) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkPaint paint;
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(SK_ColorLTGRAY, SkBlendMode::kSrcIn));
|
||||
paint.setColorFilter(SkColorFilters::Blend(SK_ColorLTGRAY, SkBlendMode::kSrcIn));
|
||||
canvas->drawRect(SkRect::MakeWH(50, 50), paint);
|
||||
paint.setColorFilter(nullptr);
|
||||
canvas->translate(70, 0);
|
||||
|
@ -115,7 +115,7 @@ static sk_sp<SkColorFilter> make_fuzz_colorfilter(Fuzz* fuzz, int depth) {
|
||||
SkBlendMode mode;
|
||||
fuzz->next(&color);
|
||||
fuzz->nextRange(&mode, 0, SkBlendMode::kLastMode);
|
||||
return SkColorFilter::MakeModeFilter(color, mode);
|
||||
return SkColorFilters::Blend(color, mode);
|
||||
}
|
||||
case 2: {
|
||||
sk_sp<SkColorFilter> outer = make_fuzz_colorfilter(fuzz, depth - 1);
|
||||
@ -129,7 +129,7 @@ static sk_sp<SkColorFilter> make_fuzz_colorfilter(Fuzz* fuzz, int depth) {
|
||||
case 3: {
|
||||
SkScalar array[20];
|
||||
fuzz->nextN(array, SK_ARRAY_COUNT(array));
|
||||
return SkColorFilter::MakeMatrixFilterRowMajor255(array);
|
||||
return SkColorFilters::MatrixRowMajor255(array);
|
||||
}
|
||||
case 4: {
|
||||
SkColor mul, add;
|
||||
|
@ -31,7 +31,7 @@ static sk_sp<SkColorFilter> make_color_filter() {
|
||||
0, 1, 0, 0, 0,
|
||||
0, 0, 0.5, 0.5, 0,
|
||||
0, 0, 0.5, 0.5, 0}; // mix G and A.
|
||||
return SkColorFilter::MakeMatrixFilterRowMajor255(colorMatrix);
|
||||
return SkColorFilters::MatrixRowMajor255(colorMatrix);
|
||||
}
|
||||
|
||||
DEF_SIMPLE_GM(alpha_image, canvas, 256, 256) {
|
||||
|
@ -67,9 +67,8 @@ protected:
|
||||
paint.setMaskFilter(SkMaskFilter::MakeBlur(
|
||||
kNormal_SkBlurStyle,
|
||||
1.366025f));
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(
|
||||
SK_ColorRED,
|
||||
SkBlendMode::kSrcIn));
|
||||
paint.setColorFilter(SkColorFilters::Blend(SK_ColorRED,
|
||||
SkBlendMode::kSrcIn));
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
canvas->drawRRect(rr, paint);
|
||||
|
@ -57,9 +57,7 @@ public:
|
||||
paint->setMaskFilter(SkMaskFilter::MakeBlur(
|
||||
kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf)));
|
||||
paint->setColorFilter(SkColorFilter::MakeModeFilter(
|
||||
SK_ColorLTGRAY,
|
||||
SkBlendMode::kSrcIn));
|
||||
paint->setColorFilter(SkColorFilters::Blend(SK_ColorLTGRAY, SkBlendMode::kSrcIn));
|
||||
paint->setColor(SK_ColorGRAY);
|
||||
}
|
||||
{
|
||||
|
@ -29,23 +29,23 @@ static sk_sp<SkColorFilter> make_cf_null() {
|
||||
static sk_sp<SkColorFilter> make_cf0() {
|
||||
SkColorMatrix cm;
|
||||
cm.setSaturation(0.75f);
|
||||
return SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat);
|
||||
return SkColorFilters::MatrixRowMajor255(cm.fMat);
|
||||
}
|
||||
|
||||
static sk_sp<SkColorFilter> make_cf1() {
|
||||
SkColorMatrix cm;
|
||||
cm.setSaturation(0.75f);
|
||||
auto a = SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat);
|
||||
auto a = SkColorFilters::MatrixRowMajor255(cm.fMat);
|
||||
// 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);
|
||||
return a->makeComposed(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
|
||||
return a->makeComposed(SkColorFilters::MatrixRowMajor255(cm.fMat));
|
||||
}
|
||||
|
||||
static sk_sp<SkColorFilter> make_cf2() {
|
||||
return SkColorFilter::MakeModeFilter(0x8044CC88, SkBlendMode::kSrcATop);
|
||||
return SkColorFilters::Blend(0x8044CC88, SkBlendMode::kSrcATop);
|
||||
}
|
||||
|
||||
static void draw_into_canvas(SkCanvas* canvas) {
|
||||
|
@ -37,7 +37,7 @@ static sk_sp<SkImageFilter> make_grayscale(sk_sp<SkImageFilter> input) {
|
||||
matrix[1] = matrix[6] = matrix[11] = 0.7152f;
|
||||
matrix[2] = matrix[7] = matrix[12] = 0.0722f;
|
||||
matrix[18] = 1.0f;
|
||||
sk_sp<SkColorFilter> filter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
|
||||
sk_sp<SkColorFilter> filter(SkColorFilters::MatrixRowMajor255(matrix));
|
||||
return SkColorFilterImageFilter::Make(std::move(filter), std::move(input));
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ protected:
|
||||
0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 255.0f
|
||||
};
|
||||
paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(opaqueGrayMatrix));
|
||||
paint.setColorFilter(SkColorFilters::MatrixRowMajor255(opaqueGrayMatrix));
|
||||
|
||||
canvas->drawBitmap(bitmap, 100.0f, 100.0f, &paint);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ static sk_sp<SkColorFilter> cf_make_brightness(float brightness) {
|
||||
0, 1, 0, 0, amount255,
|
||||
0, 0, 1, 0, amount255,
|
||||
0, 0, 0, 1, 0 };
|
||||
return SkColorFilter::MakeMatrixFilterRowMajor255(matrix);
|
||||
return SkColorFilters::MatrixRowMajor255(matrix);
|
||||
}
|
||||
|
||||
static sk_sp<SkColorFilter> cf_make_grayscale() {
|
||||
@ -37,11 +37,11 @@ static sk_sp<SkColorFilter> cf_make_grayscale() {
|
||||
matrix[1] = matrix[6] = matrix[11] = 0.7152f;
|
||||
matrix[2] = matrix[7] = matrix[12] = 0.0722f;
|
||||
matrix[18] = 1.0f;
|
||||
return SkColorFilter::MakeMatrixFilterRowMajor255(matrix);
|
||||
return SkColorFilters::MatrixRowMajor255(matrix);
|
||||
}
|
||||
|
||||
static sk_sp<SkColorFilter> cf_make_colorize(SkColor color) {
|
||||
return SkColorFilter::MakeModeFilter(color, SkBlendMode::kSrc);
|
||||
return SkColorFilters::Blend(color, SkBlendMode::kSrc);
|
||||
}
|
||||
|
||||
static void sk_gm_get_colorfilters(SkTArray<sk_sp<SkColorFilter>>* array) {
|
||||
@ -179,7 +179,7 @@ DEF_SIMPLE_GM(colorfilterimagefilter_layer, canvas, 32, 32) {
|
||||
SkAutoCanvasRestore autoCanvasRestore(canvas, false);
|
||||
SkColorMatrix cm;
|
||||
cm.setSaturation(0.0f);
|
||||
sk_sp<SkColorFilter> cf(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
|
||||
sk_sp<SkColorFilter> cf(SkColorFilters::MatrixRowMajor255(cm.fMat));
|
||||
SkPaint p;
|
||||
p.setImageFilter(SkColorFilterImageFilter::Make(std::move(cf), nullptr));
|
||||
canvas->saveLayer(nullptr, &p);
|
||||
|
@ -14,11 +14,11 @@
|
||||
#define HEIGHT 500
|
||||
|
||||
static void set_color_matrix(SkPaint* paint, const SkColorMatrix& matrix) {
|
||||
paint->setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix.fMat));
|
||||
paint->setColorFilter(SkColorFilters::MatrixRowMajor255(matrix.fMat));
|
||||
}
|
||||
|
||||
static void set_array(SkPaint* paint, const SkScalar array[]) {
|
||||
paint->setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(array));
|
||||
paint->setColorFilter(SkColorFilters::MatrixRowMajor255(array));
|
||||
}
|
||||
|
||||
class ColorMatrixGM : public skiagm::GM {
|
||||
|
@ -1006,7 +1006,7 @@ static SkTArray<sk_sp<ClipTileRenderer>> make_filtered_renderers() {
|
||||
|
||||
SkColorMatrix cm;
|
||||
cm.setSaturation(10);
|
||||
sk_sp<SkColorFilter> colorFilter = SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat);
|
||||
sk_sp<SkColorFilter> colorFilter = SkColorFilters::MatrixRowMajor255(cm.fMat);
|
||||
sk_sp<SkImageFilter> imageFilter = SkDilateImageFilter::Make(8, 8, nullptr);
|
||||
|
||||
static constexpr SkColor kAlphas[] = { SK_ColorTRANSPARENT, SK_ColorBLACK };
|
||||
|
@ -18,6 +18,6 @@ DEF_SIMPLE_GM(crbug_899512, canvas, 520, 520) {
|
||||
canvas->concat(matrix);
|
||||
SkPaint paint;
|
||||
paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 6.2735f, false));
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(SK_ColorBLACK, SkBlendMode::kSrcIn));
|
||||
paint.setColorFilter(SkColorFilters::Blend(SK_ColorBLACK, SkBlendMode::kSrcIn));
|
||||
canvas->drawRect(SkRect::MakeXYWH(0, 10, 200, 200), paint);
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ DEF_SIMPLE_GM(compare_atlas_vertices, canvas, 560, 585) {
|
||||
auto verts = make_vertices(image, tex, color);
|
||||
const sk_sp<SkColorFilter> filters[] = {
|
||||
nullptr,
|
||||
SkColorFilter::MakeModeFilter(0xFF00FF88, SkBlendMode::kModulate),
|
||||
SkColorFilters::Blend(0xFF00FF88, SkBlendMode::kModulate),
|
||||
};
|
||||
const SkBlendMode modes[] = {
|
||||
SkBlendMode::kSrcOver,
|
||||
|
@ -74,8 +74,7 @@ DEF_SIMPLE_GM(dropshadowimagefilter, canvas, 400, 656) {
|
||||
draw_bitmap, draw_path, draw_paint, draw_text
|
||||
};
|
||||
|
||||
sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorMAGENTA,
|
||||
SkBlendMode::kSrcIn));
|
||||
sk_sp<SkColorFilter> cf(SkColorFilters::Blend(SK_ColorMAGENTA, SkBlendMode::kSrcIn));
|
||||
sk_sp<SkImageFilter> cfif(SkColorFilterImageFilter::Make(std::move(cf), nullptr));
|
||||
SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)),
|
||||
SkImageFilter::CropRect::kHasAll_CropEdge);
|
||||
|
@ -53,7 +53,7 @@ protected:
|
||||
|
||||
// this combination of emboss+colorfilter used to crash -- so we exercise it to
|
||||
// confirm that we have a fix.
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(0xFFFF0000, SkBlendMode::kSrcATop));
|
||||
paint.setColorFilter(SkColorFilters::Blend(0xFFFF0000, SkBlendMode::kSrcATop));
|
||||
canvas->drawBitmap(bm, 10, 10, &paint);
|
||||
canvas->translate(bm.width() + SkIntToScalar(10), 0);
|
||||
|
||||
|
@ -15,7 +15,7 @@ DEF_SIMPLE_GM(fadefilter, canvas, 256, 256) {
|
||||
0, 1, 0, 0, 128.0f,
|
||||
0, 0, 1, 0, 128.0f,
|
||||
0, 0, 0, 1, 0 };
|
||||
sk_sp<SkColorFilter> colorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
|
||||
sk_sp<SkColorFilter> colorFilter(SkColorFilters::MatrixRowMajor255(matrix));
|
||||
SkPaint layerPaint;
|
||||
layerPaint.setImageFilter(SkColorFilterImageFilter::Make(std::move(colorFilter), nullptr));
|
||||
canvas->drawRect(SkRect::MakeLTRB(64, 64, 192, 192), layerPaint);
|
||||
|
@ -138,7 +138,7 @@ static void draw_set(SkCanvas* canvas, sk_sp<SkImageFilter> filters[], int count
|
||||
DEF_SIMPLE_GM(savelayer_with_backdrop, canvas, 830, 550) {
|
||||
SkColorMatrix cm;
|
||||
cm.setSaturation(10);
|
||||
sk_sp<SkColorFilter> cf(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
|
||||
sk_sp<SkColorFilter> cf(SkColorFilters::MatrixRowMajor255(cm.fMat));
|
||||
const SkScalar kernel[] = { 4, 0, 4, 0, -15, 0, 4, 0, 4 };
|
||||
sk_sp<SkImageFilter> filters[] = {
|
||||
SkBlurImageFilter::Make(10, 10, nullptr),
|
||||
|
@ -169,7 +169,7 @@ protected:
|
||||
draw_bitmap,
|
||||
};
|
||||
|
||||
auto cf = SkColorFilter::MakeModeFilter(SK_ColorRED, SkBlendMode::kSrcIn);
|
||||
auto cf = SkColorFilters::Blend(SK_ColorRED, SkBlendMode::kSrcIn);
|
||||
sk_sp<SkImageFilter> filters[] = {
|
||||
nullptr,
|
||||
IdentityImageFilter::Make(nullptr),
|
||||
@ -294,7 +294,7 @@ public:
|
||||
ImageFiltersText_CF() : ImageFiltersTextBaseGM("color") {}
|
||||
|
||||
void installFilter(SkPaint* paint) override {
|
||||
paint->setColorFilter(SkColorFilter::MakeModeFilter(SK_ColorBLUE, SkBlendMode::kSrcIn));
|
||||
paint->setColorFilter(SkColorFilters::Blend(SK_ColorBLUE, SkBlendMode::kSrcIn));
|
||||
}
|
||||
};
|
||||
DEF_GM( return new ImageFiltersText_CF; )
|
||||
|
@ -54,7 +54,7 @@ DEF_SIMPLE_GM(imagefilterscropexpand, canvas, 730, 650) {
|
||||
0, 1, 0, 0, 255,
|
||||
0, 0, 1, 0, 0,
|
||||
0, 0, 0, 1, 32 };
|
||||
sk_sp<SkColorFilter> cfAlphaTrans(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
|
||||
sk_sp<SkColorFilter> cfAlphaTrans(SkColorFilters::MatrixRowMajor255(matrix));
|
||||
|
||||
SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
|
||||
SkScalar MARGIN = SkIntToScalar(12);
|
||||
|
@ -114,7 +114,7 @@ protected:
|
||||
draw_bitmap, draw_path, draw_paint, draw_text
|
||||
};
|
||||
|
||||
sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorBLUE,
|
||||
sk_sp<SkColorFilter> cf(SkColorFilters::Blend(SK_ColorBLUE,
|
||||
SkBlendMode::kSrcIn));
|
||||
SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)),
|
||||
SkImageFilter::CropRect::kHasAll_CropEdge);
|
||||
|
@ -46,7 +46,7 @@ protected:
|
||||
canvas->clear(SK_ColorBLACK);
|
||||
{
|
||||
sk_sp<SkImageFilter> bitmapSource(SkImageSource::Make(fImage));
|
||||
sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorRED,
|
||||
sk_sp<SkColorFilter> cf(SkColorFilters::Blend(SK_ColorRED,
|
||||
SkBlendMode::kSrcIn));
|
||||
sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(4.0f, 4.0f, std::move(bitmapSource)));
|
||||
sk_sp<SkImageFilter> erode(SkErodeImageFilter::Make(4, 4, blur));
|
||||
@ -67,7 +67,7 @@ protected:
|
||||
0, 0, SK_Scalar1, 0, 0,
|
||||
0, 0, 0, 0.5f, 0 };
|
||||
|
||||
sk_sp<SkColorFilter> matrixFilter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
|
||||
sk_sp<SkColorFilter> matrixFilter(SkColorFilters::MatrixRowMajor255(matrix));
|
||||
sk_sp<SkImageFilter> colorMorph(SkColorFilterImageFilter::Make(std::move(matrixFilter),
|
||||
std::move(morph)));
|
||||
SkPaint paint;
|
||||
@ -82,7 +82,7 @@ protected:
|
||||
0, SK_Scalar1, 0, 0, 0,
|
||||
0, 0, SK_Scalar1, 0, 0,
|
||||
0, 0, 0, 0.5f, 0 };
|
||||
sk_sp<SkColorFilter> matrixCF(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
|
||||
sk_sp<SkColorFilter> matrixCF(SkColorFilters::MatrixRowMajor255(matrix));
|
||||
sk_sp<SkImageFilter> matrixFilter(SkColorFilterImageFilter::Make(std::move(matrixCF),
|
||||
nullptr));
|
||||
sk_sp<SkImageFilter> offsetFilter(SkOffsetImageFilter::Make(10.0f, 10.f,
|
||||
@ -141,10 +141,8 @@ protected:
|
||||
}
|
||||
{
|
||||
// Test that crop offsets are absolute, not relative to the parent's crop rect.
|
||||
sk_sp<SkColorFilter> cf1(SkColorFilter::MakeModeFilter(SK_ColorBLUE,
|
||||
SkBlendMode::kSrcIn));
|
||||
sk_sp<SkColorFilter> cf2(SkColorFilter::MakeModeFilter(SK_ColorGREEN,
|
||||
SkBlendMode::kSrcIn));
|
||||
sk_sp<SkColorFilter> cf1(SkColorFilters::Blend(SK_ColorBLUE, SkBlendMode::kSrcIn));
|
||||
sk_sp<SkColorFilter> cf2(SkColorFilters::Blend(SK_ColorGREEN, SkBlendMode::kSrcIn));
|
||||
SkImageFilter::CropRect outerRect(SkRect::MakeXYWH(SkIntToScalar(10), SkIntToScalar(10),
|
||||
SkIntToScalar(80), SkIntToScalar(80)));
|
||||
SkImageFilter::CropRect innerRect(SkRect::MakeXYWH(SkIntToScalar(20), SkIntToScalar(20),
|
||||
|
@ -26,7 +26,7 @@ static sk_sp<SkColorFilter> yuv_to_rgb_colorfilter() {
|
||||
0.0f, 0.0f, 0.0f, 1.0f, 0.0f
|
||||
};
|
||||
|
||||
return SkColorFilter::MakeMatrixFilterRowMajor255(kJPEGConversionMatrix);
|
||||
return SkColorFilters::MatrixRowMajor255(kJPEGConversionMatrix);
|
||||
}
|
||||
|
||||
namespace skiagm {
|
||||
|
@ -45,7 +45,7 @@ protected:
|
||||
SkISize onISize() override { return SkISize::Make(440, 530); }
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
auto cf = SkColorFilter::MakeModeFilter(SK_ColorGREEN, SkBlendMode::kSrc);
|
||||
auto cf = SkColorFilters::Blend(SK_ColorGREEN, SkBlendMode::kSrc);
|
||||
sk_sp<SkImageFilter> filters[] = {
|
||||
SkColorFilterImageFilter::Make(std::move(cf), nullptr),
|
||||
SkBlurImageFilter::Make(2.0f, 2.0f, nullptr),
|
||||
|
@ -174,7 +174,7 @@ private:
|
||||
|
||||
paint->setMaskFilter(MakeBlur());
|
||||
|
||||
paint->setColorFilter(SkColorFilter::MakeModeFilter(color, SkBlendMode::kSrcIn));
|
||||
paint->setColorFilter(SkColorFilters::Blend(color, SkBlendMode::kSrcIn));
|
||||
|
||||
return looperBuilder.detach();
|
||||
}
|
||||
@ -220,7 +220,7 @@ private:
|
||||
|
||||
paint->setMaskFilter(MakeBlur());
|
||||
|
||||
paint->setColorFilter(SkColorFilter::MakeModeFilter(gColors[i], SkBlendMode::kSrcIn));
|
||||
paint->setColorFilter(SkColorFilters::Blend(gColors[i], SkBlendMode::kSrcIn));
|
||||
}
|
||||
|
||||
return looperBuilder.detach();
|
||||
|
@ -46,7 +46,7 @@ static sk_sp<SkColorFilter> MakeTintColorFilter(SkColor lo, SkColor hi) {
|
||||
0, 0, 0, (a_hi - a_lo) / 255.0f, SkIntToScalar(a_lo),
|
||||
};
|
||||
|
||||
return SkColorFilter::MakeMatrixFilterRowMajor255(tint_matrix)
|
||||
return SkColorFilters::MatrixRowMajor255(tint_matrix)
|
||||
->makeComposed(SkLumaColorFilter::Make());
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ private:
|
||||
SkAutoCanvasRestore arc(canvas, true);
|
||||
for (size_t i = 0; i < fTileCount; ++i) {
|
||||
paint.setColorFilter(
|
||||
SkColorFilter::MakeLerp(cf0, cf1, static_cast<float>(i) / (fTileCount - 1)));
|
||||
SkColorFilters::Lerp(static_cast<float>(i) / (fTileCount - 1), cf0, cf1));
|
||||
canvas->translate(fTileSize.width() * 0.1f, 0);
|
||||
canvas->drawRect(SkRect::MakeWH(fTileSize.width(), fTileSize.height()), paint);
|
||||
canvas->translate(fTileSize.width() * 1.1f, 0);
|
||||
@ -220,10 +220,10 @@ DEF_SIMPLE_GM(mixercolorfilter, canvas, 768, 512) {
|
||||
|
||||
auto mx = SkMixer::MakeLerp(0.5f);
|
||||
|
||||
p.setColorFilter(SkColorFilter::MakeMixer(cf0, cf1, mx));
|
||||
p.setColorFilter(SkColorFilters::Mixer(mx, cf0, cf1));
|
||||
draw_rect(canvas, r, p, 0, 256);
|
||||
p.setColorFilter(SkColorFilter::MakeMixer(cf0, nullptr, mx));
|
||||
p.setColorFilter(SkColorFilters::Mixer(mx, cf0, nullptr));
|
||||
draw_rect(canvas, r, p, 256, 256);
|
||||
p.setColorFilter(SkColorFilter::MakeMixer(nullptr, cf1, mx));
|
||||
p.setColorFilter(SkColorFilters::Mixer(mx, nullptr, cf1));
|
||||
draw_rect(canvas, r, p, 512, 256);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ protected:
|
||||
const int kRectsPerRow = SkMax32(this->getISize().fWidth / kRectWidth, 1);
|
||||
for (size_t cfm = 0; cfm < SK_ARRAY_COUNT(modes); ++cfm) {
|
||||
for (size_t cfc = 0; cfc < SK_ARRAY_COUNT(colors); ++cfc) {
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(colors[cfc], modes[cfm]));
|
||||
paint.setColorFilter(SkColorFilters::Blend(colors[cfc], modes[cfm]));
|
||||
for (size_t s = 0; s < SK_ARRAY_COUNT(shaders); ++s) {
|
||||
paint.setShader(shaders[s]);
|
||||
bool hasShader = nullptr == paint.getShader();
|
||||
|
@ -409,7 +409,7 @@ static void tiled(SkCanvas* finalCanvas, SkMultiPictureDraw* mpd,
|
||||
step.fY = SkIntToScalar(y*kTileHeight);
|
||||
step.fPaint = new SkPaint;
|
||||
step.fPaint->setColorFilter(
|
||||
SkColorFilter::MakeModeFilter(colors[x][y], SkBlendMode::kModulate));
|
||||
SkColorFilters::Blend(colors[x][y], SkBlendMode::kModulate));
|
||||
|
||||
step.fSurf = create_compat_surface(finalCanvas, kTileWidth, kTileHeight);
|
||||
|
||||
|
@ -62,7 +62,7 @@ DEF_SIMPLE_GM_BG(skbug1719, canvas, 300, 100, 0xFF303030) {
|
||||
paint.setColor(0xFF000000);
|
||||
paint.setMaskFilter(
|
||||
SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 0.78867501f));
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(0xBFFFFFFF, SkBlendMode::kSrcIn));
|
||||
paint.setColorFilter(SkColorFilters::Blend(0xBFFFFFFF, SkBlendMode::kSrcIn));
|
||||
|
||||
canvas->clipPath(clipPath, true);
|
||||
canvas->drawPath(drawPath, paint);
|
||||
|
@ -21,9 +21,9 @@ DEF_SIMPLE_GM(srgb_colorfilter, canvas, 512, 256*3) {
|
||||
0, 0, 1, 0, 0,
|
||||
-1, 0, 0, 1, 0,
|
||||
};
|
||||
auto cf0 = SkColorFilter::MakeMatrixFilterRowMajor255(array);
|
||||
auto cf1 = SkColorFilter::MakeLinearToSRGBGamma();
|
||||
auto cf2 = SkColorFilter::MakeSRGBToLinearGamma();
|
||||
auto cf0 = SkColorFilters::MatrixRowMajor255(array);
|
||||
auto cf1 = SkColorFilters::LinearToSRGBGamma();
|
||||
auto cf2 = SkColorFilters::SRGBToLinearGamma();
|
||||
|
||||
SkPaint p;
|
||||
p.setColorFilter(cf0);
|
||||
|
@ -230,7 +230,7 @@ protected:
|
||||
int index = 0;
|
||||
for (int i = 0; i < MODE_COUNT; ++i) {
|
||||
for (int j = 0; j < COLOR_COUNT; ++j) {
|
||||
filters[index++] = SkColorFilter::MakeModeFilter(fColors[j], fModes[i]);
|
||||
filters[index++] = SkColorFilters::Blend(fColors[j], fModes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ protected:
|
||||
SkRect dstRect = SkRect::MakeWH(SkIntToScalar(fBitmap->width() * 2),
|
||||
SkIntToScalar(fBitmap->height() * 2));
|
||||
sk_sp<SkImageFilter> tile(SkTileImageFilter::Make(srcRect, dstRect, nullptr));
|
||||
sk_sp<SkColorFilter> cf(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
|
||||
sk_sp<SkColorFilter> cf(SkColorFilters::MatrixRowMajor255(matrix));
|
||||
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(SkColorFilterImageFilter::Make(std::move(cf), std::move(tile)));
|
||||
@ -110,8 +110,7 @@ protected:
|
||||
srcRect = SkRect::MakeXYWH(0, 0, 50, 50);
|
||||
dstRect = SkRect::MakeXYWH(0, 0, 100, 100);
|
||||
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(5, 5, 40, 40));
|
||||
sk_sp<SkColorFilter> greenCF = SkColorFilter::MakeModeFilter(SK_ColorGREEN,
|
||||
SkBlendMode::kSrc);
|
||||
sk_sp<SkColorFilter> greenCF = SkColorFilters::Blend(SK_ColorGREEN, SkBlendMode::kSrc);
|
||||
sk_sp<SkImageFilter> green(SkColorFilterImageFilter::Make(std::move(greenCF),
|
||||
nullptr,
|
||||
&cropRect));
|
||||
|
@ -39,7 +39,7 @@ static sk_sp<SkShader> make_shader2() {
|
||||
}
|
||||
|
||||
static sk_sp<SkColorFilter> make_color_filter() {
|
||||
return SkColorFilter::MakeModeFilter(0xFFAABBCC, SkBlendMode::kDarken);
|
||||
return SkColorFilters::Blend(0xFFAABBCC, SkBlendMode::kDarken);
|
||||
}
|
||||
|
||||
static constexpr SkScalar kMeshSize = 30;
|
||||
|
@ -782,7 +782,7 @@ static sk_sp<SkColorFilter> yuv_to_rgb_colorfilter() {
|
||||
0.0f, 0.0f, 0.0f, 1.0f, 0.0f
|
||||
};
|
||||
|
||||
return SkColorFilter::MakeMatrixFilterRowMajor255(kJPEGConversionMatrix);
|
||||
return SkColorFilters::MatrixRowMajor255(kJPEGConversionMatrix);
|
||||
}
|
||||
|
||||
namespace skiagm {
|
||||
|
@ -22,6 +22,10 @@ class SkMixer;
|
||||
struct SkStageRec;
|
||||
class SkString;
|
||||
|
||||
#ifndef SK_SUPPORT_LEGACY_COLORFILTER_FACTORIES
|
||||
#define SK_SUPPORT_LEGACY_COLORFILTER_FACTORIES
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ColorFilters are optional objects in the drawing pipeline. When present in
|
||||
* a paint, they are called with the "src" colors, and return new colors, which
|
||||
@ -61,17 +65,6 @@ public:
|
||||
SkColor filterColor(SkColor) const;
|
||||
SkColor4f filterColor4f(const SkColor4f&, SkColorSpace*) const;
|
||||
|
||||
/** Create a colorfilter that uses the specified color and mode.
|
||||
If the Mode is DST, this function will return NULL (since that
|
||||
mode will have no effect on the result).
|
||||
@param c The source color used with the specified mode
|
||||
@param mode The blend that is applied to each color in
|
||||
the colorfilter's filterSpan[16,32] methods
|
||||
@return colorfilter object that applies the src color and mode,
|
||||
or NULL if the mode will have no effect.
|
||||
*/
|
||||
static sk_sp<SkColorFilter> MakeModeFilter(SkColor c, SkBlendMode mode);
|
||||
|
||||
/** Construct a colorfilter whose effect is to first apply the inner filter and then apply
|
||||
* this filter, applied to the output of the inner filter.
|
||||
*
|
||||
@ -82,6 +75,53 @@ public:
|
||||
*/
|
||||
sk_sp<SkColorFilter> makeComposed(sk_sp<SkColorFilter> inner) const;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/**
|
||||
* A subclass may implement this factory function to work with the GPU backend. It returns
|
||||
* a GrFragmentProcessor that implemets the color filter in GPU shader code.
|
||||
*
|
||||
* The fragment processor receives a premultiplied input color and produces a premultiplied
|
||||
* output color.
|
||||
*
|
||||
* A null return indicates that the color filter isn't implemented for the GPU backend.
|
||||
*/
|
||||
virtual std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
|
||||
GrRecordingContext*, const GrColorSpaceInfo& dstColorSpaceInfo) const;
|
||||
#endif
|
||||
|
||||
bool affectsTransparentBlack() const {
|
||||
return this->filterColor(SK_ColorTRANSPARENT) != SK_ColorTRANSPARENT;
|
||||
}
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
||||
static SkFlattenable::Type GetFlattenableType() {
|
||||
return kSkColorFilter_Type;
|
||||
}
|
||||
|
||||
SkFlattenable::Type getFlattenableType() const override {
|
||||
return kSkColorFilter_Type;
|
||||
}
|
||||
|
||||
static sk_sp<SkColorFilter> Deserialize(const void* data, size_t size,
|
||||
const SkDeserialProcs* procs = nullptr) {
|
||||
return sk_sp<SkColorFilter>(static_cast<SkColorFilter*>(
|
||||
SkFlattenable::Deserialize(
|
||||
kSkColorFilter_Type, data, size, procs).release()));
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_COLORFILTER_FACTORIES
|
||||
/** Create a colorfilter that uses the specified color and mode.
|
||||
If the Mode is DST, this function will return NULL (since that
|
||||
mode will have no effect on the result).
|
||||
@param c The source color used with the specified mode
|
||||
@param mode The blend that is applied to each color in
|
||||
the colorfilter's filterSpan[16,32] methods
|
||||
@return colorfilter object that applies the src color and mode,
|
||||
or NULL if the mode will have no effect.
|
||||
*/
|
||||
static sk_sp<SkColorFilter> MakeModeFilter(SkColor c, SkBlendMode mode);
|
||||
|
||||
// DEPRECATED, call makeComposed instead
|
||||
static sk_sp<SkColorFilter> MakeComposeFilter(sk_sp<SkColorFilter> outer,
|
||||
sk_sp<SkColorFilter> inner) {
|
||||
@ -120,42 +160,8 @@ public:
|
||||
*/
|
||||
static sk_sp<SkColorFilter> MakeMixer(sk_sp<SkColorFilter> cf0, sk_sp<SkColorFilter> cf1,
|
||||
sk_sp<SkMixer> mx);
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/**
|
||||
* A subclass may implement this factory function to work with the GPU backend. It returns
|
||||
* a GrFragmentProcessor that implemets the color filter in GPU shader code.
|
||||
*
|
||||
* The fragment processor receives a premultiplied input color and produces a premultiplied
|
||||
* output color.
|
||||
*
|
||||
* A null return indicates that the color filter isn't implemented for the GPU backend.
|
||||
*/
|
||||
virtual std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
|
||||
GrRecordingContext*, const GrColorSpaceInfo& dstColorSpaceInfo) const;
|
||||
#endif
|
||||
|
||||
bool affectsTransparentBlack() const {
|
||||
return this->filterColor(SK_ColorTRANSPARENT) != SK_ColorTRANSPARENT;
|
||||
}
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
||||
static SkFlattenable::Type GetFlattenableType() {
|
||||
return kSkColorFilter_Type;
|
||||
}
|
||||
|
||||
SkFlattenable::Type getFlattenableType() const override {
|
||||
return kSkColorFilter_Type;
|
||||
}
|
||||
|
||||
static sk_sp<SkColorFilter> Deserialize(const void* data, size_t size,
|
||||
const SkDeserialProcs* procs = nullptr) {
|
||||
return sk_sp<SkColorFilter>(static_cast<SkColorFilter*>(
|
||||
SkFlattenable::Deserialize(
|
||||
kSkColorFilter_Type, data, size, procs).release()));
|
||||
}
|
||||
|
||||
protected:
|
||||
SkColorFilter() {}
|
||||
|
||||
@ -176,4 +182,21 @@ private:
|
||||
typedef SkFlattenable INHERITED;
|
||||
};
|
||||
|
||||
class SK_API SkColorFilters {
|
||||
public:
|
||||
static sk_sp<SkColorFilter> Compose(sk_sp<SkColorFilter> outer, sk_sp<SkColorFilter> inner) {
|
||||
return outer ? outer->makeComposed(inner) : inner;
|
||||
}
|
||||
static sk_sp<SkColorFilter> Blend(SkColor c, SkBlendMode mode);
|
||||
static sk_sp<SkColorFilter> MatrixRowMajor255(const SkScalar array[20]);
|
||||
static sk_sp<SkColorFilter> LinearToSRGBGamma();
|
||||
static sk_sp<SkColorFilter> SRGBToLinearGamma();
|
||||
static sk_sp<SkColorFilter> Lerp(float t, sk_sp<SkColorFilter> dst, sk_sp<SkColorFilter> src);
|
||||
static sk_sp<SkColorFilter> Mixer(sk_sp<SkMixer>,
|
||||
sk_sp<SkColorFilter> cf0, sk_sp<SkColorFilter> cf1);
|
||||
|
||||
private:
|
||||
SkColorFilters() = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -58,7 +58,7 @@ ModeColorFilter::~ModeColorFilter() {
|
||||
|
||||
sk_sp<SkColorFilter> ModeColorFilter::onRevalidateFilter() {
|
||||
fColor->revalidate(nullptr, SkMatrix::I());
|
||||
return SkColorFilter::MakeModeFilter(fColor->getColor(), fMode);
|
||||
return SkColorFilters::Blend(fColor->getColor(), fMode);
|
||||
}
|
||||
|
||||
sk_sp<GradientColorFilter> GradientColorFilter::Make(sk_sp<RenderNode> child,
|
||||
@ -132,7 +132,7 @@ sk_sp<SkColorFilter> Make2ColorGradient(const sk_sp<Color>& color0, const sk_sp<
|
||||
0, 0, 0, 1, 0,
|
||||
};
|
||||
|
||||
return SkColorFilter::MakeMatrixFilterRowMajor255(tint_matrix);
|
||||
return SkColorFilters::MatrixRowMajor255(tint_matrix);
|
||||
}
|
||||
|
||||
sk_sp<SkColorFilter> MakeNColorGradient(const std::vector<sk_sp<Color>>& colors) {
|
||||
@ -184,7 +184,7 @@ sk_sp<SkColorFilter> MakeNColorGradient(const std::vector<sk_sp<Color>>& colors)
|
||||
};
|
||||
|
||||
return SkTableColorFilter::MakeARGB(nullptr, rTable, gTable, bTable)
|
||||
->makeComposed(SkColorFilter::MakeMatrixFilterRowMajor255(luminance_matrix));
|
||||
->makeComposed(SkColorFilters::MatrixRowMajor255(luminance_matrix));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@ -202,7 +202,7 @@ sk_sp<SkColorFilter> GradientColorFilter::onRevalidateFilter() {
|
||||
auto gradientCF = (fColors.size() > 2) ? MakeNColorGradient(fColors)
|
||||
: Make2ColorGradient(fColors[0], fColors[1]);
|
||||
|
||||
return SkColorFilter::MakeLerp(nullptr, std::move(gradientCF), fWeight);
|
||||
return SkColorFilters::Lerp(fWeight, nullptr, std::move(gradientCF));
|
||||
}
|
||||
|
||||
} // namespace sksg
|
||||
|
@ -39,8 +39,7 @@ bool RenderNode::RenderContext::requiresIsolation() const {
|
||||
|
||||
void RenderNode::RenderContext::modulatePaint(const SkMatrix& ctm, SkPaint* paint) const {
|
||||
paint->setAlpha(ScaleAlpha(paint->getAlpha(), fOpacity));
|
||||
paint->setColorFilter(SkColorFilter::MakeComposeFilter(fColorFilter,
|
||||
paint->refColorFilter()));
|
||||
paint->setColorFilter(SkColorFilters::Compose(fColorFilter, paint->refColorFilter()));
|
||||
if (fShader) {
|
||||
if (fShaderCTM != ctm) {
|
||||
// The shader is declared to operate under a specific transform, but due to the
|
||||
@ -88,8 +87,7 @@ RenderNode::ScopedRenderContext::modulateOpacity(float opacity) {
|
||||
|
||||
RenderNode::ScopedRenderContext&&
|
||||
RenderNode::ScopedRenderContext::modulateColorFilter(sk_sp<SkColorFilter> cf) {
|
||||
fCtx.fColorFilter = SkColorFilter::MakeComposeFilter(std::move(fCtx.fColorFilter),
|
||||
std::move(cf));
|
||||
fCtx.fColorFilter = SkColorFilters::Compose(std::move(fCtx.fColorFilter), std::move(cf));
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ protected:
|
||||
|
||||
for (size_t y = 0; y < SK_ARRAY_COUNT(gColors); y++) {
|
||||
for (size_t x = 0; x < SK_ARRAY_COUNT(gModes); x++) {
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(gColors[y], gModes[x]));
|
||||
paint.setColorFilter(SkColorFilters::Blend(gColors[y], gModes[x]));
|
||||
canvas->drawBitmap(fBitmap, x * N * 1.25f, y * N * scale, &paint);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ protected:
|
||||
paint.setColorFilter(cf0);
|
||||
canvas->drawImage(fImg, 0, 0, &paint);
|
||||
|
||||
paint.setColorFilter(SkColorFilter::MakeLerp(cf0, cf1, fWeight));
|
||||
paint.setColorFilter(SkColorFilters::Lerp(fWeight, cf0, cf1));
|
||||
canvas->drawImage(fImg, fImg->width() + gap * fWeight, 0, &paint);
|
||||
|
||||
paint.setColorFilter(cf1);
|
||||
@ -58,8 +58,8 @@ protected:
|
||||
void onDrawContent(SkCanvas* canvas) override {
|
||||
if (!fImg) {
|
||||
fImg = GetResourceAsImage("images/mandrill_256.png");
|
||||
fCF0 = SkColorFilter::MakeMatrixFilterRowMajor255(gMat);
|
||||
fCF1 = SkColorFilter::MakeModeFilter(0xFF44CC88, SkBlendMode::kScreen);
|
||||
fCF0 = SkColorFilters::MatrixRowMajor255(gMat);
|
||||
fCF1 = SkColorFilters::Blend(0xFF44CC88, SkBlendMode::kScreen);
|
||||
}
|
||||
|
||||
float gap = fImg->width() * 3;
|
||||
|
@ -221,7 +221,7 @@ public:
|
||||
0.f, 0.f, 0.f, 255.f, 0.f
|
||||
};
|
||||
|
||||
blit.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(kFilter));
|
||||
blit.setColorFilter(SkColorFilters::MatrixRowMajor255(kFilter));
|
||||
}
|
||||
|
||||
canvas->scale(scale, scale);
|
||||
|
@ -244,11 +244,21 @@ sk_sp<SkColorFilter> MakeSRGBGammaCF() {
|
||||
return sk_ref_sp(gSingleton);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_COLORFILTER_FACTORIES
|
||||
sk_sp<SkColorFilter> SkColorFilter::MakeLinearToSRGBGamma() {
|
||||
return MakeSRGBGammaCF<SkSRGBGammaColorFilter::Direction::kLinearToSRGB>();
|
||||
return SkColorFilters::LinearToSRGBGamma();
|
||||
}
|
||||
|
||||
sk_sp<SkColorFilter> SkColorFilter::MakeSRGBToLinearGamma() {
|
||||
return SkColorFilters::SRGBToLinearGamma();
|
||||
}
|
||||
#endif
|
||||
|
||||
sk_sp<SkColorFilter> SkColorFilters::LinearToSRGBGamma() {
|
||||
return MakeSRGBGammaCF<SkSRGBGammaColorFilter::Direction::kLinearToSRGB>();
|
||||
}
|
||||
|
||||
sk_sp<SkColorFilter> SkColorFilters::SRGBToLinearGamma() {
|
||||
return MakeSRGBGammaCF<SkSRGBGammaColorFilter::Direction::kSRGBToLinear>();
|
||||
}
|
||||
|
||||
@ -331,12 +341,19 @@ sk_sp<SkFlattenable> SkMixerColorFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
sk_sp<SkColorFilter> cf0(buffer.readColorFilter());
|
||||
sk_sp<SkColorFilter> cf1(buffer.readColorFilter());
|
||||
const float weight = buffer.readScalar();
|
||||
return MakeLerp(std::move(cf0), std::move(cf1), weight);
|
||||
return SkColorFilters::Lerp(weight, std::move(cf0), std::move(cf1));
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_COLORFILTER_FACTORIES
|
||||
sk_sp<SkColorFilter> SkColorFilter::MakeLerp(sk_sp<SkColorFilter> cf0,
|
||||
sk_sp<SkColorFilter> cf1,
|
||||
float weight) {
|
||||
return SkColorFilters::Lerp(weight, std::move(cf0), std::move(cf1));
|
||||
}
|
||||
#endif
|
||||
|
||||
sk_sp<SkColorFilter> SkColorFilters::Lerp(float weight, sk_sp<SkColorFilter> cf0,
|
||||
sk_sp<SkColorFilter> cf1) {
|
||||
if (!cf0 && !cf1) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -12,7 +12,15 @@
|
||||
#include "SkWriteBuffer.h"
|
||||
#include "SkString.h"
|
||||
|
||||
sk_sp<SkColorFilter> SkColorFilter::MakeMixer(sk_sp<SkColorFilter> f0, sk_sp<SkColorFilter> f1, sk_sp<SkMixer> mixer) {
|
||||
#ifdef SK_SUPPORT_LEGACY_COLORFILTER_FACTORIES
|
||||
sk_sp<SkColorFilter> SkColorFilter::MakeMixer(sk_sp<SkColorFilter> f0, sk_sp<SkColorFilter> f1,
|
||||
sk_sp<SkMixer> mixer) {
|
||||
return SkColorFilters::Mixer(std::move(mixer), std::move(f0), std::move(f1));
|
||||
}
|
||||
#endif
|
||||
|
||||
sk_sp<SkColorFilter> SkColorFilters::Mixer(sk_sp<SkMixer> mixer,
|
||||
sk_sp<SkColorFilter> f0, sk_sp<SkColorFilter> f1) {
|
||||
if (!mixer) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -27,7 +35,7 @@ sk_sp<SkFlattenable> SkColorFilter_Mixer::CreateProc(SkReadBuffer& buffer) {
|
||||
sk_sp<SkColorFilter> s1(buffer.readColorFilter());
|
||||
sk_sp<SkMixer> mx(buffer.readMixer());
|
||||
|
||||
return MakeMixer(std::move(s0), std::move(s1), std::move(mx));
|
||||
return SkColorFilters::Mixer(std::move(mx), std::move(s0), std::move(s1));
|
||||
}
|
||||
|
||||
void SkColorFilter_Mixer::flatten(SkWriteBuffer& buffer) const {
|
||||
|
@ -202,7 +202,13 @@ std::unique_ptr<GrFragmentProcessor> SkColorMatrixFilterRowMajor255::asFragmentP
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_COLORFILTER_FACTORIES
|
||||
sk_sp<SkColorFilter> SkColorFilter::MakeMatrixFilterRowMajor255(const SkScalar array[20]) {
|
||||
return SkColorFilters::MatrixRowMajor255(array);
|
||||
}
|
||||
#endif
|
||||
|
||||
sk_sp<SkColorFilter> SkColorFilters::MatrixRowMajor255(const float array[20]) {
|
||||
if (!SkScalarsAreFinite(array, 20)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ void SkModeColorFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
sk_sp<SkFlattenable> SkModeColorFilter::CreateProc(SkReadBuffer& buffer) {
|
||||
SkColor color = buffer.readColor();
|
||||
SkBlendMode mode = (SkBlendMode)buffer.readUInt();
|
||||
return SkColorFilter::MakeModeFilter(color, mode);
|
||||
return SkColorFilters::Blend(color, mode);
|
||||
}
|
||||
|
||||
bool SkModeColorFilter::onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
|
||||
@ -104,7 +104,13 @@ std::unique_ptr<GrFragmentProcessor> SkModeColorFilter::asFragmentProcessor(
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_COLORFILTER_FACTORIES
|
||||
sk_sp<SkColorFilter> SkColorFilter::MakeModeFilter(SkColor color, SkBlendMode mode) {
|
||||
return SkColorFilters::Blend(color, mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
sk_sp<SkColorFilter> SkColorFilters::Blend(SkColor color, SkBlendMode mode) {
|
||||
if (!SkIsValidMode(mode)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ SkOverdrawCanvas::SkOverdrawCanvas(SkCanvas* canvas)
|
||||
|
||||
fPaint.setAntiAlias(false);
|
||||
fPaint.setBlendMode(SkBlendMode::kPlus);
|
||||
fPaint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(kIncrementAlpha));
|
||||
fPaint.setColorFilter(SkColorFilters::MatrixRowMajor255(kIncrementAlpha));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -20,7 +20,7 @@ sk_sp<SkColorFilter> SkColorMatrixFilter::MakeLightingFilter(SkColor mul, SkColo
|
||||
const SkColor opaqueAlphaMask = SK_ColorBLACK;
|
||||
// omit the alpha and compare only the RGB values
|
||||
if (0 == (add & ~opaqueAlphaMask)) {
|
||||
return SkColorFilter::MakeModeFilter(mul | opaqueAlphaMask, SkBlendMode::kModulate);
|
||||
return SkColorFilters::Blend(mul | opaqueAlphaMask, SkBlendMode::kModulate);
|
||||
}
|
||||
|
||||
SkColorMatrix matrix;
|
||||
@ -32,5 +32,5 @@ sk_sp<SkColorFilter> SkColorMatrixFilter::MakeLightingFilter(SkColor mul, SkColo
|
||||
SkIntToScalar(SkColorGetG(add)),
|
||||
SkIntToScalar(SkColorGetB(add)),
|
||||
0);
|
||||
return SkColorFilter::MakeMatrixFilterRowMajor255(matrix.fMat);
|
||||
return SkColorFilters::MatrixRowMajor255(matrix.fMat);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ sk_sp<SkSpecialImage> SkDropShadowImageFilter::onFilterImage(SkSpecialImage* sou
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setImageFilter(SkBlurImageFilter::Make(sigma.fX, sigma.fY, nullptr));
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(fColor, SkBlendMode::kSrcIn));
|
||||
paint.setColorFilter(SkColorFilters::Blend(fColor, SkBlendMode::kSrcIn));
|
||||
|
||||
SkVector offsetVec = SkVector::Make(fDx, fDy);
|
||||
ctx.ctm().mapVectors(&offsetVec, 1);
|
||||
|
@ -435,8 +435,8 @@ bool draw_shadow(const FACTORY& factory,
|
||||
// Run the vertex color through a GaussianColorFilter and then modulate the grayscale result of
|
||||
// that against our 'color' param.
|
||||
paint.setColorFilter(
|
||||
SkColorFilter::MakeModeFilter(color, SkBlendMode::kModulate)->makeComposed(
|
||||
SkGaussianColorFilter::Make()));
|
||||
SkColorFilters::Blend(color, SkBlendMode::kModulate)->makeComposed(
|
||||
SkGaussianColorFilter::Make()));
|
||||
|
||||
drawProc(vertices.get(), SkBlendMode::kModulate, paint,
|
||||
context.fTranslate.fX, context.fTranslate.fY, path.viewMatrix().hasPerspective());
|
||||
@ -581,7 +581,7 @@ void SkBaseDevice::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
|
||||
// Run the vertex color through a GaussianColorFilter and then modulate the
|
||||
// grayscale result of that against our 'color' param.
|
||||
paint.setColorFilter(
|
||||
SkColorFilter::MakeModeFilter(rec.fAmbientColor,
|
||||
SkColorFilters::Blend(rec.fAmbientColor,
|
||||
SkBlendMode::kModulate)->makeComposed(
|
||||
SkGaussianColorFilter::Make()));
|
||||
this->drawVertices(vertices.get(), nullptr, 0, SkBlendMode::kModulate, paint);
|
||||
@ -662,7 +662,7 @@ void SkBaseDevice::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
|
||||
// Run the vertex color through a GaussianColorFilter and then modulate the
|
||||
// grayscale result of that against our 'color' param.
|
||||
paint.setColorFilter(
|
||||
SkColorFilter::MakeModeFilter(rec.fSpotColor,
|
||||
SkColorFilters::Blend(rec.fSpotColor,
|
||||
SkBlendMode::kModulate)->makeComposed(
|
||||
SkGaussianColorFilter::Make()));
|
||||
this->drawVertices(vertices.get(), nullptr, 0, SkBlendMode::kModulate, paint);
|
||||
|
@ -136,8 +136,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ApplyGamma, reporter, ctxInfo) {
|
||||
|
||||
SkPaint gammaPaint;
|
||||
gammaPaint.setBlendMode(SkBlendMode::kSrc);
|
||||
gammaPaint.setColorFilter(toSRGB ? SkColorFilter::MakeLinearToSRGBGamma()
|
||||
: SkColorFilter::MakeSRGBToLinearGamma());
|
||||
gammaPaint.setColorFilter(toSRGB ? SkColorFilters::LinearToSRGBGamma()
|
||||
: SkColorFilters::SRGBToLinearGamma());
|
||||
|
||||
dstCanvas->drawBitmap(bm, 0, 0, &gammaPaint);
|
||||
dst->flush();
|
||||
|
@ -35,7 +35,7 @@ static sk_sp<SkColorFilter> reincarnate_colorfilter(SkFlattenable* obj) {
|
||||
|
||||
static sk_sp<SkColorFilter> make_filter() {
|
||||
// pick a filter that cannot compose with itself via newComposed()
|
||||
return SkColorFilter::MakeModeFilter(SK_ColorRED, SkBlendMode::kColorBurn);
|
||||
return SkColorFilters::Blend(SK_ColorRED, SkBlendMode::kColorBurn);
|
||||
}
|
||||
|
||||
static void test_composecolorfilter_limit(skiatest::Reporter* reporter) {
|
||||
@ -65,7 +65,7 @@ DEF_TEST(ColorFilter, reporter) {
|
||||
// special case that would return nullptr (if color's alpha is 0 or 0xFF)
|
||||
color = SkColorSetA(color, 0x7F);
|
||||
|
||||
auto cf = SkColorFilter::MakeModeFilter(color, (SkBlendMode)mode);
|
||||
auto cf = SkColorFilters::Blend(color, (SkBlendMode)mode);
|
||||
|
||||
// allow for no filter if we're in Dst mode (its a no op)
|
||||
if (SkBlendMode::kDst == (SkBlendMode)mode && nullptr == cf) {
|
||||
|
@ -47,7 +47,7 @@ static inline void test_colorMatrixCTS(skiatest::Reporter* reporter) {
|
||||
0.0f, 1.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f, 0.0f };
|
||||
paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(blueToCyan));
|
||||
paint.setColorFilter(SkColorFilters::MatrixRowMajor255(blueToCyan));
|
||||
|
||||
paint.setColor(SK_ColorBLUE);
|
||||
canvas.drawPoint(0, 0, paint);
|
||||
@ -72,7 +72,7 @@ static inline void test_colorMatrixCTS(skiatest::Reporter* reporter) {
|
||||
0.0f, 0.0f, 1.0f, 0.0f, 64.0f,
|
||||
-0.5f, 0.0f, 0.0f, 1.0f, 0.0f
|
||||
};
|
||||
paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(transparentRedAddBlue));
|
||||
paint.setColorFilter(SkColorFilters::MatrixRowMajor255(transparentRedAddBlue));
|
||||
bitmap.eraseColor(SK_ColorTRANSPARENT);
|
||||
|
||||
paint.setColor(SK_ColorRED);
|
||||
@ -93,7 +93,7 @@ static inline void test_colorMatrixCTS(skiatest::Reporter* reporter) {
|
||||
assert_color(reporter, SK_ColorCYAN, bitmap.getColor(0, 0));
|
||||
|
||||
// create a new filter with the changed matrix
|
||||
paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(transparentRedAddBlue));
|
||||
paint.setColorFilter(SkColorFilters::MatrixRowMajor255(transparentRedAddBlue));
|
||||
canvas.drawPoint(0, 0, paint);
|
||||
assert_color(reporter, SK_ColorBLUE, bitmap.getColor(0, 0));
|
||||
}
|
||||
@ -113,7 +113,7 @@ DEF_TEST(ColorMatrix_clamp_while_unpremul, r) {
|
||||
0, 0, 1, 0, 0,
|
||||
0, 0, 0, 1, 32,
|
||||
};
|
||||
auto filter = SkColorFilter::MakeMatrixFilterRowMajor255(m);
|
||||
auto filter = SkColorFilters::MatrixRowMajor255(m);
|
||||
|
||||
SkColor filtered = filter->filterColor(0xff0a0b0c);
|
||||
REPORTER_ASSERT(r, SkColorGetA(filtered) == 0xff);
|
||||
|
@ -28,7 +28,7 @@ static SkBitmap create_bm() {
|
||||
}
|
||||
|
||||
static sk_sp<SkImageFilter> make_filter() {
|
||||
sk_sp<SkColorFilter> filter(SkColorFilter::MakeModeFilter(SK_ColorBLUE,
|
||||
sk_sp<SkColorFilter> filter(SkColorFilters::Blend(SK_ColorBLUE,
|
||||
SkBlendMode::kSrcIn));
|
||||
return SkColorFilterImageFilter::Make(std::move(filter), nullptr, nullptr);
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public:
|
||||
SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1);
|
||||
const SkScalar five = SkIntToScalar(5);
|
||||
{
|
||||
sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorRED,
|
||||
sk_sp<SkColorFilter> cf(SkColorFilters::Blend(SK_ColorRED,
|
||||
SkBlendMode::kSrcIn));
|
||||
|
||||
this->addFilter("color filter",
|
||||
@ -344,7 +344,7 @@ static sk_sp<SkImageFilter> make_scale(float amount, sk_sp<SkImageFilter> input)
|
||||
0, s, 0, 0, 0,
|
||||
0, 0, s, 0, 0,
|
||||
0, 0, 0, s, 0 };
|
||||
sk_sp<SkColorFilter> filter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
|
||||
sk_sp<SkColorFilter> filter(SkColorFilters::MatrixRowMajor255(matrix));
|
||||
return SkColorFilterImageFilter::Make(std::move(filter), std::move(input));
|
||||
}
|
||||
|
||||
@ -356,14 +356,13 @@ static sk_sp<SkImageFilter> make_grayscale(sk_sp<SkImageFilter> input,
|
||||
matrix[1] = matrix[6] = matrix[11] = 0.7152f;
|
||||
matrix[2] = matrix[7] = matrix[12] = 0.0722f;
|
||||
matrix[18] = 1.0f;
|
||||
sk_sp<SkColorFilter> filter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
|
||||
sk_sp<SkColorFilter> filter(SkColorFilters::MatrixRowMajor255(matrix));
|
||||
return SkColorFilterImageFilter::Make(std::move(filter), std::move(input), cropRect);
|
||||
}
|
||||
|
||||
static sk_sp<SkImageFilter> make_blue(sk_sp<SkImageFilter> input,
|
||||
const SkImageFilter::CropRect* cropRect) {
|
||||
sk_sp<SkColorFilter> filter(SkColorFilter::MakeModeFilter(SK_ColorBLUE,
|
||||
SkBlendMode::kSrcIn));
|
||||
sk_sp<SkColorFilter> filter(SkColorFilters::Blend(SK_ColorBLUE, SkBlendMode::kSrcIn));
|
||||
return SkColorFilterImageFilter::Make(std::move(filter), std::move(input), cropRect);
|
||||
}
|
||||
|
||||
@ -459,10 +458,10 @@ DEF_TEST(ImageFilter, reporter) {
|
||||
blueToRedMatrix[2] = blueToRedMatrix[18] = SK_Scalar1;
|
||||
SkScalar redToGreenMatrix[20] = { 0 };
|
||||
redToGreenMatrix[5] = redToGreenMatrix[18] = SK_Scalar1;
|
||||
sk_sp<SkColorFilter> blueToRed(SkColorFilter::MakeMatrixFilterRowMajor255(blueToRedMatrix));
|
||||
sk_sp<SkColorFilter> blueToRed(SkColorFilters::MatrixRowMajor255(blueToRedMatrix));
|
||||
sk_sp<SkImageFilter> filter1(SkColorFilterImageFilter::Make(std::move(blueToRed),
|
||||
nullptr));
|
||||
sk_sp<SkColorFilter> redToGreen(SkColorFilter::MakeMatrixFilterRowMajor255(redToGreenMatrix));
|
||||
sk_sp<SkColorFilter> redToGreen(SkColorFilters::MatrixRowMajor255(redToGreenMatrix));
|
||||
sk_sp<SkImageFilter> filter2(SkColorFilterImageFilter::Make(std::move(redToGreen),
|
||||
std::move(filter1)));
|
||||
|
||||
@ -666,7 +665,7 @@ static void test_fail_affects_transparent_black(skiatest::Reporter* reporter, Gr
|
||||
sk_sp<SkSpecialImage> source(create_empty_special_image(context, 5));
|
||||
SkImageFilter::OutputProperties noColorSpace(kN32_SkColorType, nullptr);
|
||||
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 1, 1), nullptr, noColorSpace);
|
||||
sk_sp<SkColorFilter> green(SkColorFilter::MakeModeFilter(SK_ColorGREEN, SkBlendMode::kSrc));
|
||||
sk_sp<SkColorFilter> green(SkColorFilters::Blend(SK_ColorGREEN, SkBlendMode::kSrc));
|
||||
SkASSERT(green->affectsTransparentBlack());
|
||||
sk_sp<SkImageFilter> greenFilter(SkColorFilterImageFilter::Make(std::move(green),
|
||||
std::move(failFilter)));
|
||||
@ -757,7 +756,7 @@ static void draw_saveLayer_picture(int width, int height, int tileSize,
|
||||
SkMatrix matrix;
|
||||
matrix.setTranslate(SkIntToScalar(50), 0);
|
||||
|
||||
sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorWHITE, SkBlendMode::kSrc));
|
||||
sk_sp<SkColorFilter> cf(SkColorFilters::Blend(SK_ColorWHITE, SkBlendMode::kSrc));
|
||||
sk_sp<SkImageFilter> cfif(SkColorFilterImageFilter::Make(std::move(cf), nullptr));
|
||||
sk_sp<SkImageFilter> imageFilter(SkImageFilter::MakeMatrixFilter(matrix,
|
||||
kNone_SkFilterQuality,
|
||||
@ -1222,7 +1221,7 @@ DEF_TEST(ImageFilterEmptySaveLayer, reporter) {
|
||||
SkRTreeFactory factory;
|
||||
SkPictureRecorder recorder;
|
||||
|
||||
sk_sp<SkColorFilter> green(SkColorFilter::MakeModeFilter(SK_ColorGREEN,
|
||||
sk_sp<SkColorFilter> green(SkColorFilters::Blend(SK_ColorGREEN,
|
||||
SkBlendMode::kSrc));
|
||||
sk_sp<SkImageFilter> imageFilter(SkColorFilterImageFilter::Make(green, nullptr));
|
||||
SkPaint imageFilterPaint;
|
||||
@ -1349,8 +1348,7 @@ static void test_xfermode_cropped_input(SkSurface* surf, skiatest::Reporter* rep
|
||||
bitmap.allocN32Pixels(1, 1);
|
||||
bitmap.eraseARGB(255, 255, 255, 255);
|
||||
|
||||
sk_sp<SkColorFilter> green(SkColorFilter::MakeModeFilter(SK_ColorGREEN,
|
||||
SkBlendMode::kSrcIn));
|
||||
sk_sp<SkColorFilter> green(SkColorFilters::Blend(SK_ColorGREEN, SkBlendMode::kSrcIn));
|
||||
sk_sp<SkImageFilter> greenFilter(SkColorFilterImageFilter::Make(green, nullptr));
|
||||
SkImageFilter::CropRect cropRect(SkRect::MakeEmpty());
|
||||
sk_sp<SkImageFilter> croppedOut(SkColorFilterImageFilter::Make(green, nullptr, &cropRect));
|
||||
@ -1563,7 +1561,7 @@ DEF_TEST(ImageFilterCanComputeFastBounds, reporter) {
|
||||
0, 0, 0, 0, 1,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 1 };
|
||||
sk_sp<SkColorFilter> greenCF(SkColorFilter::MakeMatrixFilterRowMajor255(greenMatrix));
|
||||
sk_sp<SkColorFilter> greenCF(SkColorFilters::MatrixRowMajor255(greenMatrix));
|
||||
sk_sp<SkImageFilter> green(SkColorFilterImageFilter::Make(greenCF, nullptr));
|
||||
|
||||
REPORTER_ASSERT(reporter, greenCF->affectsTransparentBlack());
|
||||
@ -1774,7 +1772,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ImageFilterBlurLargeImage_Gpu, reporter, ctxInfo) {
|
||||
*/
|
||||
DEF_TEST(ImageFilterComplexCTM, reporter) {
|
||||
// just need a colorfilter to exercise the corresponding imagefilter
|
||||
sk_sp<SkColorFilter> cf = SkColorFilter::MakeModeFilter(SK_ColorRED, SkBlendMode::kSrcATop);
|
||||
sk_sp<SkColorFilter> cf = SkColorFilters::Blend(SK_ColorRED, SkBlendMode::kSrcATop);
|
||||
sk_sp<SkImageFilter> cfif = SkColorFilterImageFilter::Make(cf, nullptr); // can handle
|
||||
sk_sp<SkImageFilter> blif = SkBlurImageFilter::Make(3, 3, nullptr); // cannot handle
|
||||
|
||||
|
@ -320,11 +320,11 @@ DEF_TEST(Paint_nothingToDraw, r) {
|
||||
|
||||
SkColorMatrix cm;
|
||||
cm.setIdentity(); // does not change alpha
|
||||
paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
|
||||
paint.setColorFilter(SkColorFilters::MatrixRowMajor255(cm.fMat));
|
||||
REPORTER_ASSERT(r, paint.nothingToDraw());
|
||||
|
||||
cm.postTranslate(0, 0, 0, 1); // wacks alpha
|
||||
paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
|
||||
paint.setColorFilter(SkColorFilters::MatrixRowMajor255(cm.fMat));
|
||||
REPORTER_ASSERT(r, !paint.nothingToDraw());
|
||||
}
|
||||
|
||||
|
@ -489,7 +489,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageNullFulfill, reporter, ctxInfo) {
|
||||
// Draw the image a few different ways.
|
||||
canvas->drawImage(refImg, 0, 0);
|
||||
SkPaint paint;
|
||||
paint.setColorFilter(SkColorFilter::MakeLinearToSRGBGamma());
|
||||
paint.setColorFilter(SkColorFilters::LinearToSRGBGamma());
|
||||
canvas->drawImage(refImg, 0, 0, &paint);
|
||||
auto shader = refImg->makeShader(SkTileMode::kClamp, SkTileMode::kClamp);
|
||||
REPORTER_ASSERT(reporter, shader);
|
||||
|
@ -236,7 +236,7 @@ DEF_TEST(RecordOpts_MergeSvgOpacityAndFilterLayers, r) {
|
||||
xfermodePaint.setBlendMode(SkBlendMode::kDstIn);
|
||||
SkPaint colorFilterPaint;
|
||||
colorFilterPaint.setColorFilter(
|
||||
SkColorFilter::MakeModeFilter(SK_ColorLTGRAY, SkBlendMode::kSrcIn));
|
||||
SkColorFilters::Blend(SK_ColorLTGRAY, SkBlendMode::kSrcIn));
|
||||
|
||||
SkPaint opaqueFilterLayerPaint;
|
||||
opaqueFilterLayerPaint.setColor(0xFF020202); // Opaque.
|
||||
|
@ -359,7 +359,7 @@ DEF_TEST(SVGDevice_image_shader_tileboth, reporter) {
|
||||
DEF_TEST(SVGDevice_ColorFilters, reporter) {
|
||||
SkDOM dom;
|
||||
SkPaint paint;
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(SK_ColorRED, SkBlendMode::kSrcIn));
|
||||
paint.setColorFilter(SkColorFilters::Blend(SK_ColorRED, SkBlendMode::kSrcIn));
|
||||
{
|
||||
auto svgCanvas = MakeDOMCanvas(&dom);
|
||||
SkRect bounds{0, 0, SkIntToScalar(100), SkIntToScalar(100)};
|
||||
|
Loading…
Reference in New Issue
Block a user