diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-09 20:37:31 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-09 20:55:10 +0300 |
commit | 427c75e4c20b38611d213ca26681a5691be5d6a6 (patch) | |
tree | 9bf3ee3f22e7329c62afd574800a7e4b976e8607 /source/blender/editors | |
parent | 42b462ddd77cb73ad4f39152fc5213c43bbf2d37 (diff) |
Cleanup: avoid some floating point divisions in drawing code
Diffstat (limited to 'source/blender/editors')
5 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index baa782dcb35..6bdbd3c4f1c 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -2240,12 +2240,12 @@ int UI_idcode_icon_get(const int idcode) /* draws icon with dpi scale factor */ void UI_icon_draw(float x, float y, int icon_id) { - UI_icon_draw_ex(x, y, icon_id, 1.0f / UI_DPI_FAC, 1.0f, 0.0f, NULL, false); + UI_icon_draw_ex(x, y, icon_id, U.inv_dpi_fac, 1.0f, 0.0f, NULL, false); } void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha) { - UI_icon_draw_ex(x, y, icon_id, 1.0f / UI_DPI_FAC, alpha, 0.0f, NULL, false); + UI_icon_draw_ex(x, y, icon_id, U.inv_dpi_fac, alpha, 0.0f, NULL, false); } void UI_icon_draw_preview(float x, float y, int icon_id, float aspect, float alpha, int size) diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 724d5aa8cd2..cb2c55a26df 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -768,7 +768,7 @@ void ui_draw_aligned_panel(uiStyle *style, UI_icon_draw_ex(headrect.xmax - ((PNL_ICON * 2.2f) / block->aspect), headrect.ymin + (5.0f / block->aspect), (panel->flag & PNL_PIN) ? ICON_PINNED : ICON_UNPINNED, - (block->aspect / UI_DPI_FAC), + (block->aspect * U.inv_dpi_fac), 1.0f, 0.0f, (const char *)col_title, diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 43efa758492..8724de41e8e 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1450,7 +1450,7 @@ static void widget_draw_icon( return; } - aspect = but->block->aspect / UI_DPI_FAC; + aspect = but->block->aspect * U.inv_dpi_fac; height = ICON_DEFAULT_HEIGHT / aspect; /* calculate blend color */ @@ -1537,7 +1537,7 @@ static void widget_draw_submenu_tria(const uiBut *but, const rcti *rect, const uiWidgetColors *wcol) { - const float aspect = but->block->aspect / UI_DPI_FAC; + const float aspect = but->block->aspect * U.inv_dpi_fac; const int tria_height = (int)(ICON_DEFAULT_HEIGHT / aspect); const int tria_width = (int)(ICON_DEFAULT_WIDTH / aspect) - 2 * U.pixelsize; const int xs = rect->xmax - tria_width; @@ -2357,7 +2357,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, const BIFIconID icon = widget_icon_id(but); int icon_size_init = is_tool ? ICON_DEFAULT_HEIGHT_TOOLBAR : ICON_DEFAULT_HEIGHT; - const float icon_size = icon_size_init / (but->block->aspect / UI_DPI_FAC); + const float icon_size = icon_size_init / (but->block->aspect * U.inv_dpi_fac); const float icon_padding = 2 * UI_DPI_FAC; #ifdef USE_UI_TOOLBAR_HACK diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 322b798057e..b359a4c4440 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -203,7 +203,7 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f alpha = min_ff(alpha, 0.75f); - UI_icon_draw_ex(x, y, ICON_FULLSCREEN_EXIT, 0.7f / UI_DPI_FAC, 0.0f, alpha, NULL, false); + UI_icon_draw_ex(x, y, ICON_FULLSCREEN_EXIT, 0.7f * U.inv_dpi_fac, 0.0f, alpha, NULL, false); /* debug drawing : * The click_rect is the same as defined in fullscreen_click_rcti_init diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 042cbfdaf8d..10b248de21d 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1803,10 +1803,10 @@ static void tselem_draw_icon(uiBlock *block, * doesn't work for buttons */ char color[4]; if (UI_icon_get_theme_color(data.icon, (uchar *)color)) { - UI_icon_draw_ex(x, y, data.icon, 1.0f / UI_DPI_FAC, alpha, 0.0f, color, true); + UI_icon_draw_ex(x, y, data.icon, U.inv_dpi_fac, alpha, 0.0f, color, true); } else { - UI_icon_draw_ex(x, y, data.icon, 1.0f / UI_DPI_FAC, alpha, 0.0f, NULL, false); + UI_icon_draw_ex(x, y, data.icon, U.inv_dpi_fac, alpha, 0.0f, NULL, false); } } else { |