diff --git a/src/common/tvgStr.cpp b/src/common/tvgStr.cpp index 57bf960f..49a59017 100644 --- a/src/common/tvgStr.cpp +++ b/src/common/tvgStr.cpp @@ -183,7 +183,7 @@ float strToFloat(const char *nPtr, char **endPtr) auto scale = 1.0f; while (exponentPart >= 8U) { - scale *= 1E8; + scale *= 1E8f; exponentPart -= 8U; } while (exponentPart > 0U) { diff --git a/src/loaders/lottie/tvgLottieBuilder.cpp b/src/loaders/lottie/tvgLottieBuilder.cpp index 810b9c03..87a67939 100644 --- a/src/loaders/lottie/tvgLottieBuilder.cpp +++ b/src/loaders/lottie/tvgLottieBuilder.cpp @@ -1375,7 +1375,7 @@ void LottieBuilder::updateEffect(LottieLayer* layer, float frameNo) auto effect = static_cast(*ef); auto black = effect->black(frameNo); auto white = effect->white(frameNo); - layer->scene->push(SceneEffect::Tint, black.rgb[0], black.rgb[1], black.rgb[2], white.rgb[0], white.rgb[1], white.rgb[2], effect->intensity(frameNo)); + layer->scene->push(SceneEffect::Tint, black.rgb[0], black.rgb[1], black.rgb[2], white.rgb[0], white.rgb[1], white.rgb[2], (double)effect->intensity(frameNo)); break; } case LottieEffect::Fill: { @@ -1401,12 +1401,12 @@ void LottieBuilder::updateEffect(LottieLayer* layer, float frameNo) auto effect = static_cast(*ef); auto color = effect->color(frameNo); //seems the opacity range in dropshadow is 0 ~ 256 - layer->scene->push(SceneEffect::DropShadow, color.rgb[0], color.rgb[1], color.rgb[2], std::min(255, (int)effect->opacity(frameNo)), effect->angle(frameNo), effect->distance(frameNo), effect->blurness(frameNo) * BLUR_TO_SIGMA, QUALITY); + layer->scene->push(SceneEffect::DropShadow, color.rgb[0], color.rgb[1], color.rgb[2], std::min(255, (int)effect->opacity(frameNo)), (double)effect->angle(frameNo), (double)effect->distance(frameNo), (double)effect->blurness(frameNo) * BLUR_TO_SIGMA, QUALITY); break; } case LottieEffect::GaussianBlur: { auto effect = static_cast(*ef); - layer->scene->push(SceneEffect::GaussianBlur, effect->blurness(frameNo) * BLUR_TO_SIGMA, effect->direction(frameNo) - 1, effect->wrap(frameNo), QUALITY); + layer->scene->push(SceneEffect::GaussianBlur, (double)effect->blurness(frameNo) * BLUR_TO_SIGMA, effect->direction(frameNo) - 1, effect->wrap(frameNo), QUALITY); break; } default: break; diff --git a/src/loaders/lottie/tvgLottieExpressions.cpp b/src/loaders/lottie/tvgLottieExpressions.cpp index 318c0cee..f8321413 100644 --- a/src/loaders/lottie/tvgLottieExpressions.cpp +++ b/src/loaders/lottie/tvgLottieExpressions.cpp @@ -484,7 +484,7 @@ static jerry_value_t _linear(const jerry_call_info_t* info, const jerry_value_t static jerry_value_t _ease(const jerry_call_info_t* info, const jerry_value_t args[], const jerry_length_t argsCnt) { auto t = (float) jerry_value_as_number(args[0]); - t = (t < 0.5) ? (4 * t * t * t) : (1.0f - pow(-2.0f * t + 2.0f, 3) * 0.5f); + t = (t < 0.5f) ? (4 * t * t * t) : (1.0f - powf(-2.0f * t + 2.0f, 3) * 0.5f); return _interp(t, args, jerry_value_as_uint32(argsCnt)); } @@ -501,7 +501,7 @@ static jerry_value_t _easeIn(const jerry_call_info_t* info, const jerry_value_t static jerry_value_t _easeOut(const jerry_call_info_t* info, const jerry_value_t args[], const jerry_length_t argsCnt) { auto t = (float) jerry_value_as_number(args[0]); - t = 1.0f - pow(1.0f - t, 3); + t = 1.0f - powf(1.0f - t, 3); return _interp(t, args, jerry_value_as_uint32(argsCnt)); } diff --git a/src/loaders/lottie/tvgLottieInterpolator.cpp b/src/loaders/lottie/tvgLottieInterpolator.cpp index 140a5f25..bfba13b6 100644 --- a/src/loaders/lottie/tvgLottieInterpolator.cpp +++ b/src/loaders/lottie/tvgLottieInterpolator.cpp @@ -79,7 +79,7 @@ float LottieInterpolator::getTForX(float aX) // instead. auto initialSlope = _getSlope(guessForT, outTangent.x, inTangent.x); if (initialSlope >= NEWTON_MIN_SLOPE) return NewtonRaphsonIterate(aX, guessForT); - else if (initialSlope == 0.0) return guessForT; + else if (initialSlope == 0.0f) return guessForT; else return binarySubdivide(aX, intervalStart, intervalStart + SAMPLE_STEP_SIZE); } diff --git a/src/loaders/svg/tvgSvgLoader.cpp b/src/loaders/svg/tvgSvgLoader.cpp index 4c8b710d..d6f9958b 100644 --- a/src/loaders/svg/tvgSvgLoader.cpp +++ b/src/loaders/svg/tvgSvgLoader.cpp @@ -170,7 +170,7 @@ static float _gradientToFloat(const SvgParser* svgParse, const char* str, bool& isPercentage = false; if (strstr(str, "%")) { - parsedValue = parsedValue / 100.0; + parsedValue = parsedValue / 100.0f; isPercentage = true; } else if (strstr(str, "cm")) parsedValue *= PX_PER_CM; @@ -195,7 +195,7 @@ static float _toOffset(const char* str) auto ptr = strstr(str, "%"); if (ptr) { - parsedValue = parsedValue / 100.0; + parsedValue = parsedValue / 100.0f; if (end != ptr || (end + 1) != strEnd) return 0; } else if (end != strEnd) return 0; diff --git a/src/loaders/svg/tvgSvgPath.cpp b/src/loaders/svg/tvgSvgPath.cpp index 59af969e..59c3154a 100644 --- a/src/loaders/svg/tvgSvgPath.cpp +++ b/src/loaders/svg/tvgSvgPath.cpp @@ -374,10 +374,10 @@ static bool _processCommand(Array* cmds, Array* pts, char cm case 'q': case 'Q': { Point p[3]; - float ctrl_x0 = (cur->x + 2 * arr[0]) * (1.0 / 3.0); - float ctrl_y0 = (cur->y + 2 * arr[1]) * (1.0 / 3.0); - float ctrl_x1 = (arr[2] + 2 * arr[0]) * (1.0 / 3.0); - float ctrl_y1 = (arr[3] + 2 * arr[1]) * (1.0 / 3.0); + float ctrl_x0 = (cur->x + 2 * arr[0]) * (1.0f / 3.0f); + float ctrl_y0 = (cur->y + 2 * arr[1]) * (1.0f / 3.0f); + float ctrl_x1 = (arr[2] + 2 * arr[0]) * (1.0f / 3.0f); + float ctrl_y1 = (arr[3] + 2 * arr[1]) * (1.0f / 3.0f); cmds->push(PathCommand::CubicTo); p[0] = {ctrl_x0, ctrl_y0}; p[1] = {ctrl_x1, ctrl_y1}; @@ -400,10 +400,10 @@ static bool _processCommand(Array* cmds, Array* pts, char cm } else { ctrl = *cur; } - float ctrl_x0 = (cur->x + 2 * ctrl.x) * (1.0 / 3.0); - float ctrl_y0 = (cur->y + 2 * ctrl.y) * (1.0 / 3.0); - float ctrl_x1 = (arr[0] + 2 * ctrl.x) * (1.0 / 3.0); - float ctrl_y1 = (arr[1] + 2 * ctrl.y) * (1.0 / 3.0); + float ctrl_x0 = (cur->x + 2 * ctrl.x) * (1.0f / 3.0f); + float ctrl_y0 = (cur->y + 2 * ctrl.y) * (1.0f / 3.0f); + float ctrl_x1 = (arr[0] + 2 * ctrl.x) * (1.0f / 3.0f); + float ctrl_y1 = (arr[1] + 2 * ctrl.y) * (1.0f / 3.0f); cmds->push(PathCommand::CubicTo); p[0] = {ctrl_x0, ctrl_y0}; p[1] = {ctrl_x1, ctrl_y1}; diff --git a/src/renderer/tvgAnimation.cpp b/src/renderer/tvgAnimation.cpp index 5a1d2f85..03e9b83c 100644 --- a/src/renderer/tvgAnimation.cpp +++ b/src/renderer/tvgAnimation.cpp @@ -88,7 +88,7 @@ float Animation::duration() const noexcept Result Animation::segment(float begin, float end) noexcept { - if (begin < 0.0 || end > 1.0 || begin > end) return Result::InvalidArguments; + if (begin < 0.0f || end > 1.0f || begin > end) return Result::InvalidArguments; auto loader = PICTURE(pImpl->picture)->loader; if (!loader) return Result::InsufficientCondition; diff --git a/src/renderer/tvgRender.h b/src/renderer/tvgRender.h index f6eaf7c1..a03b5ca1 100644 --- a/src/renderer/tvgRender.h +++ b/src/renderer/tvgRender.h @@ -343,7 +343,7 @@ struct RenderEffectTint : RenderEffect inst->white[0] = va_arg(args, int); inst->white[1] = va_arg(args, int); inst->white[2] = va_arg(args, int); - inst->intensity = (uint8_t)(va_arg(args, double) * 2.55f); + inst->intensity = (uint8_t)(va_arg(args, double) * 2.55); inst->type = SceneEffect::Tint; return inst; } diff --git a/test/testAnimation.cpp b/test/testAnimation.cpp index 4a82c93b..12098412 100644 --- a/test/testAnimation.cpp +++ b/test/testAnimation.cpp @@ -308,16 +308,16 @@ TEST_CASE("Animation Segment", "[tvgAnimation]") //Get current segment REQUIRE(animation->segment(&begin, &end) == Result::Success); - REQUIRE(begin == 0.25); - REQUIRE(end == 0.5); + REQUIRE(begin == 0.25f); + REQUIRE(end == 0.5f); //Get only segment begin REQUIRE(animation->segment(&begin) == Result::Success); - REQUIRE(begin == 0.25); + REQUIRE(begin == 0.25f); //Get only segment end REQUIRE(animation->segment(nullptr, &end) == Result::Success); - REQUIRE(end == 0.5); + REQUIRE(end == 0.5f); //Segment by invalid range REQUIRE(animation->segment(-0.5, 1.5) == Result::InvalidArguments);