draw_rect.cpp 32.4 KB
Newer Older
M
mamingshuai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "draw/draw_rect.h"
#include "draw/draw_utils.h"
N
niulihua 已提交
18
#include "engines/gfx/gfx_engine_manager.h"
Z
zhangguyuan 已提交
19 20 21
#include "gfx_utils/graphic_log.h"
#include "gfx_utils/graphic_math.h"
#include "gfx_utils/style.h"
M
mamingshuai 已提交
22 23

namespace OHOS {
N
niulihua 已提交
24 25
void DrawRect::Draw(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                    const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
{
    if ((rect.GetWidth() <= 0) || (rect.GetHeight() <= 0)) {
        GRAPHIC_LOGD("DrawRect::Draw width or height is zero\n");
        return;
    }

    /**
     * no border
     *      radius = 0 (1/4)
     *      radius > 0 (2/4)
     *          rect width > rect height
     *              radius >= rect height / 2
     *              radius < rect height / 2
     *          rect width <= rect height
     *              radius >= rect width / 2
     *              radius < rect width / 2
     * have border
     *      radius = 0 (3/4)
     *      radius > 0 (4/4)
     *          radius < border width (4.1/4)
     *          radius = border width (4.2/4)
     *          radius > border width (4.3/4)
     *             rect width <= rect height
     *                  radius >= border width + rect height / 2
     *                  radius < border width + rect height / 2
     *             rect width > rect height
     *                  radius >= border width + rect height / 2
     *                  radius < border width + rect height / 2
     */
    if (style.borderWidth_ == 0) {
        if (style.borderRadius_ == 0) {
            /* no border no radius (1/4) */
            OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.bgOpa_);
N
niulihua 已提交
59
            DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rect, dirtyRect, style.bgColor_, opa);
M
mamingshuai 已提交
60 61 62
            return;
        } else {
            /* [2/4] no border with radius (2/4) */
N
niulihua 已提交
63
            DrawRectRadiusWithoutBorder(gfxDstBuffer, rect, dirtyRect, style, opaScale);
M
mamingshuai 已提交
64 65 66 67
        }
    } else {
        if (style.borderRadius_ == 0) {
            /* [3/4] border without radius (3/4) */
N
niulihua 已提交
68
            DrawRectBorderWithoutRadius(gfxDstBuffer, rect, dirtyRect, style, opaScale);
M
mamingshuai 已提交
69 70
        } else if (style.borderRadius_ < style.borderWidth_) {
            /* [4.1/4] radius < border width */
N
niulihua 已提交
71
            DrawRectRadiusSmallThanBorder(gfxDstBuffer, rect, dirtyRect, style, opaScale);
M
mamingshuai 已提交
72 73
        } else if (style.borderRadius_ == style.borderWidth_) {
            /* [4.2/4] radius = border width */
N
niulihua 已提交
74
            DrawRectRadiusEqualBorder(gfxDstBuffer, rect, dirtyRect, style, opaScale);
M
mamingshuai 已提交
75 76
        } else {
            /* [4.3/4] radius >= border width + rect height_or_width / 2 */
N
niulihua 已提交
77
            DrawRectRadiusBiggerThanBorder(gfxDstBuffer, rect, dirtyRect, style, opaScale);
M
mamingshuai 已提交
78 79 80 81
        }
    }
}

