• 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 #include "texgine_path.h"
17 
18 namespace OHOS {
19 namespace Rosen {
20 namespace TextEngine {
GetPath() const21 std::shared_ptr<SkPath> TexginePath::GetPath() const
22 {
23     return path_;
24 }
25 
SetPath(const std::shared_ptr<SkPath> path)26 void TexginePath::SetPath(const std::shared_ptr<SkPath> path)
27 {
28     path_ = path;
29 }
30 
AddOval(const TexgineRect & oval,TexginePathDirection dir)31 TexginePath &TexginePath::AddOval(const TexgineRect &oval, TexginePathDirection dir)
32 {
33     if (path_ != nullptr && oval.GetRect() != nullptr) {
34 #ifdef NEW_SKIA
35         *path_ = path_->addOval(*oval.GetRect(), static_cast<SkPathDirection>(dir));
36 #else
37         *path_ = path_->addOval(*oval.GetRect(), static_cast<SkPath::Direction>(dir));
38 #endif
39     }
40 
41     return *this;
42 }
43 
MoveTo(const TexginePoint & p)44 TexginePath &TexginePath::MoveTo(const TexginePoint &p)
45 {
46     SkPoint point({p.fX, p.fY});
47     if (path_ != nullptr) {
48         *path_ = path_->moveTo(point);
49     }
50 
51     return *this;
52 }
53 
QuadTo(const TexginePoint & p1,const TexginePoint & p2)54 TexginePath &TexginePath::QuadTo(const TexginePoint &p1, const TexginePoint &p2)
55 {
56     SkPoint point1({p1.fX, p1.fY});
57     SkPoint point2({p2.fX, p2.fY});
58     if (path_ != nullptr) {
59         *path_ = path_->quadTo(point1, point2);
60     }
61 
62     return *this;
63 }
64 
LineTo(const TexginePoint & p)65 TexginePath &TexginePath::LineTo(const TexginePoint &p)
66 {
67     SkPoint point({p.fX, p.fY});
68     if (path_ != nullptr) {
69         *path_ = path_->lineTo(point);
70     }
71 
72     return *this;
73 }
74 } // namespace TextEngine
75 } // namespace Rosen
76 } // namespace OHOS
77