summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2014-10-04 17:13:41 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2014-10-04 17:31:18 +0200
commitd980c30851d00d32f3333cbf824f53eedd2a869e (patch)
tree5ca02202833303ce8cd4fce4415ab8922ecdbd1e /video/out
parentb915852f9f697610aab474108f110fd43fb304e7 (diff)
downloadmpv-d980c30851d00d32f3333cbf824f53eedd2a869e.tar.bz2
mpv-d980c30851d00d32f3333cbf824f53eedd2a869e.tar.xz
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.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/cocoa_common.m16
1 files changed, 16 insertions, 0 deletions
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];
}