N
niulihua 已提交
82 83
void DrawRect::DrawRectRadiusWithoutBorder(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                                           const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
84 85 86
{
    // 2 : half
    if ((rect.GetWidth() > rect.GetHeight()) && (style.borderRadius_ >= rect.GetHeight() / 2)) {
N
niulihua 已提交
87
        DrawRectRadiusWithoutBorderCon1(gfxDstBuffer, rect, dirtyRect, style, opaScale);
M
mamingshuai 已提交
88
    } else if ((rect.GetWidth() < rect.GetHeight()) && (style.borderRadius_ >= rect.GetWidth() / 2)) {
N
niulihua 已提交
89
        DrawRectRadiusWithoutBorderCon2(gfxDstBuffer, rect, dirtyRect, style, opaScale);
M
mamingshuai 已提交
90
    } else if ((rect.GetWidth() == rect.GetHeight()) && (style.borderRadius_ >= rect.GetWidth() / 2)) {
N
niulihua 已提交
91
        DrawRectRadiusWithoutBorderCon3(gfxDstBuffer, rect, dirtyRect, style, opaScale);
M
mamingshuai 已提交
92
    } else {
N
niulihua 已提交
93
        DrawRectRadiusWithoutBorderCon4(gfxDstBuffer, rect, dirtyRect, style, opaScale);
M
mamingshuai 已提交
94 95 96
    }
}

N
niulihua 已提交
97 98
void DrawRect::DrawRectRadiusWithoutBorderCon1(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                                               const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
{
    int16_t radius = rect.GetHeight() / 2;
    int16_t col2X = rect.GetLeft() + radius - 1;
    int16_t col3X = rect.GetRight() - radius + 1;

    int16_t row1Y = rect.GetTop();
    int16_t row2Y = rect.GetTop() + radius - 1;
    int16_t row3Y = rect.GetBottom();

    Style arcStyle = style;
    arcStyle.lineWidth_ = radius;
    arcStyle.lineColor_ = style.bgColor_;
    arcStyle.lineOpa_ = style.bgOpa_;
    // draw left sector
    ArcInfo arcInfo;
    arcInfo.center = {col2X, row2Y};
    arcInfo.radius = radius;
    arcInfo.startAngle = SEMICIRCLE_IN_DEGREE;
    arcInfo.endAngle = CIRCLE_IN_DEGREE;
    arcInfo.imgPos = {0, 0};
    arcInfo.imgSrc = nullptr;
N
niulihua 已提交
120
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
121 122 123 124 125

    // draw right sector
    arcInfo.center = {col3X, row2Y};
    arcInfo.startAngle = 0;
    arcInfo.endAngle = SEMICIRCLE_IN_DEGREE;
N
niulihua 已提交
126
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
127 128 129 130

    // draw top rectangle
    Rect topRect(col2X, row1Y, col3X - 1, row2Y - 1);
    OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.bgOpa_);
N
niulihua 已提交
131
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, topRect, dirtyRect, style.bgColor_, opa);
M
mamingshuai 已提交
132 133 134

    // draw bottom rectangle
    Rect bottomRect(col2X + 1, row2Y, col3X - 1, row3Y);
N
niulihua 已提交
135
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, bottomRect, dirtyRect, style.bgColor_, opa);
M
mamingshuai 已提交
136 137
}

N
niulihua 已提交
138 139
void DrawRect::DrawRectRadiusWithoutBorderCon2(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                                               const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
{
    int16_t radius = rect.GetWidth() / 2;
    int16_t col1X = rect.GetLeft();
    int16_t col2X = rect.GetLeft() + radius - 1;
    int16_t col3X = rect.GetRight();

    int16_t row2Y = rect.GetTop() + radius - 1;
    int16_t row3Y = rect.GetBottom() - radius + 1;

    Style arcStyle = style;
    arcStyle.lineWidth_ = radius;
    arcStyle.lineColor_ = style.bgColor_;
    arcStyle.lineOpa_ = style.bgOpa_;
    // draw top sector
    ArcInfo arcInfo;
    arcInfo.center = {col2X, row2Y};
    arcInfo.startAngle = THREE_QUARTER_IN_DEGREE;
    arcInfo.endAngle = QUARTER_IN_DEGREE;
    arcInfo.radius = radius;
    arcInfo.imgPos = {0, 0};
    arcInfo.imgSrc = nullptr;
N
niulihua 已提交
161
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
162 163 164 165 166

    // draw bottom sector
    arcInfo.center = {col2X, row3Y};
    arcInfo.startAngle = QUARTER_IN_DEGREE;
    arcInfo.endAngle = THREE_QUARTER_IN_DEGREE;
N
niulihua 已提交
167
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
168 169 170 171

    // draw middle rectangle
    Rect middleRect(col1X, row2Y + 1, col3X, row3Y - 1);
    OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.bgOpa_);
N
niulihua 已提交
172
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, middleRect, dirtyRect, style.bgColor_, opa);
M
mamingshuai 已提交
173 174
}

