Optimize gfx_display_draw_keyboard
This commit is contained in:
parent
eb0376fe7d
commit
8c440ef72c
|
@ -848,50 +848,29 @@ void gfx_display_draw_polygon(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_display_draw_texture(
|
static void gfx_display_draw_texture(
|
||||||
|
gfx_display_t *p_disp,
|
||||||
|
gfx_display_ctx_driver_t *dispctx,
|
||||||
void *userdata,
|
void *userdata,
|
||||||
unsigned video_width,
|
unsigned video_width,
|
||||||
unsigned video_height,
|
unsigned video_height,
|
||||||
int x, int y, unsigned w, unsigned h,
|
int x, int y, unsigned w, unsigned h,
|
||||||
unsigned width, unsigned height,
|
unsigned width, unsigned height,
|
||||||
float *color, uintptr_t texture)
|
float *color, uintptr_t texture,
|
||||||
|
gfx_display_ctx_draw_t *draw
|
||||||
|
)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_draw_t draw;
|
draw->width = w;
|
||||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
draw->height = h;
|
||||||
struct video_coords coords;
|
draw->prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP;
|
||||||
math_matrix_4x4 mymat;
|
draw->pipeline_id = 0;
|
||||||
gfx_display_t
|
draw->texture = texture;
|
||||||
*p_disp = disp_get_ptr();
|
draw->x = x;
|
||||||
gfx_display_ctx_driver_t
|
draw->y = height - y;
|
||||||
*dispctx = p_disp->dispctx;
|
|
||||||
|
|
||||||
rotate_draw.matrix = &mymat;
|
|
||||||
rotate_draw.rotation = 0.0;
|
|
||||||
rotate_draw.scale_x = 1.0;
|
|
||||||
rotate_draw.scale_y = 1.0;
|
|
||||||
rotate_draw.scale_z = 1;
|
|
||||||
rotate_draw.scale_enable = true;
|
|
||||||
coords.vertices = 4;
|
|
||||||
coords.vertex = NULL;
|
|
||||||
coords.tex_coord = NULL;
|
|
||||||
coords.lut_tex_coord = NULL;
|
|
||||||
draw.width = w;
|
|
||||||
draw.height = h;
|
|
||||||
draw.coords = &coords;
|
|
||||||
draw.matrix_data = &mymat;
|
|
||||||
draw.prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP;
|
|
||||||
draw.pipeline_id = 0;
|
|
||||||
coords.color = (const float*)color;
|
|
||||||
|
|
||||||
gfx_display_rotate_z(&rotate_draw, userdata);
|
|
||||||
|
|
||||||
draw.texture = texture;
|
|
||||||
draw.x = x;
|
|
||||||
draw.y = height - y;
|
|
||||||
|
|
||||||
if (dispctx && dispctx->draw)
|
if (dispctx && dispctx->draw)
|
||||||
if (draw.width > 0 && draw.height > 0)
|
if (draw->width > 0 && draw->height > 0)
|
||||||
dispctx->draw(&draw, userdata, video_width, video_height);
|
dispctx->draw(draw, userdata, video_width, video_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw the texture split into 9 sections, without scaling the corners.
|
/* Draw the texture split into 9 sections, without scaling the corners.
|
||||||
|
@ -1588,6 +1567,22 @@ void gfx_display_draw_keyboard(
|
||||||
0.00, 0.00, 0.00, 0.85,
|
0.00, 0.00, 0.00, 0.85,
|
||||||
0.00, 0.00, 0.00, 0.85,
|
0.00, 0.00, 0.00, 0.85,
|
||||||
};
|
};
|
||||||
|
struct video_coords coords;
|
||||||
|
gfx_display_ctx_draw_t draw;
|
||||||
|
math_matrix_4x4 mymat;
|
||||||
|
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||||
|
rotate_draw.matrix = &mymat;
|
||||||
|
rotate_draw.rotation = 0.0;
|
||||||
|
rotate_draw.scale_x = 1.0;
|
||||||
|
rotate_draw.scale_y = 1.0;
|
||||||
|
rotate_draw.scale_z = 1;
|
||||||
|
rotate_draw.scale_enable = true;
|
||||||
|
|
||||||
|
coords.vertices = 4;
|
||||||
|
coords.vertex = NULL;
|
||||||
|
coords.tex_coord = NULL;
|
||||||
|
coords.lut_tex_coord = NULL;
|
||||||
|
coords.color = (const float*)&white[0];
|
||||||
|
|
||||||
gfx_display_draw_quad(
|
gfx_display_draw_quad(
|
||||||
userdata,
|
userdata,
|
||||||
|
@ -1607,6 +1602,11 @@ void gfx_display_draw_keyboard(
|
||||||
if (ptr_width >= ptr_height)
|
if (ptr_width >= ptr_height)
|
||||||
ptr_width = ptr_height;
|
ptr_width = ptr_height;
|
||||||
|
|
||||||
|
gfx_display_rotate_z(&rotate_draw, userdata);
|
||||||
|
|
||||||
|
draw.coords = &coords;
|
||||||
|
draw.matrix_data = &mymat;
|
||||||
|
|
||||||
for (i = 0; i < 44; i++)
|
for (i = 0; i < 44; i++)
|
||||||
{
|
{
|
||||||
int line_y = (i / 11) * video_height / 10.0;
|
int line_y = (i / 11) * video_height / 10.0;
|
||||||
|
@ -1618,6 +1618,8 @@ void gfx_display_draw_keyboard(
|
||||||
dispctx->blend_begin(userdata);
|
dispctx->blend_begin(userdata);
|
||||||
|
|
||||||
gfx_display_draw_texture(
|
gfx_display_draw_texture(
|
||||||
|
p_disp,
|
||||||
|
dispctx,
|
||||||
userdata,
|
userdata,
|
||||||
video_width,
|
video_width,
|
||||||
video_height,
|
video_height,
|
||||||
|
@ -1628,7 +1630,9 @@ void gfx_display_draw_keyboard(
|
||||||
video_width,
|
video_width,
|
||||||
video_height,
|
video_height,
|
||||||
&white[0],
|
&white[0],
|
||||||
hover_texture);
|
hover_texture,
|
||||||
|
&draw
|
||||||
|
);
|
||||||
|
|
||||||
if (dispctx && dispctx->blend_end)
|
if (dispctx && dispctx->blend_end)
|
||||||
dispctx->blend_end(userdata);
|
dispctx->blend_end(userdata);
|
||||||
|
@ -1649,8 +1653,7 @@ void gfx_display_draw_keyboard(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw text on top of the screen.
|
/* Draw text on top of the screen */
|
||||||
*/
|
|
||||||
void gfx_display_draw_text(
|
void gfx_display_draw_text(
|
||||||
const font_data_t *font, const char *text,
|
const font_data_t *font, const char *text,
|
||||||
float x, float y, int width, int height,
|
float x, float y, int width, int height,
|
||||||
|
|
|
@ -311,14 +311,6 @@ void gfx_display_draw_polygon(
|
||||||
unsigned width, unsigned height,
|
unsigned width, unsigned height,
|
||||||
float *color);
|
float *color);
|
||||||
|
|
||||||
void gfx_display_draw_texture(
|
|
||||||
void *userdata,
|
|
||||||
unsigned video_width,
|
|
||||||
unsigned video_height,
|
|
||||||
int x, int y, unsigned w, unsigned h,
|
|
||||||
unsigned width, unsigned height,
|
|
||||||
float *color, uintptr_t texture);
|
|
||||||
|
|
||||||
void gfx_display_draw_texture_slice(
|
void gfx_display_draw_texture_slice(
|
||||||
void *userdata,
|
void *userdata,
|
||||||
unsigned video_width,
|
unsigned video_width,
|
||||||
|
|
|
@ -684,88 +684,6 @@ static void stripes_messagebox(void *data, const char *message)
|
||||||
stripes->box_message = strdup(message);
|
stripes->box_message = strdup(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stripes_render_keyboard(
|
|
||||||
stripes_handle_t *stripes,
|
|
||||||
void *userdata,
|
|
||||||
unsigned video_width,
|
|
||||||
unsigned video_height,
|
|
||||||
char **grid, unsigned id)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
int ptr_width, ptr_height;
|
|
||||||
float dark[16] = {
|
|
||||||
0.00, 0.00, 0.00, 0.85,
|
|
||||||
0.00, 0.00, 0.00, 0.85,
|
|
||||||
0.00, 0.00, 0.00, 0.85,
|
|
||||||
0.00, 0.00, 0.00, 0.85,
|
|
||||||
};
|
|
||||||
|
|
||||||
float white[16]= {
|
|
||||||
1.00, 1.00, 1.00, 1.00,
|
|
||||||
1.00, 1.00, 1.00, 1.00,
|
|
||||||
1.00, 1.00, 1.00, 1.00,
|
|
||||||
1.00, 1.00, 1.00, 1.00,
|
|
||||||
};
|
|
||||||
gfx_display_t *p_disp = disp_get_ptr();
|
|
||||||
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
|
|
||||||
|
|
||||||
gfx_display_draw_quad(
|
|
||||||
userdata,
|
|
||||||
video_width,
|
|
||||||
video_height,
|
|
||||||
0,
|
|
||||||
video_height / 2.0,
|
|
||||||
video_width,
|
|
||||||
video_height/2.0,
|
|
||||||
video_width,
|
|
||||||
video_height,
|
|
||||||
&dark[0]);
|
|
||||||
|
|
||||||
ptr_width = video_width / 11;
|
|
||||||
ptr_height = video_height / 10;
|
|
||||||
|
|
||||||
if (ptr_width >= ptr_height)
|
|
||||||
ptr_width = ptr_height;
|
|
||||||
|
|
||||||
for (i = 0; i < 44; i++)
|
|
||||||
{
|
|
||||||
int line_y = (i / 11) * video_height / 10.0;
|
|
||||||
|
|
||||||
if (i == id)
|
|
||||||
{
|
|
||||||
uintptr_t texture = stripes->textures.list[STRIPES_TEXTURE_KEY_HOVER];
|
|
||||||
|
|
||||||
if (dispctx && dispctx->blend_begin)
|
|
||||||
dispctx->blend_begin(userdata);
|
|
||||||
|
|
||||||
gfx_display_draw_texture(
|
|
||||||
userdata,
|
|
||||||
video_width,
|
|
||||||
video_height,
|
|
||||||
video_width / 2.0f - (11 * ptr_width) / 2.0f + (i % 11) * ptr_width,
|
|
||||||
video_height / 2.0f + ptr_height * 1.5f + line_y,
|
|
||||||
ptr_width, ptr_height,
|
|
||||||
video_width,
|
|
||||||
video_height,
|
|
||||||
&white[0],
|
|
||||||
texture);
|
|
||||||
|
|
||||||
if (dispctx && dispctx->blend_end)
|
|
||||||
dispctx->blend_end(userdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
gfx_display_draw_text(stripes->font, grid[i],
|
|
||||||
video_width / 2.0f - (11 * ptr_width) / 2.0f + (i % 11) * ptr_width + ptr_width / 2.0f,
|
|
||||||
video_height / 2.0f + ptr_height + line_y + stripes->font->size / 3,
|
|
||||||
video_width,
|
|
||||||
video_height,
|
|
||||||
0xffffffff,
|
|
||||||
TEXT_ALIGN_CENTER,
|
|
||||||
1.0f,
|
|
||||||
false, 0.0f, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Returns the OSK key at a given position */
|
/* Returns the OSK key at a given position */
|
||||||
static int stripes_osk_ptr_at_pos(
|
static int stripes_osk_ptr_at_pos(
|
||||||
void *data,
|
void *data,
|
||||||
|
@ -883,12 +801,15 @@ static void stripes_render_messagebox_internal(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menu_input_dialog_get_display_kb())
|
if (menu_input_dialog_get_display_kb())
|
||||||
stripes_render_keyboard(stripes,
|
gfx_display_draw_keyboard(
|
||||||
userdata,
|
userdata,
|
||||||
video_width,
|
video_width,
|
||||||
video_height,
|
video_height,
|
||||||
|
stripes->textures.list[STRIPES_TEXTURE_KEY_HOVER],
|
||||||
|
stripes->font,
|
||||||
input_event_get_osk_grid(),
|
input_event_get_osk_grid(),
|
||||||
input_event_get_osk_ptr());
|
input_event_get_osk_ptr(),
|
||||||
|
0xffffffff);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
string_list_free(list);
|
string_list_free(list);
|
||||||
|
|
Loading…
Reference in New Issue