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<RSPath> TexginePath::GetPath() const
22 {
23     return path_;
24 }
25 
SetPath(const std::shared_ptr<RSPath> path)26 void TexginePath::SetPath(const std::shared_ptr<RSPath> 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         path_->AddOval(*oval.GetRect(), static_cast<Drawing::PathDirection>(dir));
35     }
36     return *this;
37 }
38 
MoveTo(const TexginePoint & p)39 TexginePath &TexginePath::MoveTo(const TexginePoint &p)
40 {
41     if (path_ != nullptr) {
42         path_->MoveTo(p.fX, p.fY);
43     }
44     return *this;
45 }
46 
QuadTo(const TexginePoint & p1,const TexginePoint & p2)47 TexginePath &TexginePath::QuadTo(const TexginePoint &p1, const TexginePoint &p2)
48 {
49     RSPoint pointL(p1.fX, p1.fY);
50     RSPoint pointR(p2.fX, p2.fY);
51     if (path_ != nullptr) {
52         path_->QuadTo(pointL, pointR);
53     }
54     return *this;
55 }
56 
LineTo(const TexginePoint & p)57 TexginePath &TexginePath::LineTo(const TexginePoint &p)
58 {
59     if (path_ != nullptr) {
60         path_->LineTo(p.fX, p.fY);
61     }
62     return *this;
63 }
64 } // namespace TextEngine
65 } // namespace Rosen
66 } // namespace OHOS
67