wayland/surface: Unconditionally set scanout destination rect
The cogl_scanout_get_dst_rect() fell back on the buffer dimensions as the destination rectangle when nothing was explicitly set. This, however, is not necessarily correct. For example, if a buffer is larger the CRTC resolution, but the surface is scaled to exactly match the CRTC view, the expected destination size should match the CRTC resolution, not the buffer dimension, which would be the case if no explicit destination was set. In meta_wayland_try_aquire_scanout() we're in a good position to determine the destination rect in the CRTC primary plane, since we have all the prerequisits, i.e. that the surface effectively covers the whole CRTC, the actor allocation box (the non-black border part), the scale and transform of the view. This tweaks the CoglScanout API a bit to make it explicit that the dst_rect must be unconditionally provided, and removes the fallback to the buffer dimension as the destination rectangle, which sometimes resulted in a destination rectangle being larger than the primary plane itself, resulting in clipping and incorrect scaling. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3773 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4147>
This commit is contained in:
parent
d1ec1d7c61
commit
85d2d49499
@ -48,7 +48,6 @@ struct _CoglScanout
|
|||||||
|
|
||||||
gboolean has_src_rect;
|
gboolean has_src_rect;
|
||||||
graphene_rect_t src_rect;
|
graphene_rect_t src_rect;
|
||||||
gboolean has_dst_rect;
|
|
||||||
MtkRectangle dst_rect;
|
MtkRectangle dst_rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -104,11 +103,16 @@ cogl_scanout_notify_failed (CoglScanout *scanout,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CoglScanout *
|
CoglScanout *
|
||||||
cogl_scanout_new (CoglScanoutBuffer *scanout_buffer)
|
cogl_scanout_new (CoglScanoutBuffer *scanout_buffer,
|
||||||
|
const MtkRectangle *dst_rect)
|
||||||
{
|
{
|
||||||
CoglScanout *scanout = g_object_new (COGL_TYPE_SCANOUT, NULL);
|
CoglScanout *scanout;
|
||||||
|
|
||||||
|
g_return_val_if_fail (dst_rect, NULL);
|
||||||
|
|
||||||
|
scanout = g_object_new (COGL_TYPE_SCANOUT, NULL);
|
||||||
scanout->scanout_buffer = scanout_buffer;
|
scanout->scanout_buffer = scanout_buffer;
|
||||||
|
scanout->dst_rect = *dst_rect;
|
||||||
|
|
||||||
return scanout;
|
return scanout;
|
||||||
}
|
}
|
||||||
@ -141,28 +145,9 @@ cogl_scanout_set_src_rect (CoglScanout *scanout,
|
|||||||
|
|
||||||
void
|
void
|
||||||
cogl_scanout_get_dst_rect (CoglScanout *scanout,
|
cogl_scanout_get_dst_rect (CoglScanout *scanout,
|
||||||
MtkRectangle *rect)
|
MtkRectangle *dst_rect)
|
||||||
{
|
{
|
||||||
if (scanout->has_dst_rect)
|
*dst_rect = scanout->dst_rect;
|
||||||
{
|
|
||||||
*rect = scanout->dst_rect;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rect->x = 0;
|
|
||||||
rect->y = 0;
|
|
||||||
rect->width = cogl_scanout_buffer_get_width (scanout->scanout_buffer);
|
|
||||||
rect->height = cogl_scanout_buffer_get_height (scanout->scanout_buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_scanout_set_dst_rect (CoglScanout *scanout,
|
|
||||||
const MtkRectangle *rect)
|
|
||||||
{
|
|
||||||
if (rect != NULL)
|
|
||||||
scanout->dst_rect = *rect;
|
|
||||||
|
|
||||||
scanout->has_dst_rect = rect != NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -81,7 +81,8 @@ void cogl_scanout_notify_failed (CoglScanout *scanout,
|
|||||||
CoglOnscreen *onscreen);
|
CoglOnscreen *onscreen);
|
||||||
|
|
||||||
COGL_EXPORT
|
COGL_EXPORT
|
||||||
CoglScanout * cogl_scanout_new (CoglScanoutBuffer *scanout_buffer);
|
CoglScanout * cogl_scanout_new (CoglScanoutBuffer *scanout_buffer,
|
||||||
|
const MtkRectangle *dst_rect);
|
||||||
|
|
||||||
COGL_EXPORT
|
COGL_EXPORT
|
||||||
void cogl_scanout_get_src_rect (CoglScanout *scanout,
|
void cogl_scanout_get_src_rect (CoglScanout *scanout,
|
||||||
@ -93,8 +94,4 @@ void cogl_scanout_set_src_rect (CoglScanout *scanout,
|
|||||||
|
|
||||||
COGL_EXPORT
|
COGL_EXPORT
|
||||||
void cogl_scanout_get_dst_rect (CoglScanout *scanout,
|
void cogl_scanout_get_dst_rect (CoglScanout *scanout,
|
||||||
MtkRectangle *rect);
|
MtkRectangle *dst_rect);
|
||||||
|
|
||||||
COGL_EXPORT
|
|
||||||
void cogl_scanout_set_dst_rect (CoglScanout *scanout,
|
|
||||||
const MtkRectangle *rect);
|
|
||||||
|
@ -924,9 +924,9 @@ try_acquire_egl_image_scanout (MetaWaylandBuffer *buffer,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
scanout = cogl_scanout_new (COGL_SCANOUT_BUFFER (g_steal_pointer (&fb)));
|
scanout = cogl_scanout_new (COGL_SCANOUT_BUFFER (g_steal_pointer (&fb)),
|
||||||
|
dst_rect);
|
||||||
cogl_scanout_set_src_rect (scanout, src_rect);
|
cogl_scanout_set_src_rect (scanout, src_rect);
|
||||||
cogl_scanout_set_dst_rect (scanout, dst_rect);
|
|
||||||
if (!meta_onscreen_native_is_buffer_scanout_compatible (onscreen, scanout))
|
if (!meta_onscreen_native_is_buffer_scanout_compatible (onscreen, scanout))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -666,9 +666,9 @@ meta_wayland_dma_buf_try_acquire_scanout (MetaWaylandBuffer *buffer,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
scanout = cogl_scanout_new (COGL_SCANOUT_BUFFER (g_steal_pointer (&fb)));
|
scanout = cogl_scanout_new (COGL_SCANOUT_BUFFER (g_steal_pointer (&fb)),
|
||||||
|
dst_rect);
|
||||||
cogl_scanout_set_src_rect (scanout, src_rect);
|
cogl_scanout_set_src_rect (scanout, src_rect);
|
||||||
cogl_scanout_set_dst_rect (scanout, dst_rect);
|
|
||||||
|
|
||||||
if (!meta_onscreen_native_is_buffer_scanout_compatible (onscreen, scanout))
|
if (!meta_onscreen_native_is_buffer_scanout_compatible (onscreen, scanout))
|
||||||
{
|
{
|
||||||
|
@ -2409,7 +2409,6 @@ meta_wayland_surface_try_acquire_scanout (MetaWaylandSurface *surface,
|
|||||||
MetaSurfaceActor *surface_actor;
|
MetaSurfaceActor *surface_actor;
|
||||||
MtkMonitorTransform view_transform;
|
MtkMonitorTransform view_transform;
|
||||||
ClutterActorBox actor_box;
|
ClutterActorBox actor_box;
|
||||||
MtkRectangle *crtc_dst_rect_ptr = NULL;
|
|
||||||
MtkRectangle crtc_dst_rect;
|
MtkRectangle crtc_dst_rect;
|
||||||
graphene_rect_t *src_rect_ptr = NULL;
|
graphene_rect_t *src_rect_ptr = NULL;
|
||||||
graphene_rect_t src_rect;
|
graphene_rect_t src_rect;
|
||||||
@ -2465,13 +2464,6 @@ meta_wayland_surface_try_acquire_scanout (MetaWaylandSurface *surface,
|
|||||||
view_crtc_height,
|
view_crtc_height,
|
||||||
&crtc_dst_rect);
|
&crtc_dst_rect);
|
||||||
|
|
||||||
/* Use an implicit destination rect when possible */
|
|
||||||
if (surface->viewport.has_dst_size ||
|
|
||||||
crtc_dst_rect.x != 0 || crtc_dst_rect.y != 0 ||
|
|
||||||
crtc_dst_rect.width != view_crtc_width ||
|
|
||||||
crtc_dst_rect.height != view_crtc_height)
|
|
||||||
crtc_dst_rect_ptr = &crtc_dst_rect;
|
|
||||||
|
|
||||||
if (surface->viewport.has_src_rect)
|
if (surface->viewport.has_src_rect)
|
||||||
{
|
{
|
||||||
src_rect = surface->viewport.src_rect;
|
src_rect = surface->viewport.src_rect;
|
||||||
@ -2481,7 +2473,7 @@ meta_wayland_surface_try_acquire_scanout (MetaWaylandSurface *surface,
|
|||||||
return meta_wayland_buffer_try_acquire_scanout (surface->buffer,
|
return meta_wayland_buffer_try_acquire_scanout (surface->buffer,
|
||||||
onscreen,
|
onscreen,
|
||||||
src_rect_ptr,
|
src_rect_ptr,
|
||||||
crtc_dst_rect_ptr);
|
&crtc_dst_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaCrtc *
|
MetaCrtc *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user