omap_gfx: implement _set_texture_frame

This commit is contained in:
notaz 2015-03-07 02:39:39 +02:00
parent b33630b8dc
commit a63dba42ce

View File

@ -775,6 +775,13 @@ typedef struct omap_video
/* current dimensions */
unsigned width;
unsigned height;
struct
{
bool active;
void *frame;
struct scaler_ctx scaler;
} menu;
} omap_video_t;
@ -790,6 +797,9 @@ static void omap_gfx_free(void *data)
if (vid->font)
vid->font_driver->free(vid->font);
scaler_ctx_gen_reset(&vid->menu.scaler);
free(vid->menu.frame);
free(vid);
}
@ -927,11 +937,26 @@ static void *omap_gfx_init(const video_info_t *video,
omapfb_mmap(vid->omap) != 0)
goto fail_omapfb;
/* set some initial mode for the menu */
vid->width = 320;
vid->height = 240;
if (omapfb_set_mode(vid->omap, vid->width, vid->height) != 0)
goto fail_omapfb;
if (input && input_data)
*input = NULL;
omap_init_font(vid, g_settings.video.font_path, g_settings.video.font_size);
vid->menu.frame = calloc(vid->width * vid->height, vid->bytes_per_pixel);
if (vid->menu.frame == NULL)
goto fail_omapfb;
vid->menu.scaler.scaler_type = SCALER_TYPE_BILINEAR;
vid->menu.scaler.out_fmt = (vid->bytes_per_pixel == 4)
? SCALER_FMT_ARGB8888 : SCALER_FMT_RGB565;
return vid;
fail_omapfb:
@ -952,11 +977,8 @@ static bool omap_gfx_frame(void *data, const void *frame, unsigned width,
return true;
vid = data;
if (width != vid->width || height != vid->height)
if (width > 4 && height > 4 && (width != vid->width || height != vid->height))
{
if (width == 0 || height == 0)
return true;
RARCH_LOG("video_omap: mode set (resolution changed by core)\n");
if (omapfb_set_mode(vid->omap, width, height) != 0)
@ -971,8 +993,12 @@ static bool omap_gfx_frame(void *data, const void *frame, unsigned width,
omapfb_prepare(vid->omap);
omapfb_blit_frame(vid->omap, frame, vid->height, pitch);
if (vid->menu.active)
omapfb_blit_frame(vid->omap, vid->menu.frame,
vid->menu.scaler.out_height,
vid->menu.scaler.out_stride);
if (msg)
omap_render_msg(vid, msg);
omap_render_msg(vid, msg);
g_extern.frame_count++;
@ -1055,11 +1081,80 @@ static bool omap_gfx_read_viewport(void *data, uint8_t *buffer)
return true;
}
static void update_scaler(omap_video_t *vid, struct scaler_ctx *scaler,
enum scaler_pix_fmt format, unsigned width,
unsigned height, unsigned pitch)
{
if (
width != scaler->in_width
|| height != scaler->in_height
|| format != scaler->in_fmt
|| pitch != scaler->in_stride
)
{
scaler->in_fmt = format;
scaler->in_width = width;
scaler->in_height = height;
scaler->in_stride = pitch;
scaler->out_width = vid->width;
scaler->out_height = vid->height;
scaler->out_stride = vid->width * vid->bytes_per_pixel;
if (!scaler_ctx_gen_filter(scaler))
RARCH_ERR("video_omap: scaler_ctx_gen_filter failed\n");
}
}
static void omap_gfx_set_texture_frame(void *data, const void *frame, bool rgb32,
unsigned width, unsigned height, float alpha)
{
(void) alpha;
omap_video_t *vid = (omap_video_t*)data;
enum scaler_pix_fmt format = rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGBA4444;
update_scaler(vid, &vid->menu.scaler, format, width, height,
width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)));
scaler_ctx_scale(&vid->menu.scaler, vid->menu.frame, frame);
}
static void omap_gfx_set_texture_enable(void *data, bool state, bool full_screen)
{
(void) full_screen;
omap_video_t *vid = (omap_video_t*)data;
vid->menu.active = state;
}
static const video_poke_interface_t omap_gfx_poke_interface = {
NULL,
NULL, /* set_filtering */
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
#ifdef HAVE_FBO
NULL,
NULL,
#endif
NULL, /* set_aspect_ratio */
NULL, /* apply_state_changes */
#ifdef HAVE_MENU
omap_gfx_set_texture_frame,
omap_gfx_set_texture_enable,
#endif
NULL,
NULL, /* show_mouse */
NULL, /* grab_mouse_toggle */
NULL
};
static void omap_gfx_get_poke_interface(void *data,
const video_poke_interface_t **iface)
{
(void)data;
(void)iface;
*iface = &omap_gfx_poke_interface;
}
video_driver_t video_omap = {