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

Unified Diff: gm/colorfilterimagefilter.cpp

Issue 1820303002: Revert of switch colorfilters to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/coloremoji.cpp ('k') | gm/colorfilters.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/colorfilterimagefilter.cpp
diff --git a/gm/colorfilterimagefilter.cpp b/gm/colorfilterimagefilter.cpp
index 497757e128ac50a25fca2212773193d0f89e3d1b..f72108f433a85a473df0052f4e44d396a52c8447 100644
--- a/gm/colorfilterimagefilter.cpp
+++ b/gm/colorfilterimagefilter.cpp
@@ -18,34 +18,34 @@
#define FILTER_HEIGHT SkIntToScalar(30)
#define MARGIN SkIntToScalar(10)
-static sk_sp<SkColorFilter> cf_make_brightness(float brightness) {
+static SkColorFilter* cf_make_brightness(float brightness) {
SkScalar amount255 = SkScalarMul(brightness, SkIntToScalar(255));
SkScalar matrix[20] = {
1, 0, 0, 0, amount255,
0, 1, 0, 0, amount255,
0, 0, 1, 0, amount255,
0, 0, 0, 1, 0 };
- return SkColorFilter::MakeMatrixFilterRowMajor255(matrix);
-}
-
-static sk_sp<SkColorFilter> cf_make_grayscale() {
+ return SkColorMatrixFilter::Create(matrix);
+}
+
+static SkColorFilter* cf_make_grayscale() {
SkScalar matrix[20];
memset(matrix, 0, 20 * sizeof(SkScalar));
matrix[0] = matrix[5] = matrix[10] = 0.2126f;
matrix[1] = matrix[6] = matrix[11] = 0.7152f;
matrix[2] = matrix[7] = matrix[12] = 0.0722f;
matrix[18] = 1.0f;
- return SkColorFilter::MakeMatrixFilterRowMajor255(matrix);
-}
-
-static sk_sp<SkColorFilter> cf_make_colorize(SkColor color) {
- return SkColorFilter::MakeModeFilter(color, SkXfermode::kSrc_Mode);
-}
-
-static void sk_gm_get_colorfilters(SkTArray<sk_sp<SkColorFilter>>* array) {
- array->push_back(cf_make_brightness(0.5f));
- array->push_back(cf_make_grayscale());
- array->push_back(cf_make_colorize(SK_ColorBLUE));
+ return SkColorMatrixFilter::Create(matrix);
+}
+
+static SkColorFilter* cf_make_colorize(SkColor color) {
+ return SkColorFilter::CreateModeFilter(color, SkXfermode::kSrc_Mode);
+}
+
+static void sk_gm_get_colorfilters(SkTDArray<SkColorFilter*>* array) {
+ *array->append() = cf_make_brightness(0.5f);
+ *array->append() = cf_make_grayscale();
+ *array->append() = cf_make_colorize(SK_ColorBLUE);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -92,15 +92,18 @@
}
static SkImageFilter* make_brightness(float amount, SkImageFilter* input = nullptr) {
- return SkColorFilterImageFilter::Create(cf_make_brightness(amount).get(), input);
+ SkAutoTUnref<SkColorFilter> filter(cf_make_brightness(amount));
+ return SkColorFilterImageFilter::Create(filter, input);
}
static SkImageFilter* make_grayscale(SkImageFilter* input = nullptr) {
- return SkColorFilterImageFilter::Create(cf_make_grayscale().get(), input);
+ SkAutoTUnref<SkColorFilter> filter(cf_make_grayscale());
+ return SkColorFilterImageFilter::Create(filter, input);
}
static SkImageFilter* make_mode_blue(SkImageFilter* input = nullptr) {
- return SkColorFilterImageFilter::Create(cf_make_colorize(SK_ColorBLUE).get(), input);
+ SkAutoTUnref<SkColorFilter> filter(cf_make_colorize(SK_ColorBLUE));
+ return SkColorFilterImageFilter::Create(filter, input);
}
static void drawClippedRect(SkCanvas* canvas,
@@ -176,8 +179,8 @@
SkAutoCanvasRestore autoCanvasRestore(canvas, false);
SkColorMatrix cm;
cm.setSaturation(0.0f);
- auto cf(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
- SkAutoTUnref<SkImageFilter> imf(SkColorFilterImageFilter::Create(cf.get()));
+ SkAutoTUnref<SkColorFilter> cf(SkColorMatrixFilter::Create(cm));
+ SkAutoTUnref<SkImageFilter> imf(SkColorFilterImageFilter::Create(cf));
SkPaint p;
p.setImageFilter(imf);
canvas->saveLayer(NULL, &p);
@@ -192,7 +195,7 @@
};
DEF_SIMPLE_GM(colorfiltershader, canvas, 800, 800) {
- SkTArray<sk_sp<SkColorFilter>> filters;
+ SkTRefArray<SkColorFilter*> filters;
sk_gm_get_colorfilters(&filters);
SkTRefArray<SkShader*> shaders;
@@ -207,7 +210,7 @@
canvas->save();
for (int x = -1; x < filters.count(); ++x) {
- sk_sp<SkColorFilter> filter = x >= 0 ? filters[x] : nullptr;
+ SkColorFilter* filter = x >= 0 ? filters[x] : nullptr;
paint.setShader(shader->makeWithColorFilter(filter));
canvas->drawRect(r, paint);
« no previous file with comments | « gm/coloremoji.cpp ('k') | gm/colorfilters.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698