userspace: Allow building without SSE

I had added changes that had broken compilation without sse support
This commit is contained in:
2024-09-02 21:25:00 +03:00
parent 700c3444f5
commit 5f92807fdd
9 changed files with 45 additions and 6 deletions

View File

@@ -87,10 +87,10 @@ namespace LibImage
constexpr Image::Color as_color() const
{
return Image::Color {
.r = static_cast<uint8_t>(BAN::Math::clamp<double>(r, 0.0, 255.0)),
.g = static_cast<uint8_t>(BAN::Math::clamp<double>(g, 0.0, 255.0)),
.b = static_cast<uint8_t>(BAN::Math::clamp<double>(b, 0.0, 255.0)),
.a = static_cast<uint8_t>(BAN::Math::clamp<double>(a, 0.0, 255.0)),
.r = static_cast<uint8_t>(r < 0.0 ? 0.0 : r > 255.0 ? 255.0 : r),
.g = static_cast<uint8_t>(g < 0.0 ? 0.0 : g > 255.0 ? 255.0 : g),
.b = static_cast<uint8_t>(b < 0.0 ? 0.0 : b > 255.0 ? 255.0 : b),
.a = static_cast<uint8_t>(a < 0.0 ? 0.0 : a > 255.0 ? 255.0 : a),
};
}
};
@@ -133,8 +133,13 @@ namespace LibImage
{
const double src_x = x * ratio_x;
const double src_y = y * ratio_y;
#if __enable_sse
const double weight_x = src_x - floor(src_x);
const double weight_y = src_y - floor(src_y);
#else
const double weight_x = src_x - (uint64_t)src_x;
const double weight_y = src_y - (uint64_t)src_y;
#endif
const Color avg_t = Color::average(
get_clamped_color(src_x + 0.0, src_y),
@@ -173,8 +178,13 @@ namespace LibImage
{
const double src_x = x * ratio_x;
const double src_y = y * ratio_y;
#if __enable_sse
const double weight_x = src_x - floor(src_x);
const double weight_y = src_y - floor(src_y);
#else
const double weight_x = src_x - (uint64_t)src_x;
const double weight_y = src_y - (uint64_t)src_y;
#endif
FloatingColor values[4];
for (int64_t m = -1; m <= 2; m++)

View File

@@ -22,7 +22,7 @@ namespace LibImage
// weight of 0.0 returns a and weight of 1.0 returns b
static Color average(Color a, Color b, double weight)
{
const double b_mult = BAN::Math::clamp(weight, 0.0, 1.0);
const double b_mult = weight < 0.0 ? 0.0 : weight > 1.0 ? 1.0 : weight;
const double a_mult = 1.0 - b_mult;
return Color {
.r = static_cast<uint8_t>(a.r * a_mult + b.r * b_mult),