mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-26 04:59:30 +08:00
vo_opengl/x11: fix automatic ICC profile loading
mpv would attempt to load ICC profiles several times during VO init
even if no window is displayed. This potentially causes it to load
a profile for a different screen than it is going to be displayed
on, thereby invalidating the profile cache and rebuilding the LUT
every single time.
It would not unload a previously loaded profile when the video
window is moved to a display without an installed profile.
Fix these issues and tweak the log messages a little.
(cherry picked from commit 1bab7f69ae)
This commit is contained in:
committed by
Diogo Franco (Kovensky)
parent
324a40d2e1
commit
f84ca3a516
@@ -254,15 +254,17 @@ static bool get_and_update_icc_profile(struct gl_priv *p, int *events)
|
||||
{
|
||||
if (p->icc_opts->profile_auto) {
|
||||
MP_VERBOSE(p, "Querying ICC profile...\n");
|
||||
bstr icc;
|
||||
bstr icc = bstr0(NULL);
|
||||
int r = p->glctx->vo_control(p->vo, events, VOCTRL_GET_ICC_PROFILE, &icc);
|
||||
|
||||
if (r == VO_TRUE) {
|
||||
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);
|
||||
} else if (r == VO_NOTIMPL) {
|
||||
MP_ERR(p, "icc-profile-auto not implemented on this platform.\n");
|
||||
} else {
|
||||
MP_ERR(p, "Could not retrieve an ICC profile.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1700,6 +1700,8 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg)
|
||||
return VO_TRUE;
|
||||
}
|
||||
case VOCTRL_GET_ICC_PROFILE: {
|
||||
if (!x11->pseudo_mapped)
|
||||
return VO_NOTAVAIL;
|
||||
int screen = 0; // xinerama screen number
|
||||
for (int n = 0; n < x11->num_displays; n++) {
|
||||
struct xrandr_display *disp = &x11->displays[n];
|
||||
@@ -1714,6 +1716,7 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg)
|
||||
mp_snprintf_cat(prop, sizeof(prop), "_%d", screen);
|
||||
x11->icc_profile_property = XAs(x11, prop);
|
||||
int len;
|
||||
MP_VERBOSE(x11, "Retrieving ICC profile for display: %d\n", screen);
|
||||
void *icc = x11_get_property(x11, x11->rootwin, x11->icc_profile_property,
|
||||
XA_CARDINAL, 8, &len);
|
||||
if (!icc)
|
||||
|
||||
Reference in New Issue
Block a user