general: Allow compiling Panda headers on Windows without NOMINMAX

This commit is contained in:
rdb 2022-05-10 14:08:21 +02:00
parent 0538106d52
commit fbea0056f5
27 changed files with 81 additions and 80 deletions

View File

@ -49,7 +49,7 @@ set_severity(NotifySeverity severity) {
_severity = severity; _severity = severity;
#else #else
// enforce the no-debug, no-spam rule. // enforce the no-debug, no-spam rule.
_severity = std::max(severity, NS_info); _severity = (std::max)(severity, NS_info);
#endif #endif
invalidate_cache(); invalidate_cache();
} }

View File

@ -344,7 +344,7 @@ is_axis_known(size_t index) const {
INLINE void InputDevice:: INLINE void InputDevice::
set_vibration(double strong, double weak) { set_vibration(double strong, double weak) {
LightMutexHolder holder(_lock); LightMutexHolder holder(_lock);
do_set_vibration(std::max(std::min(strong, 1.0), 0.0), std::max(std::min(weak, 1.0), 0.0)); do_set_vibration((std::max)((std::min)(strong, 1.0), 0.0), (std::max)((std::min)(weak, 1.0), 0.0));
} }
/** /**

View File

@ -242,7 +242,7 @@ INLINE void DrawableRegion::
update_pixel_factor() { update_pixel_factor() {
PN_stdfloat new_pixel_factor; PN_stdfloat new_pixel_factor;
if (supports_pixel_zoom()) { if (supports_pixel_zoom()) {
new_pixel_factor = (PN_stdfloat)1 / sqrt(std::max(_pixel_zoom, (PN_stdfloat)1.0)); new_pixel_factor = (PN_stdfloat)1 / sqrt((std::max)(_pixel_zoom, (PN_stdfloat)1.0));
} else { } else {
new_pixel_factor = 1; new_pixel_factor = 1;
} }

View File

@ -57,10 +57,11 @@ get_depth_bits() const {
*/ */
INLINE int FrameBufferProperties:: INLINE int FrameBufferProperties::
get_color_bits() const { get_color_bits() const {
return std::max(_property[FBP_color_bits], return (std::max)(
_property[FBP_red_bits] + _property[FBP_color_bits],
_property[FBP_green_bits] + _property[FBP_red_bits] +
_property[FBP_blue_bits]); _property[FBP_green_bits] +
_property[FBP_blue_bits]);
} }
/** /**

View File

@ -167,8 +167,8 @@ get_y_size() const {
*/ */
INLINE LVecBase2i GraphicsOutput:: INLINE LVecBase2i GraphicsOutput::
get_fb_size() const { get_fb_size() const {
return LVecBase2i(std::max(int(_size.get_x() * get_pixel_factor()), 1), return LVecBase2i((std::max)(int(_size.get_x() * get_pixel_factor()), 1),
std::max(int(_size.get_y() * get_pixel_factor()), 1)); (std::max)(int(_size.get_y() * get_pixel_factor()), 1));
} }
/** /**
@ -178,7 +178,7 @@ get_fb_size() const {
*/ */
INLINE int GraphicsOutput:: INLINE int GraphicsOutput::
get_fb_x_size() const { get_fb_x_size() const {
return std::max(int(_size.get_x() * get_pixel_factor()), 1); return (std::max)(int(_size.get_x() * get_pixel_factor()), 1);
} }
/** /**
@ -188,7 +188,7 @@ get_fb_x_size() const {
*/ */
INLINE int GraphicsOutput:: INLINE int GraphicsOutput::
get_fb_y_size() const { get_fb_y_size() const {
return std::max(int(_size.get_y() * get_pixel_factor()), 1); return (std::max)(int(_size.get_y() * get_pixel_factor()), 1);
} }
/** /**
@ -200,8 +200,8 @@ INLINE LVecBase2i GraphicsOutput::
get_sbs_left_size() const { get_sbs_left_size() const {
PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0]; PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0];
PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2]; PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2];
return LVecBase2i(std::max(int(_size.get_x() * left_w), 1), return LVecBase2i((std::max)(int(_size.get_x() * left_w), 1),
std::max(int(_size.get_y() * left_h), 1)); (std::max)(int(_size.get_y() * left_h), 1));
} }
/** /**
@ -212,7 +212,7 @@ get_sbs_left_size() const {
INLINE int GraphicsOutput:: INLINE int GraphicsOutput::
get_sbs_left_x_size() const { get_sbs_left_x_size() const {
PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0]; PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0];
return std::max(int(_size.get_x() * left_w), 1); return (std::max)(int(_size.get_x() * left_w), 1);
} }
/** /**
@ -223,7 +223,7 @@ get_sbs_left_x_size() const {
INLINE int GraphicsOutput:: INLINE int GraphicsOutput::
get_sbs_left_y_size() const { get_sbs_left_y_size() const {
PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2]; PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2];
return std::max(int(_size.get_y() * left_h), 1); return (std::max)(int(_size.get_y() * left_h), 1);
} }
/** /**
@ -235,8 +235,8 @@ INLINE LVecBase2i GraphicsOutput::
get_sbs_right_size() const { get_sbs_right_size() const {
PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0]; PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0];
PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2]; PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2];
return LVecBase2i(std::max(int(_size.get_x() * right_w), 1), return LVecBase2i((std::max)(int(_size.get_x() * right_w), 1),
std::max(int(_size.get_y() * right_h), 1)); (std::max)(int(_size.get_y() * right_h), 1));
} }
/** /**
@ -247,7 +247,7 @@ get_sbs_right_size() const {
INLINE int GraphicsOutput:: INLINE int GraphicsOutput::
get_sbs_right_x_size() const { get_sbs_right_x_size() const {
PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0]; PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0];
return std::max(int(_size.get_x() * right_w), 1); return (std::max)(int(_size.get_x() * right_w), 1);
} }
/** /**
@ -258,7 +258,7 @@ get_sbs_right_x_size() const {
INLINE int GraphicsOutput:: INLINE int GraphicsOutput::
get_sbs_right_y_size() const { get_sbs_right_y_size() const {
PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2]; PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2];
return std::max(int(_size.get_y() * right_h), 1); return (std::max)(int(_size.get_y() * right_h), 1);
} }
/** /**

View File

@ -258,7 +258,7 @@ get_max_vertices_per_primitive() const {
INLINE int GraphicsStateGuardian:: INLINE int GraphicsStateGuardian::
get_max_texture_stages() const { get_max_texture_stages() const {
if (max_texture_stages > 0) { if (max_texture_stages > 0) {
return std::min(_max_texture_stages, (int)max_texture_stages); return (std::min)(_max_texture_stages, (int)max_texture_stages);
} }
return _max_texture_stages; return _max_texture_stages;
} }
@ -695,7 +695,7 @@ get_timer_queries_active() const {
INLINE int GraphicsStateGuardian:: INLINE int GraphicsStateGuardian::
get_max_color_targets() const { get_max_color_targets() const {
if (max_color_targets > 0) { if (max_color_targets > 0) {
return std::min(_max_color_targets, (int)max_color_targets); return (std::min)(_max_color_targets, (int)max_color_targets);
} }
return _max_color_targets; return _max_color_targets;
} }

View File

@ -58,7 +58,7 @@ matches(const EggMesherEdge &other) const {
*/ */
INLINE EggMesherEdge *EggMesherEdge:: INLINE EggMesherEdge *EggMesherEdge::
common_ptr() { common_ptr() {
return std::min(this, _opposite); return (std::min)(this, _opposite);
} }
/** /**

View File

@ -431,6 +431,6 @@ is_cert_special() const {
*/ */
INLINE std::streampos Multifile::Subfile:: INLINE std::streampos Multifile::Subfile::
get_last_byte_pos() const { get_last_byte_pos() const {
return std::max(_index_start + (std::streampos)_index_length, return (std::max)(_index_start + (std::streampos)_index_length,
_data_start + (std::streampos)_data_length) - (std::streampos)1; _data_start + (std::streampos)_data_length) - (std::streampos)1;
} }

View File

@ -471,9 +471,9 @@ set_data(const std::string &data) {
template<class Element> template<class Element>
INLINE std::string PointerToArray<Element>:: INLINE std::string PointerToArray<Element>::
get_subdata(size_type n, size_type count) const { get_subdata(size_type n, size_type count) const {
n = std::min(n, size()); n = (std::min)(n, size());
count = std::max(count, n); count = (std::max)(count, n);
count = std::min(count, size() - n); count = (std::min)(count, size() - n);
return std::string((const char *)(p() + n), sizeof(Element) * count); return std::string((const char *)(p() + n), sizeof(Element) * count);
} }
@ -965,9 +965,9 @@ get_data() const {
template<class Element> template<class Element>
INLINE std::string ConstPointerToArray<Element>:: INLINE std::string ConstPointerToArray<Element>::
get_subdata(size_type n, size_type count) const { get_subdata(size_type n, size_type count) const {
n = std::min(n, size()); n = (std::min)(n, size());
count = std::max(count, n); count = (std::max)(count, n);
count = std::min(count, size() - n); count = (std::min)(count, size() - n);
return std::string((const char *)(p() + n), sizeof(Element) * count); return std::string((const char *)(p() + n), sizeof(Element) * count);
} }

View File

@ -249,9 +249,9 @@ set_data(PyObject *data) {
template<class Element> template<class Element>
INLINE PyObject *Extension<PointerToArray<Element> >:: INLINE PyObject *Extension<PointerToArray<Element> >::
get_subdata(size_t n, size_t count) const { get_subdata(size_t n, size_t count) const {
n = std::min(n, this->_this->size()); n = (std::min)(n, this->_this->size());
count = std::max(count, n); count = (std::max)(count, n);
count = std::min(count, this->_this->size() - n); count = (std::min)(count, this->_this->size() - n);
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
return PyBytes_FromStringAndSize((char *)(this->_this->p() + n), sizeof(Element) * count); return PyBytes_FromStringAndSize((char *)(this->_this->p() + n), sizeof(Element) * count);
#else #else
@ -313,9 +313,9 @@ get_data() const {
template<class Element> template<class Element>
INLINE PyObject *Extension<ConstPointerToArray<Element> >:: INLINE PyObject *Extension<ConstPointerToArray<Element> >::
get_subdata(size_t n, size_t count) const { get_subdata(size_t n, size_t count) const {
n = std::min(n, this->_this->size()); n = (std::min)(n, this->_this->size());
count = std::max(count, n); count = (std::max)(count, n);
count = std::min(count, this->_this->size() - n); count = (std::min)(count, this->_this->size() - n);
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
return PyBytes_FromStringAndSize((char *)(this->_this->p() + n), sizeof(Element) * count); return PyBytes_FromStringAndSize((char *)(this->_this->p() + n), sizeof(Element) * count);
#else #else

View File

@ -535,8 +535,8 @@ get_data() const {
INLINE vector_uchar GeomVertexArrayDataHandle:: INLINE vector_uchar GeomVertexArrayDataHandle::
get_subdata(size_t start, size_t size) const { get_subdata(size_t start, size_t size) const {
mark_used(); mark_used();
start = std::min(start, _cdata->_buffer.get_size()); start = (std::min)(start, _cdata->_buffer.get_size());
size = std::min(size, _cdata->_buffer.get_size() - start); size = (std::min)(size, _cdata->_buffer.get_size() - start);
const unsigned char *ptr = _cdata->_buffer.get_read_pointer(true) + start; const unsigned char *ptr = _cdata->_buffer.get_read_pointer(true) + start;
return vector_uchar(ptr, ptr + size); return vector_uchar(ptr, ptr + size);
} }

View File

@ -1382,13 +1382,13 @@ inc_add_pointer() {
_handle = nullptr; _handle = nullptr;
GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread);
writer.check_array_writers(); writer.check_array_writers();
writer.set_num_rows(std::max(write_row + 1, writer.get_num_rows())); writer.set_num_rows((std::max)(write_row + 1, writer.get_num_rows()));
_handle = writer.get_array_writer(_array); _handle = writer.get_array_writer(_array);
} else { } else {
// Otherwise, we can get away with modifying only the one array we're // Otherwise, we can get away with modifying only the one array we're
// using. // using.
_handle->set_num_rows(std::max(write_row + 1, _handle->get_num_rows())); _handle->set_num_rows((std::max)(write_row + 1, _handle->get_num_rows()));
} }
set_pointer(write_row); set_pointer(write_row);

View File

@ -55,7 +55,7 @@ INLINE ParamTextureImage::
ParamTextureImage(Texture *tex, bool read, bool write, int z, int n) : ParamTextureImage(Texture *tex, bool read, bool write, int z, int n) :
_texture(tex), _texture(tex),
_access(0), _access(0),
_bind_level(std::min(n, 127)), _bind_level((std::min)(n, 127)),
_bind_layer(z) _bind_layer(z)
{ {
if (read) { if (read) {

View File

@ -122,7 +122,7 @@ mark_loaded() {
// _data_size_bytes = _data->get_texture_size_bytes(); // _data_size_bytes = _data->get_texture_size_bytes();
_properties_modified = get_texture()->get_properties_modified(); _properties_modified = get_texture()->get_properties_modified();
_image_modified = get_texture()->get_image_modified(); _image_modified = get_texture()->get_image_modified();
update_modified(std::max(_properties_modified, _image_modified)); update_modified((std::max)(_properties_modified, _image_modified));
// Assume the texture is now resident. // Assume the texture is now resident.
set_resident(true); set_resident(true);
@ -136,7 +136,7 @@ INLINE void TextureContext::
mark_simple_loaded() { mark_simple_loaded() {
_properties_modified = get_texture()->get_properties_modified(); _properties_modified = get_texture()->get_properties_modified();
_simple_image_modified = get_texture()->get_simple_image_modified(); _simple_image_modified = get_texture()->get_simple_image_modified();
update_modified(std::max(_properties_modified, _simple_image_modified)); update_modified((std::max)(_properties_modified, _simple_image_modified));
// The texture's not exactly resident now, but some part of it is. // The texture's not exactly resident now, but some part of it is.
set_resident(true); set_resident(true);

View File

@ -479,8 +479,8 @@ get_border_stitching() {
*/ */
INLINE double GeoMipTerrain:: INLINE double GeoMipTerrain::
get_pixel_value(int x, int y) { get_pixel_value(int x, int y) {
x = std::max(std::min(x,int(_xsize-1)),0); x = (std::max)((std::min)(x,int(_xsize-1)),0);
y = std::max(std::min(y,int(_ysize-1)),0); y = (std::max)((std::min)(y,int(_ysize-1)),0);
if (_heightfield.is_grayscale()) { if (_heightfield.is_grayscale()) {
return double(_heightfield.get_bright(x, y)); return double(_heightfield.get_bright(x, y));
} else { } else {

View File

@ -183,10 +183,10 @@ angle_rad(const FLOATNAME(LVector3) &other) const {
// poorly as dot(other) approaches 1.0. // poorly as dot(other) approaches 1.0.
if (dot(other) < 0.0f) { if (dot(other) < 0.0f) {
FLOATTYPE a = ((*this)+other).length() / 2.0f; FLOATTYPE a = ((*this)+other).length() / 2.0f;
return MathNumbers::cpi((FLOATTYPE)0.0f) - 2.0f * casin(std::min(a, (FLOATTYPE)1.0)); return MathNumbers::cpi((FLOATTYPE)0.0f) - 2.0f * casin((std::min)(a, (FLOATTYPE)1.0));
} else { } else {
FLOATTYPE a = ((*this)-other).length() / 2.0f; FLOATTYPE a = ((*this)-other).length() / 2.0f;
return 2.0f * casin(std::min(a, (FLOATTYPE)1.0)); return 2.0f * casin((std::min)(a, (FLOATTYPE)1.0));
} }
} }

View File

@ -110,5 +110,5 @@ scale_t(int segment, PN_stdfloat t) const {
PN_stdfloat from = _segments[segment]._from; PN_stdfloat from = _segments[segment]._from;
PN_stdfloat to = _segments[segment]._to; PN_stdfloat to = _segments[segment]._to;
t = (t - from) / (to - from); t = (t - from) / (to - from);
return std::min(std::max(t, (PN_stdfloat)0.0), (PN_stdfloat)1.0); return (std::min)((std::max)(t, (PN_stdfloat)0.0), (PN_stdfloat)1.0);
} }

View File

@ -42,7 +42,7 @@ get_curve(int index) const {
*/ */
INLINE void ParametricCurveCollection:: INLINE void ParametricCurveCollection::
add_curve(ParametricCurve *curve, int index) { add_curve(ParametricCurve *curve, int index) {
insert_curve(std::max(index, 0), curve); insert_curve((std::max)(index, 0), curve);
} }
/** /**

View File

@ -97,7 +97,7 @@ get_cur_alpha(BaseParticle* bp) {
return bp->get_parameterized_age(); return bp->get_parameterized_age();
case PR_ALPHA_IN_OUT: case PR_ALPHA_IN_OUT:
return 2.0 * std::min(bp->get_parameterized_age(), return 2.0 * (std::min)(bp->get_parameterized_age(),
1.0f - bp->get_parameterized_age()); 1.0f - bp->get_parameterized_age());
case PR_ALPHA_USER: case PR_ALPHA_USER:

View File

@ -558,7 +558,7 @@ set_wtext(const std::wstring &wtext) {
update_text(); update_text();
} }
#endif #endif
set_cursor_position(std::min(_cursor_position, _text.get_num_characters())); set_cursor_position((std::min)(_cursor_position, _text.get_num_characters()));
return ret; return ret;
} }

View File

@ -381,7 +381,7 @@ get_adjust_event() const {
*/ */
INLINE void PGSliderBar:: INLINE void PGSliderBar::
internal_set_ratio(PN_stdfloat ratio) { internal_set_ratio(PN_stdfloat ratio) {
_ratio = std::max(std::min(ratio, (PN_stdfloat)1.0), (PN_stdfloat)0.0); _ratio = (std::max)((std::min)(ratio, (PN_stdfloat)1.0), (PN_stdfloat)0.0);
_needs_reposition = true; _needs_reposition = true;
adjust(); adjust();
} }

View File

@ -27,7 +27,7 @@ get_render_pipeline() {
*/ */
INLINE void Pipeline:: INLINE void Pipeline::
set_min_stages(int min_stages) { set_min_stages(int min_stages) {
set_num_stages(std::max(min_stages, get_num_stages())); set_num_stages((std::max)(min_stages, get_num_stages()));
} }
/** /**

View File

@ -75,7 +75,7 @@ get_pipeline_stage() const {
*/ */
INLINE void Thread:: INLINE void Thread::
set_min_pipeline_stage(int min_pipeline_stage) { set_min_pipeline_stage(int min_pipeline_stage) {
set_pipeline_stage(std::max(_pipeline_stage, min_pipeline_stage)); set_pipeline_stage((std::max)(_pipeline_stage, min_pipeline_stage));
} }
/** /**

View File

@ -44,8 +44,8 @@ INLINE unsigned char decode_sRGB_uchar(unsigned char val) {
*/ */
INLINE unsigned char decode_sRGB_uchar(float val) { INLINE unsigned char decode_sRGB_uchar(float val) {
return (val <= 0.04045f) return (val <= 0.04045f)
? (unsigned char)(std::max(0.f, val) * (255.f / 12.92f) + 0.5f) ? (unsigned char)((std::max)(0.f, val) * (255.f / 12.92f) + 0.5f)
: (unsigned char)(cpow((std::min(val, 1.f) + 0.055f) * (1.f / 1.055f), 2.4f) * 255.f + 0.5f); : (unsigned char)(cpow(((std::min)(val, 1.f) + 0.055f) * (1.f / 1.055f), 2.4f) * 255.f + 0.5f);
} }
/** /**
@ -99,8 +99,8 @@ encode_sRGB_uchar(float val) {
return encode_sRGB_uchar_sse2(val); return encode_sRGB_uchar_sse2(val);
#else #else
return (val < 0.0031308f) return (val < 0.0031308f)
? (unsigned char) (std::max(0.f, val) * 3294.6f + 0.5f) ? (unsigned char) ((std::max)(0.f, val) * 3294.6f + 0.5f)
: (unsigned char) (269.025f * cpow(std::min(val, 1.f), 0.41666f) - 13.525f); : (unsigned char) (269.025f * cpow((std::min)(val, 1.f), 0.41666f) - 13.525f);
#endif #endif
} }

View File

@ -587,12 +587,12 @@ setup_sub_image(const PfmFile &copy, int &xto, int &yto,
yto = 0; yto = 0;
} }
x_size = std::min(x_size, copy.get_x_size() - xfrom); x_size = (std::min)(x_size, copy.get_x_size() - xfrom);
y_size = std::min(y_size, copy.get_y_size() - yfrom); y_size = (std::min)(y_size, copy.get_y_size() - yfrom);
xmin = xto; xmin = xto;
ymin = yto; ymin = yto;
xmax = std::min(xmin + x_size, get_x_size()); xmax = (std::min)(xmin + x_size, get_x_size());
ymax = std::min(ymin + y_size, get_y_size()); ymax = (std::min)(ymin + y_size, get_y_size());
} }

View File

@ -68,7 +68,7 @@ INLINE PNMImage::
*/ */
INLINE xelval PNMImage:: INLINE xelval PNMImage::
clamp_val(int input_value) const { clamp_val(int input_value) const {
return (xelval)std::min(std::max(0, input_value), (int)get_maxval()); return (xelval)(std::min)((std::max)(0, input_value), (int)get_maxval());
} }
/** /**
@ -113,9 +113,9 @@ to_val(const LRGBColorf &value) const {
case XE_scRGB_alpha: case XE_scRGB_alpha:
{ {
LRGBColorf scaled = value * 8192.f + 4096.5f; LRGBColorf scaled = value * 8192.f + 4096.5f;
col.r = std::min(std::max(0, (int)scaled[0]), 65535); col.r = (std::min)((std::max)(0, (int)scaled[0]), 65535);
col.g = std::min(std::max(0, (int)scaled[1]), 65535); col.g = (std::min)((std::max)(0, (int)scaled[1]), 65535);
col.b = std::min(std::max(0, (int)scaled[2]), 65535); col.b = (std::min)((std::max)(0, (int)scaled[2]), 65535);
} }
break; break;
} }
@ -131,7 +131,7 @@ to_val(float input_value) const {
switch (_xel_encoding) { switch (_xel_encoding) {
case XE_generic: case XE_generic:
case XE_generic_alpha: case XE_generic_alpha:
return (int)(std::min(1.0f, std::max(0.0f, input_value)) * get_maxval() + 0.5f); return (int)((std::min)(1.0f, (std::max)(0.0f, input_value)) * get_maxval() + 0.5f);
case XE_generic_sRGB: case XE_generic_sRGB:
case XE_generic_sRGB_alpha: case XE_generic_sRGB_alpha:
@ -148,7 +148,7 @@ to_val(float input_value) const {
case XE_scRGB: case XE_scRGB:
case XE_scRGB_alpha: case XE_scRGB_alpha:
return std::min(std::max(0, (int)((8192 * input_value) + 4096.5f)), 65535); return (std::min)((std::max)(0, (int)((8192 * input_value) + 4096.5f)), 65535);
default: default:
return 0; return 0;
@ -210,7 +210,7 @@ from_val(xelval input_value) const {
switch (_xel_encoding) { switch (_xel_encoding) {
case XE_generic: case XE_generic:
case XE_generic_alpha: case XE_generic_alpha:
return std::min((float)input_value * _inv_maxval, 1.0f); return (std::min)((float)input_value * _inv_maxval, 1.0f);
case XE_generic_sRGB: case XE_generic_sRGB:
case XE_generic_sRGB_alpha: case XE_generic_sRGB_alpha:
@ -735,19 +735,19 @@ set_xel_a(int x, int y, const LColorf &value) {
case XE_scRGB: case XE_scRGB:
{ {
LColorf scaled = value * 8192.0f + 4096.5f; LColorf scaled = value * 8192.0f + 4096.5f;
col.r = std::min(std::max(0, (int)scaled[0]), 65535); col.r = (std::min)((std::max)(0, (int)scaled[0]), 65535);
col.g = std::min(std::max(0, (int)scaled[1]), 65535); col.g = (std::min)((std::max)(0, (int)scaled[1]), 65535);
col.b = std::min(std::max(0, (int)scaled[2]), 65535); col.b = (std::min)((std::max)(0, (int)scaled[2]), 65535);
} }
break; break;
case XE_scRGB_alpha: case XE_scRGB_alpha:
{ {
LColorf scaled = value * 8192.0f + 4096.5f; LColorf scaled = value * 8192.0f + 4096.5f;
col.r = std::min(std::max(0, (int)scaled[0]), 65535); col.r = (std::min)((std::max)(0, (int)scaled[0]), 65535);
col.g = std::min(std::max(0, (int)scaled[1]), 65535); col.g = (std::min)((std::max)(0, (int)scaled[1]), 65535);
col.b = std::min(std::max(0, (int)scaled[2]), 65535); col.b = (std::min)((std::max)(0, (int)scaled[2]), 65535);
alpha_row(y)[x] = std::min(std::max(0, (int)(value[3] * 65535 + 0.5f)), 65535); alpha_row(y)[x] = (std::min)((std::max)(0, (int)(value[3] * 65535 + 0.5f)), 65535);
} }
break; break;
} }
@ -1224,14 +1224,14 @@ setup_sub_image(const PNMImage &copy, int &xto, int &yto,
yto = 0; yto = 0;
} }
x_size = std::min(x_size, copy.get_x_size() - xfrom); x_size = (std::min)(x_size, copy.get_x_size() - xfrom);
y_size = std::min(y_size, copy.get_y_size() - yfrom); y_size = (std::min)(y_size, copy.get_y_size() - yfrom);
xmin = xto; xmin = xto;
ymin = yto; ymin = yto;
xmax = std::min(xmin + x_size, get_x_size()); xmax = (std::min)(xmin + x_size, get_x_size());
ymax = std::min(ymin + y_size, get_y_size()); ymax = (std::min)(ymin + y_size, get_y_size());
} }
/** /**

View File

@ -110,7 +110,7 @@ INLINE double ClockObject::
get_dt(Thread *current_thread) const { get_dt(Thread *current_thread) const {
CDReader cdata(_cycler, current_thread); CDReader cdata(_cycler, current_thread);
if (_max_dt > 0.0) { if (_max_dt > 0.0) {
return std::min(_max_dt, cdata->_dt); return (std::min)(_max_dt, cdata->_dt);
} }
return cdata->_dt; return cdata->_dt;
} }