diff options
author | Mike Erwin <significant.bit@gmail.com> | 2016-07-22 01:52:44 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2016-07-22 01:52:44 +0300 |
commit | 08e1bba10c17fb0733b1795447f6c95a4318bdca (patch) | |
tree | e322cff3d9b041e50030187e9a97e70674ffb499 /source/blender/blenfont | |
parent | 9ff8d4a9578619786a39abfd40174e227df38152 (diff) |
fix confusing operator precedence
Assigning within a conditional is confusing and error prone so I
rewrote in a more straightforward way.
Found with PVS-Studio T48917
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index dfebaecb96e..44a1d08f1fd 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -370,12 +370,10 @@ static void blf_font_draw_buffer_ex( fbuf[3] = 1.0f; } else { - float alphatest; fbuf[0] = (b_col_float[0] * a) + (fbuf[0] * (1.0f - a)); fbuf[1] = (b_col_float[1] * a) + (fbuf[1] * (1.0f - a)); fbuf[2] = (b_col_float[2] * a) + (fbuf[2] * (1.0f - a)); - fbuf[3] = (alphatest = (fbuf[3] + a)) < 1.0f ? - alphatest : 1.0f; + fbuf[3] = MIN2(fbuf[3] + a, 1.0f); /* clamp to 1.0 */ } } } @@ -407,12 +405,10 @@ static void blf_font_draw_buffer_ex( cbuf[3] = 255; } else { - int alphatest; 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] = (unsigned char)(((alphatest = ((int)cbuf[3] + (int)(a * 255))) < 255) ? - alphatest : 255); + cbuf[3] = (unsigned char)MIN2((int)cbuf[3] + (int)(a * 255), 255); /* clamp to 255 */ } } } |