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_UTILS_H 17a3e0fd82Sopenharmony_ci#define GRAPHIC_LITE_DRAW_UTILS_H 18a3e0fd82Sopenharmony_ci 19a3e0fd82Sopenharmony_ci#include "common/text.h" 20a3e0fd82Sopenharmony_ci#include "font/ui_font_header.h" 21a3e0fd82Sopenharmony_ci#include "gfx_utils/color.h" 22a3e0fd82Sopenharmony_ci#include "gfx_utils/geometry2d.h" 23a3e0fd82Sopenharmony_ci#include "gfx_utils/graphic_buffer.h" 24a3e0fd82Sopenharmony_ci#include "gfx_utils/graphic_types.h" 25a3e0fd82Sopenharmony_ci#include "gfx_utils/list.h" 26a3e0fd82Sopenharmony_ci#include "gfx_utils/style.h" 27a3e0fd82Sopenharmony_ci#include "gfx_utils/transform.h" 28a3e0fd82Sopenharmony_ci 29a3e0fd82Sopenharmony_cinamespace OHOS { 30a3e0fd82Sopenharmony_ci#define SWAP_INT16(x, y) \ 31a3e0fd82Sopenharmony_ci do { \ 32a3e0fd82Sopenharmony_ci int16_t temp = (x); \ 33a3e0fd82Sopenharmony_ci (x) = (y); \ 34a3e0fd82Sopenharmony_ci (y) = temp; \ 35a3e0fd82Sopenharmony_ci } while (0) 36a3e0fd82Sopenharmony_ci 37a3e0fd82Sopenharmony_ci#define SWAP_POINTS(x1, x2, y1, y2) \ 38a3e0fd82Sopenharmony_ci SWAP_INT16(x1, x2); \ 39a3e0fd82Sopenharmony_ci SWAP_INT16(y1, y2); 40a3e0fd82Sopenharmony_ci 41a3e0fd82Sopenharmony_ci// FixedPointed Related definition. 42a3e0fd82Sopenharmony_ci#define FIXED_NUM_1 1048576 43a3e0fd82Sopenharmony_ci#define FIXED_Q_NUM 20 44a3e0fd82Sopenharmony_ci#define FO_TRANS_FLOAT_TO_FIXED(f) (static_cast<int64_t>((f) * FIXED_NUM_1)) 45a3e0fd82Sopenharmony_ci#define FO_TRANS_INTEGER_TO_FIXED(f) ((static_cast<int64_t>(f)) << FIXED_Q_NUM) 46a3e0fd82Sopenharmony_ci#define FO_DIV(n1, n2) ((static_cast<int64_t>(n1) << FIXED_Q_NUM) / (n2)) 47a3e0fd82Sopenharmony_ci#define FO_TO_INTEGER(n) ((n) >= 0 ? ((n) >> FIXED_Q_NUM) : (((n) >> FIXED_Q_NUM) + 1)) 48a3e0fd82Sopenharmony_ci#define FO_DECIMAL(n) ((n) >= 0 ? ((n) & (FIXED_NUM_1 - 1)) : ((n) | (-FIXED_NUM_1))) 49a3e0fd82Sopenharmony_ci#define FO_MUL(n1, n2) ((static_cast<int64_t>(n1) * (n2)) >> FIXED_Q_NUM) 50a3e0fd82Sopenharmony_ci 51a3e0fd82Sopenharmony_cistruct EdgeSides { 52a3e0fd82Sopenharmony_ci int16_t left; 53a3e0fd82Sopenharmony_ci int16_t right; 54a3e0fd82Sopenharmony_ci int16_t top; 55a3e0fd82Sopenharmony_ci int16_t bottom; 56a3e0fd82Sopenharmony_ci}; 57a3e0fd82Sopenharmony_ci 58a3e0fd82Sopenharmony_cistruct LabelLineInfo { 59a3e0fd82Sopenharmony_ci Point& pos; 60a3e0fd82Sopenharmony_ci Point& offset; 61a3e0fd82Sopenharmony_ci const Rect& mask; 62a3e0fd82Sopenharmony_ci int16_t lineHeight; 63a3e0fd82Sopenharmony_ci uint16_t lineLength; 64a3e0fd82Sopenharmony_ci uint8_t shapingId; 65a3e0fd82Sopenharmony_ci uint8_t opaScale; 66a3e0fd82Sopenharmony_ci const Style& style; 67a3e0fd82Sopenharmony_ci const char* text; 68a3e0fd82Sopenharmony_ci uint16_t length; 69a3e0fd82Sopenharmony_ci uint16_t start; 70a3e0fd82Sopenharmony_ci uint16_t fontId; 71a3e0fd82Sopenharmony_ci uint8_t fontSize; 72a3e0fd82Sopenharmony_ci uint8_t txtFlag; 73a3e0fd82Sopenharmony_ci UITextLanguageDirect direct; 74a3e0fd82Sopenharmony_ci uint32_t* codePoints; 75a3e0fd82Sopenharmony_ci bool baseLine; 76a3e0fd82Sopenharmony_ci#if defined(ENABLE_TEXT_STYLE) && ENABLE_TEXT_STYLE 77a3e0fd82Sopenharmony_ci TextStyle* textStyles; 78a3e0fd82Sopenharmony_ci#endif 79a3e0fd82Sopenharmony_ci List<BackgroundColor>* backgroundColor; 80a3e0fd82Sopenharmony_ci List<ForegroundColor>* foregroundColor; 81a3e0fd82Sopenharmony_ci List<LineBackgroundColor>* linebackgroundColor; 82a3e0fd82Sopenharmony_ci SpannableString* spannableString; 83a3e0fd82Sopenharmony_ci uint16_t ellipsisOssetY; 84a3e0fd82Sopenharmony_ci}; 85a3e0fd82Sopenharmony_ci 86a3e0fd82Sopenharmony_cistruct LabelLetterInfo { 87a3e0fd82Sopenharmony_ci const Point& pos; 88a3e0fd82Sopenharmony_ci Rect mask; 89a3e0fd82Sopenharmony_ci const ColorType& color; 90a3e0fd82Sopenharmony_ci OpacityType opa; 91a3e0fd82Sopenharmony_ci int8_t offsetX; 92a3e0fd82Sopenharmony_ci int8_t offsetY; 93a3e0fd82Sopenharmony_ci 94a3e0fd82Sopenharmony_ci const uint32_t& letter; 95a3e0fd82Sopenharmony_ci UITextLanguageDirect direct; 96a3e0fd82Sopenharmony_ci uint16_t fontId; 97a3e0fd82Sopenharmony_ci uint8_t shapingId; 98a3e0fd82Sopenharmony_ci uint8_t fontSize; 99a3e0fd82Sopenharmony_ci#if defined(ENABLE_TEXT_STYLE) && ENABLE_TEXT_STYLE 100a3e0fd82Sopenharmony_ci TextStyle textStyle; 101a3e0fd82Sopenharmony_ci#endif 102a3e0fd82Sopenharmony_ci bool baseLine; 103a3e0fd82Sopenharmony_ci int16_t letterSpace_; 104a3e0fd82Sopenharmony_ci int16_t lineSpace_; 105a3e0fd82Sopenharmony_ci bool havebackgroundColor; 106a3e0fd82Sopenharmony_ci ColorType& backgroundColor; 107a3e0fd82Sopenharmony_ci bool haveLineBackgroundColor; 108a3e0fd82Sopenharmony_ci ColorType& lineBackgroundColor; 109a3e0fd82Sopenharmony_ci}; 110a3e0fd82Sopenharmony_ci 111a3e0fd82Sopenharmony_cistruct TransformInitState { 112a3e0fd82Sopenharmony_ci#if defined(ENABLE_FIXED_POINT) && ENABLE_FIXED_POINT 113a3e0fd82Sopenharmony_ci // parameters below are Q15 fixed-point number 114a3e0fd82Sopenharmony_ci int64_t verticalU; 115a3e0fd82Sopenharmony_ci int64_t verticalV; 116a3e0fd82Sopenharmony_ci int64_t duHorizon; 117a3e0fd82Sopenharmony_ci int64_t dvHorizon; 118a3e0fd82Sopenharmony_ci int64_t duVertical; 119a3e0fd82Sopenharmony_ci int64_t dvVertical; 120a3e0fd82Sopenharmony_ci // parameters above are Q15 fixed-point number 121a3e0fd82Sopenharmony_ci#else 122a3e0fd82Sopenharmony_ci float verticalU; 123a3e0fd82Sopenharmony_ci float verticalV; 124a3e0fd82Sopenharmony_ci float duHorizon; 125a3e0fd82Sopenharmony_ci float dvHorizon; 126a3e0fd82Sopenharmony_ci float duVertical; 127a3e0fd82Sopenharmony_ci float dvVertical; 128a3e0fd82Sopenharmony_ci#endif 129a3e0fd82Sopenharmony_ci}; 130a3e0fd82Sopenharmony_ci 131a3e0fd82Sopenharmony_cistruct TriangleEdge { 132a3e0fd82Sopenharmony_ci TriangleEdge() {} 133a3e0fd82Sopenharmony_ci TriangleEdge(int16_t x1, int16_t y1, int16_t duInt, int16_t dvInt); 134a3e0fd82Sopenharmony_ci ~TriangleEdge(); 135a3e0fd82Sopenharmony_ci#if defined(ENABLE_FIXED_POINT) && ENABLE_FIXED_POINT 136a3e0fd82Sopenharmony_ci // parameters below are Q15 fixed-point number 137a3e0fd82Sopenharmony_ci int64_t curX = 0; 138a3e0fd82Sopenharmony_ci int64_t curY = 0; 139a3e0fd82Sopenharmony_ci int64_t du = 0; 140a3e0fd82Sopenharmony_ci int64_t dv = 0; 141a3e0fd82Sopenharmony_ci // parameters above are Q15 fixed-point number 142a3e0fd82Sopenharmony_ci#else 143a3e0fd82Sopenharmony_ci float curX = 0.0f; 144a3e0fd82Sopenharmony_ci float curY = 0.0f; 145a3e0fd82Sopenharmony_ci float du = 0.0f; 146a3e0fd82Sopenharmony_ci float dv = 0.0f; 147a3e0fd82Sopenharmony_ci#endif 148a3e0fd82Sopenharmony_ci}; 149a3e0fd82Sopenharmony_ci 150a3e0fd82Sopenharmony_cistruct TriangleTransformDataInfo { 151a3e0fd82Sopenharmony_ci const TransformDataInfo& info; 152a3e0fd82Sopenharmony_ci Point p1; 153a3e0fd82Sopenharmony_ci Point p2; 154a3e0fd82Sopenharmony_ci Point p3; 155a3e0fd82Sopenharmony_ci bool isRightPart; 156a3e0fd82Sopenharmony_ci bool ignoreJunctionPoint; 157a3e0fd82Sopenharmony_ci}; 158a3e0fd82Sopenharmony_ci 159a3e0fd82Sopenharmony_cistruct TriangleScanInfo { 160a3e0fd82Sopenharmony_ci int16_t yMin; 161a3e0fd82Sopenharmony_ci int16_t yMax; 162a3e0fd82Sopenharmony_ci TriangleEdge& edge1; 163a3e0fd82Sopenharmony_ci TriangleEdge& edge2; 164a3e0fd82Sopenharmony_ci uint8_t* screenBuffer; 165a3e0fd82Sopenharmony_ci uint8_t bufferPxSize; 166a3e0fd82Sopenharmony_ci const ColorType& color; 167a3e0fd82Sopenharmony_ci const OpacityType opaScale; 168a3e0fd82Sopenharmony_ci TransformInitState& init; 169a3e0fd82Sopenharmony_ci uint16_t screenBufferWidth; 170a3e0fd82Sopenharmony_ci uint8_t pixelSize; 171a3e0fd82Sopenharmony_ci const int32_t srcLineWidth; 172a3e0fd82Sopenharmony_ci const TransformDataInfo& info; 173a3e0fd82Sopenharmony_ci const Rect& mask; 174a3e0fd82Sopenharmony_ci bool isRightPart; 175a3e0fd82Sopenharmony_ci bool ignoreJunctionPoint; 176a3e0fd82Sopenharmony_ci Matrix3<float> matrix; 177a3e0fd82Sopenharmony_ci}; 178a3e0fd82Sopenharmony_ci 179a3e0fd82Sopenharmony_cistruct TrianglePartInfo { 180a3e0fd82Sopenharmony_ci const Rect& mask; 181a3e0fd82Sopenharmony_ci const TransformMap& transMap; 182a3e0fd82Sopenharmony_ci const Point& position; 183a3e0fd82Sopenharmony_ci TriangleEdge& edge1; 184a3e0fd82Sopenharmony_ci TriangleEdge& edge2; 185a3e0fd82Sopenharmony_ci int16_t yMin; 186a3e0fd82Sopenharmony_ci int16_t yMax; 187a3e0fd82Sopenharmony_ci const TransformDataInfo& info; 188a3e0fd82Sopenharmony_ci const ColorType& color; 189a3e0fd82Sopenharmony_ci const OpacityType opaScale; 190a3e0fd82Sopenharmony_ci bool isRightPart; 191a3e0fd82Sopenharmony_ci bool ignoreJunctionPoint; 192a3e0fd82Sopenharmony_ci}; 193a3e0fd82Sopenharmony_ci 194a3e0fd82Sopenharmony_cienum { 195a3e0fd82Sopenharmony_ci IMG_SRC_VARIABLE, 196a3e0fd82Sopenharmony_ci IMG_SRC_FILE, 197a3e0fd82Sopenharmony_ci IMG_SRC_UNKNOWN, 198a3e0fd82Sopenharmony_ci}; 199a3e0fd82Sopenharmony_ci 200a3e0fd82Sopenharmony_ciclass DrawUtils : public HeapBase { 201a3e0fd82Sopenharmony_cipublic: 202a3e0fd82Sopenharmony_ci static DrawUtils* GetInstance(); 203a3e0fd82Sopenharmony_ci 204a3e0fd82Sopenharmony_ci void DrawColorArea(BufferInfo& gfxDstBuffer, const Rect& area, const Rect& mask, 205a3e0fd82Sopenharmony_ci const ColorType& color, OpacityType opa) const; 206a3e0fd82Sopenharmony_ci 207a3e0fd82Sopenharmony_ci void DrawColorAreaBySides(BufferInfo& gfxDstBuffer, const Rect& mask, const ColorType& color, 208a3e0fd82Sopenharmony_ci OpacityType opa, const EdgeSides& sides) const; 209a3e0fd82Sopenharmony_ci 210a3e0fd82Sopenharmony_ci void DrawPixel(BufferInfo& gfxDstBuffer, int16_t x, int16_t y, const Rect& mask, 211a3e0fd82Sopenharmony_ci const ColorType& color, OpacityType opa) const; 212a3e0fd82Sopenharmony_ci 213a3e0fd82Sopenharmony_ci void DrawColorLetter(BufferInfo& gfxDstBuffer, 214a3e0fd82Sopenharmony_ci const LabelLetterInfo& letterInfo, 215a3e0fd82Sopenharmony_ci uint8_t* fontMap, 216a3e0fd82Sopenharmony_ci GlyphNode node, 217a3e0fd82Sopenharmony_ci int16_t lineHeight) const; 218a3e0fd82Sopenharmony_ci void DrawNormalLetter(BufferInfo& gfxDstBuffer, 219a3e0fd82Sopenharmony_ci const LabelLetterInfo& letterInfo, 220a3e0fd82Sopenharmony_ci uint8_t* fontMap, 221a3e0fd82Sopenharmony_ci GlyphNode node, 222a3e0fd82Sopenharmony_ci uint8_t maxLetterSize) const; 223a3e0fd82Sopenharmony_ci 224a3e0fd82Sopenharmony_ci void DrawLetter(BufferInfo& gfxDstBuffer, 225a3e0fd82Sopenharmony_ci const uint8_t* fontMap, 226a3e0fd82Sopenharmony_ci const Rect& fontRect, 227a3e0fd82Sopenharmony_ci const Rect& subRect, 228a3e0fd82Sopenharmony_ci const uint8_t fontWeight, 229a3e0fd82Sopenharmony_ci const ColorType& color, 230a3e0fd82Sopenharmony_ci const OpacityType opa) const; 231a3e0fd82Sopenharmony_ci 232a3e0fd82Sopenharmony_ci void DrawImage(BufferInfo& gfxDstBuffer, const Rect& area, const Rect& mask, 233a3e0fd82Sopenharmony_ci const uint8_t* image, OpacityType opa, uint8_t pxBitSize, ColorMode colorMode) const; 234a3e0fd82Sopenharmony_ci 235a3e0fd82Sopenharmony_ci static void 236a3e0fd82Sopenharmony_ci GetXAxisErrForJunctionLine(bool ignoreJunctionPoint, bool isRightPart, int16_t& xMinErr, int16_t& xMaxErr); 237a3e0fd82Sopenharmony_ci 238a3e0fd82Sopenharmony_ci static void GetTransformInitState(const TransformMap& transMap, 239a3e0fd82Sopenharmony_ci const Point& position, 240a3e0fd82Sopenharmony_ci const Rect& trans, 241a3e0fd82Sopenharmony_ci TransformInitState& init); 242a3e0fd82Sopenharmony_ci 243a3e0fd82Sopenharmony_ci static void DrawTriangleTransform(BufferInfo& gfxDstBuffer, 244a3e0fd82Sopenharmony_ci const Rect& mask, 245a3e0fd82Sopenharmony_ci const Point& position, 246a3e0fd82Sopenharmony_ci const ColorType& color, 247a3e0fd82Sopenharmony_ci OpacityType opaScale, 248a3e0fd82Sopenharmony_ci const TransformMap& transMap, 249a3e0fd82Sopenharmony_ci const TriangleTransformDataInfo& dataInfo); 250a3e0fd82Sopenharmony_ci 251a3e0fd82Sopenharmony_ci void DrawTransform(BufferInfo& gfxDstBuffer, 252a3e0fd82Sopenharmony_ci const Rect& mask, 253a3e0fd82Sopenharmony_ci const Point& position, 254a3e0fd82Sopenharmony_ci const ColorType& color, 255a3e0fd82Sopenharmony_ci OpacityType opaScale, 256a3e0fd82Sopenharmony_ci const TransformMap& transMap, 257a3e0fd82Sopenharmony_ci const TransformDataInfo& dataInfo) const; 258a3e0fd82Sopenharmony_ci 259a3e0fd82Sopenharmony_ci void DrawTranspantArea(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& mask); 260a3e0fd82Sopenharmony_ci 261a3e0fd82Sopenharmony_ci void DrawWithBuffer(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& mask, const ColorType* colorBuf); 262a3e0fd82Sopenharmony_ci 263a3e0fd82Sopenharmony_ci static uint8_t GetPxSizeByColorMode(uint8_t colorMode); 264a3e0fd82Sopenharmony_ci 265a3e0fd82Sopenharmony_ci static uint8_t GetByteSizeByColorMode(uint8_t colorMode); 266a3e0fd82Sopenharmony_ci 267a3e0fd82Sopenharmony_ci static OpacityType GetMixOpacity(OpacityType opa1, OpacityType opa2) 268a3e0fd82Sopenharmony_ci { 269a3e0fd82Sopenharmony_ci // 8: Shift right 8 bits 270a3e0fd82Sopenharmony_ci OpacityType opaMix = (opa1 == OPA_OPAQUE) ? opa2 : ((static_cast<uint16_t>(opa1) * opa2) >> 8); 271a3e0fd82Sopenharmony_ci return opaMix; 272a3e0fd82Sopenharmony_ci } 273a3e0fd82Sopenharmony_ci 274a3e0fd82Sopenharmony_ci void DrawAdjPixelInLine(BufferInfo& gfxDstBuffer, 275a3e0fd82Sopenharmony_ci int16_t x1, 276a3e0fd82Sopenharmony_ci int16_t y1, 277a3e0fd82Sopenharmony_ci int16_t x2, 278a3e0fd82Sopenharmony_ci int16_t y2, 279a3e0fd82Sopenharmony_ci const Rect& mask, 280a3e0fd82Sopenharmony_ci const ColorType& color, 281a3e0fd82Sopenharmony_ci OpacityType opa, 282a3e0fd82Sopenharmony_ci uint16_t w) const; 283a3e0fd82Sopenharmony_ci 284a3e0fd82Sopenharmony_ci void DrawPixelInLine(BufferInfo& gfxDstBuffer, int16_t x, int16_t y, const Rect& mask, 285a3e0fd82Sopenharmony_ci const ColorType& color, OpacityType opa, uint16_t w) const; 286a3e0fd82Sopenharmony_ci 287a3e0fd82Sopenharmony_ci void DrawVerPixelInLine(BufferInfo& gfxDstBuffer, 288a3e0fd82Sopenharmony_ci int16_t x, 289a3e0fd82Sopenharmony_ci int16_t y, 290a3e0fd82Sopenharmony_ci int8_t dir, 291a3e0fd82Sopenharmony_ci const Rect& mask, 292a3e0fd82Sopenharmony_ci const ColorType& color, 293a3e0fd82Sopenharmony_ci OpacityType opa, 294a3e0fd82Sopenharmony_ci uint16_t weight) const; 295a3e0fd82Sopenharmony_ci 296a3e0fd82Sopenharmony_ci void DrawHorPixelInLine(BufferInfo& gfxDstBuffer, 297a3e0fd82Sopenharmony_ci int16_t x, 298a3e0fd82Sopenharmony_ci int16_t y, 299a3e0fd82Sopenharmony_ci int8_t dir, 300a3e0fd82Sopenharmony_ci const Rect& mask, 301a3e0fd82Sopenharmony_ci const ColorType& color, 302a3e0fd82Sopenharmony_ci OpacityType opa, 303a3e0fd82Sopenharmony_ci uint16_t weight) const; 304a3e0fd82Sopenharmony_ci 305a3e0fd82Sopenharmony_ci void BlendWithSoftWare(const uint8_t* src1, 306a3e0fd82Sopenharmony_ci const Rect& srcRect, 307a3e0fd82Sopenharmony_ci uint32_t srcStride, 308a3e0fd82Sopenharmony_ci uint32_t srcLineNumber, 309a3e0fd82Sopenharmony_ci ColorMode srcMode, 310a3e0fd82Sopenharmony_ci uint32_t color, 311a3e0fd82Sopenharmony_ci OpacityType opa, 312a3e0fd82Sopenharmony_ci uint8_t* dst, 313a3e0fd82Sopenharmony_ci uint32_t destStride, 314a3e0fd82Sopenharmony_ci ColorMode destMode, 315a3e0fd82Sopenharmony_ci uint32_t x, 316a3e0fd82Sopenharmony_ci uint32_t y) const; 317a3e0fd82Sopenharmony_ci 318a3e0fd82Sopenharmony_ci void FillAreaWithSoftWare(BufferInfo& gfxDstBuffer, 319a3e0fd82Sopenharmony_ci const Rect& fillArea, 320a3e0fd82Sopenharmony_ci const ColorType& color, 321a3e0fd82Sopenharmony_ci const OpacityType& opa) const; 322a3e0fd82Sopenharmony_ci#ifdef ARM_NEON_OPT 323a3e0fd82Sopenharmony_ci 324a3e0fd82Sopenharmony_ci void BlendLerpPix(uint8_t* color, uint8_t red, uint8_t green, uint8_t blue, 325a3e0fd82Sopenharmony_ci uint8_t alpha, uint8_t cover); 326a3e0fd82Sopenharmony_ci void BlendLerpPix(uint8_t* color, uint8_t red, uint8_t green, uint8_t blue, 327a3e0fd82Sopenharmony_ci uint8_t alpha); 328a3e0fd82Sopenharmony_ci void BlendLerpPix(uint8_t* dstColors, uint8_t* srcColors, uint8_t srcCover); 329a3e0fd82Sopenharmony_ci void BlendLerpPix(uint8_t* dstColors, uint8_t* srcColors, uint8_t* srcCovers); 330a3e0fd82Sopenharmony_ci void BlendLerpPix(uint8_t* color, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha, uint8_t* covers); 331a3e0fd82Sopenharmony_ci void BlendPreLerpPix(uint8_t* color, uint8_t red, uint8_t green, uint8_t blue, 332a3e0fd82Sopenharmony_ci uint8_t alpha, uint8_t cover); 333a3e0fd82Sopenharmony_ci void BlendPreLerpPix(uint8_t* color, uint8_t red, uint8_t green, uint8_t blue, 334a3e0fd82Sopenharmony_ci uint8_t alpha); 335a3e0fd82Sopenharmony_ci void BlendPreLerpPix(uint8_t* dstColors, uint8_t* srcColors, uint8_t srcCover); 336a3e0fd82Sopenharmony_ci void BlendPreLerpPix(uint8_t* dstColors, uint8_t* srcColors, uint8_t* srcCovers); 337a3e0fd82Sopenharmony_ci void BlendPreLerpPix(uint8_t* color, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha, uint8_t* covers); 338a3e0fd82Sopenharmony_ci#endif 339a3e0fd82Sopenharmony_ciprivate: 340a3e0fd82Sopenharmony_ci using DrawTriangleTransformFuc = void (*)(const TriangleScanInfo& triangle, const ColorMode bufferMode); 341a3e0fd82Sopenharmony_ci 342a3e0fd82Sopenharmony_ci static void DrawTriangleTrueColorNearest(const TriangleScanInfo& triangle, const ColorMode bufferMode); 343a3e0fd82Sopenharmony_ci 344a3e0fd82Sopenharmony_ci static void DrawTriangleAlphaBilinear(const TriangleScanInfo& triangle, const ColorMode bufferMode); 345a3e0fd82Sopenharmony_ci 346a3e0fd82Sopenharmony_ci static void DrawTriangleTrueColorBilinear565(const TriangleScanInfo& triangle, const ColorMode bufferMode); 347a3e0fd82Sopenharmony_ci 348a3e0fd82Sopenharmony_ci static void DrawTriangleTrueColorBilinear888(const TriangleScanInfo& triangle, const ColorMode bufferMode); 349a3e0fd82Sopenharmony_ci 350a3e0fd82Sopenharmony_ci static void Draw3DTriangleTrueColorBilinear8888(const TriangleScanInfo& triangle, const ColorMode bufferMode); 351a3e0fd82Sopenharmony_ci 352a3e0fd82Sopenharmony_ci static void DrawTriangleTrueColorBilinear8888(const TriangleScanInfo& triangle, const ColorMode bufferMode); 353a3e0fd82Sopenharmony_ci 354a3e0fd82Sopenharmony_ci inline static void StepToNextLine(TriangleEdge& edg1, TriangleEdge& edg2); 355a3e0fd82Sopenharmony_ci 356a3e0fd82Sopenharmony_ci static void DrawTriangleTransformPart(BufferInfo& gfxDstBuffer, const TrianglePartInfo& part); 357a3e0fd82Sopenharmony_ci 358a3e0fd82Sopenharmony_ci static OpacityType GetPxAlphaForAlphaImg(const TransformDataInfo& dataInfo, const Point& point); 359a3e0fd82Sopenharmony_ci 360a3e0fd82Sopenharmony_ci static void AddBorderToImageData(TransformDataInfo& newDataInfo, ImageInfo& imageinfo); 361a3e0fd82Sopenharmony_ci 362a3e0fd82Sopenharmony_ci static void UpdateTransMap(int16_t width, int16_t height, TransformMap& transMap); 363a3e0fd82Sopenharmony_ci 364a3e0fd82Sopenharmony_ci void FillArea(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& mask, 365a3e0fd82Sopenharmony_ci bool isTransparent, const ColorType* colorBuf); 366a3e0fd82Sopenharmony_ci 367a3e0fd82Sopenharmony_ci#ifdef ARM_NEON_OPT 368a3e0fd82Sopenharmony_ci void SetDestAndSrc(ColorMode& srcMode, ColorMode& destMode, uint32_t height, uint8_t* src, 369a3e0fd82Sopenharmony_ci uint32_t width, OpacityType opa, uint8_t* dest, uint32_t destStride, 370a3e0fd82Sopenharmony_ci uint32_t srcStride, uint8_t destByteSize, uint8_t srcByteSize) const; 371a3e0fd82Sopenharmony_ci#endif 372a3e0fd82Sopenharmony_ci 373a3e0fd82Sopenharmony_ci void SetFucInfo(BufferInfo& gfxDstBuffer, const TrianglePartInfo& part, 374a3e0fd82Sopenharmony_ci uint8_t* screenBuffer, TransformInitState& init); 375a3e0fd82Sopenharmony_ci void SetPartEdge(BufferInfo& gfxDstBuffer, const TriangleTransformDataInfo& triangleInfo, 376a3e0fd82Sopenharmony_ci TriangleEdge& edge1, TriangleEdge& edge2, bool p3IsInRight, 377a3e0fd82Sopenharmony_ci const Rect& mask, uint8_t yErr, TrianglePartInfo& part) const; 378a3e0fd82Sopenharmony_ci}; 379a3e0fd82Sopenharmony_ci} // namespace OHOS 380a3e0fd82Sopenharmony_ci#endif // GRAPHIC_LITE_DRAW_UTILS_H 381