mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00
common: fixed double-precision promotion compilation warnings
Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
This commit is contained in:
parent
d44f037bc0
commit
71bb4163ed
12 changed files with 50 additions and 50 deletions
|
@ -101,13 +101,13 @@ struct UserExample : tvgexam::Example
|
||||||
//Clear the previously applied effects
|
//Clear the previously applied effects
|
||||||
scene1->push(tvg::SceneEffect::ClearAll);
|
scene1->push(tvg::SceneEffect::ClearAll);
|
||||||
//Apply DropShadow post effect (r, g, b, a, angle, distance, sigma of blurness, quality)
|
//Apply DropShadow post effect (r, g, b, a, angle, distance, sigma of blurness, quality)
|
||||||
scene1->push(tvg::SceneEffect::DropShadow, 0, 0, 0, 125, 120.0f, 20.0f * progress, 3.0f, 100);
|
scene1->push(tvg::SceneEffect::DropShadow, 0, 0, 0, 125, 120, (double)(20.0f * progress), 3, 100);
|
||||||
|
|
||||||
scene2->push(tvg::SceneEffect::ClearAll);
|
scene2->push(tvg::SceneEffect::ClearAll);
|
||||||
scene2->push(tvg::SceneEffect::DropShadow, 65, 143, 222, (int)(255.0f * progress), 135.0f, 10.0f, 3.0f, 100);
|
scene2->push(tvg::SceneEffect::DropShadow, 65, 143, 222, (int)(255.0f * progress), 135, 10, 3, 100);
|
||||||
|
|
||||||
scene3->push(tvg::SceneEffect::ClearAll);
|
scene3->push(tvg::SceneEffect::ClearAll);
|
||||||
scene3->push(tvg::SceneEffect::DropShadow, 0, 0, 0, 125, 360.0f * progress, 20.0f, 3.0f, 100);
|
scene3->push(tvg::SceneEffect::DropShadow, 0, 0, 0, 125, (double)(360.0f * progress), 20, 3, 100);
|
||||||
|
|
||||||
canvas->update();
|
canvas->update();
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,8 @@ struct UserExample : tvgexam::Example
|
||||||
shape->translate(385, 400);
|
shape->translate(385, 400);
|
||||||
|
|
||||||
//Update Shape1
|
//Update Shape1
|
||||||
shape->scale(1 - 0.75 * progress);
|
shape->scale(1.0f - 0.75f * progress);
|
||||||
shape->rotate(360 * progress);
|
shape->rotate(360.0f * progress);
|
||||||
|
|
||||||
canvas->push(shape);
|
canvas->push(shape);
|
||||||
|
|
||||||
|
@ -113,8 +113,8 @@ struct UserExample : tvgexam::Example
|
||||||
shape3->translate(400, 400);
|
shape3->translate(400, 400);
|
||||||
|
|
||||||
//Update Shape3
|
//Update Shape3
|
||||||
shape3->rotate(-360 * progress);
|
shape3->rotate(-360.0f * progress);
|
||||||
shape3->scale(0.5 + progress);
|
shape3->scale(0.5f + progress);
|
||||||
|
|
||||||
canvas->push(shape3);
|
canvas->push(shape3);
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
float deg2rad(float degree)
|
float deg2rad(float degree)
|
||||||
{
|
{
|
||||||
return degree * (M_PI / 180.0f);
|
return degree * (float(M_PI) / 180.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
|
|
|
@ -104,7 +104,7 @@ struct UserExample : tvgexam::Example
|
||||||
//Apply GaussianBlur post effect (sigma, direction, border option, quality)
|
//Apply GaussianBlur post effect (sigma, direction, border option, quality)
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
blur[i]->push(tvg::SceneEffect::ClearAll);
|
blur[i]->push(tvg::SceneEffect::ClearAll);
|
||||||
blur[i]->push(tvg::SceneEffect::GaussianBlur, 10.0f * progress, i, 0, 100);
|
blur[i]->push(tvg::SceneEffect::GaussianBlur, (double)(10.0f * progress), i, 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Apply Fill post effect (rgba)
|
//Apply Fill post effect (rgba)
|
||||||
|
@ -113,7 +113,7 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
//Apply Tint post effect (black:rgb, white:rgb, intensity)
|
//Apply Tint post effect (black:rgb, white:rgb, intensity)
|
||||||
tint->push(tvg::SceneEffect::ClearAll);
|
tint->push(tvg::SceneEffect::ClearAll);
|
||||||
tint->push(tvg::SceneEffect::Tint, 0, 0, 0, 0, (int)(progress * 255), 0, progress * 100.0f);
|
tint->push(tvg::SceneEffect::Tint, 0, 0, 0, 0, (int)(progress * 255), 0, (double)(progress * 100.0f));
|
||||||
|
|
||||||
//Apply Trintone post effect (shadow:rgb, midtone:rgb, highlight:rgb)
|
//Apply Trintone post effect (shadow:rgb, midtone:rgb, highlight:rgb)
|
||||||
trintone->push(tvg::SceneEffect::ClearAll);
|
trintone->push(tvg::SceneEffect::ClearAll);
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct UserExample : tvgexam::Example
|
||||||
shape->appendCircle(115, 200, 170, 100);
|
shape->appendCircle(115, 200, 170, 100);
|
||||||
shape->fill(255, 255, 255);
|
shape->fill(255, 255, 255);
|
||||||
shape->translate(385, 400);
|
shape->translate(385, 400);
|
||||||
shape->scale(1 - 0.75 * progress);
|
shape->scale(1.0f - 0.75f * progress);
|
||||||
shape->rotate(360 * progress);
|
shape->rotate(360 * progress);
|
||||||
|
|
||||||
canvas->push(shape);
|
canvas->push(shape);
|
||||||
|
@ -71,8 +71,8 @@ struct UserExample : tvgexam::Example
|
||||||
shape3->appendRect(100, 100, 150, 50, 20, 20);
|
shape3->appendRect(100, 100, 150, 50, 20, 20);
|
||||||
shape3->fill(255, 0, 255);
|
shape3->fill(255, 0, 255);
|
||||||
shape3->translate(400, 400);
|
shape3->translate(400, 400);
|
||||||
shape3->rotate(-360 * progress);
|
shape3->rotate(-360.0f * progress);
|
||||||
shape3->scale(0.5 + progress);
|
shape3->scale(0.5f + progress);
|
||||||
canvas->push(shape3);
|
canvas->push(shape3);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -54,8 +54,8 @@ struct UserExample : tvgexam::Example
|
||||||
shape->appendRect(-100, -100, 200, 200, (100 * progress), (100 * progress));
|
shape->appendRect(-100, -100, 200, 200, (100 * progress), (100 * progress));
|
||||||
shape->fill(rand() % 255, rand() % 255, rand() % 255);
|
shape->fill(rand() % 255, rand() % 255, rand() % 255);
|
||||||
shape->translate(800 * progress, 800 * progress);
|
shape->translate(800 * progress, 800 * progress);
|
||||||
shape->scale(1 - 0.75 * progress);
|
shape->scale(1.0f - 0.75f * progress);
|
||||||
shape->rotate(360 * progress);
|
shape->rotate(360.0f * progress);
|
||||||
|
|
||||||
canvas->push(shape);
|
canvas->push(shape);
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,7 @@ enum class SceneEffect : uint8_t
|
||||||
{
|
{
|
||||||
ClearAll = 0, ///< Reset all previously applied scene effects, restoring the scene to its original state.
|
ClearAll = 0, ///< Reset all previously applied scene effects, restoring the scene to its original state.
|
||||||
GaussianBlur, ///< Apply a blur effect with a Gaussian filter. Param(3) = {sigma(float)[> 0], direction(int)[both: 0 / horizontal: 1 / vertical: 2], border(int)[duplicate: 0 / wrap: 1], quality(int)[0 - 100]}
|
GaussianBlur, ///< Apply a blur effect with a Gaussian filter. Param(3) = {sigma(float)[> 0], direction(int)[both: 0 / horizontal: 1 / vertical: 2], border(int)[duplicate: 0 / wrap: 1], quality(int)[0 - 100]}
|
||||||
DropShadow, ///< Apply a drop shadow effect with a Gaussian Blur filter. Param(8) = {color_R(int)[0 - 255], color_G(int)[0 - 255], color_B(int)[0 - 255], opacity(int)[0 - 255], angle(float)[0 - 360], distance(float), blur_sigma(float)[> 0], quality(int)[0 - 100]}
|
DropShadow, ///< Apply a drop shadow effect with a Gaussian Blur filter. Param(8) = {color_R(int)[0 - 255], color_G(int)[0 - 255], color_B(int)[0 - 255], opacity(int)[0 - 255], angle(double)[0 - 360], distance(double), blur_sigma(double)[> 0], quality(int)[0 - 100]}
|
||||||
Fill, ///< Override the scene content color with a given fill information (Experimental API). Param(5) = {color_R(int)[0 - 255], color_G(int)[0 - 255], color_B(int)[0 - 255], opacity(int)[0 - 255]}
|
Fill, ///< Override the scene content color with a given fill information (Experimental API). Param(5) = {color_R(int)[0 - 255], color_G(int)[0 - 255], color_B(int)[0 - 255], opacity(int)[0 - 255]}
|
||||||
Tint, ///< Tinting the current scene color with a given black, white color paramters (Experimental API). Param(7) = {black_R(int)[0 - 255], black_G(int)[0 - 255], black_B(int)[0 - 255], white_R(int)[0 - 255], white_G(int)[0 - 255], white_B(int)[0 - 255], intensity(float)[0 - 100]}
|
Tint, ///< Tinting the current scene color with a given black, white color paramters (Experimental API). Param(7) = {black_R(int)[0 - 255], black_G(int)[0 - 255], black_B(int)[0 - 255], white_R(int)[0 - 255], white_G(int)[0 - 255], white_B(int)[0 - 255], intensity(float)[0 - 100]}
|
||||||
Tritone ///< Apply a tritone color effect to the scene using three color parameters for shadows, midtones, and highlights (Experimental API). Param(9) = {Shadow_R(int)[0 - 255], Shadow_G(int)[0 - 255], Shadow_B(int)[0 - 255], Midtone_R(int)[0 - 255], Midtone_G(int)[0 - 255], Midtone_B(int)[0 - 255], Highlight_R(int)[0 - 255], Highlight_G(int)[0 - 255], Highlight_B(int)[0 - 255]}
|
Tritone ///< Apply a tritone color effect to the scene using three color parameters for shadows, midtones, and highlights (Experimental API). Param(9) = {Shadow_R(int)[0 - 255], Shadow_G(int)[0 - 255], Shadow_B(int)[0 - 255], Midtone_R(int)[0 - 255], Midtone_G(int)[0 - 255], Midtone_B(int)[0 - 255], Highlight_R(int)[0 - 255], Highlight_G(int)[0 - 255], Highlight_B(int)[0 - 255]}
|
||||||
|
|
|
@ -1303,12 +1303,12 @@ void LottieBuilder::updateEffect(LottieLayer* layer, float frameNo)
|
||||||
auto effect = static_cast<LottieFxDropShadow*>(*p);
|
auto effect = static_cast<LottieFxDropShadow*>(*p);
|
||||||
auto color = effect->color(frameNo);
|
auto color = effect->color(frameNo);
|
||||||
//seems the opacity range in dropshadow is 0 ~ 256
|
//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)), (double)effect->angle(frameNo), (double)effect->distance(frameNo), (double)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;
|
break;
|
||||||
}
|
}
|
||||||
case LottieEffect::GaussianBlur: {
|
case LottieEffect::GaussianBlur: {
|
||||||
auto effect = static_cast<LottieFxGaussianBlur*>(*p);
|
auto effect = static_cast<LottieFxGaussianBlur*>(*p);
|
||||||
layer->scene->push(SceneEffect::GaussianBlur, (double)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;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
|
|
|
@ -372,7 +372,7 @@ LottieInterpolator* LottieParser::getInterpolator(const char* key, Point& in, Po
|
||||||
char buf[20];
|
char buf[20];
|
||||||
|
|
||||||
if (!key) {
|
if (!key) {
|
||||||
snprintf(buf, sizeof(buf), "%.2f_%.2f_%.2f_%.2f", in.x, in.y, out.x, out.y);
|
snprintf(buf, sizeof(buf), "%.2f_%.2f_%.2f_%.2f", (double)in.x, (double)in.y, (double)out.x, (double)out.y);
|
||||||
key = buf;
|
key = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -384,7 +384,7 @@ static Paint* _applyFilter(SvgLoaderData& loaderData, Paint* paint, const SvgNod
|
||||||
stdDevX *= bbox.w;
|
stdDevX *= bbox.w;
|
||||||
stdDevY *= bbox.h;
|
stdDevY *= bbox.h;
|
||||||
}
|
}
|
||||||
scene->push(SceneEffect::GaussianBlur, 1.25f * (direction == 2 ? stdDevY * sy : stdDevX * sx), direction, gauss.edgeModeWrap, 55);
|
scene->push(SceneEffect::GaussianBlur, (double)(1.25f * (direction == 2 ? stdDevY * sy : stdDevX * sx)), direction, gauss.edgeModeWrap, 55);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ void VP8InitRandom(VP8Random* const rg, float dithering) {
|
||||||
memcpy(rg->tab_, kRandomTable, sizeof(rg->tab_));
|
memcpy(rg->tab_, kRandomTable, sizeof(rg->tab_));
|
||||||
rg->index1_ = 0;
|
rg->index1_ = 0;
|
||||||
rg->index2_ = 31;
|
rg->index2_ = 31;
|
||||||
rg->amp_ = (dithering < 0.0) ? 0
|
rg->amp_ = (dithering < 0.0f) ? 0
|
||||||
: (dithering > 1.0) ? (1 << VP8_RANDOM_DITHER_FIX)
|
: (dithering > 1.0f) ? (1 << VP8_RANDOM_DITHER_FIX)
|
||||||
: (uint32_t)((1 << VP8_RANDOM_DITHER_FIX) * dithering);
|
: (uint32_t)((1 << VP8_RANDOM_DITHER_FIX) * dithering);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,16 +182,16 @@ struct Edge : public Object
|
||||||
// https://stackoverflow.com/questions/1560492/how-to-tell-whether-a-point-is-to-the-right-or-left-side-of-a-line
|
// https://stackoverflow.com/questions/1560492/how-to-tell-whether-a-point-is-to-the-right-or-left-side-of-a-line
|
||||||
// return > 0 means point in left
|
// return > 0 means point in left
|
||||||
// return < 0 means point in right
|
// return < 0 means point in right
|
||||||
double sideDist(const Point& p);
|
float sideDist(const Point& p);
|
||||||
|
|
||||||
bool isRightOf(const Point& p)
|
bool isRightOf(const Point& p)
|
||||||
{
|
{
|
||||||
return sideDist(p) < 0.0;
|
return sideDist(p) < 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isLeftOf(const Point& p)
|
bool isLeftOf(const Point& p)
|
||||||
{
|
{
|
||||||
return sideDist(p) > 0.0;
|
return sideDist(p) > 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
|
// https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
|
||||||
|
@ -202,9 +202,9 @@ struct Edge : public Object
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double le_a;
|
float le_a;
|
||||||
double le_b;
|
float le_b;
|
||||||
double le_c;
|
float le_c;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -403,14 +403,14 @@ Edge::Edge(Vertex *top, Vertex *bottom, int32_t winding)
|
||||||
: top(top),
|
: top(top),
|
||||||
bottom(bottom),
|
bottom(bottom),
|
||||||
winding(winding),
|
winding(winding),
|
||||||
le_a(static_cast<double>(bottom->point.y) - top->point.y),
|
le_a(bottom->point.y - top->point.y),
|
||||||
le_b(static_cast<double>(top->point.x) - bottom->point.x),
|
le_b(top->point.x - bottom->point.x),
|
||||||
le_c(static_cast<double>(top->point.y) * bottom->point.x - static_cast<double>(top->point.x) * bottom->point.y)
|
le_c(top->point.y * bottom->point.x - top->point.x * bottom->point.y)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double Edge::sideDist(const Point& p)
|
float Edge::sideDist(const Point& p)
|
||||||
{
|
{
|
||||||
return le_a * p.x + le_b * p.y + le_c;
|
return le_a * p.x + le_b * p.y + le_c;
|
||||||
}
|
}
|
||||||
|
@ -431,22 +431,22 @@ bool Edge::intersect(Edge *other, Point* point)
|
||||||
auto denom = le_a * other->le_b - le_b * other->le_a;
|
auto denom = le_a * other->le_b - le_b * other->le_a;
|
||||||
if (tvg::zero(denom)) return false;
|
if (tvg::zero(denom)) return false;
|
||||||
|
|
||||||
auto dx = static_cast<double>(other->top->point.x) - top->point.x;
|
auto dx = other->top->point.x - top->point.x;
|
||||||
auto dy = static_cast<double>(other->top->point.y) - top->point.y;
|
auto dy = other->top->point.y - top->point.y;
|
||||||
auto s_number = dy * other->le_b + dx * other->le_a;
|
auto s_number = dy * other->le_b + dx * other->le_a;
|
||||||
auto t_number = dy * le_b + dx * le_a;
|
auto t_number = dy * le_b + dx * le_a;
|
||||||
|
|
||||||
if (denom > 0.0 ? (s_number < 0.0 || s_number > denom || t_number < 0.0 || t_number > denom) : (s_number > 0.0 || s_number < denom || t_number > 0.0 || t_number < denom)) return false;
|
if (denom > 0.0f ? (s_number < 0.0f || s_number > denom || t_number < 0.0f || t_number > denom) : (s_number > 0.0f || s_number < denom || t_number > 0.0f || t_number < denom)) return false;
|
||||||
|
|
||||||
auto scale = 1.0 / denom;
|
auto scale = 1.0f / denom;
|
||||||
point->x = nearbyintf(static_cast<float>(top->point.x - s_number * le_b * scale));
|
point->x = nearbyintf(top->point.x - s_number * le_b * scale);
|
||||||
point->y = nearbyintf(static_cast<float>(top->point.y + s_number * le_a * scale));
|
point->y = nearbyintf(top->point.y + s_number * le_a * scale);
|
||||||
|
|
||||||
if (std::isinf(point->x) || std::isinf(point->y)) return false;
|
if (std::isinf(point->x) || std::isinf(point->y)) return false;
|
||||||
if (std::abs(point->x - top->point.x) < 1e-6 && std::abs(point->y - top->point.y) < 1e-6) return false;
|
if (fabsf(point->x - top->point.x) < 1e-6f && fabsf(point->y - top->point.y) < 1e-6f) return false;
|
||||||
if (std::abs(point->x - bottom->point.x) < 1e-6 && std::abs(point->y - bottom->point.y) < 1e-6) return false;
|
if (fabsf(point->x - bottom->point.x) < 1e-6f && fabsf(point->y - bottom->point.y) < 1e-6f) return false;
|
||||||
if (std::abs(point->x - other->top->point.x) < 1e-6 && std::abs(point->y - other->top->point.y) < 1e-6) return false;
|
if (fabsf(point->x - other->top->point.x) < 1e-6f && fabsf(point->y - other->top->point.y) < 1e-6f) return false;
|
||||||
if (std::abs(point->x - other->bottom->point.x) < 1e-6 && std::abs(point->y - other->bottom->point.y) < 1e-6) return false;
|
if (fabsf(point->x - other->bottom->point.x) < 1e-6f && fabsf(point->y - other->bottom->point.y) < 1e-6f) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -454,9 +454,9 @@ bool Edge::intersect(Edge *other, Point* point)
|
||||||
|
|
||||||
void Edge::recompute()
|
void Edge::recompute()
|
||||||
{
|
{
|
||||||
le_a = static_cast<double>(bottom->point.y) - top->point.y;
|
le_a = bottom->point.y - top->point.y;
|
||||||
le_b = static_cast<double>(top->point.x) - bottom->point.x;
|
le_b = top->point.x - bottom->point.x;
|
||||||
le_c = static_cast<double>(top->point.y) * bottom->point.x - static_cast<double>(top->point.x) * bottom->point.y;
|
le_c = top->point.y * bottom->point.x - top->point.x * bottom->point.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1488,12 +1488,12 @@ void Tessellator::emitPoly(MonotonePolygon *poly)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double ax = static_cast<double>(curr->point.x) - prev->point.x;
|
auto ax = curr->point.x - prev->point.x;
|
||||||
double ay = static_cast<double>(curr->point.y) - prev->point.y;
|
auto ay = curr->point.y - prev->point.y;
|
||||||
double bx = static_cast<double>(next->point.x) - curr->point.x;
|
auto bx = next->point.x - curr->point.x;
|
||||||
double by = static_cast<double>(next->point.y) - curr->point.y;
|
auto by = next->point.y - curr->point.y;
|
||||||
|
|
||||||
if (ax * by - ay * bx >= 0.0) {
|
if (ax * by - ay * bx >= 0.0f) {
|
||||||
emitTriangle(prev, curr, next);
|
emitTriangle(prev, curr, next);
|
||||||
v->prev->next = v->next;
|
v->prev->next = v->next;
|
||||||
v->next->prev = v->prev;
|
v->next->prev = v->prev;
|
||||||
|
|
Loading…
Add table
Reference in a new issue