(XMB/Zarch) Use same coord array for XMB/Zarch

This commit is contained in:
twinaphex 2016-04-19 07:17:17 +02:00
parent 03de4a0b35
commit ee639d8b20
4 changed files with 51 additions and 37 deletions

View File

@ -49,7 +49,7 @@
#include "../../tasks/tasks_internal.h"
#if 0
#if 1
#define XMB_RIBBON_ENABLE
#define XMB_RIBBON_ROWS 16
#define XMB_RIBBON_COLS 32
@ -142,7 +142,6 @@ enum
typedef struct xmb_handle
{
gfx_coord_array_t ribbon_coords;
file_list_t *menu_stack_old;
file_list_t *selection_buf_old;
file_list_t *horizontal_list;
@ -1907,6 +1906,9 @@ static void xmb_draw_ribbon(xmb_handle_t *xmb, menu_display_ctx_draw_t *draw)
1, 1, 1, 1,
1, 1, 1, 1,
};
gfx_coord_array_t *ca = NULL;
menu_display_ctl(MENU_DISPLAY_CTL_COORDS_ARRAY_GET, &ca);
if (menu_display_ctl(MENU_DISPLAY_CTL_LIBRETRO_RUNNING, NULL))
draw->handle_alpha = 0.75;
@ -1917,7 +1919,7 @@ static void xmb_draw_ribbon(xmb_handle_t *xmb, menu_display_ctx_draw_t *draw)
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL);
coords.vertex = xmb->ribbon_coords.coords.vertex;
coords.vertex = ca->coords.vertex;
coords.index = ribbon_idx;
coords.color = white;
@ -2335,8 +2337,9 @@ static void xmb_init_ribbon(xmb_handle_t * xmb)
unsigned r, c;
unsigned i = 0;
float white[XMB_RIBBON_VERTICES*4] = { 1.0f };
gfx_coord_array_t *ca = NULL;
xmb->ribbon_coords.allocated = 0;
menu_display_ctl(MENU_DISPLAY_CTL_COORDS_ARRAY_GET, &ca);
/* Set up vertices */
for (r = 0; r < XMB_RIBBON_ROWS; ++r)
@ -2358,7 +2361,7 @@ static void xmb_init_ribbon(xmb_handle_t * xmb)
coords.lut_tex_coord = coord_draw.ptr;
coords.vertices = XMB_RIBBON_VERTICES;
gfx_coord_array_append(&xmb->ribbon_coords, &coords, XMB_RIBBON_VERTICES);
gfx_coord_array_append(ca, &coords, XMB_RIBBON_VERTICES);
for (r = 0; r < XMB_RIBBON_ROWS - 1; ++r)
{
@ -2466,9 +2469,6 @@ static void xmb_free(void *data)
file_list_free(xmb->horizontal_list);
xmb->horizontal_list = NULL;
#ifdef XMB_ENABLE_RIBBON
gfx_coord_array_free(&xmb->ribbon_coords);
#endif
gfx_coord_array_free(&xmb->raster_block.carr);
}

View File

