Reland of [2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (patchset #1 id:1 of https://codereview.chromium.org/1821103004/ )
Reason for revert:
guard has now landed in chrome
Original issue's description:
> Revert of Revert[2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (patchset #3 id:40001 of https://codereview.chromium.org/1825073002/ )
>
> Reason for revert:
> CreateModeFilter not compiling
>
> Original issue's description:
> > Revert[2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.org/1822623002/ )"
> >
> > Fixed legacy withColorFilter to call new(er) make method
> >
> > This reverts commit 1eb81db650d31f50be67b12d60c4f9e7dd08432f.
> >
> > BUG=skia:
> > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1825073002
> >
> > TBR=
> >
> > Committed: https://skia.googlesource.com/skia/+/4c9776b046dd5e9e46e2d1ce35154855c8fcb381
>
> TBR=
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/d6889293dd0942f27f9593f679722c956831f2c4
TBR=
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=skia:
Review URL: https://codereview.chromium.org/1827433002
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index fd916cf..c2230b7 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -137,8 +137,8 @@
0, s, 0, 0, 0,
0, 0, s, 0, 0,
0, 0, 0, s, 0 };
- SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix));
- return SkColorFilterImageFilter::Create(filter, input);
+ auto filter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
+ return SkColorFilterImageFilter::Create(filter.get(), input);
}
static SkImageFilter* make_grayscale(SkImageFilter* input, const SkImageFilter::CropRect* cropRect) {
@@ -148,14 +148,13 @@
matrix[1] = matrix[6] = matrix[11] = 0.7152f;
matrix[2] = matrix[7] = matrix[12] = 0.0722f;
matrix[18] = 1.0f;
- SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix));
- return SkColorFilterImageFilter::Create(filter, input, cropRect);
+ auto filter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
+ return SkColorFilterImageFilter::Create(filter.get(), input, cropRect);
}
static SkImageFilter* make_blue(SkImageFilter* input, const SkImageFilter::CropRect* cropRect) {
- SkAutoTUnref<SkColorFilter> filter(SkColorFilter::CreateModeFilter(SK_ColorBLUE,
- SkXfermode::kSrcIn_Mode));
- return SkColorFilterImageFilter::Create(filter, input, cropRect);
+ auto filter(SkColorFilter::MakeModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mode));
+ return SkColorFilterImageFilter::Create(filter.get(), input, cropRect);
}
static sk_sp<SkSpecialSurface> create_empty_special_surface(GrContext* context,
@@ -258,9 +257,9 @@
blueToRedMatrix[2] = blueToRedMatrix[18] = SK_Scalar1;
SkScalar redToGreenMatrix[20] = { 0 };
redToGreenMatrix[5] = redToGreenMatrix[18] = SK_Scalar1;
- SkAutoTUnref<SkColorFilter> blueToRed(SkColorMatrixFilter::Create(blueToRedMatrix));
+ auto blueToRed(SkColorFilter::MakeMatrixFilterRowMajor255(blueToRedMatrix));
SkAutoTUnref<SkImageFilter> filter1(SkColorFilterImageFilter::Create(blueToRed.get()));
- SkAutoTUnref<SkColorFilter> redToGreen(SkColorMatrixFilter::Create(redToGreenMatrix));
+ auto redToGreen(SkColorFilter::MakeMatrixFilterRowMajor255(redToGreenMatrix));
SkAutoTUnref<SkImageFilter> filter2(SkColorFilterImageFilter::Create(redToGreen.get(), filter1.get()));
SkBitmap result;
@@ -320,7 +319,7 @@
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 30, 60, 60));
SkAutoTUnref<SkImageFilter> input(make_grayscale(nullptr, &inputCropRect));
- SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED, SkXfermode::kSrcIn_Mode));
+ auto cf(SkColorFilter::MakeModeFilter(SK_ColorRED, SkXfermode::kSrcIn_Mode));
SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1);
SkScalar kernel[9] = {
SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1),
@@ -564,7 +563,7 @@
// match the same filters drawn with a single full-canvas bitmap draw.
// Tests pass by not asserting.
- SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED, SkXfermode::kSrcIn_Mode));
+ auto cf(SkColorFilter::MakeModeFilter(SK_ColorRED, SkXfermode::kSrcIn_Mode));
SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1);
SkScalar kernel[9] = {
SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1),
@@ -693,7 +692,7 @@
SkMatrix matrix;
matrix.setTranslate(SkIntToScalar(50), 0);
- SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorWHITE, SkXfermode::kSrc_Mode));
+ auto cf(SkColorFilter::MakeModeFilter(SK_ColorWHITE, SkXfermode::kSrc_Mode));
SkAutoTUnref<SkImageFilter> cfif(SkColorFilterImageFilter::Create(cf.get()));
SkAutoTUnref<SkImageFilter> imageFilter(SkImageFilter::CreateMatrixFilter(matrix, kNone_SkFilterQuality, cfif.get()));
@@ -1122,14 +1121,13 @@
SkRTreeFactory factory;
SkPictureRecorder recorder;
- SkAutoTUnref<SkColorFilter> green(
- SkColorFilter::CreateModeFilter(SK_ColorGREEN, SkXfermode::kSrc_Mode));
+ auto green(SkColorFilter::MakeModeFilter(SK_ColorGREEN, SkXfermode::kSrc_Mode));
SkAutoTUnref<SkImageFilter> imageFilter(
SkColorFilterImageFilter::Create(green.get()));
SkPaint imageFilterPaint;
imageFilterPaint.setImageFilter(imageFilter.get());
SkPaint colorFilterPaint;
- colorFilterPaint.setColorFilter(green.get());
+ colorFilterPaint.setColorFilter(green);
SkRect bounds = SkRect::MakeWH(10, 10);
@@ -1245,8 +1243,7 @@
bitmap.allocN32Pixels(1, 1);
bitmap.eraseARGB(255, 255, 255, 255);
- SkAutoTUnref<SkColorFilter> green(
- SkColorFilter::CreateModeFilter(SK_ColorGREEN, SkXfermode::kSrcIn_Mode));
+ auto green(SkColorFilter::MakeModeFilter(SK_ColorGREEN, SkXfermode::kSrcIn_Mode));
SkAutoTUnref<SkImageFilter> greenFilter(SkColorFilterImageFilter::Create(green.get()));
SkImageFilter::CropRect cropRect(SkRect::MakeEmpty());
SkAutoTUnref<SkImageFilter> croppedOut(
@@ -1467,8 +1464,8 @@
0, 0, 0, 0, 1,
0, 0, 0, 0, 0,
0, 0, 0, 0, 1 };
- SkAutoTUnref<SkColorFilter> greenCF(SkColorMatrixFilter::Create(greenMatrix));
- SkAutoTUnref<SkImageFilter> green(SkColorFilterImageFilter::Create(greenCF));
+ auto greenCF(SkColorFilter::MakeMatrixFilterRowMajor255(greenMatrix));
+ SkAutoTUnref<SkImageFilter> green(SkColorFilterImageFilter::Create(greenCF.get()));
REPORTER_ASSERT(reporter, greenCF->affectsTransparentBlack());
REPORTER_ASSERT(reporter, !green->canComputeFastBounds());
@@ -1482,14 +1479,12 @@
allOne[i] = 255;
}
- SkAutoTUnref<SkColorFilter> identityCF(
- SkTableColorFilter::CreateARGB(identity, identity, identity, allOne));
+ auto identityCF(SkTableColorFilter::MakeARGB(identity, identity, identity, allOne));
SkAutoTUnref<SkImageFilter> identityFilter(SkColorFilterImageFilter::Create(identityCF.get()));
REPORTER_ASSERT(reporter, !identityCF->affectsTransparentBlack());
REPORTER_ASSERT(reporter, identityFilter->canComputeFastBounds());
- SkAutoTUnref<SkColorFilter> forceOpaqueCF(
- SkTableColorFilter::CreateARGB(allOne, identity, identity, identity));
+ auto forceOpaqueCF(SkTableColorFilter::MakeARGB(allOne, identity, identity, identity));
SkAutoTUnref<SkImageFilter> forceOpaque(SkColorFilterImageFilter::Create(forceOpaqueCF.get()));
REPORTER_ASSERT(reporter, forceOpaqueCF->affectsTransparentBlack());
REPORTER_ASSERT(reporter, !forceOpaque->canComputeFastBounds());