• 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 ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_RECT_H
17 #define ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_RECT_H
18 
19 #include <memory>
20 
21 #include <include/core/SkRect.h>
22 
23 namespace OHOS {
24 namespace Rosen {
25 namespace TextEngine {
26 class TexgineRect {
27 public:
28     TexgineRect();
29 
30     /*
31      * @brief Create TexgineRect
32      * @param left The left boundary of TexgineRect
33      * @param right The right boundary of TexgineRect
34      * @param top The top boundary of TexgineRect
35      * @param bottom The bottom boundary of TexgineRect
36      */
37     static TexgineRect MakeLTRB(float left, float top, float right, float bottom);
38 
39     /*
40      * @brief Create TexgineRect
41      * @param x The left boundary of TexgineRect
42      * @param y The top boundary of TexgineRect
43      * @param w The width of TexgineRect
44      * @param h The height of TexgineRect
45      */
46     static TexgineRect MakeXYWH(float x, float y, float w, float h);
47 
48     /*
49      * @brief Create TexgineRect at (0, 0, w, h)
50      * @param w The width of TexgineRect
51      * @param h The height of TexgineRect
52      */
53     static TexgineRect MakeWH(float w, float h);
54 
55     /*
56      * @brief Return SkRect that user init or set to TexgineRect
57      */
58     std::shared_ptr<SkRect> GetRect() const;
59 
60     /*
61      * @brief Sets SkRect to TexgineRect
62      * @param rect SkRect user want
63      */
64     void SetRect(const SkRect &rect);
65 
66     float *fLeft_ = nullptr;
67     float *fTop_ = nullptr;
68     float *fRight_ = nullptr;
69     float *fBottom_ = nullptr;
70 
71 private:
72     std::shared_ptr<SkRect> rect_ = nullptr;
73 };
74 } // namespace TextEngine
75 } // namespace Rosen
76 } // namespace OHOS
77 
78 #endif // ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_RECT_H
79