1 // Copyright 2021 The Flutter Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef FLUTTER_FLOW_LAYERS_MASK_LAYER_H_ 6 #define FLUTTER_FLOW_LAYERS_MASK_LAYER_H_ 7 8 #include "flutter/flow/layers/container_layer.h" 9 10 #include "experimental/svg/model/SkSVGDOM.h" 11 #include "third_party/skia/include/core/SkPaint.h" 12 #include "third_party/skia/include/core/SkPath.h" 13 14 namespace flutter { 15 16 class MaskLayer : public ContainerLayer { 17 public: MaskLayer(const SkPaint & maskPaint)18 MaskLayer(const SkPaint& maskPaint) 19 : isGradientMask_(true), maskPaint_(maskPaint) {} MaskLayer(double x,double y,double scaleX,double scaleY,const sk_sp<SkSVGDOM> & svgDom)20 MaskLayer(double x, double y, double scaleX, double scaleY, const sk_sp<SkSVGDOM>& svgDom) 21 : isSvgMask_(true), svgX_(x), svgY_(y), scaleX_(scaleX), scaleY_(scaleY), svgDom_(svgDom) {} MaskLayer(const SkPaint & maskPaint,const SkPath & maskPath)22 MaskLayer(const SkPaint& maskPaint, const SkPath& maskPath) 23 : isPathMask_(true), maskPaint_(maskPaint), maskPath_(maskPath) {} 24 ~MaskLayer() override = default; 25 26 void Paint(PaintContext& context) const override; 27 28 private: 29 bool isSvgMask_ = false; 30 bool isGradientMask_ = false; 31 bool isPathMask_ = false; 32 double svgX_ = 0.0f; 33 double svgY_ = 0.0f; 34 double scaleX_ = 1.0f; 35 double scaleY_ = 1.0f; 36 sk_sp<SkSVGDOM> svgDom_; 37 SkPaint maskPaint_; 38 SkPath maskPath_; 39 40 FML_DISALLOW_COPY_AND_ASSIGN(MaskLayer); 41 }; 42 43 } // namespace flutter 44 45 #endif // FLUTTER_FLOW_LAYERS_MASK_LAYER_H_ 46