diff options
Diffstat (limited to 'src/screen')
| -rw-r--r-- | src/screen/screen.c | 38 | ||||
| -rw-r--r-- | src/screen/screen.h | 6 |
2 files changed, 20 insertions, 24 deletions
diff --git a/src/screen/screen.c b/src/screen/screen.c index 841fe0a..2648387 100644 --- a/src/screen/screen.c +++ b/src/screen/screen.c @@ -56,7 +56,7 @@ static void do_resize(struct camu_screen *scr, u32 width, u32 height) al_array_foreach_ptr(scr->videos, i, video) { camu_view_calculate(&video->view, scr->width, scr->height); } - // No buffers resize. + // Resize with no buffers. atomic_add(u32)(&scr->force_refresh, 1, AL_ATOMIC_RELAXED); } @@ -103,7 +103,7 @@ static bool pointer_callback(void *userdata, u8 type, f64 x, f64 y) if (IS_DRAGGING(scr)) { #ifdef CAMU_SCREEN_DRAG_SEEK u64 now = nn_get_timestamp(); - if (view && now - scr->last_seek_ts > 100000) { + if (view && now - scr->last_seek_ts > 50000) { seek_to_percent_at_pointer(scr, x); scr->last_seek_ts = now; } @@ -396,8 +396,8 @@ static bool key_callback(void *userdata, u8 state, u16 button) scr->callback(scr->userdata, CAMU_SCREEN_SET_VOLUME, &volume); scr->osd.bar_mode = CAMU_OSD_BAR_VOLUME; scr->osd.bar = volume; + scr->osd.flash = CAMU_OSD_FLASH_FOR(0.75); if (!scr->osd.show) { - scr->osd.flash = CAMU_OSD_FLASH_FOR(0.75); scr->osd.show = true; } break; @@ -412,7 +412,7 @@ static bool key_callback(void *userdata, u8 state, u16 button) scr->osd.shown_for = 0; atomic_add(u32)(&scr->force_refresh, 1, AL_ATOMIC_RELAXED); } - scr->osd.alt = 0; + scr->osd.alt = CAMU_OSD_ALT_NONE; } else { scr->osd.alt = CAMU_OSD_ALT_BINDS; } @@ -426,7 +426,7 @@ static bool key_callback(void *userdata, u8 state, u16 button) if (scr->osd.show) { scr->osd.show = false; scr->osd.shown_for = 0; - scr->osd.alt = 0; + scr->osd.alt = CAMU_OSD_ALT_NONE; atomic_add(u32)(&scr->force_refresh, 1, AL_ATOMIC_RELAXED); } else { scr->osd.show = true; @@ -682,8 +682,9 @@ static void drag_and_drop_callback(void *userdata, str *path) } #endif -bool camu_screen_init(struct camu_screen *scr) +void camu_screen_init(struct camu_screen *scr) { + al_memset(scr, 0, sizeof(struct camu_screen)); atomic_store(s32)(&scr->state, CAMU_SCREEN_PAUSED, AL_ATOMIC_RELAXED); scr->window = stl_window_create(); scr->window->render_callback = render_callback; @@ -699,26 +700,17 @@ bool camu_screen_init(struct camu_screen *scr) #endif scr->window->should_close_callback = should_close_callback; scr->window->userdata = scr; - scr->renderer = NULL; atomic_store(u32)(&scr->force_refresh, 1, AL_ATOMIC_RELAXED); scr->flags = CAMU_SCREEN_ZOOM_PAN_SIMPLE; - scr->scaling_disabled = false; - scr->transparent_background = false; #ifdef CAMU_HAVE_SUBTITLES scr->subtitles_enabled = true; #endif scr->last_click_ts = INVALID_TS; - scr->last_pointer_x = 0.0; - scr->last_pointer_y = 0.0; -#ifdef CAMU_SCREEN_DRAG_SEEK - scr->last_seek_ts = 0; -#endif scr->touch_mode = false; - scr->osd.show = false; + scr->osd.alt = CAMU_OSD_ALT_NONE; scr->osd.flash = -1.0; - scr->osd.bar = -1.0; + scr->osd.bar_mode = CAMU_OSD_BAR_PROGRESS; scr->vr_emulation = CAMU_VR_DISABLED; - scr->vr_left_eye = false; scr->vr_calibrate_x = 0.5; scr->vr_calibrate_y = 0.5; al_array_init(scr->videos); @@ -728,7 +720,6 @@ bool camu_screen_init(struct camu_screen *scr) atomic_store(bool)(&scr->queued, false, AL_ATOMIC_RELAXED); nn_mutex_init(&scr->mutex); #endif - return true; } #ifdef STELA_EVENT_BUFFER @@ -975,6 +966,8 @@ bool camu_screen_tick(struct camu_screen *scr, bool *force) s32 state = atomic_load(s32)(&scr->state, AL_ATOMIC_RELAXED); u32 force_refresh = atomic_load(u32)(&scr->force_refresh, AL_ATOMIC_ACQUIRE); bool paused = state == CAMU_SCREEN_PAUSED && force_refresh == 0; + bool osd_was_paused = scr->osd.paused; + scr->callback(scr->userdata, CAMU_SCREEN_STATUS, &scr->osd); paused &= !scr->osd.show; paused &= !scr->vr_emulation; bool do_render = camu_screen_poll(scr, paused) || !paused; @@ -985,8 +978,6 @@ bool camu_screen_tick(struct camu_screen *scr, bool *force) if (force_refresh > 0) { atomic_sub(u32)(&scr->force_refresh, 1, AL_ATOMIC_RELEASE); } - bool was_paused = scr->osd.paused; - scr->callback(scr->userdata, CAMU_SCREEN_STATUS, &scr->osd); if (scr->osd.flash >= 0.0) { if (nn_get_tick() >= scr->osd.flash) { scr->osd.flash = -1.0; @@ -1001,7 +992,7 @@ bool camu_screen_tick(struct camu_screen *scr, bool *force) f64 percent = scr->last_pointer_x / scr->width; scr->osd.bar = CLAMP(percent, 0.0, 100.0); } - if (was_paused != scr->osd.paused) { + if (osd_was_paused != scr->osd.paused) { if (scr->osd.paused && !scr->osd.show) { scr->osd.show = true; scr->osd.shown_for |= CAMU_OSD_PAUSE; @@ -1009,11 +1000,14 @@ bool camu_screen_tick(struct camu_screen *scr, bool *force) scr->osd.shown_for &= ~CAMU_OSD_PAUSE; if (scr->osd.shown_for == 0) { scr->osd.show = false; + *force = true; } } - *force = true; } *force |= scr->osd.show; + if (scr->osd.no_force_render) { + *force = false; + } return do_render; } diff --git a/src/screen/screen.h b/src/screen/screen.h index 0be414f..bb28a1b 100644 --- a/src/screen/screen.h +++ b/src/screen/screen.h @@ -71,7 +71,8 @@ enum { }; enum { - CAMU_OSD_ALT_BINDS = 1 + CAMU_OSD_ALT_NONE = 0, + CAMU_OSD_ALT_BINDS }; enum { @@ -86,6 +87,7 @@ struct camu_osd { u32 show; u8 alt; u8 shown_for; + bool no_force_render; f64 flash; u32 connecting; u32 paused; @@ -140,7 +142,7 @@ struct camu_screen { void *userdata; }; -bool camu_screen_init(struct camu_screen *scr); +void camu_screen_init(struct camu_screen *scr); bool camu_screen_create_window(struct camu_screen *scr, const char *name); bool camu_screen_create_renderer(struct camu_screen *scr, struct camu_renderer *renderer); void camu_screen_add_buffer(struct camu_screen *scr, struct camu_video_buffer *buf); |