1 /*
2 * Copyright (c) 2022-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 #include "core/components_ng/pattern/loading_progress/loading_progress_modifier.h"
17 #include <algorithm>
18
19 #include "base/geometry/arc.h"
20 #include "base/geometry/dimension.h"
21 #include "base/memory/ace_type.h"
22 #include "base/utils/utils.h"
23 #include "bridge/common/dom/dom_type.h"
24 #include "core/components/common/properties/animation_option.h"
25 #include "core/components/progress/progress_theme.h"
26 #include "core/components_ng/base/modifier.h"
27 #include "core/components_ng/pattern/loading_progress/loading_progress_utill.h"
28 #include "core/components_ng/pattern/refresh/refresh_animation_state.h"
29 #include "core/components_ng/render/animation_utils.h"
30 #include "core/components_ng/render/drawing_prop_convertor.h"
31
32 namespace OHOS::Ace::NG {
33 namespace {
34 constexpr float TOTAL_ANGLE = 360.0f;
35 constexpr float ROTATEX = -116.0f;
36 constexpr float ROTATEY = 30.0f;
37 constexpr float ROTATEZ = 22.0f;
38 constexpr float COUNT = 50.0f;
39 constexpr float HALF = 0.5f;
40 constexpr float DOUBLE = 2.0f;
41 constexpr int32_t SKEWY = 3;
42 constexpr int32_t SCALEY = 4;
43 constexpr int32_t RING_ALPHA = 200;
44 constexpr int32_t TOTAL_POINTS_COUNT = 20;
45 constexpr int32_t TAIL_ANIAMTION_DURATION = 400;
46 constexpr int32_t TRANS_DURATION = 100;
47 constexpr float TOTAL_TAIL_LENGTH = 60.0f;
48 constexpr float TAIL_ALPHA_RATIO = 0.82f;
49 constexpr float INITIAL_SIZE_SCALE = 0.825f;
50 constexpr float INITIAL_OPACITY_SCALE = 0.7f;
51 constexpr float COMET_TAIL_ANGLE = 3.0f;
52 constexpr int32_t LOADING_DURATION = 1200;
53 constexpr float FOLLOW_START = 72.0f;
54 constexpr float FOLLOW_SPAN = 10.0f;
55 constexpr float FULL_COUNT = 100.0f;
56 constexpr float STAGE1 = 0.25f;
57 constexpr float STAGE2 = 0.65f;
58 constexpr float STAGE3 = 0.75f;
59 constexpr float STAGE4 = 0.85f;
60 constexpr float STAGE5 = 1.0f;
61 constexpr float OPACITY1 = 0.2f;
62 constexpr float OPACITY2 = 0.7f;
63 constexpr float OPACITY3 = 1.0f;
64 constexpr float SIZE_SCALE1 = 0.65f;
65 constexpr float SIZE_SCALE2 = 0.825f;
66 constexpr float SIZE_SCALE3 = 0.93f;
67 constexpr float MOVE_STEP = 0.06f;
68 constexpr float TRANS_OPACITY_SPAN = 0.3f;
69 constexpr float FULL_OPACITY = 255.0f;
70 constexpr float FAKE_DELTA = 0.01f;
71 constexpr float BASE_SCALE = 0.707f; // std::sqrt(2)/2
72 } // namespace
LoadingProgressModifier(LoadingProgressOwner loadingProgressOwner)73 LoadingProgressModifier::LoadingProgressModifier(LoadingProgressOwner loadingProgressOwner)
74 : enableLoading_(AceType::MakeRefPtr<PropertyBool>(true)),
75 offset_(AceType::MakeRefPtr<PropertyOffsetF>(OffsetF())),
76 contentSize_(AceType::MakeRefPtr<PropertySizeF>(SizeF())),
77 date_(AceType::MakeRefPtr<AnimatablePropertyFloat>(0.0f)),
78 color_(AceType::MakeRefPtr<AnimatablePropertyColor>(LinearColor::TRANSPARENT)),
79 centerDeviation_(AceType::MakeRefPtr<AnimatablePropertyFloat>(0.0f)),
80 cometOpacity_(AceType::MakeRefPtr<AnimatablePropertyFloat>(INITIAL_OPACITY_SCALE)),
81 cometSizeScale_(AceType::MakeRefPtr<AnimatablePropertyFloat>(INITIAL_SIZE_SCALE)),
82 cometTailLen_(AceType::MakeRefPtr<AnimatablePropertyFloat>(TOTAL_TAIL_LENGTH)),
83 sizeScale_(AceType::MakeRefPtr<AnimatablePropertyFloat>(1.0f)),
84 loadingProgressOwner_(loadingProgressOwner)
85 {
86 AttachProperty(enableLoading_);
87 AttachProperty(offset_);
88 AttachProperty(contentSize_);
89 AttachProperty(date_);
90 AttachProperty(color_);
91 AttachProperty(centerDeviation_);
92 AttachProperty(cometOpacity_);
93 AttachProperty(cometSizeScale_);
94 AttachProperty(cometTailLen_);
95 };
96
onDraw(DrawingContext & context)97 void LoadingProgressModifier::onDraw(DrawingContext& context)
98 {
99 if (!enableLoading_->Get()) {
100 return;
101 }
102 float date = date_->Get();
103 auto diameter = std::min(contentSize_->Get().Width(), contentSize_->Get().Height());
104 RingParam ringParam;
105 ringParam.strokeWidth = LoadingProgressUtill::GetRingStrokeWidth(diameter) * sizeScale_->Get();
106 ringParam.radius = LoadingProgressUtill::GetRingRadius(diameter) * sizeScale_->Get();
107 ringParam.movement =
108 (ringParam.radius * DOUBLE + ringParam.strokeWidth) * centerDeviation_->Get() * sizeScale_->Get();
109
110 CometParam cometParam;
111 cometParam.radius = LoadingProgressUtill::GetCometRadius(diameter) * sizeScale_->Get();
112 cometParam.alphaScale = cometOpacity_->Get();
113 cometParam.sizeScale = cometSizeScale_->Get();
114 cometParam.pointCount = GetCometNumber();
115
116 auto orbitRadius = LoadingProgressUtill::GetOrbitRadius(diameter) * sizeScale_->Get();
117 if (date > COUNT) {
118 DrawRing(context, ringParam);
119 DrawOrbit(context, cometParam, orbitRadius, date);
120 } else {
121 DrawOrbit(context, cometParam, orbitRadius, date);
122 DrawRing(context, ringParam);
123 }
124 }
125
DrawRing(DrawingContext & context,const RingParam & ringParam)126 void LoadingProgressModifier::DrawRing(DrawingContext& context, const RingParam& ringParam)
127 {
128 auto& canvas = context.canvas;
129 canvas.Save();
130 RSPen pen;
131 auto ringColor = color_->Get();
132 auto pipeline = PipelineBase::GetCurrentContext();
133 CHECK_NULL_VOID(pipeline);
134 auto progressTheme = pipeline->GetTheme<ProgressTheme>();
135 CHECK_NULL_VOID(progressTheme);
136 auto defaultColor = progressTheme->GetLoadingColor();
137 if (ringColor.GetValue() == defaultColor.GetValue()) {
138 pen.SetColor(
139 ToRSColor(Color::FromARGB(RING_ALPHA, ringColor.GetRed(), ringColor.GetGreen(), ringColor.GetBlue())));
140 } else {
141 pen.SetColor(ToRSColor(
142 Color::FromARGB(ringColor.GetAlpha(), ringColor.GetRed(), ringColor.GetGreen(), ringColor.GetBlue())));
143 }
144 pen.SetWidth(ringParam.strokeWidth);
145 pen.SetAntiAlias(true);
146 canvas.AttachPen(pen);
147 canvas.DrawCircle(
148 { offset_->Get().GetX() + contentSize_->Get().Width() * HALF,
149 offset_->Get().GetY() + contentSize_->Get().Height() * HALF + ringParam.movement },
150 ringParam.radius);
151 canvas.DetachPen();
152 canvas.Restore();
153 }
154
DrawOrbit(DrawingContext & context,const CometParam & cometParam,float orbitRadius,float date)155 void LoadingProgressModifier::DrawOrbit(
156 DrawingContext& context, const CometParam& cometParam, float orbitRadius, float date)
157 {
158 auto pointCounts = cometParam.pointCount;
159 auto& canvas = context.canvas;
160 float width = contentSize_->Get().Width();
161 float height = contentSize_->Get().Height();
162 double angle = TOTAL_ANGLE * date / FULL_COUNT;
163 RSCamera3D camera;
164 RSMatrix matrix;
165 AdjustMatrix(camera, matrix);
166 auto center = RSPoint(offset_->Get().GetX() + width / 2, offset_->Get().GetY() + height / 2);
167 RSBrush brush;
168 brush.SetAntiAlias(true);
169 canvas.Save();
170 canvas.Translate(center.GetX(), center.GetY());
171 std::vector<RSPoint> points;
172 for (uint32_t i = 0; i < pointCounts; i++) {
173 RSPoint point;
174 float cometAngal = GetCurentCometAngle(angle, pointCounts - i, pointCounts);
175 float rad = cometAngal * PI_NUM / (TOTAL_ANGLE * HALF);
176 point.SetX(std::cos(rad) * orbitRadius);
177 point.SetY(-std::sin(rad) * orbitRadius);
178 points.push_back(point);
179 }
180 std::vector<RSPoint> distPoints(points.size());
181 matrix.MapPoints(distPoints, points, points.size());
182 auto cometColor = color_->Get();
183 float colorAlpha = cometColor.GetAlpha() / FULL_OPACITY;
184 auto baseAlpha = colorAlpha * cometParam.alphaScale;
185 for (uint32_t i = 0; i < distPoints.size(); i++) {
186 RSPoint pointCenter = distPoints[i];
187 if (cometColor.GetValue() == Color::FOREGROUND.GetValue()) {
188 brush.SetColor(ToRSColor(cometColor));
189 } else {
190 float setAlpha = GetCurentCometOpacity(baseAlpha, distPoints.size() - i, distPoints.size());
191 if (NearZero(setAlpha)) {
192 continue;
193 }
194 brush.SetColor(
195 ToRSColor(Color::FromRGBO(cometColor.GetRed(), cometColor.GetGreen(), cometColor.GetBlue(), setAlpha)));
196 }
197 canvas.AttachBrush(brush);
198 canvas.DrawCircle(pointCenter, cometParam.radius * cometParam.sizeScale);
199 }
200 canvas.DetachBrush();
201 canvas.Restore();
202 }
203
AdjustMatrix(RSCamera3D & camera,RSMatrix & matrix)204 void LoadingProgressModifier::AdjustMatrix(RSCamera3D& camera, RSMatrix& matrix)
205 {
206 camera.Save();
207 camera.RotateYDegrees(ROTATEY);
208 camera.RotateXDegrees(ROTATEX);
209 camera.RotateZDegrees(ROTATEZ);
210 camera.ApplyToMatrix(matrix);
211 camera.Restore();
212 auto temp = matrix.Get(SKEWY);
213 matrix.Set(RSMatrix::SKEW_Y, matrix.Get(SCALEY));
214 matrix.Set(RSMatrix::SCALE_Y, temp);
215 }
216
StartRecycleRingAnimation()217 void LoadingProgressModifier::StartRecycleRingAnimation()
218 {
219 auto context = PipelineBase::GetCurrentContext();
220 CHECK_NULL_VOID(context);
221 auto previousStageCurve = AceType::MakeRefPtr<CubicCurve>(0.0f, 0.0f, 0.67f, 1.0f);
222 AnimationOption option;
223 option.SetDuration(isVisible_ ? LOADING_DURATION : 0);
224 option.SetCurve(previousStageCurve);
225 if (context->IsFormRender()) {
226 option.SetIteration(1);
227 } else {
228 option.SetIteration(-1);
229 }
230 AnimationUtils::OpenImplicitAnimation(option, previousStageCurve, nullptr);
231 auto middleStageCurve = AceType::MakeRefPtr<CubicCurve>(0.33f, 0.0f, 0.67f, 1.0f);
232 AnimationUtils::AddKeyFrame(
233 STAGE1, middleStageCurve, [weakCenterDeviation = AceType::WeakClaim(AceType::RawPtr(centerDeviation_))]() {
234 auto centerDeviation = weakCenterDeviation.Upgrade();
235 CHECK_NULL_VOID(centerDeviation);
236 centerDeviation->Set(-1 * MOVE_STEP);
237 });
238 auto latterStageCurve = AceType::MakeRefPtr<CubicCurve>(0.33f, 0.0f, 1.0f, 1.0f);
239 AnimationUtils::AddKeyFrame(
240 STAGE3, latterStageCurve, [weakCenterDeviation = AceType::WeakClaim(AceType::RawPtr(centerDeviation_))]() {
241 auto centerDeviation = weakCenterDeviation.Upgrade();
242 CHECK_NULL_VOID(centerDeviation);
243 centerDeviation->Set(MOVE_STEP);
244 });
245 AnimationUtils::AddKeyFrame(
246 STAGE5, latterStageCurve, [weakCenterDeviation = AceType::WeakClaim(AceType::RawPtr(centerDeviation_))]() {
247 auto centerDeviation = weakCenterDeviation.Upgrade();
248 CHECK_NULL_VOID(centerDeviation);
249 centerDeviation->Set(0.0f);
250 });
251 AnimationUtils::CloseImplicitAnimation();
252 }
253
StartRecycleCometAnimation()254 void LoadingProgressModifier::StartRecycleCometAnimation()
255 {
256 auto context = PipelineBase::GetCurrentContext();
257 CHECK_NULL_VOID(context);
258 auto curve = AceType::MakeRefPtr<LinearCurve>();
259 AnimationOption option;
260 option.SetDuration(isVisible_ ? LOADING_DURATION : 0);
261 option.SetCurve(curve);
262 if (context->IsFormRender()) {
263 option.SetIteration(1);
264 } else {
265 option.SetIteration(-1);
266 }
267
268 cometOpacity_->Set(OPACITY2);
269 cometTailLen_->Set(TOTAL_TAIL_LENGTH);
270 AnimationUtils::OpenImplicitAnimation(option, curve, nullptr);
271 AnimationUtils::AddKeyFrame(STAGE1, curve,
272 [weakCometOpacity = AceType::WeakClaim(AceType::RawPtr(cometOpacity_)),
273 weakCometSizeScale = AceType::WeakClaim(AceType::RawPtr(cometSizeScale_))]() {
274 auto cometOpacity = weakCometOpacity.Upgrade();
275 if (cometOpacity) {
276 cometOpacity->Set(OPACITY1);
277 }
278 auto cometSizeScale = weakCometSizeScale.Upgrade();
279 if (cometSizeScale) {
280 cometSizeScale->Set(SIZE_SCALE1);
281 }
282 });
283 AnimationUtils::AddKeyFrame(STAGE2, curve,
284 [weakCometOpacity = AceType::WeakClaim(AceType::RawPtr(cometOpacity_)),
285 weakCometSizeScale = AceType::WeakClaim(AceType::RawPtr(cometSizeScale_))]() {
286 auto cometOpacity = weakCometOpacity.Upgrade();
287 if (cometOpacity) {
288 cometOpacity->Set(OPACITY3);
289 }
290 auto cometSizeScale = weakCometSizeScale.Upgrade();
291 if (cometSizeScale) {
292 cometSizeScale->Set(SIZE_SCALE3);
293 }
294 });
295 AnimationUtils::AddKeyFrame(STAGE3, curve,
296 [weakCometOpacity = AceType::WeakClaim(AceType::RawPtr(cometOpacity_)),
297 weakCometSizeScale = AceType::WeakClaim(AceType::RawPtr(cometSizeScale_))]() {
298 auto cometOpacity = weakCometOpacity.Upgrade();
299 if (cometOpacity) {
300 cometOpacity->Set(OPACITY3);
301 }
302 auto cometSizeScale = weakCometSizeScale.Upgrade();
303 if (cometSizeScale) {
304 cometSizeScale->Set(1.0f);
305 }
306 });
307 AnimationUtils::AddKeyFrame(STAGE4, curve,
308 [weakCometOpacity = AceType::WeakClaim(AceType::RawPtr(cometOpacity_)),
309 weakCometSizeScale = AceType::WeakClaim(AceType::RawPtr(cometSizeScale_))]() {
310 auto cometOpacity = weakCometOpacity.Upgrade();
311 if (cometOpacity) {
312 cometOpacity->Set(OPACITY3);
313 }
314 auto cometSizeScale = weakCometSizeScale.Upgrade();
315 if (cometSizeScale) {
316 cometSizeScale->Set(SIZE_SCALE3);
317 }
318 });
319 AnimationUtils::AddKeyFrame(STAGE5, curve,
320 [weakCometOpacity = AceType::WeakClaim(AceType::RawPtr(cometOpacity_)),
321 weakCometSizeScale = AceType::WeakClaim(AceType::RawPtr(cometSizeScale_))]() {
322 auto cometOpacity = weakCometOpacity.Upgrade();
323 if (cometOpacity) {
324 cometOpacity->Set(OPACITY2);
325 }
326 auto cometSizeScale = weakCometSizeScale.Upgrade();
327 if (cometSizeScale) {
328 cometSizeScale->Set(SIZE_SCALE2);
329 }
330 });
331 AnimationUtils::CloseImplicitAnimation();
332 }
333
StartCometTailAnimation()334 void LoadingProgressModifier::StartCometTailAnimation()
335 {
336 auto curve = AceType::MakeRefPtr<LinearCurve>();
337 AnimationOption option;
338 option.SetDuration(TAIL_ANIAMTION_DURATION);
339 option.SetIteration(1);
340 option.SetCurve(curve);
341 AnimationUtils::Animate(option, [weakCometTailLen = AceType::WeakClaim(AceType::RawPtr(cometTailLen_))]() {
342 auto cometTailLen = weakCometTailLen.Upgrade();
343 CHECK_NULL_VOID(cometTailLen);
344 cometTailLen->Set(TOTAL_TAIL_LENGTH);
345 });
346 }
347
GetCurentCometOpacity(float baseOpacity,uint32_t index,uint32_t totalNumber)348 float LoadingProgressModifier::GetCurentCometOpacity(float baseOpacity, uint32_t index, uint32_t totalNumber)
349 {
350 return baseOpacity * std::pow(TAIL_ALPHA_RATIO, std::clamp(index, 1u, totalNumber) - 1);
351 }
352
GetCurentCometAngle(float baseAngle,uint32_t index,uint32_t totalNumber)353 float LoadingProgressModifier::GetCurentCometAngle(float baseAngle, uint32_t index, uint32_t totalNumber)
354 {
355 return std::fmod((baseAngle - (std::clamp(index, 1u, totalNumber) - 1) * COMET_TAIL_ANGLE), TOTAL_ANGLE);
356 }
357
GetCometNumber()358 uint32_t LoadingProgressModifier::GetCometNumber()
359 {
360 CHECK_NULL_RETURN(cometTailLen_, TOTAL_POINTS_COUNT);
361 return static_cast<uint32_t>(cometTailLen_->Get() / COMET_TAIL_ANGLE);
362 }
363
StartRecycle()364 void LoadingProgressModifier::StartRecycle()
365 {
366 auto context = PipelineBase::GetCurrentContext();
367 CHECK_NULL_VOID(context);
368 if (isLoading_) {
369 return;
370 }
371 sizeScale_->Set(1.0f);
372 if (date_) {
373 isLoading_ = true;
374 date_->Set(0.0f);
375 AnimationOption option = AnimationOption();
376 RefPtr<Curve> curve = AceType::MakeRefPtr<LinearCurve>();
377 option.SetDuration(isVisible_ ? LOADING_DURATION : 0);
378 option.SetDelay(0);
379 option.SetCurve(curve);
380 if (context->IsFormRender()) {
381 option.SetIteration(1);
382 } else {
383 option.SetIteration(-1);
384 }
385 AnimationUtils::Animate(option, [weakDate = AceType::WeakClaim(AceType::RawPtr(date_))]() {
386 auto date = weakDate.Upgrade();
387 CHECK_NULL_VOID(date);
388 date->Set(FULL_COUNT);
389 });
390 }
391 cometOpacity_->Set(INITIAL_OPACITY_SCALE);
392 cometSizeScale_->Set(INITIAL_SIZE_SCALE);
393 // ring up and down shift animation
394 StartRecycleRingAnimation();
395 // comet's circle Color transparency and sizeScale animation
396 StartRecycleCometAnimation();
397 }
398
StartTransToRecycleAnimation()399 void LoadingProgressModifier::StartTransToRecycleAnimation()
400 {
401 sizeScale_->Set(1.0f);
402 auto curve = AceType::MakeRefPtr<CubicCurve>(0.6f, 0.2f, 1.0f, 1.0f);
403 AnimationOption option;
404 option.SetDuration(TRANS_DURATION);
405 option.SetIteration(1);
406 option.SetCurve(curve);
407 AnimationUtils::Animate(
408 option,
409 [weakDate = AceType::WeakClaim(AceType::RawPtr(date_)),
410 weakCometOpacity = AceType::WeakClaim(AceType::RawPtr(cometOpacity_)),
411 weakCometSizeScale = AceType::WeakClaim(AceType::RawPtr(cometSizeScale_))]() {
412 auto date = weakDate.Upgrade();
413 if (date) {
414 date->Set(FULL_COUNT);
415 }
416 auto cometOpacity = weakCometOpacity.Upgrade();
417 if (cometOpacity) {
418 cometOpacity->Set(1.0 - TRANS_OPACITY_SPAN);
419 }
420 auto cometSizeScale = weakCometSizeScale.Upgrade();
421 if (cometSizeScale) {
422 cometSizeScale->Set(INITIAL_SIZE_SCALE);
423 }
424 },
425 [weak = AceType::WeakClaim(this)]() {
426 auto modify = weak.Upgrade();
427 CHECK_NULL_VOID(modify);
428 modify->StartRecycle();
429 });
430 StartCometTailAnimation();
431 }
432
ChangeRefreshFollowData(float refreshFollowRatio)433 void LoadingProgressModifier::ChangeRefreshFollowData(float refreshFollowRatio)
434 {
435 auto ratio = CorrectNormalize(refreshFollowRatio);
436 sizeScale_->Set(BASE_SCALE + (1.0 - BASE_SCALE) * ratio);
437 if (isLoading_) {
438 CloseAnimation(FOLLOW_START, COMET_TAIL_ANGLE, 1.0f, 1.0f);
439 }
440 CHECK_NULL_VOID(date_);
441 date_->Set(FOLLOW_START + FOLLOW_SPAN * ratio);
442 cometTailLen_->Set(COMET_TAIL_ANGLE);
443 cometOpacity_->Set(1.0f);
444 cometSizeScale_->Set(1.0f);
445 }
446
ChangeSizeScaleData(float refreshFadeAwayRatio)447 void LoadingProgressModifier::ChangeSizeScaleData(float refreshFadeAwayRatio)
448 {
449 auto ratio = CorrectNormalize(refreshFadeAwayRatio);
450 sizeScale_->Set(BASE_SCALE + (1.0 - BASE_SCALE) * ratio);
451 }
452
CloseAnimation(float date,float cometLen,float cometOpacity,float cometScale)453 void LoadingProgressModifier::CloseAnimation(float date, float cometLen, float cometOpacity, float cometScale)
454 {
455 isLoading_ = false;
456 AnimationOption option = AnimationOption();
457 RefPtr<Curve> curve = AceType::MakeRefPtr<LinearCurve>();
458 option.SetDuration(0);
459 option.SetIteration(1);
460 option.SetCurve(curve);
461 date_->Set(date + FAKE_DELTA);
462 cometTailLen_->Set(cometLen + FAKE_DELTA);
463 cometOpacity_->Set(cometOpacity + FAKE_DELTA);
464 cometSizeScale_->Set(cometScale + FAKE_DELTA);
465 centerDeviation_->Set(0.0f + FAKE_DELTA);
466 AnimationUtils::Animate(option, [weak = AceType::WeakClaim(this), date, cometLen, cometOpacity, cometScale]() {
467 auto curObj = weak.Upgrade();
468 CHECK_NULL_VOID(curObj);
469 curObj->date_->Set(date);
470 curObj->cometTailLen_->Set(cometLen);
471 curObj->cometOpacity_->Set(cometOpacity);
472 curObj->cometSizeScale_->Set(cometScale);
473 curObj->centerDeviation_->Set(0.0f);
474 });
475 }
CorrectNormalize(float originData)476 float LoadingProgressModifier::CorrectNormalize(float originData)
477 {
478 auto ratio = originData;
479 if (ratio < 0.0f) {
480 ratio = 0.0f;
481 }
482 if (ratio > 1.0f) {
483 ratio = 1.0f;
484 };
485 return ratio;
486 }
487 } // namespace OHOS::Ace::NG
488