From d980c30851d00d32f3333cbf824f53eedd2a869e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 4 Oct 2014 17:13:41 +0200 Subject: cocoa: make fullscreening look like an atomic operation At the moment when you fullscreen mpv there is a very small time interval where the fullscreen windows is semi-transparent. Apparently whem moving the view to another parent it's better to make Cocoa not draw anything globally. An Apple engineer said it, so it must be correct: http://www.cocoabuilder.com/archive/cocoa/142020-preventing-flicker-on-moving-nsview-to-different-superview.html I know I will regret this in the future. --- video/out/cocoa_common.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'video/out') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 37cbac14b5..be180cc0e7 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -67,6 +67,7 @@ struct vo_cocoa_state { NSInteger window_level; bool did_resize; + bool waiting_frame; IOPMAssertionID power_mgmt_assertion; @@ -134,6 +135,7 @@ int vo_cocoa_init(struct vo *vo) struct vo_cocoa_state *s = talloc_zero(vo, struct vo_cocoa_state); *s = (struct vo_cocoa_state){ .did_resize = false, + .waiting_frame = false, .power_mgmt_assertion = kIOPMNullAssertionID, .log = mp_log_new(s, vo->log, "cocoa"), .icc_profile_path_changed = false, @@ -415,10 +417,23 @@ void vo_cocoa_set_current_context(struct vo *vo, bool current) } } +static void draw_changes_after_next_frame(struct vo *vo) +{ + struct vo_cocoa_state *s = vo->cocoa; + if (!s->waiting_frame) { + s->waiting_frame = true; + NSDisableScreenUpdates(); + } +} + void vo_cocoa_swap_buffers(struct vo *vo) { struct vo_cocoa_state *s = vo->cocoa; [s->gl_ctx flushBuffer]; + if (s->waiting_frame) { + s->waiting_frame = false; + NSEnableScreenUpdates(); + } } int vo_cocoa_check_events(struct vo *vo) @@ -456,6 +471,7 @@ static void vo_cocoa_fullscreen(struct vo *vo) if (opts->fs_missioncontrol) { [s->window setFullScreen:opts->fullscreen]; } else { + draw_changes_after_next_frame(vo); [s->view setFullScreen:opts->fullscreen]; } -- cgit v1.2.3