avoid calling glGetFloatv() twice when UI_RB_ALPHA is enabled with uiRoundBox()

This commit is contained in:
Campbell Barton 2013-03-07 06:46:50 +00:00
parent dfa8540cdf
commit a816b0b3d2
3 changed files with 6 additions and 12 deletions

View File

@ -381,16 +381,7 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad)
/* (old, used in outliner) plain antialiased filled box */
void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad)
{
float color[4];
if (roundboxtype & UI_RB_ALPHA) {
glGetFloatv(GL_CURRENT_COLOR, color);
color[3] = 0.5;
glColor4fv(color);
glEnable(GL_BLEND);
}
ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad);
ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad, roundboxtype & UI_RB_ALPHA);
}

View File

@ -522,7 +522,7 @@ extern void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiB
/* interface_widgets.c */
void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad);
void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad, bool use_alpha);
void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
uiWidgetColors *ui_tooltip_get_theme(void);
void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock * block, rcti * rect);

View File

@ -218,13 +218,16 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y
glDisable(GL_BLEND);
}
void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad)
void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad, bool use_alpha)
{
float color[4];
int j;
glEnable(GL_BLEND);
glGetFloatv(GL_CURRENT_COLOR, color);
if (use_alpha) {
color[3] = 0.5f;
}
color[3] *= 0.125f;
glColor4fv(color);