N
niulihua 已提交
175 176
void DrawRect::DrawRectRadiusWithoutBorderCon3(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                                               const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
{
    int16_t radius = rect.GetWidth() / 2;
    int16_t col1X = rect.GetLeft() + radius - 1;
    int16_t row1Y = rect.GetTop() + radius - 1;

    Style arcStyle = style;
    arcStyle.lineWidth_ = radius;
    arcStyle.lineColor_ = style.bgColor_;
    arcStyle.lineOpa_ = style.bgOpa_;
    // draw circle
    ArcInfo arcInfo;
    arcInfo.center = {col1X, row1Y};
    arcInfo.startAngle = 0;
    arcInfo.endAngle = CIRCLE_IN_DEGREE;
    arcInfo.radius = radius;
    arcInfo.imgPos = {0, 0};
    arcInfo.imgSrc = nullptr;
N
niulihua 已提交
194
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
195 196
}

N
niulihua 已提交
197 198
void DrawRect::DrawRectRadiusWithoutBorderCon4(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                                               const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
{
    int16_t radius = style.borderRadius_;
    int16_t col1X = rect.GetLeft();
    int16_t col2X = rect.GetLeft() + radius - 1;
    int16_t col3X = rect.GetRight() - radius + 1;
    int16_t col4X = rect.GetRight();

    int16_t row1Y = rect.GetTop();
    int16_t row2Y = rect.GetTop() + radius - 1;
    int16_t row3Y = rect.GetBottom() - radius + 1;
    int16_t row4Y = rect.GetBottom();

    OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.bgOpa_);
    // draw top rectangle
    Rect topRect(col2X, row1Y, col3X - 1, row2Y);
N
niulihua 已提交
214
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, topRect, dirtyRect, style.bgColor_, opa);
M
mamingshuai 已提交
215 216 217

    // draw middle rectangle
    Rect middleRect(col1X, row2Y + 1, col4X, row3Y - 1);
N
niulihua 已提交
218
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, middleRect, dirtyRect, style.bgColor_, opa);
M
mamingshuai 已提交
219 220 221

    // draw bottom rectangle
    Rect bottomRect(col2X + 1, row3Y, col3X - 1, row4Y);
N
niulihua 已提交
222
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, bottomRect, dirtyRect, style.bgColor_, opa);
M
mamingshuai 已提交
223 224 225 226 227 228 229 230 231 232 233 234 235

    Style arcStyle = style;
    arcStyle.lineWidth_ = radius;
    arcStyle.lineColor_ = style.bgColor_;
    arcStyle.lineOpa_ = style.bgOpa_;
    // top left sector
    ArcInfo arcInfo;
    arcInfo.center = {col2X, row2Y};
    arcInfo.startAngle = THREE_QUARTER_IN_DEGREE;
    arcInfo.endAngle = CIRCLE_IN_DEGREE;
    arcInfo.radius = radius;
    arcInfo.imgPos = {0, 0};
    arcInfo.imgSrc = nullptr;
N
niulihua 已提交
236
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
237 238 239 240 241

    // top right sector
    arcInfo.center = {col3X, row2Y};
    arcInfo.startAngle = 0;
    arcInfo.endAngle = QUARTER_IN_DEGREE;
N
niulihua 已提交
242
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
243 244 245 246 247

    // bottom left sector
    arcInfo.center = {col2X, row3Y};
    arcInfo.startAngle = SEMICIRCLE_IN_DEGREE;
    arcInfo.endAngle = THREE_QUARTER_IN_DEGREE;
N
niulihua 已提交
248
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
249 250 251 252 253

    // bottom right sector
    arcInfo.center = {col3X, row3Y};
    arcInfo.startAngle = QUARTER_IN_DEGREE;
    arcInfo.endAngle = SEMICIRCLE_IN_DEGREE;
N
niulihua 已提交
254
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
255 256
}

N
niulihua 已提交
257 258
void DrawRect::DrawRectBorderWithoutRadius(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                                           const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
259 260 261 262 263 264 265 266 267 268 269 270 271 272
{
    int16_t col1X = rect.GetLeft();
    int16_t col2X = rect.GetLeft() + style.borderWidth_ - 1;
    int16_t col3X = rect.GetRight() - style.borderWidth_ + 1;
    int16_t col4X = rect.GetRight();

    int16_t row1Y = rect.GetTop();
    int16_t row2Y = rect.GetTop() + style.borderWidth_ - 1;
    int16_t row3Y = rect.GetBottom() - style.borderWidth_ + 1;
    int16_t row4Y = rect.GetBottom();

    OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.borderOpa_);
    // draw top border
    Rect topRect(col1X, row1Y, col4X, row2Y);
N
niulihua 已提交
273
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, topRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
274 275 276

    // draw left border
    Rect leftRect(col1X, row2Y + 1, col2X, row3Y - 1);
N
niulihua 已提交
277
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, leftRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
278 279 280 281

    OpacityType opaBg = DrawUtils::GetMixOpacity(opaScale, style.bgOpa_);
    // draw middle rectangle
    Rect middleRect(col2X + 1, row2Y + 1, col3X - 1, row3Y - 1);
N
niulihua 已提交
282
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, middleRect, dirtyRect, style.bgColor_, opaBg);
M
mamingshuai 已提交
283 284 285

    // draw right border
    Rect rightRect(col3X, row2Y + 1, col4X, row3Y - 1);
N
niulihua 已提交
286
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rightRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
287 288 289

    // draw bottom border
    Rect bottomRect(col1X, row3Y, col4X, row4Y);
N
niulihua 已提交
290
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, bottomRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
291 292
}