@ -115,8 +115,6 @@ typedef struct zarch_handle
unsigned hot;
} item;
gfx_coord_array_t ca;
struct
{
int wheel;
@ -322,7 +320,7 @@ static bool zarch_zui_button_full(zui_t *zui,
if (zui->item.active == id || zui->item.hot == id)
bg = zui_bg_hilite;
menu_display_push_quad(&zui->ca, zui->width, zui->height, bg, x1, y1, x2, y2);
menu_display_push_quad(zui->width, zui->height, bg, x1, y1, x2, y2);
zarch_zui_draw_text(zui, ZUI_FG_NORMAL, x1+12, y1 + 41, label);
return active;
@ -378,7 +376,7 @@ static bool zarch_zui_list_item(zui_t *zui, struct zui_tabbed *tab, int x1, int
menu_animation_ctl(MENU_ANIMATION_CTL_TICKER, &ticker);
menu_display_push_quad(&zui->ca, zui->width, zui->height, bg, x1, y1, x2, y2);
menu_display_push_quad(zui->width, zui->height, bg, x1, y1, x2, y2);
zarch_zui_draw_text(zui, ZUI_FG_NORMAL, 12, y1 + 35, title_buf);
if (entry)
@ -437,7 +435,7 @@ static bool zarch_zui_tab(zui_t *zui, struct zui_tabbed *tab,
else if (selected)
bg = zui_bg_pad_hilite;
menu_display_push_quad(&zui->ca, zui->width, zui->height, bg, x1+0, y1+0, x2, y2);
menu_display_push_quad(zui->width, zui->height, bg, x1+0, y1+0, x2, y2);
zarch_zui_draw_text(zui, ZUI_FG_NORMAL, x1+12, y1 + 41, label);
if (tab->vertical)
@ -762,7 +760,7 @@ static int zarch_zui_render_lay_root(zui_t *zui)
zarch_zui_draw_text(zui, ZUI_FG_NORMAL, 1600 +12, 300 + 111, item);
#endif
menu_display_push_quad(&zui->ca, zui->width, zui->height,
menu_display_push_quad(zui->width, zui->height,
zui_bg_hilite, 0, 60, zui->width - 290 - 40, 60+4);
return 0;
@ -872,6 +870,9 @@ static void zarch_frame(void *data)
menu_display_ctx_coord_draw_t coord_draw;
settings_t *settings = config_get_ptr();
zui_t *zui = (zui_t*)data;
gfx_coord_array_t *ca = NULL;
menu_display_ctl(MENU_DISPLAY_CTL_COORDS_ARRAY_GET, &ca);
if (!zui)
return;
@ -901,15 +902,15 @@ static void zarch_frame(void *data)
zui->mouse.wheel = menu_input_mouse_state(MENU_MOUSE_WHEEL_DOWN) -
menu_input_mouse_state(MENU_MOUSE_WHEEL_UP);
zui->ca.coords.vertices = 0;
menu_display_ctl(MENU_DISPLAY_CTL_COORDS_ARRAY_RESET, NULL);
zui->tmp_block.carr.coords.vertices = 0;
menu_display_ctl(MENU_DISPLAY_CTL_FONT_BIND_BLOCK, &zui->tmp_block);
menu_display_push_quad(&zui->ca, zui->width, zui->height, zui_bg_screen,
menu_display_push_quad(zui->width, zui->height, zui_bg_screen,
0, 0, zui->width, zui->height);
menu_display_snow(&zui->ca, zui->width, zui->height);
menu_display_snow(zui->width, zui->height);
switch (zarch_layout)
{
@ -947,7 +948,7 @@ static void zarch_frame(void *data)
draw.y = 0;
draw.width = zui->width;
draw.height = zui->height;
draw.coords = (struct gfx_coords*)&zui->ca;
draw.coords = (struct gfx_coords*)ca;
draw.matrix_data = &zui->mvp;
draw.texture = zui->textures.white;
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLES;
@ -1034,8 +1035,6 @@ static void *zarch_init(void **userdata)
"cb_menu_wallpaper",
menu_display_handle_wallpaper_upload, NULL);
zui->ca.allocated = 0;
matrix_4x4_ortho(&zui->mvp, 0, 1, 1, 0, 0, 1);
zarch_zui_font();
@ -1052,10 +1051,7 @@ static void zarch_free(void *data)
zui_t *zui = (zui_t*)data;
if (zui)
{
gfx_coord_array_free(&zui->ca);
gfx_coord_array_free(&zui->tmp_block.carr);
}
font_driver_bind_block(NULL, NULL);
}

View File

@ -132,6 +132,7 @@ static void menu_display_timedate(void *data)
bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
{
unsigned width, height;
static gfx_coord_array_t menu_disp_ca;
static unsigned menu_display_framebuf_width = 0;
static unsigned menu_display_framebuf_height = 0;
static size_t menu_display_framebuf_pitch = 0;
@ -202,6 +203,7 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
case MENU_DISPLAY_CTL_DEINIT:
if (menu_display_msg_queue)
msg_queue_free(menu_display_msg_queue);
gfx_coord_array_free(&menu_disp_ca);
menu_display_msg_queue = NULL;
menu_display_msg_force = false;
menu_display_header_height = 0;
@ -212,6 +214,18 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
break;
case MENU_DISPLAY_CTL_INIT:
retro_assert(menu_display_msg_queue = msg_queue_new(8));
menu_disp_ca.allocated = 0;
break;
case MENU_DISPLAY_CTL_COORDS_ARRAY_RESET:
menu_disp_ca.coords.vertices = 0;
break;
case MENU_DISPLAY_CTL_COORDS_ARRAY_GET:
{
void **ptr = (void**)data;
if (!ptr)
return false;
*ptr = &menu_disp_ca;
}
break;
case MENU_DISPLAY_CTL_SET_STUB_DRAW_FRAME:
break;
@ -603,8 +617,7 @@ static INLINE float menu_display_randf(float min, float max)
return (rand() * ((max - min) / RAND_MAX)) + min;
}
void menu_display_push_quad(gfx_coord_array_t *ca,
void menu_display_push_quad(
unsigned width, unsigned height,
const float *colors, int x1, int y1,
int x2, int y2)
@ -612,6 +625,9 @@ void menu_display_push_quad(gfx_coord_array_t *ca,
menu_display_ctx_coord_draw_t coord_draw;
gfx_coords_t coords;
float vertex[8];
gfx_coord_array_t *ca = NULL;
menu_display_ctl(MENU_DISPLAY_CTL_COORDS_ARRAY_GET, &ca);
vertex[0] = x1 / (float)width;
vertex[1] = y1 / (float)height;
@ -644,7 +660,7 @@ void menu_display_push_quad(gfx_coord_array_t *ca,
#define PARTICLES_COUNT 100
void menu_display_snow(gfx_coord_array_t *ca, int width, int height)
void menu_display_snow(int width, int height)
{
struct display_particle
{
@ -722,7 +738,7 @@ void menu_display_snow(gfx_coord_array_t *ca, int width, int height)
colors[j] = alpha;
}
menu_display_push_quad(ca, width, height,
menu_display_push_quad(width, height,
colors, p->x-2, p->y-2, p->x+2, p->y+2);
j++;

View File

@ -78,7 +78,9 @@ enum menu_display_ctl_state
MENU_DISPLAY_CTL_DRAW_GRADIENT,
MENU_DISPLAY_CTL_ROTATE_Z,
MENU_DISPLAY_CTL_TEX_COORDS_GET,
MENU_DISPLAY_CTL_TIMEDATE
MENU_DISPLAY_CTL_TIMEDATE,
MENU_DISPLAY_CTL_COORDS_ARRAY_RESET,
MENU_DISPLAY_CTL_COORDS_ARRAY_GET
};
enum menu_display_prim_type
@ -174,12 +176,12 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data);
void menu_display_handle_wallpaper_upload(void *task_data,
void *user_data, const char *err);
void menu_display_push_quad(gfx_coord_array_t *ca,
void menu_display_push_quad(
unsigned width, unsigned height,
const float *colors, int x1, int y1,
int x2, int y2);
void menu_display_snow(gfx_coord_array_t *ca, int width, int height);
void menu_display_snow(int width, int height);
extern uintptr_t menu_display_white_texture;
void menu_display_allocate_white_texture();