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

Unified Diff: tests/SkColor4fTest.cpp

Issue 1625263002: add 4f support to colorfiltershader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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/core/SkColorFilterShader.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SkColor4fTest.cpp
diff --git a/tests/SkColor4fTest.cpp b/tests/SkColor4fTest.cpp
index 737200c76e1d41fbba652e36ebeaf060b1978a0b..48a0c38286da1a5e08347c120593d8411b6dcb97 100644
--- a/tests/SkColor4fTest.cpp
+++ b/tests/SkColor4fTest.cpp
@@ -77,9 +77,29 @@ DEF_TEST(Color4f_premul, reporter) {
//////////////////////////////////////////////////////////////////////////////////////////////////
-static SkShader* make_color() { return SkShader::CreateColorShader(0xFFBB8855); }
+static SkColorFilter* make_mode_cf() {
+ return SkColorFilter::CreateModeFilter(0xFFBB8855, SkXfermode::kPlus_Mode);
+}
-static SkShader* make_image() {
+static SkColorFilter* make_mx_cf() {
+ const float mx[] = {
+ 0.5f, 0, 0, 0, 0.1f,
+ 0, 0.5f, 0, 0, 0.2f,
+ 0, 0, 1, 0, -0.1f,
+ 0, 0, 0, 1, 0,
+ };
+ return SkColorMatrixFilter::Create(mx);
+}
+
+static SkColorFilter* make_compose_cf() {
+ SkAutoTUnref<SkColorFilter> cf0(make_mode_cf());
+ SkAutoTUnref<SkColorFilter> cf1(make_mx_cf());
+ return SkColorFilter::CreateComposeFilter(cf0, cf1);
+}
+
+static SkShader* make_color_sh() { return SkShader::CreateColorShader(0xFFBB8855); }
+
+static SkShader* make_image_sh() {
const SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2);
const SkPMColor pixels[] {
SkPackARGB32(0xFF, 0xBB, 0x88, 0x55),
@@ -91,12 +111,18 @@ static SkShader* make_image() {
return image->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
}
-static SkShader* make_grad() {
+static SkShader* make_grad_sh() {
const SkPoint pts[] {{ 0, 0 }, { 100, 100 }};
const SkColor colors[] { SK_ColorRED, SK_ColorBLUE };
return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
}
+static SkShader* make_cf_sh() {
+ SkAutoTUnref<SkColorFilter> filter(make_mx_cf());
+ SkAutoTUnref<SkShader> shader(make_color_sh());
+ return shader->newWithColorFilter(filter);
+}
+
static void compare_spans(const SkPM4f span4f[], const SkPMColor span4b[], int count,
skiatest::Reporter* reporter) {
for (int i = 0; i < count; ++i) {
@@ -111,9 +137,10 @@ DEF_TEST(Color4f_shader, reporter) {
SkShader* (*fFact)();
bool fSupports4f;
} recs[] = {
- { make_color, true },
- { make_grad, false },
- { make_image, false },
+ { make_color_sh, true },
+ { make_grad_sh, false },
+ { make_image_sh, false },
+ { make_cf_sh, true },
};
SkPaint paint;
@@ -136,26 +163,6 @@ DEF_TEST(Color4f_shader, reporter) {
}
}
-static SkColorFilter* make_mode_cf() {
- return SkColorFilter::CreateModeFilter(0xFFBB8855, SkXfermode::kPlus_Mode);
-}
-
-static SkColorFilter* make_mx_cf() {
- const float mx[] = {
- 0.5f, 0, 0, 0, 0.1f,
- 0, 0.5f, 0, 0, 0.2f,
- 0, 0, 1, 0, -0.1f,
- 0, 0, 0, 1, 0,
- };
- return SkColorMatrixFilter::Create(mx);
-}
-
-static SkColorFilter* make_compose_cf() {
- SkAutoTUnref<SkColorFilter> cf0(make_mode_cf());
- SkAutoTUnref<SkColorFilter> cf1(make_mx_cf());
- return SkColorFilter::CreateComposeFilter(cf0, cf1);
-}
-
DEF_TEST(Color4f_colorfilter, reporter) {
struct {
SkColorFilter* (*fFact)();
« no previous file with comments | « src/core/SkColorFilterShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698