• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SVG_FLUTTER_RENDER_SVG_PATTERN_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SVG_FLUTTER_RENDER_SVG_PATTERN_H
18 
19 #include "frameworks/core/components/svg/render_svg_pattern.h"
20 #include "frameworks/core/pipeline/base/flutter_render_context.h"
21 #include "frameworks/core/pipeline/layers/transform_layer.h"
22 
23 namespace OHOS::Ace {
24 
25 class FlutterRenderSvgPattern : public RenderSvgPattern {
26     DECLARE_ACE_TYPE(FlutterRenderSvgPattern, RenderSvgPattern);
27 
28 public:
29     RenderLayer GetRenderLayer() override;
30     void Paint(RenderContext& context, const Offset& offset) override;
31 
IsRepaintBoundary()32     bool IsRepaintBoundary() const override
33     {
34         return true;
35     }
36 
37     bool OnAsPaint(const Offset& offset, const Rect& paintRect, SkPaint& skPaint);
38 
39 protected:
40     bool FitAttribute(const Rect& paintRect, Rect& tileRect, SkMatrix& skMatrix4);
41     void FitRenderContext(FlutterRenderContext& context, const Rect& patternRect);
42 
43 private:
44     void ResetAttrOffset();
45     const Matrix4 GetTransform(const Rect& patternRect) const;
46 
47     RefPtr<Flutter::TransformLayer> transformLayer_;
48     float scaleY_ = 1.0f;
49     float scaleX_ = 1.0f;
50     float scale_ = 1.0f;
51     float tx_ = 0.0f;
52     float ty_ = 0.0f;
53 };
54 
55 } // namespace OHOS::Ace
56 
57 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SVG_FLUTTER_RENDER_SVG_PATTERN_H
58