mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:17:35 +00:00
Everywhere: Add -Wdouble-promotion
warning
This warning informs of float-to-double conversions. The best solution seems to be to do math *either* in 32-bit *or* in 64-bit, and only to cross over when absolutely necessary.
This commit is contained in:
parent
6606d70826
commit
73dd293ec4
26 changed files with 105 additions and 98 deletions
|
@ -95,7 +95,7 @@ inline f32x4 gamma_accurate_lerp4(f32x4 v1, f32x4 v2, float mix)
|
|||
// Assumes x is in range [0, 1]
|
||||
constexpr float gamma_to_linear(float x)
|
||||
{
|
||||
return (0.8 + 0.2 * x) * x * x;
|
||||
return (0.8f + 0.2f * x) * x * x;
|
||||
}
|
||||
|
||||
// Transform scalar from linear space to gamma2.2 space
|
||||
|
@ -105,7 +105,7 @@ inline float linear_to_gamma(float x)
|
|||
// Source for approximation: https://mimosa-pudica.net/fast-gamma/
|
||||
constexpr float a = 0.00279491;
|
||||
constexpr float b = 1.15907984;
|
||||
float c = (b / sqrt(1 + a)) - 1;
|
||||
float c = (b / sqrtf(1 + a)) - 1;
|
||||
return ((b / __builtin_sqrtf(x + a)) - c) * x;
|
||||
}
|
||||
|
||||
|
@ -135,9 +135,9 @@ inline Color gamma_accurate_blend(Color a, Color b, float mix)
|
|||
return Color(out[0], out[1], out[2]);
|
||||
# else
|
||||
return {
|
||||
static_cast<u8>(255. * gamma_accurate_lerp(a.red() / 255., b.red() / 255., mix)),
|
||||
static_cast<u8>(255. * gamma_accurate_lerp(a.green() / 255., b.green() / 255., mix)),
|
||||
static_cast<u8>(255. * gamma_accurate_lerp(a.blue() / 255., b.blue() / 255., mix)),
|
||||
static_cast<u8>(255.f * gamma_accurate_lerp(a.red() / 255.f, b.red() / 255.f, mix)),
|
||||
static_cast<u8>(255.f * gamma_accurate_lerp(a.green() / 255.f, b.green() / 255.f, mix)),
|
||||
static_cast<u8>(255.f * gamma_accurate_lerp(a.blue() / 255.f, b.blue() / 255.f, mix)),
|
||||
};
|
||||
# endif
|
||||
}
|
||||
|
|
|
@ -299,7 +299,7 @@ void Painter::draw_ellipse_intersecting(const IntRect& rect, Color color, int th
|
|||
return (sin(theta) * rect.height() / sqrt(2)) + rect.center().y();
|
||||
};
|
||||
|
||||
for (float theta = 0; theta < 2 * M_PI; theta += increment) {
|
||||
for (auto theta = 0.0; theta < 2 * M_PI; theta += increment) {
|
||||
draw_line({ ellipse_x(theta), ellipse_y(theta) }, { ellipse_x(theta + increment), ellipse_y(theta + increment) }, color, thickness);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,8 +75,8 @@ void Path::elliptical_arc_to(const FloatPoint& point, const FloatPoint& radii, d
|
|||
|
||||
// Find (cx, cy), theta_1, theta_delta
|
||||
// Step 1: Compute (x1', y1')
|
||||
auto x_avg = (last_point.x() - next_point.x()) / 2.0f;
|
||||
auto y_avg = (last_point.y() - next_point.y()) / 2.0f;
|
||||
auto x_avg = static_cast<double>(last_point.x() - next_point.x()) / 2.0;
|
||||
auto y_avg = static_cast<double>(last_point.y() - next_point.y()) / 2.0;
|
||||
auto x1p = x_axis_rotation_c * x_avg + x_axis_rotation_s * y_avg;
|
||||
auto y1p = -x_axis_rotation_s * x_avg + x_axis_rotation_c * y_avg;
|
||||
|
||||
|
@ -118,7 +118,7 @@ void Path::elliptical_arc_to(const FloatPoint& point, const FloatPoint& radii, d
|
|||
|
||||
auto theta_delta = theta_2 - theta_1;
|
||||
|
||||
if (!sweep && theta_delta > 0.0f) {
|
||||
if (!sweep && theta_delta > 0.0) {
|
||||
theta_delta -= 2 * M_PI;
|
||||
} else if (sweep && theta_delta < 0) {
|
||||
theta_delta += 2 * M_PI;
|
||||
|
@ -226,7 +226,7 @@ String Path::to_string() const
|
|||
break;
|
||||
case Segment::Type::EllipticalArcTo: {
|
||||
auto& arc = static_cast<const EllipticalArcSegment&>(segment);
|
||||
builder.appendf(", %s, %s, %f, %f, %f",
|
||||
builder.appendff(", {}, {}, {}, {}, {}",
|
||||
arc.radii().to_string().characters(),
|
||||
arc.center().to_string().characters(),
|
||||
arc.x_axis_rotation(),
|
||||
|
|
|
@ -160,7 +160,7 @@ String IntRect::to_string() const
|
|||
template<>
|
||||
String FloatRect::to_string() const
|
||||
{
|
||||
return String::format("[%f,%f %fx%f]", x(), y(), width(), height());
|
||||
return String::formatted("[{},{} {}x{}]", x(), y(), width(), height());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue