diff --git a/src/core/SkColorFilter_Matrix.cpp b/src/core/SkColorFilter_Matrix.cpp index 6ae3d1844d..a0a047c345 100644 --- a/src/core/SkColorFilter_Matrix.cpp +++ b/src/core/SkColorFilter_Matrix.cpp @@ -229,65 +229,7 @@ static sk_sp MakeMatrix(const float array[20], if (!sk_floats_are_finite(array, 20)) { return nullptr; } -#if 1 return sk_make_sp(array, domain); -#else - const bool alphaUnchanged = SkScalarNearlyEqual(array[15], 0) - && SkScalarNearlyEqual(array[16], 0) - && SkScalarNearlyEqual(array[17], 0) - && SkScalarNearlyEqual(array[18], 1) - && SkScalarNearlyEqual(array[19], 0); - - struct { SkM44 m; SkV4 b; } uniforms; - SkString code { - "uniform half4x4 m;" - "uniform half4 b;" - }; - if (domain == SkColorFilter_Matrix::Domain::kHSLA) { - code += kRGB_to_HSL_sksl; - code += kHSL_to_RGB_sksl; - } - - code += "half4 main(half4 inColor) {"; - if (true) { - code += "half4 c = inColor;"; // unpremul - } - if (alphaUnchanged) { - code += "half a = c.a;"; - } - if (domain == SkColorFilter_Matrix::Domain::kHSLA) { - code += "c.rgb = rgb_to_hsl(c.rgb);"; - } - if (true) { - uniforms.m = SkM44{array[ 0], array[ 1], array[ 2], array[ 3], - array[ 5], array[ 6], array[ 7], array[ 8], - array[10], array[11], array[12], array[13], - array[15], array[16], array[17], array[18]}; - uniforms.b = SkV4{array[4], array[9], array[14], array[19]}; - code += "c = m*c + b;"; - } - if (domain == SkColorFilter_Matrix::Domain::kHSLA) { - code += "c.rgb = hsl_to_rgb(c.rgb);"; - } - if (alphaUnchanged) { - code += "return half4(saturate(c.rgb), a);"; - } else { - code += "return saturate(c);"; - } - code += "}"; - - sk_sp effect = SkMakeCachedRuntimeEffect(SkRuntimeEffect::MakeForColorFilter, - std::move(code)); - SkASSERT(effect); - - SkAlphaType unpremul = kUnpremul_SkAlphaType; - return SkColorFilters::WithWorkingFormat( - effect->makeColorFilter(SkData::MakeWithCopy(&uniforms,sizeof(uniforms))), - nullptr/*keep dst TF encoding*/, - nullptr/*stay in dst gamut*/, - &unpremul); - -#endif } sk_sp SkColorFilters::Matrix(const float array[20]) { @@ -308,18 +250,4 @@ sk_sp SkColorFilters::HSLAMatrix(const SkColorMatrix& cm) { void SkColorFilter_Matrix::RegisterFlattenables() { SK_REGISTER_FLATTENABLE(SkColorFilter_Matrix); - - // This subclass was removed 4/2019 - SkFlattenable::Register("SkColorMatrixFilterRowMajor255", - [](SkReadBuffer& buffer) -> sk_sp { - float matrix[20]; - if (buffer.readScalarArray(matrix, 20)) { - matrix[ 4] *= (1.0f/255); - matrix[ 9] *= (1.0f/255); - matrix[14] *= (1.0f/255); - matrix[19] *= (1.0f/255); - return SkColorFilters::Matrix(matrix); - } - return nullptr; - }); }