N
niulihua 已提交
293 294
void DrawRect::DrawRectRadiusEqualBorder(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                                         const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
{
    int16_t col1X = rect.GetLeft();
    int16_t col2X = rect.GetLeft() + style.borderRadius_ - 1;
    int16_t col3X = rect.GetRight() - style.borderRadius_ + 1;
    int16_t col4X = rect.GetRight();

    int16_t row1Y = rect.GetTop();
    int16_t row2Y = rect.GetTop() + style.borderRadius_ - 1;
    int16_t row3Y = rect.GetBottom() - style.borderRadius_ + 1;
    int16_t row4Y = rect.GetBottom();

    Style arcStyle = style;
    arcStyle.lineWidth_ = style.borderWidth_;
    arcStyle.lineColor_ = style.borderColor_;
    arcStyle.lineOpa_ = style.borderOpa_;
    // draw top left sector in border
    ArcInfo arcInfo;
    arcInfo.center = {col2X, row2Y};
    arcInfo.startAngle = THREE_QUARTER_IN_DEGREE;
    arcInfo.endAngle = CIRCLE_IN_DEGREE;
    arcInfo.radius = style.borderRadius_;
    arcInfo.imgPos = {0, 0};
    arcInfo.imgSrc = nullptr;
N
niulihua 已提交
318
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
319 320 321 322 323

    // draw top right sector in border
    arcInfo.center = {col3X, row2Y};
    arcInfo.startAngle = 0;
    arcInfo.endAngle = QUARTER_IN_DEGREE;
N
niulihua 已提交
324
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
325 326 327 328 329

    // draw bottom left sector in border
    arcInfo.center = {col2X, row3Y};
    arcInfo.startAngle = SEMICIRCLE_IN_DEGREE;
    arcInfo.endAngle = THREE_QUARTER_IN_DEGREE;
N
niulihua 已提交
330
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
331 332 333 334 335

    // draw bottom right sector in border
    arcInfo.center = {col3X, row3Y};
    arcInfo.startAngle = QUARTER_IN_DEGREE;
    arcInfo.endAngle = SEMICIRCLE_IN_DEGREE;
N
niulihua 已提交
336
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
337 338 339 340

    OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.borderOpa_);
    // draw top rectangle in border
    Rect topRect(col2X, row1Y, col3X - 1, row2Y);
N
niulihua 已提交
341
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, topRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
342 343 344

    // draw left rectangle in border
    Rect leftRect(col1X, row2Y + 1, col2X, row3Y - 1);
N
niulihua 已提交
345
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, leftRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
346 347 348 349

    OpacityType opaBg = DrawUtils::GetMixOpacity(opaScale, style.bgOpa_);
    // draw middle rectangle
    Rect middleRect(col2X + 1, row2Y + 1, col3X - 1, row3Y - 1);
N
niulihua 已提交
350
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, middleRect, dirtyRect, style.bgColor_, opaBg);
M
mamingshuai 已提交
351 352 353

    // draw right rectangle in border
    Rect rightRect(col3X, row2Y + 1, col4X, row3Y - 1);
N
niulihua 已提交
354
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rightRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
355 356 357

    // draw bottom rectangle in border
    Rect bottomRect(col2X + 1, row3Y, col3X - 1, row4Y);
N
niulihua 已提交
358
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, bottomRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
359 360
}

