• 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_rect.h"
17 
18 namespace OHOS {
19 namespace Rosen {
20 namespace TextEngine {
TexgineRect()21 TexgineRect::TexgineRect(): rect_(std::make_shared<SkRect>())
22 {
23     fBottom_ = &rect_->fBottom;
24     fLeft_ = &rect_->fLeft;
25     fTop_ = &rect_->fTop;
26     fRight_ = &rect_->fRight;
27 }
28 
MakeLTRB(float left,float top,float right,float bottom)29 TexgineRect TexgineRect::MakeLTRB(float left, float top, float right, float bottom)
30 {
31     auto rect = std::make_shared<TexgineRect>();
32     rect->SetRect(SkRect::MakeLTRB(left, top, right, bottom));
33     return *rect;
34 }
35 
MakeXYWH(float x,float y,float w,float h)36 TexgineRect TexgineRect::MakeXYWH(float x, float y, float w, float h)
37 {
38     auto rect = std::make_shared<TexgineRect>();
39     rect->SetRect(SkRect::MakeXYWH(x, y, w, h));
40     return *rect;
41 }
42 
MakeWH(float w,float h)43 TexgineRect TexgineRect::MakeWH(float w, float h)
44 {
45     auto rect = std::make_shared<TexgineRect>();
46     rect->SetRect(SkRect::MakeWH(w, h));
47     return *rect;
48 }
49 
GetRect() const50 std::shared_ptr<SkRect> TexgineRect::GetRect() const
51 {
52     return rect_;
53 }
54 
SetRect(const SkRect & rect)55 void TexgineRect::SetRect(const SkRect &rect)
56 {
57     *rect_ = rect;
58     fBottom_ = &rect_->fBottom;
59     fLeft_ = &rect_->fLeft;
60     fTop_ = &rect_->fTop;
61     fRight_ = &rect_->fRight;
62 }
63 } // namespace TextEngine
64 } // namespace Rosen
65 } // namespace OHOS
66