• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 SKIA_REGION_H
17 #define SKIA_REGION_H
18 
19 #include "include/core/SkRegion.h"
20 #include "impl_interface/region_impl.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 namespace Drawing {
25 class SkiaRegion : public RegionImpl {
26 public:
27     static inline constexpr AdapterType TYPE = AdapterType::SKIA_ADAPTER;
28 
29     SkiaRegion() noexcept;
~SkiaRegion()30     ~SkiaRegion() override {};
31 
GetType()32     AdapterType GetType() const override
33     {
34         return AdapterType::SKIA_ADAPTER;
35     }
36 
37     bool Contains(int32_t x, int32_t y) const override;
38     bool Equals(const Region& other) const override;
39     void SetEmpty() override;
40     bool SetRect(const RectI& rectI) override;
41     bool SetRegion(const Region& region) override;
42     bool SetPath(const Path& path, const Region& clip) override;
43     bool GetBoundaryPath(Path* path) const override;
44     RectI GetBounds() const override;
45     bool IsComplex() const override;
46     bool IsIntersects(const Region& other) const override;
47     bool IsEmpty() const override;
48     bool IsRect() const override;
49     bool IsRegionContained(const Region& other) const override;
50     bool Op(const Region& region, RegionOp op) override;
51     bool QuickReject(const RectI& rectI) const override;
52     bool QuickReject(const Region& region) const override;
53     void Translate(int32_t x, int32_t y) override;
54     void Clone(const Region& other) override;
55     std::shared_ptr<Data> Serialize() const override;
56     bool Deserialize(std::shared_ptr<Data> data) override;
57 
58     /*
59      * @brief   Export Skia member variables for use by the adaptation layer.
60      * @return  A shared pointer to SkRegion that its mutable.
61      */
62     std::shared_ptr<SkRegion> GetSkRegion() const;
63 
64 private:
65     std::shared_ptr<SkRegion> skRegion_;
66 };
67 } // namespace Drawing
68 } // namespace Rosen
69 } // namespace OHOS
70 #endif
71