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