stop calling legacy 255-biased colormatrix
... but keep the apis for now
Bug: skia:4872
Bug: skia:9012
Change-Id: I3a9b0c9194be6897c0e59b7edd972b7218168183
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/211343
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
diff --git a/gm/alpha_image.cpp b/gm/alpha_image.cpp
index e659c46..5a7078c 100644
--- a/gm/alpha_image.cpp
+++ b/gm/alpha_image.cpp
@@ -26,12 +26,12 @@
}
static sk_sp<SkColorFilter> make_color_filter() {
- SkScalar colorMatrix[20] = {
+ float colorMatrix[20] = {
1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 0.5, 0.5, 0,
0, 0, 0.5, 0.5, 0}; // mix G and A.
- return SkColorFilters::MatrixRowMajor255(colorMatrix);
+ return SkColorFilters::Matrix(colorMatrix);
}
DEF_SIMPLE_GM(alpha_image, canvas, 256, 256) {
diff --git a/gm/coloremoji.cpp b/gm/coloremoji.cpp
index c02c9a6..b8e3f99 100644
--- a/gm/coloremoji.cpp
+++ b/gm/coloremoji.cpp
@@ -31,13 +31,13 @@
}
static sk_sp<SkImageFilter> make_grayscale(sk_sp<SkImageFilter> input) {
- SkScalar matrix[20];
- memset(matrix, 0, 20 * sizeof(SkScalar));
+ float matrix[20];
+ memset(matrix, 0, 20 * sizeof(float));
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;
- sk_sp<SkColorFilter> filter(SkColorFilters::MatrixRowMajor255(matrix));
+ sk_sp<SkColorFilter> filter(SkColorFilters::Matrix(matrix));
return SkColorFilterImageFilter::Make(std::move(filter), std::move(input));
}
diff --git a/gm/colorfilteralpha8.cpp b/gm/colorfilteralpha8.cpp
index 4c116d5..54bf9ff 100644
--- a/gm/colorfilteralpha8.cpp
+++ b/gm/colorfilteralpha8.cpp
@@ -35,9 +35,9 @@
0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 255.0f
+ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f
};
- paint.setColorFilter(SkColorFilters::MatrixRowMajor255(opaqueGrayMatrix));
+ paint.setColorFilter(SkColorFilters::Matrix(opaqueGrayMatrix));
canvas->drawBitmap(bitmap, 100.0f, 100.0f, &paint);
}
diff --git a/gm/colorfilterimagefilter.cpp b/gm/colorfilterimagefilter.cpp
index 38797a0..70f95ef 100644
--- a/gm/colorfilterimagefilter.cpp
+++ b/gm/colorfilterimagefilter.cpp
@@ -20,23 +20,22 @@
#define MARGIN SkIntToScalar(10)
static sk_sp<SkColorFilter> cf_make_brightness(float brightness) {
- SkScalar amount255 = brightness * 255;
- SkScalar matrix[20] = {
- 1, 0, 0, 0, amount255,
- 0, 1, 0, 0, amount255,
- 0, 0, 1, 0, amount255,
+ float matrix[20] = {
+ 1, 0, 0, 0, brightness,
+ 0, 1, 0, 0, brightness,
+ 0, 0, 1, 0, brightness,
0, 0, 0, 1, 0 };
- return SkColorFilters::MatrixRowMajor255(matrix);
+ return SkColorFilters::Matrix(matrix);
}
static sk_sp<SkColorFilter> cf_make_grayscale() {
- SkScalar matrix[20];
- memset(matrix, 0, 20 * sizeof(SkScalar));
+ float matrix[20];
+ memset(matrix, 0, 20 * sizeof(float));
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 SkColorFilters::MatrixRowMajor255(matrix);
+ return SkColorFilters::Matrix(matrix);
}
static sk_sp<SkColorFilter> cf_make_colorize(SkColor color) {
diff --git a/gm/colormatrix.cpp b/gm/colormatrix.cpp
index 21c14ca..cf3faca 100644
--- a/gm/colormatrix.cpp
+++ b/gm/colormatrix.cpp
@@ -17,8 +17,8 @@
paint->setColorFilter(SkColorFilters::Matrix(matrix));
}
-static void set_array(SkPaint* paint, const SkScalar array[]) {
- paint->setColorFilter(SkColorFilters::MatrixRowMajor255(array));
+static void set_array(SkPaint* paint, const float array[]) {
+ paint->setColorFilter(SkColorFilters::Matrix(array));
}
class ColorMatrixGM : public skiagm::GM {
@@ -121,14 +121,12 @@
set_color_matrix(&paint, matrix);
canvas->drawImage(bmps[i], 80, 160, &paint);
- SkScalar s1 = SK_Scalar1;
- SkScalar s255 = SkIntToScalar(255);
// Move red into alpha, set color to white
- SkScalar data[20] = {
- 0, 0, 0, 0, s255,
- 0, 0, 0, 0, s255,
- 0, 0, 0, 0, s255,
- s1, 0, 0, 0, 0,
+ float data[20] = {
+ 0, 0, 0, 0, 1,
+ 0, 0, 0, 0, 1,
+ 0, 0, 0, 0, 1,
+ 1, 0, 0, 0, 0,
};
set_array(&paint, data);
diff --git a/gm/fadefilter.cpp b/gm/fadefilter.cpp
index fe31033..1240519 100644
--- a/gm/fadefilter.cpp
+++ b/gm/fadefilter.cpp
@@ -11,11 +11,11 @@
// This GM renders correctly in 8888, but fails in PDF
DEF_SIMPLE_GM(fadefilter, canvas, 256, 256) {
- SkScalar matrix[20] = { 1, 0, 0, 0, 128.0f,
- 0, 1, 0, 0, 128.0f,
- 0, 0, 1, 0, 128.0f,
- 0, 0, 0, 1, 0 };
- sk_sp<SkColorFilter> colorFilter(SkColorFilters::MatrixRowMajor255(matrix));
+ float matrix[20] = { 1, 0, 0, 0, 0.5f,
+ 0, 1, 0, 0, 0.5f,
+ 0, 0, 1, 0, 0.5f,
+ 0, 0, 0, 1, 0 };
+ sk_sp<SkColorFilter> colorFilter(SkColorFilters::Matrix(matrix));
SkPaint layerPaint;
layerPaint.setImageFilter(SkColorFilterImageFilter::Make(std::move(colorFilter), nullptr));
canvas->drawRect(SkRect::MakeLTRB(64, 64, 192, 192), layerPaint);
diff --git a/gm/imagefilterscropexpand.cpp b/gm/imagefilterscropexpand.cpp
index 5274304..5f312b0 100644
--- a/gm/imagefilterscropexpand.cpp
+++ b/gm/imagefilterscropexpand.cpp
@@ -50,11 +50,11 @@
// This color matrix saturates the green component but only partly increases the opacity.
// For the opaque checkerboard, the opacity boost doesn't matter but it does impact the
// area outside the checkerboard.
- SkScalar matrix[20] = { 1, 0, 0, 0, 0,
- 0, 1, 0, 0, 255,
- 0, 0, 1, 0, 0,
- 0, 0, 0, 1, 32 };
- sk_sp<SkColorFilter> cfAlphaTrans(SkColorFilters::MatrixRowMajor255(matrix));
+ float matrix[20] = { 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 1,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 1, 32.0f/255 };
+ sk_sp<SkColorFilter> cfAlphaTrans(SkColorFilters::Matrix(matrix));
SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
SkScalar MARGIN = SkIntToScalar(12);
diff --git a/gm/imagefiltersgraph.cpp b/gm/imagefiltersgraph.cpp
index f41be74..c26f9bf 100644
--- a/gm/imagefiltersgraph.cpp
+++ b/gm/imagefiltersgraph.cpp
@@ -62,12 +62,12 @@
{
sk_sp<SkImageFilter> morph(SkDilateImageFilter::Make(5, 5, nullptr));
- SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0,
- 0, SK_Scalar1, 0, 0, 0,
- 0, 0, SK_Scalar1, 0, 0,
- 0, 0, 0, 0.5f, 0 };
+ float matrix[20] = { 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 0.5f, 0 };
- sk_sp<SkColorFilter> matrixFilter(SkColorFilters::MatrixRowMajor255(matrix));
+ sk_sp<SkColorFilter> matrixFilter(SkColorFilters::Matrix(matrix));
sk_sp<SkImageFilter> colorMorph(SkColorFilterImageFilter::Make(std::move(matrixFilter),
std::move(morph)));
SkPaint paint;
@@ -78,11 +78,11 @@
canvas->translate(SkIntToScalar(100), 0);
}
{
- SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0,
- 0, SK_Scalar1, 0, 0, 0,
- 0, 0, SK_Scalar1, 0, 0,
- 0, 0, 0, 0.5f, 0 };
- sk_sp<SkColorFilter> matrixCF(SkColorFilters::MatrixRowMajor255(matrix));
+ float matrix[20] = { 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 0.5f, 0 };
+ sk_sp<SkColorFilter> matrixCF(SkColorFilters::Matrix(matrix));
sk_sp<SkImageFilter> matrixFilter(SkColorFilterImageFilter::Make(std::move(matrixCF),
nullptr));
sk_sp<SkImageFilter> offsetFilter(SkOffsetImageFilter::Make(10.0f, 10.f,
diff --git a/gm/imagefromyuvtextures.cpp b/gm/imagefromyuvtextures.cpp
index 72f4278..b19b7e9 100644
--- a/gm/imagefromyuvtextures.cpp
+++ b/gm/imagefromyuvtextures.cpp
@@ -20,13 +20,13 @@
static sk_sp<SkColorFilter> yuv_to_rgb_colorfilter() {
static const float kJPEGConversionMatrix[20] = {
- 1.0f, 0.0f, 1.402f, 0.0f, -180.0f,
- 1.0f, -0.344136f, -0.714136f, 0.0f, 136.0f,
- 1.0f, 1.772f, 0.0f, 0.0f, -227.6f,
+ 1.0f, 0.0f, 1.402f, 0.0f, -180.0f/255,
+ 1.0f, -0.344136f, -0.714136f, 0.0f, 136.0f/255,
+ 1.0f, 1.772f, 0.0f, 0.0f, -227.6f/255,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f
};
- return SkColorFilters::MatrixRowMajor255(kJPEGConversionMatrix);
+ return SkColorFilters::Matrix(kJPEGConversionMatrix);
}
namespace skiagm {
diff --git a/gm/mixercolorfilter.cpp b/gm/mixercolorfilter.cpp
index 603159a..e73b540 100644
--- a/gm/mixercolorfilter.cpp
+++ b/gm/mixercolorfilter.cpp
@@ -39,14 +39,14 @@
//
// The input luminance is stored in the alpha channel
// (and RGB are cleared -- see SkLumaColorFilter). Thus:
- const SkScalar tint_matrix[] = {
- 0, 0, 0, (r_hi - r_lo) / 255.0f, SkIntToScalar(r_lo),
- 0, 0, 0, (g_hi - g_lo) / 255.0f, SkIntToScalar(g_lo),
- 0, 0, 0, (b_hi - b_lo) / 255.0f, SkIntToScalar(b_lo),
- 0, 0, 0, (a_hi - a_lo) / 255.0f, SkIntToScalar(a_lo),
+ const float tint_matrix[] = {
+ 0, 0, 0, (r_hi - r_lo) / 255.0f, SkIntToScalar(r_lo) / 255.0f,
+ 0, 0, 0, (g_hi - g_lo) / 255.0f, SkIntToScalar(g_lo) / 255.0f,
+ 0, 0, 0, (b_hi - b_lo) / 255.0f, SkIntToScalar(b_lo) / 255.0f,
+ 0, 0, 0, (a_hi - a_lo) / 255.0f, SkIntToScalar(a_lo) / 255.0f,
};
- return SkColorFilters::MatrixRowMajor255(tint_matrix)
+ return SkColorFilters::Matrix(tint_matrix)
->makeComposed(SkLumaColorFilter::Make());
}
diff --git a/gm/srgb.cpp b/gm/srgb.cpp
index 4968a67..358c138 100644
--- a/gm/srgb.cpp
+++ b/gm/srgb.cpp
@@ -21,7 +21,7 @@
0, 0, 1, 0, 0,
-1, 0, 0, 1, 0,
};
- auto cf0 = SkColorFilters::MatrixRowMajor255(array);
+ auto cf0 = SkColorFilters::Matrix(array);
auto cf1 = SkColorFilters::LinearToSRGBGamma();
auto cf2 = SkColorFilters::SRGBToLinearGamma();
diff --git a/gm/tileimagefilter.cpp b/gm/tileimagefilter.cpp
index a3f4f1e..b2c5b19 100644
--- a/gm/tileimagefilter.cpp
+++ b/gm/tileimagefilter.cpp
@@ -85,17 +85,17 @@
}
{
- SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0,
- 0, SK_Scalar1, 0, 0, 0,
- 0, 0, SK_Scalar1, 0, 0,
- 0, 0, 0, SK_Scalar1, 0 };
+ float matrix[20] = { 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 1, 0 };
SkRect srcRect = SkRect::MakeWH(SkIntToScalar(fBitmap->width()),
SkIntToScalar(fBitmap->height()));
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(SkColorFilters::MatrixRowMajor255(matrix));
+ sk_sp<SkColorFilter> cf(SkColorFilters::Matrix(matrix));
SkPaint paint;
paint.setImageFilter(SkColorFilterImageFilter::Make(std::move(cf), std::move(tile)));
diff --git a/gm/wacky_yuv_formats.cpp b/gm/wacky_yuv_formats.cpp
index 77a1919..945b8a9 100644
--- a/gm/wacky_yuv_formats.cpp
+++ b/gm/wacky_yuv_formats.cpp
@@ -784,13 +784,13 @@
static sk_sp<SkColorFilter> yuv_to_rgb_colorfilter() {
static const float kJPEGConversionMatrix[20] = {
- 1.0f, 0.0f, 1.402f, 0.0f, -180.0f,
- 1.0f, -0.344136f, -0.714136f, 0.0f, 136.0f,
- 1.0f, 1.772f, 0.0f, 0.0f, -227.6f,
+ 1.0f, 0.0f, 1.402f, 0.0f, -180.0f/255,
+ 1.0f, -0.344136f, -0.714136f, 0.0f, 136.0f/255,
+ 1.0f, 1.772f, 0.0f, 0.0f, -227.6f/255,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f
};
- return SkColorFilters::MatrixRowMajor255(kJPEGConversionMatrix);
+ return SkColorFilters::Matrix(kJPEGConversionMatrix);
}
namespace skiagm {