• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // 2021.2.10 Increase the process used in native_view mode.
6 //           Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved.
7 
8 #ifndef FLUTTER_FLOW_OHOS_LAYERS_LAYER_H
9 #define FLUTTER_FLOW_OHOS_LAYERS_LAYER_H
10 
11 #include "third_party/skia/include/core/SkRRect.h"
12 #include "third_party/skia/include/core/SkRect.h"
13 
14 #include "flutter/fml/macros.h"
15 
16 namespace flutter::OHOS {
17 
18 constexpr uint32_t DEAFAULT_UNIQUEID = -1;
19 
20 enum Clip { NONE, HARDEDGE, ANTIALIAS, ANTIALIAS_WITH_SAVELAYER };
21 
22 class ContainerLayer;
23 struct PaintContext;
24 
25 class Layer {
26 public:
27     Layer() = default;
28     virtual ~Layer() = default;
29 
Paint(const PaintContext & paintContext)30     virtual void Paint(const PaintContext& paintContext) const {};
31 
Prepare(const SkMatrix & matrix)32     virtual void Prepare(const SkMatrix& matrix) {};
33 
parent()34     ContainerLayer* parent() const
35     {
36         return parent_;
37     }
38 
setParent(ContainerLayer * parent)39     void setParent(ContainerLayer* parent)
40     {
41         parent_ = parent;
42     }
GetNeedsSystemComposite()43     bool GetNeedsSystemComposite() const
44     {
45         return needsSystemComposite_;
46     }
47 
SetNeedsSystemComposite(bool value)48     void SetNeedsSystemComposite(bool value)
49     {
50         needsSystemComposite_ = value;
51     }
52 
GetPaintBounds()53     const SkRect& GetPaintBounds() const
54     {
55         return paintBounds_;
56     }
57 
SetPaintBounds(const SkRect & paintBounds)58     void SetPaintBounds(const SkRect& paintBounds)
59     {
60         paintBounds_ = paintBounds;
61     }
62 
NeedsPainting()63     bool NeedsPainting() const
64     {
65         return !paintBounds_.isEmpty();
66     }
67 
GetUniqueId()68     uint64_t GetUniqueId() const
69     {
70         return uniqueId_;
71     }
72 
73 private:
74     ContainerLayer* parent_;
75     SkRect paintBounds_;
76     bool needsSystemComposite_ = false;
77     uint64_t uniqueId_ = DEAFAULT_UNIQUEID;
78 
79     FML_DISALLOW_COPY_AND_ASSIGN(Layer);
80 };
81 
82 }  // namespace flutter::OHOS
83 
84 #endif // FLUTTER_FLOW_OHOS_LAYERS_LAYER_H