1a3e0fd82Sopenharmony_ci/* 2a3e0fd82Sopenharmony_ci * Copyright (c) 2020-2022 Huawei Device Co., Ltd. 3a3e0fd82Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4a3e0fd82Sopenharmony_ci * you may not use this file except in compliance with the License. 5a3e0fd82Sopenharmony_ci * You may obtain a copy of the License at 6a3e0fd82Sopenharmony_ci * 7a3e0fd82Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8a3e0fd82Sopenharmony_ci * 9a3e0fd82Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10a3e0fd82Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11a3e0fd82Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12a3e0fd82Sopenharmony_ci * See the License for the specific language governing permissions and 13a3e0fd82Sopenharmony_ci * limitations under the License. 14a3e0fd82Sopenharmony_ci */ 15a3e0fd82Sopenharmony_ci 16a3e0fd82Sopenharmony_ci#ifndef GRAPHIC_LITE_DRAW_LABEL_H 17a3e0fd82Sopenharmony_ci#define GRAPHIC_LITE_DRAW_LABEL_H 18a3e0fd82Sopenharmony_ci 19a3e0fd82Sopenharmony_ci#include "common/typed_text.h" 20a3e0fd82Sopenharmony_ci#include "draw/draw_utils.h" 21a3e0fd82Sopenharmony_ci#include "gfx_utils/geometry2d.h" 22a3e0fd82Sopenharmony_ci#include "gfx_utils/heap_base.h" 23a3e0fd82Sopenharmony_ci#include "gfx_utils/style.h" 24a3e0fd82Sopenharmony_ci 25a3e0fd82Sopenharmony_cinamespace OHOS { 26a3e0fd82Sopenharmony_ciclass DrawLabel : public HeapBase { 27a3e0fd82Sopenharmony_cipublic: 28a3e0fd82Sopenharmony_ci static uint16_t DrawTextOneLine(BufferInfo& gfxDstBuffer, const LabelLineInfo& labelLine, 29a3e0fd82Sopenharmony_ci uint16_t& letterIndex); 30a3e0fd82Sopenharmony_ci 31a3e0fd82Sopenharmony_ci static void DrawArcText(BufferInfo& gfxDstBuffer, const Rect& mask, const char* text, const Point& arcCenter, 32a3e0fd82Sopenharmony_ci uint16_t fontId, uint8_t fontSize, const ArcTextInfo arcTextInfo, const float changeAngle, 33a3e0fd82Sopenharmony_ci TextOrientation orientation, const Style& style, uint8_t opaScale, bool compatibilityMode); 34a3e0fd82Sopenharmony_ci 35a3e0fd82Sopenharmony_ci static bool CalculateAngle(uint16_t letterWidth, 36a3e0fd82Sopenharmony_ci uint16_t letterHeight, 37a3e0fd82Sopenharmony_ci int16_t letterSpace, 38a3e0fd82Sopenharmony_ci const ArcTextInfo arcTextInfo, 39a3e0fd82Sopenharmony_ci bool xorFlag, 40a3e0fd82Sopenharmony_ci uint32_t index, 41a3e0fd82Sopenharmony_ci TextOrientation orientation, 42a3e0fd82Sopenharmony_ci float& posX, 43a3e0fd82Sopenharmony_ci float& posY, 44a3e0fd82Sopenharmony_ci float& rotateAngle, 45a3e0fd82Sopenharmony_ci float& angle, 46a3e0fd82Sopenharmony_ci const Point& arcCenter, 47a3e0fd82Sopenharmony_ci bool compatibilityMode); 48a3e0fd82Sopenharmony_ci 49a3e0fd82Sopenharmony_ci static void DrawLetterWithRotate(BufferInfo& gfxDstBuffer, 50a3e0fd82Sopenharmony_ci const Rect& mask, 51a3e0fd82Sopenharmony_ci const ArcLetterInfo& letterInfo, 52a3e0fd82Sopenharmony_ci float posX, 53a3e0fd82Sopenharmony_ci float posY); 54a3e0fd82Sopenharmony_ci 55a3e0fd82Sopenharmony_ci static uint8_t GetLineMaxLetterSize(const char* text, uint16_t lineLength, uint16_t fontId, uint8_t fontSize, 56a3e0fd82Sopenharmony_ci uint16_t letterIndex, SpannableString* spannableString); 57a3e0fd82Sopenharmony_ci static void GetLineBackgroundColor(uint16_t letterIndex, List<LineBackgroundColor>* linebackgroundColor, 58a3e0fd82Sopenharmony_ci bool& havelinebackground, ColorType& linebgColor); 59a3e0fd82Sopenharmony_ci static void GetBackgroundColor(uint16_t letterIndex, List<BackgroundColor>* backgroundColor, 60a3e0fd82Sopenharmony_ci bool& havebackground, ColorType& bgColor); 61a3e0fd82Sopenharmony_ci static void GetForegroundColor(uint16_t letterIndex, List<ForegroundColor>* foregroundColor, ColorType& fgColor); 62a3e0fd82Sopenharmony_ci static void DrawLineBackgroundColor(BufferInfo& gfxDstBuffer, uint16_t letterIndex, 63a3e0fd82Sopenharmony_ci const LabelLineInfo& labelLine); 64a3e0fd82Sopenharmony_ci 65a3e0fd82Sopenharmony_ciprivate: 66a3e0fd82Sopenharmony_ci static bool CalculatedTransformDataInfo(uint8_t** buffer, TransformDataInfo& letterTranDataInfo, 67a3e0fd82Sopenharmony_ci const ArcLetterInfo& letterInfo); 68a3e0fd82Sopenharmony_ci 69a3e0fd82Sopenharmony_ci static bool CalculatedClipAngle(const ArcLetterInfo& letterInfo, float& angle); 70a3e0fd82Sopenharmony_ci 71a3e0fd82Sopenharmony_ci static void CalculatedBeginAndCopySize(const ArcLetterInfo& letterInfo, const uint16_t sizePerPx, 72a3e0fd82Sopenharmony_ci const uint16_t cols, const int16_t offsetX, uint16_t& begin, uint16_t& copyCols, TextInRange& range); 73a3e0fd82Sopenharmony_ci 74a3e0fd82Sopenharmony_ci static void OnCalculatedClockwise(const ArcLetterInfo& letterInfo, const uint16_t sizePerPx, 75a3e0fd82Sopenharmony_ci const uint16_t cols, const int16_t offsetX, uint16_t& begin, uint16_t& copyCols, TextInRange& range); 76a3e0fd82Sopenharmony_ci 77a3e0fd82Sopenharmony_ci static void OnCalculatedAnticlockwise(const ArcLetterInfo& letterInfo, const uint16_t sizePerPx, 78a3e0fd82Sopenharmony_ci const uint16_t cols, const int16_t offsetX, uint16_t& begin, uint16_t& copyCols, TextInRange& range); 79a3e0fd82Sopenharmony_ci}; 80a3e0fd82Sopenharmony_ci} // namespace OHOS 81a3e0fd82Sopenharmony_ci#endif // GRAPHIC_LITE_DRAW_LABEL_H 82