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

Unified Diff: tests/ColorFilterTest.cpp

Issue 1822623002: switch colorfilters to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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 | « src/utils/SkRGBAToYUV.cpp ('k') | tests/ColorMatrixTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ColorFilterTest.cpp
diff --git a/tests/ColorFilterTest.cpp b/tests/ColorFilterTest.cpp
index ee8f12b2fbc9387658a719f0ffc6717d8a4cce0e..822fb0bd70f5a34eb8b3ca0516b79206269bf2de 100644
--- a/tests/ColorFilterTest.cpp
+++ b/tests/ColorFilterTest.cpp
@@ -15,7 +15,7 @@
#include "SkXfermode.h"
#include "Test.h"
-static SkColorFilter* reincarnate_colorfilter(SkFlattenable* obj) {
+static sk_sp<SkColorFilter> reincarnate_colorfilter(SkFlattenable* obj) {
SkWriteBuffer wb;
wb.writeFlattenable(obj);
@@ -30,18 +30,18 @@ static SkColorFilter* reincarnate_colorfilter(SkFlattenable* obj) {
///////////////////////////////////////////////////////////////////////////////
-static SkColorFilter* make_filter() {
+static sk_sp<SkColorFilter> make_filter() {
// pick a filter that cannot compose with itself via newComposed()
- return SkColorFilter::CreateModeFilter(SK_ColorRED, SkXfermode::kColorBurn_Mode);
+ return SkColorFilter::MakeModeFilter(SK_ColorRED, SkXfermode::kColorBurn_Mode);
}
static void test_composecolorfilter_limit(skiatest::Reporter* reporter) {
// Test that CreateComposeFilter() has some finite limit (i.e. that the factory can return null)
const int way_too_many = 100;
- SkAutoTUnref<SkColorFilter> parent(make_filter());
+ auto parent(make_filter());
for (int i = 2; i < way_too_many; ++i) {
- SkAutoTUnref<SkColorFilter> filter(make_filter());
- parent.reset(SkColorFilter::CreateComposeFilter(parent, filter));
+ auto filter(make_filter());
+ parent = SkColorFilter::MakeComposeFilter(parent, filter);
if (nullptr == parent) {
REPORTER_ASSERT(reporter, i > 2); // we need to have succeeded at least once!
return;
@@ -62,15 +62,13 @@ DEF_TEST(ColorFilter, reporter) {
// special case that would return nullptr (if color's alpha is 0 or 0xFF)
color = SkColorSetA(color, 0x7F);
- SkColorFilter* cf = SkColorFilter::CreateModeFilter(color,
- (SkXfermode::Mode)mode);
+ auto cf = SkColorFilter::MakeModeFilter(color, (SkXfermode::Mode)mode);
// allow for no filter if we're in Dst mode (its a no op)
if (SkXfermode::kDst_Mode == mode && nullptr == cf) {
continue;
}
- SkAutoUnref aur(cf);
REPORTER_ASSERT(reporter, cf);
SkColor c = ~color;
@@ -98,8 +96,7 @@ DEF_TEST(ColorFilter, reporter) {
REPORTER_ASSERT(reporter, m == expectedMode);
{
- SkColorFilter* cf2 = reincarnate_colorfilter(cf);
- SkAutoUnref aur2(cf2);
+ auto cf2 = reincarnate_colorfilter(cf.get());
REPORTER_ASSERT(reporter, cf2);
SkColor c2 = ~color;
@@ -117,7 +114,7 @@ DEF_TEST(ColorFilter, reporter) {
DEF_TEST(LumaColorFilter, reporter) {
SkPMColor in, out;
- SkAutoTUnref<SkColorFilter> lf(SkLumaColorFilter::Create());
+ auto lf(SkLumaColorFilter::Make());
// Applying luma to white produces black with the same transparency.
for (unsigned i = 0; i < 256; ++i) {
@@ -183,31 +180,31 @@ static void get_grayscale_matrix(float amount, float matrix[20]) {
matrix[18] = 1.f;
}
-static SkColorFilter* make_cf0() {
+static sk_sp<SkColorFilter> make_cf0() {
SkScalar matrix[20];
get_brightness_matrix(0.5f, matrix);
- return SkColorMatrixFilter::Create(matrix);
+ return SkColorFilter::MakeMatrixFilterRowMajor255(matrix);
}
-static SkColorFilter* make_cf1() {
+static sk_sp<SkColorFilter> make_cf1() {
SkScalar matrix[20];
get_grayscale_matrix(1, matrix);
- return SkColorMatrixFilter::Create(matrix);
+ return SkColorFilter::MakeMatrixFilterRowMajor255(matrix);
}
-static SkColorFilter* make_cf2() {
+static sk_sp<SkColorFilter> make_cf2() {
SkColorMatrix m0, m1;
get_brightness_matrix(0.5f, m0.fMat);
get_grayscale_matrix(1, m1.fMat);
m0.preConcat(m1);
- return SkColorMatrixFilter::Create(m0);
+ return SkColorFilter::MakeMatrixFilterRowMajor255(m0.fMat);
}
-static SkColorFilter* make_cf3() {
+static sk_sp<SkColorFilter> make_cf3() {
SkColorMatrix m0, m1;
get_brightness_matrix(0.5f, m0.fMat);
get_grayscale_matrix(1, m1.fMat);
m0.postConcat(m1);
- return SkColorMatrixFilter::Create(m0);
+ return SkColorFilter::MakeMatrixFilterRowMajor255(m0.fMat);
}
-typedef SkColorFilter* (*CFProc)();
+typedef sk_sp<SkColorFilter> (*CFProc)();
// Test that a colormatrix that "should" preserve opaquness actually does.
DEF_TEST(ColorMatrixFilter, reporter) {
@@ -216,7 +213,7 @@ DEF_TEST(ColorMatrixFilter, reporter) {
};
for (size_t i = 0; i < SK_ARRAY_COUNT(procs); ++i) {
- SkAutoTUnref<SkColorFilter> cf(procs[i]());
+ auto cf(procs[i]());
// generate all possible r,g,b triples
for (int r = 0; r < 256; ++r) {
« no previous file with comments | « src/utils/SkRGBAToYUV.cpp ('k') | tests/ColorMatrixTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698