Created
March 10, 2013 18:18
-
-
Save Themaister/5129744 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 63d946c69f3a09fcdaa19ff4d16c73ce1a4245b9 | |
Author: Themaister <[email protected]> | |
Date: Sun Mar 10 19:14:28 2013 +0100 | |
Add set_rgui_texture interface to video_poke. | |
diff --git a/driver.h b/driver.h | |
index 33d7157..b8bab0f 100644 | |
--- a/driver.h | |
+++ b/driver.h | |
@@ -234,12 +234,16 @@ typedef struct video_poke_interface | |
void (*set_filtering)(void *data, unsigned index, bool smooth); | |
void (*set_fbo_state)(void *data, unsigned state); | |
void (*set_aspect_ratio)(void *data, unsigned aspectratio_index); | |
+ | |
+ // Set to NULL if RGUI texture is not supposed to be rendered. | |
+ void (*set_rgui_texture)(void *data, const void *frame); | |
} video_poke_interface_t; | |
typedef struct video_driver | |
{ | |
void *(*init)(const video_info_t *video, const input_driver_t **input, void **input_data); | |
- // Should the video driver act as an input driver as well? :) The video init might preinitialize an input driver to override the settings in case the video driver relies on input driver for event handling, e.g. | |
+ // Should the video driver act as an input driver as well? :) | |
+ // The video init might preinitialize an input driver to override the settings in case the video driver relies on input driver for event handling, e.g. | |
bool (*frame)(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg); // msg is for showing a message on the screen along with the video frame. | |
void (*set_nonblock_state)(void *data, bool toggle); // Should we care about syncing to vblank? Fast forwarding. | |
// Is the window still active? | |
diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c | |
index be634aa..67b26e9 100644 | |
--- a/frontend/menu/rgui.c | |
+++ b/frontend/menu/rgui.c | |
@@ -1594,10 +1594,6 @@ RMENU API | |
void menu_init(void) | |
{ | |
- DECLARE_DEVICE_PTR(); | |
- | |
- device_ptr->menu_data = (uint32_t *) menu_framebuf; | |
- | |
rgui = rgui_init("", | |
menu_framebuf, RGUI_WIDTH * sizeof(uint16_t), | |
NULL, bitmap_bin, folder_cb, NULL); | |
@@ -1767,7 +1763,9 @@ bool menu_iterate(void) | |
input_entry_ret = rgui_iterate(rgui, action); | |
// draw last frame for loading messages | |
+ driver.video_poke->set_rgui_texture(driver.video_data, menu_framebuf); | |
rarch_render_cached_frame(); | |
+ driver.video_poke->set_rgui_texture(driver.video_data, NULL); | |
input_process_ret = menu_input_process(NULL, NULL); | |
diff --git a/gfx/gl.c b/gfx/gl.c | |
index 48cb3fe..9be3389 100644 | |
--- a/gfx/gl.c | |
+++ b/gfx/gl.c | |
@@ -1270,7 +1270,7 @@ static inline void gl_draw_rgui(void *data) | |
// RGUI is always packed so pitch = width * bpp | |
glTexImage2D(GL_TEXTURE_2D, | |
0, GL_RGBA, RGUI_WIDTH, RGUI_HEIGHT, 0, GL_RGBA, | |
- GL_UNSIGNED_SHORT_4_4_4_4, gl->menu_data); | |
+ GL_UNSIGNED_SHORT_4_4_4_4, gl->rgui_data); | |
gl_shader_use_func(gl, 0); | |
gl_shader_set_coords_func(gl, &gl->coords, &gl->mvp_no_rot); | |
@@ -1356,7 +1356,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei | |
gl_set_prev_texture(gl, &tex_info); | |
#ifdef HAVE_RGUI | |
- if (lifecycle_mode_state & (1ULL << MODE_MENU_DRAW)) | |
+ if (gl->rgui_data) | |
gl_draw_rgui(gl); | |
#endif | |
@@ -2286,11 +2286,22 @@ static void gl_set_blend(void *data, bool enable) | |
glDisable(GL_BLEND); | |
} | |
+#ifdef HAVE_RGUI | |
+static void gl_set_rgui_texture(void *data, const void *frame) | |
+{ | |
+ gl_t *gl = (gl_t*)data; | |
+ gl->rgui_data = frame; | |
+} | |
+#endif | |
+ | |
static const video_poke_interface_t gl_poke_interface = { | |
gl_set_blend, | |
gl_set_filtering, | |
gl_set_fbo_state, | |
gl_set_aspect_ratio, | |
+#ifdef HAVE_RGUI | |
+ gl_set_rgui_texture, | |
+#endif | |
}; | |
static void gl_get_poke_interface(void *data, const video_poke_interface_t **iface) | |
diff --git a/gfx/gl_common.h b/gfx/gl_common.h | |
index dede0b3..68dfc02 100644 | |
--- a/gfx/gl_common.h | |
+++ b/gfx/gl_common.h | |
@@ -304,7 +304,7 @@ typedef struct gl | |
#ifdef HAVE_RGUI | |
GLuint rgui_texture; | |
- uint32_t *menu_data; | |
+ const void *rgui_data; | |
#endif | |
} gl_t; | |
diff --git a/gfx/thread_wrapper.c b/gfx/thread_wrapper.c | |
index 8621663..56f7095 100644 | |
--- a/gfx/thread_wrapper.c | |
+++ b/gfx/thread_wrapper.c | |
@@ -68,6 +68,10 @@ typedef struct thread_video | |
const input_driver_t **input; | |
void **input_data; | |
+#ifdef HAVE_RGUI | |
+ const void *rgui_texture; | |
+#endif | |
+ | |
bool alive; | |
bool focus; | |
@@ -292,6 +296,11 @@ static void thread_loop(void *data) | |
if (updated) | |
{ | |
slock_lock(thr->frame.lock); | |
+ | |
+#ifdef HAVE_RGUI | |
+ thr->poke->set_rgui_texture(thr->driver_data, thr->rgui_texture); | |
+#endif | |
+ | |
bool ret = thr->driver->frame(thr->driver_data, | |
thr->frame.buffer, thr->frame.width, thr->frame.height, | |
thr->frame.pitch, *thr->frame.msg ? thr->frame.msg : NULL); | |
@@ -397,8 +406,7 @@ static bool thread_frame(void *data, const void *frame_, | |
// we'll want to block to avoid stepping menu | |
// at crazy speeds. | |
#ifdef HAVE_RGUI | |
- uint64_t lifecycle_mode_state = g_extern.lifecycle_mode_state; | |
- if (lifecycle_mode_state & (1ULL << MODE_MENU_DRAW)) | |
+ if (thr->rgui_texture) | |
{ | |
while (thr->frame.updated) | |
scond_wait(thr->cond_cmd, thr->lock); | |
@@ -619,11 +627,25 @@ static void thread_set_aspect_ratio(void *data, unsigned aspectratio_index) | |
thread_wait_reply(thr, CMD_POKE_SET_ASPECT_RATIO); | |
} | |
+#ifdef HAVE_RGUI | |
+static void thread_set_rgui_texture(void *data, const void *frame) | |
+{ | |
+ thread_video_t *thr = (thread_video_t*)data; | |
+ | |
+ slock_lock(thr->frame.lock); | |
+ thr->rgui_texture = frame; | |
+ slock_unlock(thr->frame.lock); | |
+} | |
+#endif | |
+ | |
static const video_poke_interface_t thread_poke = { | |
thread_set_blend, | |
thread_set_filtering, | |
thread_set_fbo_state, | |
thread_set_aspect_ratio, | |
+#ifdef HAVE_RGUI | |
+ thread_set_rgui_texture, | |
+#endif | |
}; | |
static void thread_get_poke_interface(void *data, const video_poke_interface_t **iface) | |
diff --git a/gx/gx_video.c b/gx/gx_video.c | |
index ead54ef..b5fa122 100644 | |
--- a/gx/gx_video.c | |
+++ b/gx/gx_video.c | |
@@ -920,7 +920,7 @@ static bool gx_frame(void *data, const void *frame, | |
DCFlushRange(g_tex.data, height * (width << (gx->rgb32 ? 2 : 1))); | |
} | |
- if (lifecycle_mode_state & (1ULL << MODE_MENU_DRAW)) | |
+ if (gx->menu_data) | |
{ | |
convert_texture16(gx->menu_data, menu_tex.data, RGUI_WIDTH, RGUI_HEIGHT, RGUI_WIDTH * 2); | |
DCFlushRange(menu_tex.data, RGUI_WIDTH * RGUI_HEIGHT * 2); | |
@@ -1009,8 +1009,7 @@ static void gx_free(void *data) | |
static void gx_set_rotation(void *data, unsigned orientation) | |
{ | |
- (void)data; | |
- gx_video_t *gx = (gx_video_t*)driver.video_data; | |
+ gx_video_t *gx = (gx_video_t*)data; | |
g_orientation = orientation; | |
gx->should_resize = true; | |
} | |
@@ -1026,11 +1025,18 @@ static bool gx_set_shader(void *data, enum rarch_shader_type type, const char *p | |
return false; | |
} | |
+static void gx_set_rgui_texture(void *data, const void *frame) | |
+{ | |
+ gx_video_t *gx = (gx_video_t*)data; | |
+ gx->menu_data = (uint32_t*)frame; | |
+} | |
+ | |
static const video_poke_interface_t gx_poke_interface = { | |
NULL, | |
NULL, | |
NULL, | |
gx_set_aspect_ratio, | |
+ gx_set_rgui_texture, | |
}; | |
static void gx_get_poke_interface(void *data, const video_poke_interface_t **iface) | |
diff --git a/gx/gx_video.h b/gx/gx_video.h | |
index 5bd40ad..f608888 100644 | |
--- a/gx/gx_video.h | |
+++ b/gx/gx_video.h | |
@@ -24,7 +24,7 @@ typedef struct gx_video | |
bool keep_aspect; | |
bool double_strike; | |
bool rgb32; | |
- uint32_t *menu_data; | |
+ uint32_t *menu_data; // FIXME: Should be const uint16_t*. | |
unsigned win_width; | |
unsigned win_height; | |
unsigned scale; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment