diff options
author | 2023-11-04 14:06:34 -0400 | |
---|---|---|
committer | 2023-11-04 14:06:34 -0400 | |
commit | a140272be00542ca8ffc1827b50655bc5682d723 (patch) | |
tree | 2003865687cbeba42f9d8e44bec3aaf93562246b /src/osd | |
parent | b3e2de66007f2818d9e3c486ec3c93c1a52213a5 (diff) |
modules/render/bgfx/clearreader.cpp: Use std::clamp
Diffstat (limited to 'src/osd')
-rw-r--r-- | src/osd/modules/render/bgfx/clearreader.cpp | 6 |
1 files 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 <bgfx/bgfx.h> +#include <algorithm> + 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<int32_t>(float(colors[i].GetDouble()) * 255.0f, 0, 255); clear_color |= val << (24 - (i * 3)); } clear_flags |= BGFX_CLEAR_COLOR; |