diff options
author | Joshua Leung <aligorith@gmail.com> | 2013-09-01 09:36:29 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2013-09-01 09:36:29 +0400 |
commit | 7176cbf466a49d78d3777595b2c6435ffa168df1 (patch) | |
tree | dedb4e6ea7670f6dd9f7c44aebf1f309f8bf2366 | |
parent | 33c68846de10c53c56eba3a6f5ce7f8d52ddb735 (diff) |
Mingw Compiling Fix - Conversion from int to unsigned char...
Apparently mingw/gcc is too stupid to recognise that the values
in alphatest will only be used if they're within the range of
unsigned char (i.e. 0 <= x < 255) when this is done using a ternary
operator. Then again, it's quite hard for humans to immediately
parse what is going on here either! Converting this clever code
back to a more obvious form that mere mortals (and compilers it
seems) can handle with ease ;)
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index c7f829a3a42..d46df829295 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -376,15 +376,27 @@ void blf_font_buffer(FontBLF *font, const char *str) cbuf[0] = b_col_char[0]; cbuf[1] = b_col_char[1]; cbuf[2] = b_col_char[2]; - cbuf[3] = (alphatest = ((int)cbuf[3] + (int)b_col_char[3])) < 255 ? - (unsigned char)(alphatest) : 255; + + alphatest = (int)cbuf[3] + (int)b_col_char[3]; + if (alphatest < 255) { + cbuf[3] = (unsigned char)(alphatest); + } + else { + cbuf[3] = 255; + } } else { cbuf[0] = (unsigned char)((b_col_char[0] * a) + (cbuf[0] * (1.0f - a))); cbuf[1] = (unsigned char)((b_col_char[1] * a) + (cbuf[1] * (1.0f - a))); cbuf[2] = (unsigned char)((b_col_char[2] * a) + (cbuf[2] * (1.0f - a))); - cbuf[3] = (alphatest = ((int)cbuf[3] + (int)((b_col_float[3] * a) * 255.0f))) < 255 ? - (unsigned char)(alphatest) : 255; + + alphatest = ((int)cbuf[3] + (int)((b_col_float[3] * a) * 255.0f)); + if (alphatest < 255) { + cbuf[3] = (unsigned char)(alphatest); + } + else { + cbuf[3] = 255; + } } } } |