From a140272be00542ca8ffc1827b50655bc5682d723 Mon Sep 17 00:00:00 2001 From: AJR Date: Sat, 4 Nov 2023 14:06:34 -0400 Subject: modules/render/bgfx/clearreader.cpp: Use std::clamp --- src/osd/modules/render/bgfx/clearreader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/osd/modules/render/bgfx/clearreader.cpp b/src/osd/modules/render/bgfx/clearreader.cpp index 414e5f27988..58c4d5f01aa 100644 --- a/src/osd/modules/render/bgfx/clearreader.cpp +++ b/src/osd/modules/render/bgfx/clearreader.cpp @@ -12,6 +12,8 @@ #include +#include + clear_state* clear_reader::read_from_value(const Value& value, const std::string &prefix) { if (!validate_parameters(value, prefix)) @@ -30,9 +32,7 @@ clear_state* clear_reader::read_from_value(const Value& value, const std::string for (int i = 0; i < colors.Size(); i++) { if (!READER_CHECK(colors[i].IsNumber(), "%sclearcolor[%d] must be a numeric value\n", prefix, i)) return nullptr; - auto val = int32_t(float(colors[i].GetDouble()) * 255.0f); - if (val > 255) val = 255; - if (val < 0) val = 0; + auto val = std::clamp(float(colors[i].GetDouble()) * 255.0f, 0, 255); clear_color |= val << (24 - (i * 3)); } clear_flags |= BGFX_CLEAR_COLOR; -- cgit v1.2.3