summaryrefslogtreecommitdiffstats
path: root/video/out/vo_opengl.c
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2014-02-25 00:04:30 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2014-03-31 22:07:33 +0200
commitb0ee9334e33a8603dd07f991ee5cd5f2345030ed (patch)
treea3c5e4d92b028be15d084e664343aee81f458bb9 /video/out/vo_opengl.c
parent956b01ec4eaecef0d48409e7aa5c1d133132fb82 (diff)
downloadmpv-b0ee9334e33a8603dd07f991ee5cd5f2345030ed.tar.bz2
mpv-b0ee9334e33a8603dd07f991ee5cd5f2345030ed.tar.xz
vo_opengl, cocoa: allow to autoselect a color profile
This commit adds support for automatic selection of color profiles based on the display where mpv is initialized, and automatically changes the color profile when display is changed or the profile itself is changed from System Preferences. @UliZappe was responsible with the testing and implementation of a lot of this commit, including the original implementation of `cocoa_get_icc_profile_path` (See #594). Fixes #594
Diffstat (limited to 'video/out/vo_opengl.c')
-rw-r--r--video/out/vo_opengl.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index 485fbdf8fa..c243cdeb85 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -275,6 +275,25 @@ static bool update_icc_profile(struct gl_priv *p, struct mp_icc_opts *opts)
return true;
}
+static bool get_and_update_icc_profile(struct vo *vo,
+ struct mp_icc_opts *opts)
+{
+ struct gl_priv *p = vo->priv;
+
+ if (!opts->profile_auto)
+ return update_icc_profile(p, opts);
+
+ char *icc = NULL;
+ int r = p->glctx->vo_control(vo, NULL, VOCTRL_GET_ICC_PROFILE_PATH, &icc);
+ if (r != VO_TRUE)
+ return false;
+
+ if (mp_icc_set_profile(opts, icc))
+ return update_icc_profile(p, opts);
+
+ return true;
+}
+
static bool reparse_cmdline(struct gl_priv *p, char *args)
{
struct m_config *cfg = NULL;
@@ -377,6 +396,10 @@ static int control(struct vo *vo, uint32_t request, void *data)
resize(p);
if (events & VO_EVENT_EXPOSE)
vo->want_redraw = true;
+ if (events & VO_EVENT_ICC_PROFILE_PATH_CHANGED) {
+ get_and_update_icc_profile(vo, p->icc_opts);
+ vo->want_redraw = true;
+ }
mpgl_unlock(p->glctx);
return r;
@@ -416,7 +439,7 @@ static int preinit(struct vo *vo)
gl_video_set_output_depth(p->renderer, p->glctx->depth_r, p->glctx->depth_g,
p->glctx->depth_b);
gl_video_set_options(p->renderer, p->renderer_opts);
- if (!update_icc_profile(p, p->icc_opts))
+ if (!get_and_update_icc_profile(vo, p->icc_opts))
goto err_out;
mpgl_unset_context(p->glctx);