From bd8ba89cca217cc78df31a357f77220a618a9b9a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 4 Dec 2011 18:52:16 +0100 Subject: vo_gl: cocoa: decouple cocoa_common from gl_common Remove the useless dependency on MPGLContext from cocoa_common, since it was used just to access the vo struct. Change gl_common to pass the vo struct directly to all the cocoa_common functions. --- libvo/cocoa_common.h | 6 +++--- libvo/cocoa_common.m | 15 +++++++-------- libvo/gl_common.c | 8 ++++++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libvo/cocoa_common.h b/libvo/cocoa_common.h index c5d24e9178..a69f61916c 100644 --- a/libvo/cocoa_common.h +++ b/libvo/cocoa_common.h @@ -1,15 +1,15 @@ #ifndef MPLAYER_COCOA_COMMON_H #define MPLAYER_COCOA_COMMON_H -#include "gl_common.h" +#include "video_out.h" int vo_cocoa_init(struct vo *vo); void vo_cocoa_uninit(struct vo *vo); void vo_cocoa_update_xinerama_info(struct vo *vo); -int vo_cocoa_change_attributes(struct MPGLContext *ctx); -int vo_cocoa_create_window(struct MPGLContext *ctx, uint32_t d_width, +int vo_cocoa_change_attributes(struct vo *vo); +int vo_cocoa_create_window(struct vo *vo, uint32_t d_width, uint32_t d_height, uint32_t flags); void vo_cocoa_swap_buffers(void); diff --git a/libvo/cocoa_common.m b/libvo/cocoa_common.m index 56749861c2..c509dbcf39 100644 --- a/libvo/cocoa_common.m +++ b/libvo/cocoa_common.m @@ -3,7 +3,6 @@ #import #import // for CGDisplayHideCursor #include "cocoa_common.h" -#include "gl_common.h" #include "options.h" #include "video_out.h" @@ -130,9 +129,9 @@ void vo_cocoa_update_xinerama_info(struct vo *vo) aspect_save_screenres(vo, s->screen_frame.size.width, s->screen_frame.size.height); } -int vo_cocoa_change_attributes(struct MPGLContext *ctx) +int vo_cocoa_change_attributes(struct vo *vo) { - return SET_WINDOW_OK; + return 0; } void resize_window(struct vo *vo) @@ -142,7 +141,7 @@ void resize_window(struct vo *vo) [s->glContext update]; } -int vo_cocoa_create_window(struct MPGLContext *ctx, uint32_t d_width, +int vo_cocoa_create_window(struct vo *vo, uint32_t d_width, uint32_t d_height, uint32_t flags) { if (s->current_video_size.width > 0 || s->current_video_size.height > 0) @@ -187,7 +186,7 @@ int vo_cocoa_create_window(struct MPGLContext *ctx, uint32_t d_width, } if (flags & VOFLAG_FULLSCREEN) - vo_cocoa_fullscreen(ctx->vo); + vo_cocoa_fullscreen(vo); } else { if (s->current_video_size.width != s->previous_video_size.width || s->current_video_size.height != s->previous_video_size.height) { @@ -203,15 +202,15 @@ int vo_cocoa_create_window(struct MPGLContext *ctx, uint32_t d_width, } } - resize_window(ctx->vo); + resize_window(vo); if (s->window_title) [s->window_title release]; - s->window_title = [[NSString alloc] initWithUTF8String:vo_get_window_title(ctx->vo)]; + s->window_title = [[NSString alloc] initWithUTF8String:vo_get_window_title(vo)]; [s->window setTitle: s->window_title]; - return SET_WINDOW_OK; + return 0; } void vo_cocoa_swap_buffers() diff --git a/libvo/gl_common.c b/libvo/gl_common.c index 27febc1b36..d9814c6f6a 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -1615,11 +1615,15 @@ void glDrawTex(GL *gl, GLfloat x, GLfloat y, GLfloat w, GLfloat h, static int create_window_cocoa(struct MPGLContext *ctx, uint32_t d_width, uint32_t d_height, uint32_t flags) { - return vo_cocoa_create_window(ctx, d_width, d_height, flags); + if (vo_cocoa_create_window(ctx->vo, d_width, d_height, flags) == 0) { + return SET_WINDOW_OK; + } else { + return SET_WINDOW_FAILED; + } } static int setGlWindow_cocoa(MPGLContext *ctx) { - vo_cocoa_change_attributes(ctx); + vo_cocoa_change_attributes(ctx->vo); getFunctions(ctx->gl, (void *)getdladdr, NULL); return SET_WINDOW_OK; } -- cgit v1.2.3 From b2a41e20be6c1831543e72987ce7d285655fc311 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 4 Dec 2011 21:53:43 +0100 Subject: vo_gl: cocoa: point swapinterval to cocoa_common function Currently there is no way to set the swap interval with a function that has a signature compatible with other platforms' gl extensions. Make a wrapper function around the gui toolkit method of setting the swap interval property, and point gl->SwapInterval to it. --- libvo/cocoa_common.h | 3 +++ libvo/cocoa_common.m | 6 ++++++ libvo/gl_common.c | 2 ++ 3 files changed, 11 insertions(+) diff --git a/libvo/cocoa_common.h b/libvo/cocoa_common.h index a69f61916c..4fbbb32dd9 100644 --- a/libvo/cocoa_common.h +++ b/libvo/cocoa_common.h @@ -16,4 +16,7 @@ void vo_cocoa_swap_buffers(void); int vo_cocoa_check_events(struct vo *vo); void vo_cocoa_fullscreen(struct vo *vo); +// returns an int to conform to the gl extensions from other platforms +int vo_cocoa_swap_interval(int enabled); + #endif /* MPLAYER_COCOA_COMMON_H */ diff --git a/libvo/cocoa_common.m b/libvo/cocoa_common.m index c509dbcf39..5658ecb7bf 100644 --- a/libvo/cocoa_common.m +++ b/libvo/cocoa_common.m @@ -262,6 +262,12 @@ void vo_cocoa_fullscreen(struct vo *vo) resize_window(vo); } +int vo_cocoa_swap_interval(int enabled) +{ + [s->glContext setValues:&enabled forParameter:NSOpenGLCPSwapInterval]; + return 0; +} + void create_menu() { NSMenu *menu; diff --git a/libvo/gl_common.c b/libvo/gl_common.c index d9814c6f6a..7cca800d40 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -1625,6 +1625,8 @@ static int setGlWindow_cocoa(MPGLContext *ctx) { vo_cocoa_change_attributes(ctx->vo); getFunctions(ctx->gl, (void *)getdladdr, NULL); + if (!ctx->gl->SwapInterval) + ctx->gl->SwapInterval = vo_cocoa_swap_interval; return SET_WINDOW_OK; } -- cgit v1.2.3