N
niulihua 已提交
361 362
void DrawRect::DrawRectRadiusSmallThanBorder(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                                             const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394
{
    int16_t radiusCol1X = rect.GetLeft();
    int16_t radiusCol2X = rect.GetLeft() + style.borderRadius_ - 1;
    int16_t radiusCol3X = rect.GetRight() - style.borderRadius_ + 1;
    int16_t radiusCol4X = rect.GetRight();

    int16_t radiusRow1Y = rect.GetTop();
    int16_t radiusRow2Y = rect.GetTop() + style.borderRadius_ - 1;
    int16_t radiusRow3Y = rect.GetBottom() - style.borderRadius_ + 1;
    int16_t radiusRow4Y = rect.GetBottom();

    int16_t rectCol1X = radiusCol1X;
    int16_t rectCol2X = rect.GetLeft() + style.borderWidth_ - 1;
    int16_t rectCol3X = rect.GetRight() - style.borderWidth_ + 1;
    int16_t rectCol4X = radiusCol4X;

    int16_t rectRow1Y = radiusRow2Y;
    int16_t rectRow2Y = rect.GetTop() + style.borderWidth_ - 1;
    int16_t rectRow3Y = rect.GetBottom() - style.borderWidth_ + 1;

    Style arcStyle = style;
    arcStyle.lineWidth_ = style.borderWidth_;
    arcStyle.lineColor_ = style.borderColor_;
    arcStyle.lineOpa_ = style.borderOpa_;
    // draw top left sector in border
    ArcInfo arcInfo;
    arcInfo.center = {radiusCol2X, radiusRow2Y};
    arcInfo.startAngle = THREE_QUARTER_IN_DEGREE;
    arcInfo.endAngle = CIRCLE_IN_DEGREE;
    arcInfo.radius = style.borderRadius_;
    arcInfo.imgPos = {0, 0};
    arcInfo.imgSrc = nullptr;
N
niulihua 已提交
395
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
396 397 398 399 400

    // draw top right sector in border
    arcInfo.center = {radiusCol3X, radiusRow2Y};
    arcInfo.startAngle = 0;
    arcInfo.endAngle = QUARTER_IN_DEGREE;
N
niulihua 已提交
401
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
402 403 404 405 406

    // draw bottom left sector in border
    arcInfo.center = {radiusCol2X, radiusRow3Y};
    arcInfo.startAngle = SEMICIRCLE_IN_DEGREE;
    arcInfo.endAngle = THREE_QUARTER_IN_DEGREE;
N
niulihua 已提交
407
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
408 409 410 411 412

    // draw bottom right sector in border
    arcInfo.center = {radiusCol3X, radiusRow3Y};
    arcInfo.startAngle = QUARTER_IN_DEGREE;
    arcInfo.endAngle = SEMICIRCLE_IN_DEGREE;
N
niulihua 已提交
413
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
414 415 416 417

    OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.borderOpa_);
    // draw top rectangle in border
    Rect topRect(radiusCol2X, radiusRow1Y, radiusCol3X - 1, radiusRow2Y);
N
niulihua 已提交
418
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, topRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
419
    Rect topRect2(rectCol1X, rectRow1Y + 1, rectCol4X, rectRow2Y);
N
niulihua 已提交
420
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, topRect2, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
421 422 423

    // draw left rectangle in border
    Rect leftRect(rectCol1X, rectRow2Y + 1, rectCol2X, rectRow3Y - 1);
N
niulihua 已提交
424
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, leftRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
425 426 427 428

    OpacityType opaBg = DrawUtils::GetMixOpacity(opaScale, style.bgOpa_);
    // draw middle rectangle
    Rect middleRect(rectCol2X + 1, rectRow2Y + 1, rectCol3X - 1, rectRow3Y - 1);
N
niulihua 已提交
429
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, middleRect, dirtyRect, style.bgColor_, opaBg);
M
mamingshuai 已提交
430 431 432

    // draw right rectangle in border
    Rect rightRect(rectCol3X, rectRow2Y + 1, rectCol4X, rectRow3Y - 1);
N
niulihua 已提交
433
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rightRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
434 435 436

    // draw bottom rectangle in border
    Rect bottomRect(radiusCol2X + 1, radiusRow3Y, radiusCol3X - 1, radiusRow4Y);
N
niulihua 已提交
437
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, bottomRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
438
    Rect bottomRect2(rectCol1X, rectRow3Y, rectCol4X, radiusRow3Y - 1);
N
niulihua 已提交
439
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, bottomRect2, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
440 441
}

