1 /* 2 * Copyright 2020 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkSVGFeColorMatrix_DEFINED 9 #define SkSVGFeColorMatrix_DEFINED 10 11 #include "include/effects/SkColorMatrix.h" 12 #include "modules/svg/include/SkSVGFe.h" 13 #include "modules/svg/include/SkSVGTypes.h" 14 15 class SkSVGFeColorMatrix final : public SkSVGFe { 16 public: Make()17 static sk_sp<SkSVGFeColorMatrix> Make() { 18 return sk_sp<SkSVGFeColorMatrix>(new SkSVGFeColorMatrix()); 19 } 20 21 SVG_ATTR(Type, SkSVGFeColorMatrixType, SkSVGFeColorMatrixType(SkSVGFeColorMatrixType::kMatrix)) 22 SVG_ATTR(Values, SkSVGFeColorMatrixValues, SkSVGFeColorMatrixValues()) 23 24 protected: 25 sk_sp<SkImageFilter> onMakeImageFilter(const SkSVGRenderContext&, 26 const SkSVGFilterContext&) const override; 27 getInputs()28 std::vector<SkSVGFeInputType> getInputs() const override { return {this->getIn()}; } 29 30 bool parseAndSetAttribute(const char*, const char*) override; 31 32 private: SkSVGFeColorMatrix()33 SkSVGFeColorMatrix() : INHERITED(SkSVGTag::kFeColorMatrix) {} 34 35 SkColorMatrix makeMatrixForType() const; 36 37 static SkColorMatrix MakeSaturate(SkSVGNumberType s); 38 39 static SkColorMatrix MakeHueRotate(SkSVGNumberType degrees); 40 41 static SkColorMatrix MakeLuminanceToAlpha(); 42 43 using INHERITED = SkSVGFe; 44 }; 45 46 #endif // SkSVGFeColorMatrix_DEFINED 47