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 "drawing.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 Create TexgineRect 57 * @param x The left boundary of TexgineRect 58 * @param y The top boundary of TexgineRect 59 * @param w The width of TexgineRect 60 * @param h The height of TexgineRect 61 * @param skRadii The SkVector of TexgineRect 62 */ 63 static TexgineRect MakeRRect(float x, float y, float w, float h, const SkVector skRadii[4]); 64 65 /* 66 * @brief Return SkRect that user init or set to TexgineRect 67 */ 68 std::shared_ptr<RSRect> GetRect() const; 69 70 /* 71 * @brief Return SkRRect that user set to TexgineRect 72 */ 73 std::shared_ptr<RSRoundRect> GetRRect() const; 74 75 /* 76 * @brief Sets SkRect to TexgineRect 77 * @param rect SkRect user want 78 */ 79 void SetRect(const RSRect &rect); 80 81 /* 82 * @brief Sets SkRRect to TexgineRect 83 * @param rect SkRRect user want 84 */ 85 void SetRRect(const RSRoundRect &rrect); 86 87 float *fLeft_ = nullptr; 88 float *fTop_ = nullptr; 89 float *fRight_ = nullptr; 90 float *fBottom_ = nullptr; 91 92 private: 93 std::shared_ptr<RSRect> rect_ = nullptr; 94 std::shared_ptr<RSRoundRect> rrect_ = nullptr; 95 }; 96 } // namespace TextEngine 97 } // namespace Rosen 98 } // namespace OHOS 99 100 #endif // ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_RECT_H 101