N
niulihua 已提交
442 443
void DrawRect::DrawRectRadiusBiggerThanBorder(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                                              const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
444 445 446
{
    // 2 : half
    if ((rect.GetWidth() > rect.GetHeight()) && (style.borderRadius_ >= rect.GetHeight() / 2)) {
N
niulihua 已提交
447
        DrawRectRadiusBiggerThanBorderCon1(gfxDstBuffer, rect, dirtyRect, style, opaScale);
M
mamingshuai 已提交
448
    } else if ((rect.GetWidth() < rect.GetHeight()) && (style.borderRadius_ >= rect.GetWidth() / 2)) {
N
niulihua 已提交
449
        DrawRectRadiusBiggerThanBorderCon2(gfxDstBuffer, rect, dirtyRect, style, opaScale);
M
mamingshuai 已提交
450
    } else if ((rect.GetWidth() == rect.GetHeight()) && (style.borderRadius_ >= rect.GetWidth() / 2)) {
N
niulihua 已提交
451
        DrawRectRadiusBiggerThanBorderCon3(gfxDstBuffer, rect, dirtyRect, style, opaScale);
M
mamingshuai 已提交
452
    } else {
N
niulihua 已提交
453
        DrawRectRadiusBiggerThanBorderCon4(gfxDstBuffer, rect, dirtyRect, style, opaScale);
M
mamingshuai 已提交
454 455 456
    }
}

N
niulihua 已提交
457 458
void DrawRect::DrawRectRadiusBiggerThanBorderCon1(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                                                  const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
{
    int16_t radius = rect.GetHeight() / 2;
    int16_t borderWidth = style.borderWidth_;
    int16_t col2X = rect.GetLeft() + radius - 1;
    int16_t col3X = rect.GetRight() - radius + 1;

    int16_t row1Y = rect.GetTop();
    int16_t row2Y = rect.GetTop() + borderWidth - 1;
    int16_t row3Y = rect.GetTop() + radius - 1;
    int16_t row4Y = rect.GetBottom() - borderWidth + 1;
    int16_t row5Y = rect.GetBottom();

    Style arcStyle = style;
    arcStyle.lineWidth_ = borderWidth;
    arcStyle.lineColor_ = style.borderColor_;
    arcStyle.lineOpa_ = style.borderOpa_;
    // draw left arc in border
    ArcInfo arcInfo;
    arcInfo.center = {col2X, row3Y};
    arcInfo.startAngle = SEMICIRCLE_IN_DEGREE;
    arcInfo.endAngle = CIRCLE_IN_DEGREE;
    arcInfo.radius = radius;
    arcInfo.imgPos = {0, 0};
    arcInfo.imgSrc = nullptr;
N
niulihua 已提交
483
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
484 485 486 487
    // draw right arc in border
    arcInfo.center = {col3X, row3Y};
    arcInfo.startAngle = 0;
    arcInfo.endAngle = SEMICIRCLE_IN_DEGREE;
N
niulihua 已提交
488
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
489 490 491 492 493 494 495 496 497 498 499

    radius = radius - borderWidth;
    arcStyle.lineWidth_ = radius;
    arcStyle.lineColor_ = style.bgColor_;
    arcStyle.lineOpa_ = style.bgOpa_;

    // draw left sector in rectangle
    arcInfo.center = {col2X, row3Y};
    arcInfo.startAngle = SEMICIRCLE_IN_DEGREE;
    arcInfo.endAngle = CIRCLE_IN_DEGREE;
    arcInfo.radius = radius;
N
niulihua 已提交
500
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
501 502 503 504
    // draw right sector in rectangle
    arcInfo.center = {col3X, row3Y};
    arcInfo.startAngle = 0;
    arcInfo.endAngle = SEMICIRCLE_IN_DEGREE;
N
niulihua 已提交
505
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
506 507 508 509

    OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.borderOpa_);
    // top rectangle in border
    Rect topBorderRect(col2X, row1Y, col3X - 1, row2Y);
N
niulihua 已提交
510
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, topBorderRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
511 512 513
    OpacityType opaBg = DrawUtils::GetMixOpacity(opaScale, style.bgOpa_);
    // middle rectangle inner
    Rect middleInnerRect(col2X, row2Y + 1, col3X - 1, row3Y);
N
niulihua 已提交
514
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, middleInnerRect, dirtyRect, style.bgColor_, opaBg);
M
mamingshuai 已提交
515
    Rect middleInnerRect2(col2X + 1, row3Y + 1, col3X - 1, row4Y - 1);
N
niulihua 已提交
516
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, middleInnerRect2, dirtyRect, style.bgColor_, opaBg);
M
mamingshuai 已提交
517 518 519

    // bottom rectangle in border
    Rect bottomBorderRect(col2X + 1, row4Y, col3X - 1, row5Y);
N
niulihua 已提交
520
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, bottomBorderRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
521 522
}

N
niulihua 已提交
523 524
void DrawRect::DrawRectRadiusBiggerThanBorderCon2(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                                                  const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
{
    int16_t radius = rect.GetWidth() / 2;
    int16_t borderWidth = style.borderWidth_;
    int16_t col1X = rect.GetLeft();
    int16_t col2X = rect.GetLeft() + borderWidth - 1;
    int16_t col3X = rect.GetLeft() + radius - 1;
    int16_t col4X = rect.GetRight() - borderWidth + 1;
    int16_t col5X = rect.GetRight();

    int16_t row2Y = rect.GetTop() + radius - 1;
    int16_t row3Y = rect.GetBottom() - radius + 1;

    Style arcStyle = style;
    arcStyle.lineWidth_ = borderWidth;
    arcStyle.lineColor_ = style.borderColor_;
    arcStyle.lineOpa_ = style.borderOpa_;
    // draw top arc in border
    ArcInfo arcInfo;
    arcInfo.center = {col3X, row2Y};
    arcInfo.startAngle = THREE_QUARTER_IN_DEGREE;
    arcInfo.endAngle = QUARTER_IN_DEGREE;
    arcInfo.radius = radius;
    arcInfo.imgPos = {0, 0};
    arcInfo.imgSrc = nullptr;
N
niulihua 已提交
549
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
550 551 552 553
    // draw bottom arc in border
    arcInfo.center = {col3X, row3Y};
    arcInfo.startAngle = QUARTER_IN_DEGREE;
    arcInfo.endAngle = THREE_QUARTER_IN_DEGREE;
N
niulihua 已提交
554
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
555 556 557 558 559 560 561 562 563 564 565

    radius = radius - borderWidth;
    arcStyle.lineWidth_ = radius;
    arcStyle.lineColor_ = style.bgColor_;
    arcStyle.lineOpa_ = style.bgOpa_;

    // draw top sector in rectangle
    arcInfo.center = {col3X, row2Y};
    arcInfo.startAngle = THREE_QUARTER_IN_DEGREE;
    arcInfo.endAngle = QUARTER_IN_DEGREE;
    arcInfo.radius = radius;
N
niulihua 已提交
566
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
567 568 569 570
    // draw bottom sector in rectangle
    arcInfo.center = {col3X, row3Y};
    arcInfo.startAngle = QUARTER_IN_DEGREE;
    arcInfo.endAngle = THREE_QUARTER_IN_DEGREE;
N
niulihua 已提交
571
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
572 573 574 575

    OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.borderOpa_);
    // left rectangle in border
    Rect topBorderRect(col1X, row2Y + 1, col2X, row3Y - 1);
N
niulihua 已提交
576
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, topBorderRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
577 578 579 580

    OpacityType opaBg = DrawUtils::GetMixOpacity(opaScale, style.bgOpa_);
    // middle rectangle inner
    Rect middleInnerRect(col2X + 1, row2Y + 1, col4X - 1, row3Y - 1);
N
niulihua 已提交
581
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, middleInnerRect, dirtyRect, style.bgColor_, opaBg);
M
mamingshuai 已提交
582 583 584

    // right rectangle in border
    Rect bottomBorderRect(col4X, row2Y + 1, col5X, row3Y - 1);
N
niulihua 已提交
585
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, bottomBorderRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
586 587
}

