(gfx_display.c) Do early returns before computing a bunch of stuff
This commit is contained in:
parent
cd469d3fb2
commit
079c2dadff
|
@ -695,15 +695,17 @@ void gfx_display_draw_quad(
|
|||
unsigned width, unsigned height,
|
||||
float *color)
|
||||
{
|
||||
gfx_display_ctx_draw_t draw;
|
||||
struct video_coords coords;
|
||||
gfx_display_t
|
||||
*p_disp = disp_get_ptr();
|
||||
gfx_display_ctx_driver_t
|
||||
*dispctx = p_disp->dispctx;
|
||||
|
||||
if (dispctx)
|
||||
{
|
||||
gfx_display_ctx_draw_t draw;
|
||||
struct video_coords coords;
|
||||
if (w == 0 || h == 0)
|
||||
return;
|
||||
if (!dispctx)
|
||||
return;
|
||||
|
||||
coords.vertices = 4;
|
||||
coords.vertex = NULL;
|
||||
|
@ -723,8 +725,6 @@ void gfx_display_draw_quad(
|
|||
draw.scale_factor = 1.0f;
|
||||
draw.rotation = 0.0f;
|
||||
|
||||
if (draw.height > 0 && draw.width > 0)
|
||||
{
|
||||
if (dispctx->blend_begin)
|
||||
dispctx->blend_begin(data);
|
||||
if (dispctx->draw)
|
||||
|
@ -732,8 +732,6 @@ void gfx_display_draw_quad(
|
|||
if (dispctx->blend_end)
|
||||
dispctx->blend_end(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gfx_display_draw_polygon(
|
||||
void *userdata,
|
||||
|
@ -749,6 +747,9 @@ void gfx_display_draw_polygon(
|
|||
gfx_display_t *p_disp = disp_get_ptr();
|
||||
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
|
||||
|
||||
if (width == 0 || height == 0)
|
||||
return;
|
||||
|
||||
if (dispctx)
|
||||
{
|
||||
float vertex[8];
|
||||
|
@ -781,8 +782,6 @@ void gfx_display_draw_polygon(
|
|||
draw.scale_factor = 1.0f;
|
||||
draw.rotation = 0.0f;
|
||||
|
||||
if (draw.height > 0 && draw.width > 0)
|
||||
{
|
||||
if (dispctx->blend_begin)
|
||||
dispctx->blend_begin(userdata);
|
||||
if (dispctx->draw)
|
||||
|
@ -791,7 +790,6 @@ void gfx_display_draw_polygon(
|
|||
dispctx->blend_end(userdata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void gfx_display_draw_texture(
|
||||
gfx_display_t *p_disp,
|
||||
|
@ -805,6 +803,11 @@ static void gfx_display_draw_texture(
|
|||
gfx_display_ctx_draw_t *draw
|
||||
)
|
||||
{
|
||||
if (w == 0 || h == 0)
|
||||
return;
|
||||
if (!dispctx || !dispctx->draw)
|
||||
return;
|
||||
|
||||
draw->width = w;
|
||||
draw->height = h;
|
||||
draw->prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP;
|
||||
|
@ -813,8 +816,6 @@ static void gfx_display_draw_texture(
|
|||
draw->x = x;
|
||||
draw->y = height - y;
|
||||
|
||||
if (dispctx && dispctx->draw)
|
||||
if (draw->width > 0 && draw->height > 0)
|
||||
dispctx->draw(draw, userdata, video_width, video_height);
|
||||
}
|
||||
|
||||
|
@ -909,6 +910,11 @@ void gfx_display_draw_texture_slice(
|
|||
float norm_x = x / (float)width;
|
||||
float norm_y = (height - y) / (float)height;
|
||||
|
||||
if (width == 0 || height == 0)
|
||||
return;
|
||||
if (!dispctx || !dispctx->draw)
|
||||
return;
|
||||
|
||||
/* the four vertices of the top-left corner of the image,
|
||||
* used as a starting point for all the other sections */
|
||||
V_BL[0] = norm_x;
|
||||
|
@ -977,8 +983,6 @@ void gfx_display_draw_texture_slice(
|
|||
tex_coord[6] = T_TR[0];
|
||||
tex_coord[7] = T_TR[1];
|
||||
|
||||
if (dispctx && dispctx->draw)
|
||||
if (draw.width > 0 && draw.height > 0)
|
||||
dispctx->draw(&draw, userdata, video_width, video_height);
|
||||
|
||||
/* top-middle section */
|
||||
|
@ -1000,8 +1004,6 @@ void gfx_display_draw_texture_slice(
|
|||
tex_coord[6] = T_TR[0] + tex_mid_width;
|
||||
tex_coord[7] = T_TR[1];
|
||||
|
||||
if (dispctx && dispctx->draw)
|
||||
if (draw.width > 0 && draw.height > 0)
|
||||
dispctx->draw(&draw, userdata, video_width, video_height);
|
||||
|
||||
/* top-right corner */
|
||||
|
@ -1023,8 +1025,6 @@ void gfx_display_draw_texture_slice(
|
|||
tex_coord[6] = T_TR[0] + tex_mid_width + tex_woff;
|
||||
tex_coord[7] = T_TR[1];
|
||||
|
||||
if (dispctx && dispctx->draw)
|
||||
if (draw.width > 0 && draw.height > 0)
|
||||
dispctx->draw(&draw, userdata, video_width, video_height);
|
||||
|
||||
/* middle-left section */
|
||||
|
@ -1046,8 +1046,6 @@ void gfx_display_draw_texture_slice(
|
|||
tex_coord[6] = T_TR[0];
|
||||
tex_coord[7] = T_TR[1] + tex_hoff;
|
||||
|
||||
if (dispctx && dispctx->draw)
|
||||
if (draw.width > 0 && draw.height > 0)
|
||||
dispctx->draw(&draw, userdata, video_width, video_height);
|
||||
|
||||
/* center section */
|
||||
|
@ -1069,8 +1067,6 @@ void gfx_display_draw_texture_slice(
|
|||
tex_coord[6] = T_TR[0] + tex_mid_width;
|
||||
tex_coord[7] = T_TR[1] + tex_hoff;
|
||||
|
||||
if (dispctx && dispctx->draw)
|
||||
if (draw.width > 0 && draw.height > 0)
|
||||
dispctx->draw(&draw, userdata, video_width, video_height);
|
||||
|
||||
/* middle-right section */
|
||||
|
@ -1092,8 +1088,6 @@ void gfx_display_draw_texture_slice(
|
|||
tex_coord[6] = T_TR[0] + tex_woff + tex_mid_width;
|
||||
tex_coord[7] = T_TR[1] + tex_hoff;
|
||||
|
||||
if (dispctx && dispctx->draw)
|
||||
if (draw.width > 0 && draw.height > 0)
|
||||
dispctx->draw(&draw, userdata, video_width, video_height);
|
||||
|
||||
/* bottom-left corner */
|
||||
|
@ -1115,8 +1109,6 @@ void gfx_display_draw_texture_slice(
|
|||
tex_coord[6] = T_TR[0];
|
||||
tex_coord[7] = T_TR[1] + tex_hoff + tex_mid_height;
|
||||
|
||||
if (dispctx && dispctx->draw)
|
||||
if (draw.width > 0 && draw.height > 0)
|
||||
dispctx->draw(&draw, userdata, video_width, video_height);
|
||||
|
||||
/* bottom-middle section */
|
||||
|
@ -1138,8 +1130,6 @@ void gfx_display_draw_texture_slice(
|
|||
tex_coord[6] = T_TR[0] + tex_mid_width;
|
||||
tex_coord[7] = T_TR[1] + tex_hoff + tex_mid_height;
|
||||
|
||||
if (dispctx && dispctx->draw)
|
||||
if (draw.width > 0 && draw.height > 0)
|
||||
dispctx->draw(&draw, userdata, video_width, video_height);
|
||||
|
||||
/* bottom-right corner */
|
||||
|
@ -1161,8 +1151,6 @@ void gfx_display_draw_texture_slice(
|
|||
tex_coord[6] = T_TR[0] + tex_woff + tex_mid_width;
|
||||
tex_coord[7] = T_TR[1] + tex_hoff + tex_mid_height;
|
||||
|
||||
if (dispctx && dispctx->draw)
|
||||
if (draw.width > 0 && draw.height > 0)
|
||||
dispctx->draw(&draw, userdata, video_width, video_height);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue