Skip to content

Commit

Permalink
performance: update the OSD if switching patches while it's still on
Browse files Browse the repository at this point in the history
Before, one could bring up the OSD with F1 and then switch to a
completely different patch with the OSD still showing the name of
the old patch.

Now the OSD is updated. This also helps when searching for a patch
without having dt_mode on all the time.
  • Loading branch information
wpwrak committed Jan 14, 2012
1 parent f680dbf commit bb6ff7c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/gui/performance.c
Expand Up @@ -55,6 +55,7 @@ static int simple_mode_current;
static int dt_mode;
static int as_mode;
static int input_video;
static int showing_title;

static int add_patch(const char *filename)
{
Expand Down Expand Up @@ -414,12 +415,19 @@ static void skip_unsuitable(int next)
}
}

static void osd_off(void)
{
showing_title = 0;
}

static void simple_mode_event(mtk_event *e, int *next)
{
if(e->type != EVENT_TYPE_PRESS)
return;
if(e->press.code == MTK_KEY_F1)
osd_event(patches[simple_mode_current].filename);
if(e->press.code == MTK_KEY_F1) {
osd_event_cb(patches[simple_mode_current].filename, osd_off);
showing_title = 1;
}
if(e->press.code == MTK_KEY_F11)
*next = 1;
if(e->press.code == MTK_KEY_F9)
Expand All @@ -432,8 +440,8 @@ static void simple_mode_next(int next)
renderer_pulse_patch(patches[simple_mode_current].p);
if(as_mode)
update_next_as_time();
if(dt_mode)
osd_event(patches[simple_mode_current].filename);
if(dt_mode || showing_title)
osd_event_cb(patches[simple_mode_current].filename, osd_off);
}

static void configured_mode_event(mtk_event *e)
Expand Down
13 changes: 12 additions & 1 deletion src/renderer/osd.c
Expand Up @@ -34,6 +34,7 @@ static unsigned short int osd_fb[OSD_W*OSD_H] __attribute__((aligned(32)));
static struct font_context osd_font;
static int osd_alpha;
static int osd_timer;
static void (*osd_callback)(void) = NULL;

static void round_corners(void)
{
Expand Down Expand Up @@ -90,6 +91,12 @@ void osd_event(const char *string)
osd_timer = OSD_DURATION;
}

void osd_event_cb(const char *string, void (*faded)(void))
{
osd_event(string);
osd_callback = faded;
}

void osd_per_frame(int tmu_fd, unsigned short *dest, int hres, int vres)
{
struct tmu_td td;
Expand All @@ -107,8 +114,12 @@ void osd_per_frame(int tmu_fd, unsigned short *dest, int hres, int vres)
osd_alpha = 0;
}

if(osd_alpha == 0)
if(osd_alpha == 0) {
if(osd_callback)
osd_callback();
osd_callback = NULL;
return;
}

osd_x = (hres - OSD_W) >> 1;
osd_y = vres - OSD_H - 20;
Expand Down
1 change: 1 addition & 0 deletions src/renderer/osd.h
Expand Up @@ -20,6 +20,7 @@

void osd_init(void);
void osd_event(const char *string);
void osd_event_cb(const char *string, void (*faded)(void));
void osd_per_frame(int tmu_fd, unsigned short *dest, int hres, int vres);

#endif /* __OSD_H */

0 comments on commit bb6ff7c

Please sign in to comment.