N
niulihua 已提交
588 589
void DrawRect::DrawRectRadiusBiggerThanBorderCon3(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                                                  const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607
{
    int16_t radius = rect.GetWidth() / 2;
    int16_t borderWidth = style.borderWidth_;
    int16_t col2X = rect.GetLeft() + radius - 1;
    int16_t row2Y = rect.GetTop() + radius - 1;

    Style arcStyle = style;
    arcStyle.lineWidth_ = borderWidth;
    arcStyle.lineColor_ = style.borderColor_;
    arcStyle.lineOpa_ = style.borderOpa_;
    // draw circle in border
    ArcInfo arcInfo;
    arcInfo.center = {col2X, row2Y};
    arcInfo.startAngle = 0;
    arcInfo.endAngle = CIRCLE_IN_DEGREE;
    arcInfo.radius = radius;
    arcInfo.imgPos = {0, 0};
    arcInfo.imgSrc = nullptr;
N
niulihua 已提交
608
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
609 610 611 612 613 614 615 616 617 618 619

    radius = radius - borderWidth;
    arcStyle.lineWidth_ = radius;
    arcStyle.lineColor_ = style.bgColor_;
    arcStyle.lineOpa_ = style.bgOpa_;

    // draw circle in rectangle
    arcInfo.center = {col2X, row2Y};
    arcInfo.startAngle = 0;
    arcInfo.endAngle = CIRCLE_IN_DEGREE;
    arcInfo.radius = radius;
N
niulihua 已提交
620
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
621 622
}

N
niulihua 已提交
623 624
void DrawRect::DrawRectRadiusBiggerThanBorderCon4(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
                                                  const Style& style, OpacityType opaScale)
M
mamingshuai 已提交
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
{
    int16_t radius = style.borderRadius_;
    int16_t borderWidth = style.borderWidth_;
    int16_t col1X = rect.GetLeft();
    int16_t col2X = rect.GetLeft() + borderWidth - 1;
    int16_t col3X = rect.GetLeft() + radius - 1;
    int16_t col4X = rect.GetRight() - radius + 1;
    int16_t col5X = rect.GetRight() - borderWidth + 1;
    int16_t col6X = rect.GetRight();

    int16_t row1Y = rect.GetTop();
    int16_t row2Y = rect.GetTop() + borderWidth - 1;
    int16_t row3Y = rect.GetTop() + radius - 1;
    int16_t row4Y = rect.GetBottom() - radius + 1;
    int16_t row5Y = rect.GetBottom() - borderWidth + 1;
    int16_t row6Y = rect.GetBottom();

    Style arcStyle = style;
    arcStyle.lineWidth_ = borderWidth;
    arcStyle.lineColor_ = style.borderColor_;
    arcStyle.lineOpa_ = style.borderOpa_;

    // draw top left arc in border
    ArcInfo arcInfo;
    arcInfo.center = {col3X, row3Y};
    arcInfo.startAngle = THREE_QUARTER_IN_DEGREE;
    arcInfo.endAngle = CIRCLE_IN_DEGREE;
    arcInfo.radius = radius;
    arcInfo.imgPos = {0, 0};
    arcInfo.imgSrc = nullptr;
N
niulihua 已提交
655
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
656 657 658 659
    // draw top right arc in border
    arcInfo.center = {col4X, row3Y};
    arcInfo.startAngle = 0;
    arcInfo.endAngle = QUARTER_IN_DEGREE;
N
niulihua 已提交
660
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
661 662 663 664
    // draw bottom left arc in border
    arcInfo.center = {col3X, row4Y};
    arcInfo.startAngle = SEMICIRCLE_IN_DEGREE;
    arcInfo.endAngle = THREE_QUARTER_IN_DEGREE;
N
niulihua 已提交
665
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
666 667 668 669
    // draw bottom right arc in border
    arcInfo.center = {col4X, row4Y};
    arcInfo.startAngle = QUARTER_IN_DEGREE;
    arcInfo.endAngle = SEMICIRCLE_IN_DEGREE;
N
niulihua 已提交
670
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
671 672 673 674 675 676 677 678 679 680 681

    radius = radius - borderWidth;
    arcStyle.lineWidth_ = radius;
    arcStyle.lineColor_ = style.bgColor_;
    arcStyle.lineOpa_ = style.bgOpa_;

    // draw top left sector in rectangle
    arcInfo.center = {col3X, row3Y};
    arcInfo.startAngle = THREE_QUARTER_IN_DEGREE;
    arcInfo.endAngle = CIRCLE_IN_DEGREE;
    arcInfo.radius = radius;
N
niulihua 已提交
682
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
683 684 685 686
    // draw top right sector in rectangle
    arcInfo.center = {col4X, row3Y};
    arcInfo.startAngle = 0;
    arcInfo.endAngle = QUARTER_IN_DEGREE;
N
niulihua 已提交
687
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
688 689 690 691
    // draw bottom left sector in rectangle
    arcInfo.center = {col3X, row4Y};
    arcInfo.startAngle = SEMICIRCLE_IN_DEGREE;
    arcInfo.endAngle = THREE_QUARTER_IN_DEGREE;
N
niulihua 已提交
692
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
693 694 695 696
    // draw bottom right sector in rectangle
    arcInfo.center = {col4X, row4Y};
    arcInfo.startAngle = QUARTER_IN_DEGREE;
    arcInfo.endAngle = SEMICIRCLE_IN_DEGREE;
N
niulihua 已提交
697
    BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, dirtyRect, arcStyle, opaScale, CapType::CAP_NONE);
M
mamingshuai 已提交
698 699 700 701

    OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.borderOpa_);
    // top rectangle in border
    Rect topBorderRect(col3X, row1Y, col4X - 1, row2Y);
N
niulihua 已提交
702
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, topBorderRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
703 704 705 706

    OpacityType opaBg = DrawUtils::GetMixOpacity(opaScale, style.bgOpa_);
    // top rectangle inner
    Rect topInnerRect(col3X, row2Y + 1, col4X - 1, row3Y);
N
niulihua 已提交
707
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, topInnerRect, dirtyRect, style.bgColor_, opaBg);
M
mamingshuai 已提交
708 709 710

    // left rectangle in border
    Rect leftBorderRect(col1X, row3Y + 1, col2X, row4Y - 1);
N
niulihua 已提交
711
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, leftBorderRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
712 713 714

    // middle rectangle inner
    Rect middleInnerRect(col2X + 1, row3Y + 1, col5X - 1, row4Y - 1);
N
niulihua 已提交
715
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, middleInnerRect, dirtyRect, style.bgColor_, opaBg);
M
mamingshuai 已提交
716 717 718

    // right rectangle in border
    Rect rightBorderRect(col5X, row3Y + 1, col6X, row4Y - 1);
N
niulihua 已提交
719
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rightBorderRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
720 721 722

    // bottom rectangle inner
    Rect bottomInnerRect(col3X + 1, row4Y, col4X - 1, row5Y - 1);
N
niulihua 已提交
723
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, bottomInnerRect, dirtyRect, style.bgColor_, opaBg);
M
mamingshuai 已提交
724 725 726

    // bottom rectangle in border
    Rect bottomBorderRect(col3X + 1, row5Y, col4X - 1, row6Y);
N
niulihua 已提交
727
    DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, bottomBorderRect, dirtyRect, style.borderColor_, opa);
M
mamingshuai 已提交
728 729
}
} // namespace OHOS