1a3e0fd82Sopenharmony_ci/* 2a3e0fd82Sopenharmony_ci * Copyright (c) 2020-2021 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#include "components/ui_box_progress.h" 17a3e0fd82Sopenharmony_ci#include "draw/draw_utils.h" 18a3e0fd82Sopenharmony_ci#include "engines/gfx/gfx_engine_manager.h" 19a3e0fd82Sopenharmony_ci#include "gfx_utils/graphic_log.h" 20a3e0fd82Sopenharmony_ci 21a3e0fd82Sopenharmony_cinamespace OHOS { 22a3e0fd82Sopenharmony_ciUIBoxProgress::UIBoxProgress() 23a3e0fd82Sopenharmony_ci : progressWidth_(0), progressHeight_(0), isValidWidthSet_(false), isValidHeightSet_(false) 24a3e0fd82Sopenharmony_ci{ 25a3e0fd82Sopenharmony_ci SetDirection(Direction::DIR_LEFT_TO_RIGHT); 26a3e0fd82Sopenharmony_ci} 27a3e0fd82Sopenharmony_ci 28a3e0fd82Sopenharmony_civoid UIBoxProgress::DrawValidRect(BufferInfo& gfxDstBuffer, 29a3e0fd82Sopenharmony_ci const Image* image, 30a3e0fd82Sopenharmony_ci const Rect& rect, 31a3e0fd82Sopenharmony_ci const Rect& invalidatedArea, 32a3e0fd82Sopenharmony_ci const Style& style, 33a3e0fd82Sopenharmony_ci uint16_t radius) 34a3e0fd82Sopenharmony_ci{ 35a3e0fd82Sopenharmony_ci Rect cordsTmp; 36a3e0fd82Sopenharmony_ci if ((image != nullptr) && (image->GetSrcType() != IMG_SRC_UNKNOWN)) { 37a3e0fd82Sopenharmony_ci ImageHeader header = {0}; 38a3e0fd82Sopenharmony_ci image->GetHeader(header); 39a3e0fd82Sopenharmony_ci 40a3e0fd82Sopenharmony_ci Rect area(rect); 41a3e0fd82Sopenharmony_ci switch (direction_) { 42a3e0fd82Sopenharmony_ci case Direction::DIR_LEFT_TO_RIGHT: 43a3e0fd82Sopenharmony_ci cordsTmp.SetPosition(area.GetLeft() - radius, area.GetTop()); 44a3e0fd82Sopenharmony_ci break; 45a3e0fd82Sopenharmony_ci case Direction::DIR_TOP_TO_BOTTOM: 46a3e0fd82Sopenharmony_ci cordsTmp.SetPosition(area.GetLeft(), area.GetTop() - radius); 47a3e0fd82Sopenharmony_ci break; 48a3e0fd82Sopenharmony_ci case Direction::DIR_RIGHT_TO_LEFT: 49a3e0fd82Sopenharmony_ci cordsTmp.SetPosition(area.GetRight() + radius - header.width, area.GetTop()); 50a3e0fd82Sopenharmony_ci break; 51a3e0fd82Sopenharmony_ci case Direction::DIR_BOTTOM_TO_TOP: 52a3e0fd82Sopenharmony_ci cordsTmp.SetPosition(area.GetLeft(), area.GetBottom() + radius - header.height); 53a3e0fd82Sopenharmony_ci break; 54a3e0fd82Sopenharmony_ci default: 55a3e0fd82Sopenharmony_ci GRAPHIC_LOGE("UIBoxProgress: DrawValidRect direction Err!\n"); 56a3e0fd82Sopenharmony_ci break; 57a3e0fd82Sopenharmony_ci } 58a3e0fd82Sopenharmony_ci cordsTmp.SetHeight(header.height); 59a3e0fd82Sopenharmony_ci cordsTmp.SetWidth(header.width); 60a3e0fd82Sopenharmony_ci if (area.Intersect(area, invalidatedArea)) { 61a3e0fd82Sopenharmony_ci image->DrawImage(gfxDstBuffer, cordsTmp, area, style, opaScale_); 62a3e0fd82Sopenharmony_ci } 63a3e0fd82Sopenharmony_ci } else { 64a3e0fd82Sopenharmony_ci BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, rect, invalidatedArea, style, opaScale_); 65a3e0fd82Sopenharmony_ci } 66a3e0fd82Sopenharmony_ci 67a3e0fd82Sopenharmony_ci if (style.lineCap_ == CapType::CAP_ROUND) { 68a3e0fd82Sopenharmony_ci DrawRoundCap(gfxDstBuffer, image, {cordsTmp.GetX(), cordsTmp.GetY()}, rect, invalidatedArea, radius, style); 69a3e0fd82Sopenharmony_ci } 70a3e0fd82Sopenharmony_ci} 71a3e0fd82Sopenharmony_ci 72a3e0fd82Sopenharmony_civoid UIBoxProgress::DrawRoundCap(BufferInfo& gfxDstBuffer, 73a3e0fd82Sopenharmony_ci const Image* image, 74a3e0fd82Sopenharmony_ci const Point& imgPos, 75a3e0fd82Sopenharmony_ci const Rect& rect, 76a3e0fd82Sopenharmony_ci const Rect& invalidatedArea, 77a3e0fd82Sopenharmony_ci uint16_t radius, 78a3e0fd82Sopenharmony_ci const Style& style) 79a3e0fd82Sopenharmony_ci{ 80a3e0fd82Sopenharmony_ci Point leftTop; 81a3e0fd82Sopenharmony_ci Point leftBottom; 82a3e0fd82Sopenharmony_ci Point rightTop; 83a3e0fd82Sopenharmony_ci Point rightBottom; 84a3e0fd82Sopenharmony_ci 85a3e0fd82Sopenharmony_ci switch (direction_) { 86a3e0fd82Sopenharmony_ci case Direction::DIR_LEFT_TO_RIGHT: 87a3e0fd82Sopenharmony_ci case Direction::DIR_RIGHT_TO_LEFT: { 88a3e0fd82Sopenharmony_ci leftTop.x = rect.GetLeft() - 1; 89a3e0fd82Sopenharmony_ci leftTop.y = rect.GetTop() + radius - 1; 90a3e0fd82Sopenharmony_ci leftBottom.x = leftTop.x; 91a3e0fd82Sopenharmony_ci leftBottom.y = rect.GetBottom() - radius + 1; 92a3e0fd82Sopenharmony_ci rightTop.x = rect.GetRight() + 1; 93a3e0fd82Sopenharmony_ci rightTop.y = leftTop.y; 94a3e0fd82Sopenharmony_ci rightBottom.x = rightTop.x; 95a3e0fd82Sopenharmony_ci rightBottom.y = leftBottom.y; 96a3e0fd82Sopenharmony_ci break; 97a3e0fd82Sopenharmony_ci } 98a3e0fd82Sopenharmony_ci 99a3e0fd82Sopenharmony_ci case Direction::DIR_TOP_TO_BOTTOM: 100a3e0fd82Sopenharmony_ci case Direction::DIR_BOTTOM_TO_TOP: { 101a3e0fd82Sopenharmony_ci leftTop.x = rect.GetLeft() + radius - 1; 102a3e0fd82Sopenharmony_ci leftTop.y = rect.GetTop() - 1; 103a3e0fd82Sopenharmony_ci rightTop.x = rect.GetRight() - radius + 1; 104a3e0fd82Sopenharmony_ci rightTop.y = leftTop.y; 105a3e0fd82Sopenharmony_ci leftBottom.x = leftTop.x; 106a3e0fd82Sopenharmony_ci leftBottom.y = rect.GetBottom() + 1; 107a3e0fd82Sopenharmony_ci rightBottom.x = rightTop.x; 108a3e0fd82Sopenharmony_ci rightBottom.y = leftBottom.y; 109a3e0fd82Sopenharmony_ci break; 110a3e0fd82Sopenharmony_ci } 111a3e0fd82Sopenharmony_ci default: 112a3e0fd82Sopenharmony_ci GRAPHIC_LOGE("UIBoxProgress: DrawRoundCap direction Err!\n"); 113a3e0fd82Sopenharmony_ci break; 114a3e0fd82Sopenharmony_ci } 115a3e0fd82Sopenharmony_ci 116a3e0fd82Sopenharmony_ci Style capStyle = style; 117a3e0fd82Sopenharmony_ci capStyle.lineWidth_ = radius; 118a3e0fd82Sopenharmony_ci capStyle.lineColor_ = style.bgColor_; 119a3e0fd82Sopenharmony_ci if ((image != nullptr) && (image->GetSrcType() != IMG_SRC_UNKNOWN)) { 120a3e0fd82Sopenharmony_ci capStyle.lineOpa_ = style.imageOpa_; 121a3e0fd82Sopenharmony_ci } else { 122a3e0fd82Sopenharmony_ci capStyle.lineOpa_ = style.bgOpa_; 123a3e0fd82Sopenharmony_ci } 124a3e0fd82Sopenharmony_ci 125a3e0fd82Sopenharmony_ci ArcInfo arcInfo = {{0}}; 126a3e0fd82Sopenharmony_ci arcInfo.radius = radius; 127a3e0fd82Sopenharmony_ci arcInfo.imgPos = imgPos; 128a3e0fd82Sopenharmony_ci arcInfo.imgSrc = image; 129a3e0fd82Sopenharmony_ci 130a3e0fd82Sopenharmony_ci bool isEvenLen = false; 131a3e0fd82Sopenharmony_ci if (direction_ == Direction::DIR_LEFT_TO_RIGHT || direction_ == Direction::DIR_RIGHT_TO_LEFT) { 132a3e0fd82Sopenharmony_ci if (rect.GetHeight() % 2 == 0) { // 2: determine the odd or even number of the height 133a3e0fd82Sopenharmony_ci isEvenLen = true; 134a3e0fd82Sopenharmony_ci } 135a3e0fd82Sopenharmony_ci } else if (rect.GetWidth() % 2 == 0) { // 2: determine the odd or even number of the width 136a3e0fd82Sopenharmony_ci isEvenLen = true; 137a3e0fd82Sopenharmony_ci } 138a3e0fd82Sopenharmony_ci BaseGfxEngine* baseGfxEngine = BaseGfxEngine::GetInstance(); 139a3e0fd82Sopenharmony_ci if (isEvenLen) { 140a3e0fd82Sopenharmony_ci arcInfo.center = leftTop; 141a3e0fd82Sopenharmony_ci arcInfo.startAngle = THREE_QUARTER_IN_DEGREE; 142a3e0fd82Sopenharmony_ci arcInfo.endAngle = 0; 143a3e0fd82Sopenharmony_ci baseGfxEngine->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_, 144a3e0fd82Sopenharmony_ci CapType::CAP_NONE); 145a3e0fd82Sopenharmony_ci 146a3e0fd82Sopenharmony_ci arcInfo.center = leftBottom; 147a3e0fd82Sopenharmony_ci arcInfo.startAngle = SEMICIRCLE_IN_DEGREE; 148a3e0fd82Sopenharmony_ci arcInfo.endAngle = THREE_QUARTER_IN_DEGREE; 149a3e0fd82Sopenharmony_ci baseGfxEngine->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_, 150a3e0fd82Sopenharmony_ci CapType::CAP_NONE); 151a3e0fd82Sopenharmony_ci 152a3e0fd82Sopenharmony_ci arcInfo.center = rightTop; 153a3e0fd82Sopenharmony_ci arcInfo.startAngle = 0; 154a3e0fd82Sopenharmony_ci arcInfo.endAngle = QUARTER_IN_DEGREE; 155a3e0fd82Sopenharmony_ci baseGfxEngine->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_, 156a3e0fd82Sopenharmony_ci CapType::CAP_NONE); 157a3e0fd82Sopenharmony_ci 158a3e0fd82Sopenharmony_ci arcInfo.center = rightBottom; 159a3e0fd82Sopenharmony_ci arcInfo.startAngle = QUARTER_IN_DEGREE; 160a3e0fd82Sopenharmony_ci arcInfo.endAngle = SEMICIRCLE_IN_DEGREE; 161a3e0fd82Sopenharmony_ci baseGfxEngine->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_, 162a3e0fd82Sopenharmony_ci CapType::CAP_NONE); 163a3e0fd82Sopenharmony_ci } else { 164a3e0fd82Sopenharmony_ci switch (direction_) { 165a3e0fd82Sopenharmony_ci case Direction::DIR_LEFT_TO_RIGHT: 166a3e0fd82Sopenharmony_ci case Direction::DIR_RIGHT_TO_LEFT: { 167a3e0fd82Sopenharmony_ci arcInfo.center = leftTop; 168a3e0fd82Sopenharmony_ci arcInfo.startAngle = SEMICIRCLE_IN_DEGREE; 169a3e0fd82Sopenharmony_ci arcInfo.endAngle = 0; 170a3e0fd82Sopenharmony_ci baseGfxEngine->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_, 171a3e0fd82Sopenharmony_ci CapType::CAP_NONE); 172a3e0fd82Sopenharmony_ci 173a3e0fd82Sopenharmony_ci arcInfo.center = rightTop; 174a3e0fd82Sopenharmony_ci arcInfo.startAngle = 0; 175a3e0fd82Sopenharmony_ci arcInfo.endAngle = SEMICIRCLE_IN_DEGREE; 176a3e0fd82Sopenharmony_ci baseGfxEngine->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_, 177a3e0fd82Sopenharmony_ci CapType::CAP_NONE); 178a3e0fd82Sopenharmony_ci break; 179a3e0fd82Sopenharmony_ci } 180a3e0fd82Sopenharmony_ci 181a3e0fd82Sopenharmony_ci case Direction::DIR_TOP_TO_BOTTOM: 182a3e0fd82Sopenharmony_ci case Direction::DIR_BOTTOM_TO_TOP: { 183a3e0fd82Sopenharmony_ci arcInfo.center = leftTop; 184a3e0fd82Sopenharmony_ci arcInfo.startAngle = THREE_QUARTER_IN_DEGREE; 185a3e0fd82Sopenharmony_ci arcInfo.endAngle = QUARTER_IN_DEGREE; 186a3e0fd82Sopenharmony_ci baseGfxEngine->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_, 187a3e0fd82Sopenharmony_ci CapType::CAP_NONE); 188a3e0fd82Sopenharmony_ci 189a3e0fd82Sopenharmony_ci arcInfo.center = leftBottom; 190a3e0fd82Sopenharmony_ci arcInfo.startAngle = QUARTER_IN_DEGREE; 191a3e0fd82Sopenharmony_ci arcInfo.endAngle = THREE_QUARTER_IN_DEGREE; 192a3e0fd82Sopenharmony_ci baseGfxEngine->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_, 193a3e0fd82Sopenharmony_ci CapType::CAP_NONE); 194a3e0fd82Sopenharmony_ci break; 195a3e0fd82Sopenharmony_ci } 196a3e0fd82Sopenharmony_ci default: 197a3e0fd82Sopenharmony_ci GRAPHIC_LOGE("UIBoxProgress: DrawRoundCap direction Err!\n"); 198a3e0fd82Sopenharmony_ci break; 199a3e0fd82Sopenharmony_ci } 200a3e0fd82Sopenharmony_ci } 201a3e0fd82Sopenharmony_ci} 202a3e0fd82Sopenharmony_ci 203a3e0fd82Sopenharmony_civoid UIBoxProgress::GetBackgroundParam(Point& startPoint, 204a3e0fd82Sopenharmony_ci int16_t& width, 205a3e0fd82Sopenharmony_ci int16_t& height, 206a3e0fd82Sopenharmony_ci uint16_t& radius, 207a3e0fd82Sopenharmony_ci const Style& style) 208a3e0fd82Sopenharmony_ci{ 209a3e0fd82Sopenharmony_ci Rect rect = GetOrigRect(); 210a3e0fd82Sopenharmony_ci // 2: Half of the gap 211a3e0fd82Sopenharmony_ci startPoint.x = rect.GetLeft() + style_->borderWidth_ + style_->paddingLeft_ + (GetWidth() - progressWidth_) / 2; 212a3e0fd82Sopenharmony_ci // 2: Half of the gap 213a3e0fd82Sopenharmony_ci startPoint.y = rect.GetTop() + style_->borderWidth_ + style_->paddingTop_ + (GetHeight() - progressHeight_) / 2; 214a3e0fd82Sopenharmony_ci 215a3e0fd82Sopenharmony_ci radius = 0; 216a3e0fd82Sopenharmony_ci width = progressWidth_; 217a3e0fd82Sopenharmony_ci height = progressHeight_; 218a3e0fd82Sopenharmony_ci if (style.lineCap_ == CapType::CAP_ROUND) { 219a3e0fd82Sopenharmony_ci switch (direction_) { 220a3e0fd82Sopenharmony_ci case Direction::DIR_LEFT_TO_RIGHT: 221a3e0fd82Sopenharmony_ci case Direction::DIR_RIGHT_TO_LEFT: 222a3e0fd82Sopenharmony_ci radius = (progressHeight_ + 1) >> 1; 223a3e0fd82Sopenharmony_ci width -= radius << 1; 224a3e0fd82Sopenharmony_ci startPoint.x += radius; 225a3e0fd82Sopenharmony_ci break; 226a3e0fd82Sopenharmony_ci case Direction::DIR_TOP_TO_BOTTOM: 227a3e0fd82Sopenharmony_ci case Direction::DIR_BOTTOM_TO_TOP: 228a3e0fd82Sopenharmony_ci radius = (progressWidth_ + 1) >> 1; 229a3e0fd82Sopenharmony_ci height -= radius << 1; 230a3e0fd82Sopenharmony_ci startPoint.y += radius; 231a3e0fd82Sopenharmony_ci break; 232a3e0fd82Sopenharmony_ci default: 233a3e0fd82Sopenharmony_ci GRAPHIC_LOGE("UIBoxProgress: GetBackgroundParam direction Err!\n"); 234a3e0fd82Sopenharmony_ci return; 235a3e0fd82Sopenharmony_ci } 236a3e0fd82Sopenharmony_ci } 237a3e0fd82Sopenharmony_ci} 238a3e0fd82Sopenharmony_ci 239a3e0fd82Sopenharmony_civoid UIBoxProgress::DrawBackground(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea) 240a3e0fd82Sopenharmony_ci{ 241a3e0fd82Sopenharmony_ci Point startPoint; 242a3e0fd82Sopenharmony_ci int16_t progressWidth; 243a3e0fd82Sopenharmony_ci int16_t progressHeight; 244a3e0fd82Sopenharmony_ci uint16_t radius; 245a3e0fd82Sopenharmony_ci GetBackgroundParam(startPoint, progressWidth, progressHeight, radius, *backgroundStyle_); 246a3e0fd82Sopenharmony_ci 247a3e0fd82Sopenharmony_ci Rect coords(startPoint.x, startPoint.y, startPoint.x + progressWidth - 1, startPoint.y + progressHeight - 1); 248a3e0fd82Sopenharmony_ci 249a3e0fd82Sopenharmony_ci DrawValidRect(gfxDstBuffer, backgroundImage_, coords, invalidatedArea, *backgroundStyle_, radius); 250a3e0fd82Sopenharmony_ci} 251a3e0fd82Sopenharmony_ci 252a3e0fd82Sopenharmony_civoid UIBoxProgress::DrawForeground(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, Rect& coords) 253a3e0fd82Sopenharmony_ci{ 254a3e0fd82Sopenharmony_ci Point startPoint; 255a3e0fd82Sopenharmony_ci int16_t progressWidth; 256a3e0fd82Sopenharmony_ci int16_t progressHeight; 257a3e0fd82Sopenharmony_ci uint16_t radius; 258a3e0fd82Sopenharmony_ci GetBackgroundParam(startPoint, progressWidth, progressHeight, radius, *foregroundStyle_); 259a3e0fd82Sopenharmony_ci int16_t length; 260a3e0fd82Sopenharmony_ci 261a3e0fd82Sopenharmony_ci switch (direction_) { 262a3e0fd82Sopenharmony_ci case Direction::DIR_LEFT_TO_RIGHT: { 263a3e0fd82Sopenharmony_ci length = GetCurrentPos(progressWidth - 1); 264a3e0fd82Sopenharmony_ci coords.SetRect(startPoint.x, startPoint.y, startPoint.x + length, startPoint.y + progressHeight - 1); 265a3e0fd82Sopenharmony_ci break; 266a3e0fd82Sopenharmony_ci } 267a3e0fd82Sopenharmony_ci case Direction::DIR_RIGHT_TO_LEFT: { 268a3e0fd82Sopenharmony_ci length = GetCurrentPos(progressWidth - 1); 269a3e0fd82Sopenharmony_ci coords.SetRect(startPoint.x + progressWidth - 1 - length, 270a3e0fd82Sopenharmony_ci startPoint.y, startPoint.x + progressWidth - 1, startPoint.y + progressHeight - 1); 271a3e0fd82Sopenharmony_ci break; 272a3e0fd82Sopenharmony_ci } 273a3e0fd82Sopenharmony_ci case Direction::DIR_TOP_TO_BOTTOM: { 274a3e0fd82Sopenharmony_ci length = GetCurrentPos(progressHeight - 1); 275a3e0fd82Sopenharmony_ci coords.SetRect(startPoint.x, startPoint.y, startPoint.x + progressWidth - 1, startPoint.y + length); 276a3e0fd82Sopenharmony_ci break; 277a3e0fd82Sopenharmony_ci } 278a3e0fd82Sopenharmony_ci case Direction::DIR_BOTTOM_TO_TOP: { 279a3e0fd82Sopenharmony_ci length = GetCurrentPos(progressHeight - 1); 280a3e0fd82Sopenharmony_ci coords.SetRect(startPoint.x, startPoint.y + progressHeight - 1 - length, 281a3e0fd82Sopenharmony_ci startPoint.x + progressWidth - 1, startPoint.y + progressHeight - 1); 282a3e0fd82Sopenharmony_ci break; 283a3e0fd82Sopenharmony_ci } 284a3e0fd82Sopenharmony_ci default: { 285a3e0fd82Sopenharmony_ci GRAPHIC_LOGE("UIBoxProgress: DrawForeground direction Err!\n"); 286a3e0fd82Sopenharmony_ci return; 287a3e0fd82Sopenharmony_ci } 288a3e0fd82Sopenharmony_ci } 289a3e0fd82Sopenharmony_ci 290a3e0fd82Sopenharmony_ci DrawValidRect(gfxDstBuffer, foregroundImage_, coords, invalidatedArea, *foregroundStyle_, radius); 291a3e0fd82Sopenharmony_ci} 292a3e0fd82Sopenharmony_ci 293a3e0fd82Sopenharmony_civoid UIBoxProgress::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea) 294a3e0fd82Sopenharmony_ci{ 295a3e0fd82Sopenharmony_ci UIView::OnDraw(gfxDstBuffer, invalidatedArea); 296a3e0fd82Sopenharmony_ci if (enableBackground_) { 297a3e0fd82Sopenharmony_ci DrawBackground(gfxDstBuffer, invalidatedArea); 298a3e0fd82Sopenharmony_ci } 299a3e0fd82Sopenharmony_ci 300a3e0fd82Sopenharmony_ci if ((lastValue_ - rangeMin_ != 0) || (foregroundStyle_->lineCap_ == CapType::CAP_ROUND)) { 301a3e0fd82Sopenharmony_ci Rect coords; 302a3e0fd82Sopenharmony_ci DrawForeground(gfxDstBuffer, invalidatedArea, coords); 303a3e0fd82Sopenharmony_ci } 304a3e0fd82Sopenharmony_ci} 305a3e0fd82Sopenharmony_ci} // namespace OHOS 306