mirror of https://github.com/mpv-player/mpv
vo_opengl: cocoa: switch to new internal API
This commit is contained in:
parent
ae7212963e
commit
f4d62da8f0
|
@ -27,10 +27,10 @@
|
||||||
struct vo;
|
struct vo;
|
||||||
struct vo_cocoa_state;
|
struct vo_cocoa_state;
|
||||||
|
|
||||||
int vo_cocoa_init(struct vo *vo);
|
void vo_cocoa_init(struct vo *vo);
|
||||||
void vo_cocoa_uninit(struct vo *vo);
|
void vo_cocoa_uninit(struct vo *vo);
|
||||||
|
|
||||||
int vo_cocoa_config_window(struct vo *vo, uint32_t flags);
|
int vo_cocoa_config_window(struct vo *vo);
|
||||||
|
|
||||||
int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg);
|
int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg);
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ static void cocoa_uninit_light_sensor(struct vo_cocoa_state *s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int vo_cocoa_init(struct vo *vo)
|
void vo_cocoa_init(struct vo *vo)
|
||||||
{
|
{
|
||||||
struct vo_cocoa_state *s = talloc_zero(NULL, struct vo_cocoa_state);
|
struct vo_cocoa_state *s = talloc_zero(NULL, struct vo_cocoa_state);
|
||||||
*s = (struct vo_cocoa_state){
|
*s = (struct vo_cocoa_state){
|
||||||
|
@ -265,7 +265,6 @@ int vo_cocoa_init(struct vo *vo)
|
||||||
pthread_cond_init(&s->wakeup, NULL);
|
pthread_cond_init(&s->wakeup, NULL);
|
||||||
vo->cocoa = s;
|
vo->cocoa = s;
|
||||||
cocoa_init_light_sensor(vo);
|
cocoa_init_light_sensor(vo);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vo_cocoa_set_cursor_visibility(struct vo *vo, bool *visible)
|
static int vo_cocoa_set_cursor_visibility(struct vo *vo, bool *visible)
|
||||||
|
@ -554,7 +553,7 @@ void vo_cocoa_set_opengl_ctx(struct vo *vo, CGLContextObj ctx)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
int vo_cocoa_config_window(struct vo *vo, uint32_t flags)
|
int vo_cocoa_config_window(struct vo *vo)
|
||||||
{
|
{
|
||||||
struct vo_cocoa_state *s = vo->cocoa;
|
struct vo_cocoa_state *s = vo->cocoa;
|
||||||
run_on_main_thread(vo, ^{
|
run_on_main_thread(vo, ^{
|
||||||
|
@ -572,7 +571,7 @@ int vo_cocoa_config_window(struct vo *vo, uint32_t flags)
|
||||||
s->old_dwidth = width;
|
s->old_dwidth = width;
|
||||||
s->old_dheight = height;
|
s->old_dheight = height;
|
||||||
|
|
||||||
if (!(flags & VOFLAG_HIDDEN) && !s->view) {
|
if (!s->view) {
|
||||||
create_ui(vo, &geo.win, geo.flags);
|
create_ui(vo, &geo.win, geo.flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,40 +132,47 @@ static bool create_gl_context(struct MPGLContext *ctx)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool config_window_cocoa(struct MPGLContext *ctx, int flags)
|
static void cocoa_uninit(MPGLContext *ctx)
|
||||||
{
|
|
||||||
struct cgl_context *p = ctx->priv;
|
|
||||||
|
|
||||||
if (p->ctx == NULL)
|
|
||||||
if (!create_gl_context(ctx))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!ctx->gl->SwapInterval)
|
|
||||||
ctx->gl->SwapInterval = set_swap_interval;
|
|
||||||
|
|
||||||
vo_cocoa_config_window(ctx->vo, flags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void releaseGlContext_cocoa(MPGLContext *ctx)
|
|
||||||
{
|
{
|
||||||
struct cgl_context *p = ctx->priv;
|
struct cgl_context *p = ctx->priv;
|
||||||
CGLReleaseContext(p->ctx);
|
CGLReleaseContext(p->ctx);
|
||||||
|
vo_cocoa_uninit(ctx->vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void swapGlBuffers_cocoa(MPGLContext *ctx)
|
static int cocoa_init(MPGLContext *ctx, int vo_flags)
|
||||||
|
{
|
||||||
|
vo_cocoa_init(ctx->vo);
|
||||||
|
|
||||||
|
if (!create_gl_context(ctx))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
ctx->gl->SwapInterval = set_swap_interval;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cocoa_reconfig(struct MPGLContext *ctx, int flags)
|
||||||
|
{
|
||||||
|
vo_cocoa_config_window(ctx->vo);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cocoa_control(struct MPGLContext *ctx, int *events, int request,
|
||||||
|
void *arg)
|
||||||
|
{
|
||||||
|
return vo_cocoa_control(ctx->vo, events, request, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cocoa_swap_buffers(struct MPGLContext *ctx)
|
||||||
{
|
{
|
||||||
vo_cocoa_swap_buffers(ctx->vo);
|
vo_cocoa_swap_buffers(ctx->vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mpgl_set_backend_cocoa(MPGLContext *ctx)
|
const struct mpgl_driver mpgl_driver_cocoa = {
|
||||||
{
|
.name = "cocoa",
|
||||||
ctx->priv = talloc_zero(ctx, struct cgl_context);
|
.priv_size = sizeof(struct cgl_context),
|
||||||
ctx->config_window = config_window_cocoa;
|
.init = cocoa_init,
|
||||||
ctx->releaseGlContext = releaseGlContext_cocoa;
|
.reconfig = cocoa_reconfig,
|
||||||
ctx->swapGlBuffers = swapGlBuffers_cocoa;
|
.swap_buffers = cocoa_swap_buffers,
|
||||||
ctx->vo_init = vo_cocoa_init;
|
.control = cocoa_control,
|
||||||
ctx->vo_uninit = vo_cocoa_uninit;
|
.uninit = cocoa_uninit,
|
||||||
ctx->vo_control = vo_cocoa_control;
|
};
|
||||||
}
|
|
|
@ -500,13 +500,14 @@ struct backend {
|
||||||
|
|
||||||
extern const struct mpgl_driver mpgl_driver_x11;
|
extern const struct mpgl_driver mpgl_driver_x11;
|
||||||
extern const struct mpgl_driver mpgl_driver_x11egl;
|
extern const struct mpgl_driver mpgl_driver_x11egl;
|
||||||
|
extern const struct mpgl_driver mpgl_driver_cocoa;
|
||||||
|
|
||||||
static const struct backend backends[] = {
|
static const struct backend backends[] = {
|
||||||
#if HAVE_RPI
|
#if HAVE_RPI
|
||||||
{"rpi", mpgl_set_backend_rpi},
|
{"rpi", mpgl_set_backend_rpi},
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_GL_COCOA
|
#if HAVE_GL_COCOA
|
||||||
{"cocoa", mpgl_set_backend_cocoa},
|
{.driver = &mpgl_driver_cocoa},
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_GL_WIN32
|
#if HAVE_GL_WIN32
|
||||||
{"win", mpgl_set_backend_w32},
|
{"win", mpgl_set_backend_w32},
|
||||||
|
|
|
@ -154,7 +154,6 @@ struct m_option;
|
||||||
int mpgl_validate_backend_opt(struct mp_log *log, const struct m_option *opt,
|
int mpgl_validate_backend_opt(struct mp_log *log, const struct m_option *opt,
|
||||||
struct bstr name, struct bstr param);
|
struct bstr name, struct bstr param);
|
||||||
|
|
||||||
void mpgl_set_backend_cocoa(MPGLContext *ctx);
|
|
||||||
void mpgl_set_backend_w32(MPGLContext *ctx);
|
void mpgl_set_backend_w32(MPGLContext *ctx);
|
||||||
void mpgl_set_backend_wayland(MPGLContext *ctx);
|
void mpgl_set_backend_wayland(MPGLContext *ctx);
|
||||||
void mpgl_set_backend_rpi(MPGLContext *ctx);
|
void mpgl_set_backend_rpi(MPGLContext *ctx);
|
||||||
|
|
|
@ -247,7 +247,7 @@ static bool get_and_update_icc_profile(struct gl_priv *p, int *events)
|
||||||
static void get_and_update_ambient_lighting(struct gl_priv *p, int *events)
|
static void get_and_update_ambient_lighting(struct gl_priv *p, int *events)
|
||||||
{
|
{
|
||||||
int lux;
|
int lux;
|
||||||
int r = p->glctx->vo_control(p->vo, events, VOCTRL_GET_AMBIENT_LUX, &lux);
|
int r = mpgl_control(p->glctx, events, VOCTRL_GET_AMBIENT_LUX, &lux);
|
||||||
if (r == VO_TRUE) {
|
if (r == VO_TRUE) {
|
||||||
gl_video_set_ambient_lux(p->renderer, lux);
|
gl_video_set_ambient_lux(p->renderer, lux);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue