diff options
author | Campbell Barton <campbell@blender.org> | 2022-08-18 07:45:47 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-08-18 07:45:47 +0300 |
commit | fcd72756abb7912669feb2dbcda9a647d1537d43 (patch) | |
tree | 5aed0a437001464c52bd6b84731be356491e0c68 /source/blender/windowmanager/intern/wm_splash_screen.c | |
parent | f5234474bde953356c72633bd05a1c6c9f747758 (diff) |
Cleanup: early return, reduce right-shift
Diffstat (limited to 'source/blender/windowmanager/intern/wm_splash_screen.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_splash_screen.c | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/source/blender/windowmanager/intern/wm_splash_screen.c b/source/blender/windowmanager/intern/wm_splash_screen.c index 2e04a629308..8fca3deef92 100644 --- a/source/blender/windowmanager/intern/wm_splash_screen.c +++ b/source/blender/windowmanager/intern/wm_splash_screen.c @@ -78,50 +78,51 @@ static void wm_block_splash_add_label(uiBlock *block, const char *label, int x, static void wm_block_splash_image_roundcorners_add(ImBuf *ibuf) { uchar *rct = (uchar *)ibuf->rect; + if (!rct) { + return; + } - if (rct) { - bTheme *btheme = UI_GetTheme(); - const float roundness = btheme->tui.wcol_menu_back.roundness * U.dpi_fac; - const int size = roundness * 20; - - if (size < ibuf->x && size < ibuf->y) { - /* Y-axis initial offset. */ - rct += 4 * (ibuf->y - size) * ibuf->x; - - for (int y = 0; y < size; y++) { - for (int x = 0; x < size; x++, rct += 4) { - const float pixel = 1.0 / size; - const float u = pixel * x; - const float v = pixel * y; - const float distance = sqrt(u * u + v * v); - - /* Pointer offset to the alpha value of pixel. */ - /* NOTE: the left corner is flipped in the X-axis. */ - const int offset_l = 4 * (size - x - x - 1) + 3; - const int offset_r = 4 * (ibuf->x - size) + 3; - - if (distance > 1.0) { - rct[offset_l] = 0; - rct[offset_r] = 0; - } - else { - /* Create a single pixel wide transition for anti-aliasing. - * Invert the distance and map its range [0, 1] to [0, pixel]. */ - const float fac = (1.0 - distance) * size; - - if (fac > 1.0) { - continue; - } - - const uchar alpha = unit_float_to_uchar_clamp(fac); - rct[offset_l] = alpha; - rct[offset_r] = alpha; - } + bTheme *btheme = UI_GetTheme(); + const float roundness = btheme->tui.wcol_menu_back.roundness * U.dpi_fac; + const int size = roundness * 20; + + if (size < ibuf->x && size < ibuf->y) { + /* Y-axis initial offset. */ + rct += 4 * (ibuf->y - size) * ibuf->x; + + for (int y = 0; y < size; y++) { + for (int x = 0; x < size; x++, rct += 4) { + const float pixel = 1.0 / size; + const float u = pixel * x; + const float v = pixel * y; + const float distance = sqrt(u * u + v * v); + + /* Pointer offset to the alpha value of pixel. */ + /* NOTE: the left corner is flipped in the X-axis. */ + const int offset_l = 4 * (size - x - x - 1) + 3; + const int offset_r = 4 * (ibuf->x - size) + 3; + + if (distance > 1.0) { + rct[offset_l] = 0; + rct[offset_r] = 0; } + else { + /* Create a single pixel wide transition for anti-aliasing. + * Invert the distance and map its range [0, 1] to [0, pixel]. */ + const float fac = (1.0 - distance) * size; - /* X-axis offset to the next row. */ - rct += 4 * (ibuf->x - size); + if (fac > 1.0) { + continue; + } + + const uchar alpha = unit_float_to_uchar_clamp(fac); + rct[offset_l] = alpha; + rct[offset_r] = alpha; + } } + + /* X-axis offset to the next row. */ + rct += 4 * (ibuf->x - size); } } } |