• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 RENDER_SERVICE_CLIENT_CORE_RENDER_RS_PATH_H
17 #define RENDER_SERVICE_CLIENT_CORE_RENDER_RS_PATH_H
18 
19 #include <memory>
20 #include <string>
21 
22 #include "common/rs_macros.h"
23 #include "common/rs_matrix3.h"
24 #include "common/rs_rect.h"
25 #include "common/rs_vector2.h"
26 
27 #ifndef USE_ROSEN_DRAWING
28 class SkPath;
29 #else
30 #include "draw/path.h"
31 #endif
32 namespace OHOS {
33 namespace Rosen {
34 class RSB_EXPORT RSPath {
35 public:
36     RSPath();
37     virtual ~RSPath();
38     static RSB_EXPORT std::shared_ptr<RSPath> CreateRSPath();
39 #ifndef USE_ROSEN_DRAWING
40     static RSB_EXPORT std::shared_ptr<RSPath> CreateRSPath(const SkPath& skPath);
41 #else
42     static RSB_EXPORT std::shared_ptr<RSPath> CreateRSPath(const Drawing::Path& path);
43 #endif
44     static RSB_EXPORT std::shared_ptr<RSPath> CreateRSPath(const std::string& path);
45     float GetDistance() const;
46     template<typename T>
GetPosTan(float distance,T & pos,float & degrees)47     bool GetPosTan(float distance, T& pos, float& degrees) const
48     {
49         return true;
50     }
51 
52     std::shared_ptr<RSPath> Reverse();
53 
54 #ifndef USE_ROSEN_DRAWING
55     void SetSkiaPath(const SkPath& skPath);
56     const SkPath& GetSkiaPath() const;
57 #else
58     void SetDrawingPath(const Drawing::Path& path);
59     const Drawing::Path& GetDrawingPath() const;
60 #endif
61 
62 private:
63     RSPath(const RSPath&) = delete;
64     RSPath(const RSPath&&) = delete;
65     RSPath& operator=(const RSPath&) = delete;
66     RSPath& operator=(const RSPath&&) = delete;
67 
68 #ifndef USE_ROSEN_DRAWING
69     SkPath* skPath_ = nullptr;
70 #else
71     Drawing::Path* drPath_ = nullptr;
72 #endif
73 };
74 
75 template<>
76 RSB_EXPORT bool RSPath::GetPosTan(float distance, Vector2f& pos, float& degrees) const;
77 template<>
78 RSB_EXPORT bool RSPath::GetPosTan(float distance, Vector4f& pos, float& degrees) const;
79 } // namespace Rosen
80 } // namespace OHOS
81 
82 #endif // RENDER_SERVICE_CLIENT_CORE_RENDER_RS_PATH_H
83