static void get_and_update_ambient_lighting(struct gl_priv *p, int *events) { int lux; int r = mpgl_control(p->glctx, events, VOCTRL_GET_AMBIENT_LUX, &lux); if (r == VO_TRUE) { gl_video_set_ambient_lux(p->renderer, lux); } if (r != VO_TRUE && p->renderer_opts->gamma_auto) { MP_ERR(p, "gamma_auto option provided, but querying for ambient" " lighting is not supported on this platform\n"); } }
static void get_and_update_icc_profile(struct gl_priv *p, int *events) { if (gl_video_icc_auto_enabled(p->renderer)) { MP_VERBOSE(p, "Querying ICC profile...\n"); bstr icc = bstr0(NULL); int r = mpgl_control(p->glctx, events, VOCTRL_GET_ICC_PROFILE, &icc); if (r != VO_NOTAVAIL) { if (r == VO_FALSE) { MP_WARN(p, "Could not retrieve an ICC profile.\n"); } else if (r == VO_NOTIMPL) { MP_ERR(p, "icc-profile-auto not implemented on this platform.\n"); } gl_video_set_icc_profile(p->renderer, icc); } } }
static void get_and_update_icc_profile(struct gl_priv *p, int *events) { bool has_profile = p->icc_opts->profile && p->icc_opts->profile[0]; if (p->icc_opts->profile_auto && !has_profile) { MP_VERBOSE(p, "Querying ICC profile...\n"); bstr icc = bstr0(NULL); int r = mpgl_control(p->glctx, events, VOCTRL_GET_ICC_PROFILE, &icc); if (r != VO_NOTAVAIL) { if (r == VO_FALSE) { MP_WARN(p, "Could not retrieve an ICC profile.\n"); } else if (r == VO_NOTIMPL) { MP_ERR(p, "icc-profile-auto not implemented on this platform.\n"); } gl_lcms_set_memory_profile(p->cms, &icc); has_profile = true; } } if (has_profile) gl_video_update_profile(p->renderer); }
static int control(struct vo *vo, uint32_t request, void *data) { struct gl_priv *p = vo->priv; switch (request) { case VOCTRL_GET_PANSCAN: return VO_TRUE; case VOCTRL_SET_PANSCAN: resize(p); return VO_TRUE; case VOCTRL_GET_EQUALIZER: { struct voctrl_get_equalizer_args *args = data; struct mp_csp_equalizer *eq = gl_video_eq_ptr(p->renderer); bool r = mp_csp_equalizer_get(eq, args->name, args->valueptr) >= 0; return r ? VO_TRUE : VO_NOTIMPL; } case VOCTRL_SET_EQUALIZER: { struct voctrl_set_equalizer_args *args = data; struct mp_csp_equalizer *eq = gl_video_eq_ptr(p->renderer); if (mp_csp_equalizer_set(eq, args->name, args->value) >= 0) { gl_video_eq_update(p->renderer); vo->want_redraw = true; return VO_TRUE; } return VO_NOTIMPL; } case VOCTRL_SCREENSHOT_WIN: { struct mp_image *screen = gl_read_window_contents(p->gl); // set image parameters according to the display, if possible if (screen) { screen->params.primaries = p->renderer_opts->target_prim; screen->params.gamma = p->renderer_opts->target_trc; if (p->glctx->flip_v) mp_image_vflip(screen); } *(struct mp_image **)data = screen; return true; } case VOCTRL_LOAD_HWDEC_API: request_hwdec_api(vo, data); return true; case VOCTRL_SET_COMMAND_LINE: { char *arg = data; return reparse_cmdline(p, arg); } case VOCTRL_RESET: gl_video_reset(p->renderer); return true; case VOCTRL_PAUSE: if (gl_video_showing_interpolated_frame(p->renderer)) { vo->want_redraw = true; vo_wakeup(vo); } return true; } int events = 0; int r = mpgl_control(p->glctx, &events, request, data); if (events & VO_EVENT_ICC_PROFILE_CHANGED) { get_and_update_icc_profile(p, &events); vo->want_redraw = true; } if (events & VO_EVENT_AMBIENT_LIGHTING_CHANGED) { get_and_update_ambient_lighting(p, &events); vo->want_redraw = true; } if (events & VO_EVENT_RESIZE) resize(p); if (events & VO_EVENT_EXPOSE) vo->want_redraw = true; vo_event(vo, events); return r; }