wayland/surface: Move shaped-texture synchronization to actor surface

As with most other state that ends up being pushed to the actor and the
associated shaped texture, also push the texture and the corresponding
metadata from the actor surface. This fixes an issue when a toplevel
surface was reset, where before the subsurface content was not properly
re-initialized, as content state synchronization only happened on
commit, not when asked to synchronize.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
This commit is contained in:
Jonas Ådahl 2019-12-06 18:57:10 +01:00 committed by Georges Basile Stavracas Neto
parent fe7bece31e
commit f0df07cba3
6 changed files with 25 additions and 38 deletions

View File

@ -28,6 +28,7 @@
#include "compositor/meta-surface-actor-wayland.h" #include "compositor/meta-surface-actor-wayland.h"
#include "compositor/meta-window-actor-wayland.h" #include "compositor/meta-window-actor-wayland.h"
#include "compositor/region-utils.h" #include "compositor/region-utils.h"
#include "wayland/meta-wayland-buffer.h"
#include "wayland/meta-wayland-surface.h" #include "wayland/meta-wayland-surface.h"
#include "wayland/meta-window-wayland.h" #include "wayland/meta-window-wayland.h"
@ -147,13 +148,33 @@ meta_wayland_actor_surface_real_sync_actor_state (MetaWaylandActorSurface *actor
meta_wayland_surface_role_get_surface (surface_role); meta_wayland_surface_role_get_surface (surface_role);
MetaSurfaceActor *surface_actor; MetaSurfaceActor *surface_actor;
MetaShapedTexture *stex; MetaShapedTexture *stex;
MetaWaylandBuffer *buffer;
cairo_rectangle_int_t surface_rect; cairo_rectangle_int_t surface_rect;
int geometry_scale; int geometry_scale;
MetaWaylandSurface *subsurface_surface; MetaWaylandSurface *subsurface_surface;
surface_actor = priv->actor; surface_actor = priv->actor;
stex = meta_surface_actor_get_texture (surface_actor); stex = meta_surface_actor_get_texture (surface_actor);
buffer = surface->buffer_ref.buffer;
if (buffer)
{
CoglSnippet *snippet;
gboolean is_y_inverted;
snippet = meta_wayland_buffer_create_snippet (buffer);
is_y_inverted = meta_wayland_buffer_is_y_inverted (buffer);
meta_shaped_texture_set_texture (stex, surface->texture);
meta_shaped_texture_set_snippet (stex, snippet);
meta_shaped_texture_set_is_y_inverted (stex, is_y_inverted);
meta_shaped_texture_set_buffer_scale (stex, surface->scale); meta_shaped_texture_set_buffer_scale (stex, surface->scale);
cogl_clear_object (&snippet);
}
else
{
meta_shaped_texture_set_texture (stex, NULL);
}
/* Wayland surface coordinate space -> stage coordinate space */ /* Wayland surface coordinate space -> stage coordinate space */
geometry_scale = meta_wayland_actor_surface_get_geometry_scale (actor_surface); geometry_scale = meta_wayland_actor_surface_get_geometry_scale (actor_surface);

View File

@ -222,7 +222,6 @@ shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer,
static gboolean static gboolean
shm_buffer_attach (MetaWaylandBuffer *buffer, shm_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, CoglTexture **texture,
gboolean *changed_texture,
GError **error) GError **error)
{ {
MetaBackend *backend = meta_get_backend (); MetaBackend *backend = meta_get_backend ();
@ -248,7 +247,6 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
_cogl_texture_get_format (*texture) == format) _cogl_texture_get_format (*texture) == format)
{ {
buffer->is_y_inverted = TRUE; buffer->is_y_inverted = TRUE;
*changed_texture = FALSE;
return TRUE; return TRUE;
} }
@ -293,7 +291,6 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
return FALSE; return FALSE;
*texture = new_texture; *texture = new_texture;
*changed_texture = TRUE;
buffer->is_y_inverted = TRUE; buffer->is_y_inverted = TRUE;
return TRUE; return TRUE;
@ -302,7 +299,6 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
static gboolean static gboolean
egl_image_buffer_attach (MetaWaylandBuffer *buffer, egl_image_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, CoglTexture **texture,
gboolean *changed_texture,
GError **error) GError **error)
{ {
MetaBackend *backend = meta_get_backend (); MetaBackend *backend = meta_get_backend ();
@ -318,7 +314,6 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
if (buffer->egl_image.texture) if (buffer->egl_image.texture)
{ {
*changed_texture = *texture != buffer->egl_image.texture;
cogl_clear_object (texture); cogl_clear_object (texture);
*texture = cogl_object_ref (buffer->egl_image.texture); *texture = cogl_object_ref (buffer->egl_image.texture);
return TRUE; return TRUE;
@ -386,7 +381,6 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
cogl_clear_object (texture); cogl_clear_object (texture);
*texture = cogl_object_ref (buffer->egl_image.texture); *texture = cogl_object_ref (buffer->egl_image.texture);
*changed_texture = TRUE;
return TRUE; return TRUE;
} }
@ -395,7 +389,6 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
static gboolean static gboolean
egl_stream_buffer_attach (MetaWaylandBuffer *buffer, egl_stream_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, CoglTexture **texture,
gboolean *changed_texture,
GError **error) GError **error)
{ {
MetaWaylandEglStream *stream = buffer->egl_stream.stream; MetaWaylandEglStream *stream = buffer->egl_stream.stream;
@ -405,7 +398,6 @@ egl_stream_buffer_attach (MetaWaylandBuffer *buffer,
if (!meta_wayland_egl_stream_attach (stream, error)) if (!meta_wayland_egl_stream_attach (stream, error))
return FALSE; return FALSE;
*changed_texture = *texture != buffer->egl_stream.texture;
cogl_clear_object (texture); cogl_clear_object (texture);
*texture = cogl_object_ref (buffer->egl_stream.texture); *texture = cogl_object_ref (buffer->egl_stream.texture);
@ -435,7 +427,6 @@ egl_stream_buffer_attach (MetaWaylandBuffer *buffer,
gboolean gboolean
meta_wayland_buffer_attach (MetaWaylandBuffer *buffer, meta_wayland_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, CoglTexture **texture,
gboolean *changed_texture,
GError **error) GError **error)
{ {
g_return_val_if_fail (buffer->resource, FALSE); g_return_val_if_fail (buffer->resource, FALSE);
@ -452,17 +443,16 @@ meta_wayland_buffer_attach (MetaWaylandBuffer *buffer,
switch (buffer->type) switch (buffer->type)
{ {
case META_WAYLAND_BUFFER_TYPE_SHM: case META_WAYLAND_BUFFER_TYPE_SHM:
return shm_buffer_attach (buffer, texture, changed_texture, error); return shm_buffer_attach (buffer, texture, error);
case META_WAYLAND_BUFFER_TYPE_EGL_IMAGE: case META_WAYLAND_BUFFER_TYPE_EGL_IMAGE:
return egl_image_buffer_attach (buffer, texture, changed_texture, error); return egl_image_buffer_attach (buffer, texture, error);
#ifdef HAVE_WAYLAND_EGLSTREAM #ifdef HAVE_WAYLAND_EGLSTREAM
case META_WAYLAND_BUFFER_TYPE_EGL_STREAM: case META_WAYLAND_BUFFER_TYPE_EGL_STREAM:
return egl_stream_buffer_attach (buffer, texture, changed_texture, error); return egl_stream_buffer_attach (buffer, texture, error);
#endif #endif
case META_WAYLAND_BUFFER_TYPE_DMA_BUF: case META_WAYLAND_BUFFER_TYPE_DMA_BUF:
return meta_wayland_dma_buf_buffer_attach (buffer, return meta_wayland_dma_buf_buffer_attach (buffer,
texture, texture,
changed_texture,
error); error);
case META_WAYLAND_BUFFER_TYPE_UNKNOWN: case META_WAYLAND_BUFFER_TYPE_UNKNOWN:
g_assert_not_reached (); g_assert_not_reached ();

View File

@ -82,7 +82,6 @@ gboolean meta_wayland_buffer_is_realized (MetaWaylandBuff
gboolean meta_wayland_buffer_realize (MetaWaylandBuffer *buffer); gboolean meta_wayland_buffer_realize (MetaWaylandBuffer *buffer);
gboolean meta_wayland_buffer_attach (MetaWaylandBuffer *buffer, gboolean meta_wayland_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, CoglTexture **texture,
gboolean *changed_texture,
GError **error); GError **error);
CoglSnippet * meta_wayland_buffer_create_snippet (MetaWaylandBuffer *buffer); CoglSnippet * meta_wayland_buffer_create_snippet (MetaWaylandBuffer *buffer);
gboolean meta_wayland_buffer_is_y_inverted (MetaWaylandBuffer *buffer); gboolean meta_wayland_buffer_is_y_inverted (MetaWaylandBuffer *buffer);

View File

@ -168,13 +168,11 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer,
gboolean gboolean
meta_wayland_dma_buf_buffer_attach (MetaWaylandBuffer *buffer, meta_wayland_dma_buf_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, CoglTexture **texture,
gboolean *changed_texture,
GError **error) GError **error)
{ {
if (!meta_wayland_dma_buf_realize_texture (buffer, error)) if (!meta_wayland_dma_buf_realize_texture (buffer, error))
return FALSE; return FALSE;
*changed_texture = *texture != buffer->dma_buf.texture;
cogl_clear_object (texture); cogl_clear_object (texture);
*texture = cogl_object_ref (buffer->dma_buf.texture); *texture = cogl_object_ref (buffer->dma_buf.texture);
return TRUE; return TRUE;

View File

@ -44,7 +44,6 @@ gboolean meta_wayland_dma_buf_init (MetaWaylandCompositor *compositor);
gboolean gboolean
meta_wayland_dma_buf_buffer_attach (MetaWaylandBuffer *buffer, meta_wayland_dma_buf_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, CoglTexture **texture,
gboolean *changed_texture,
GError **error); GError **error);
MetaWaylandDmaBufBuffer * MetaWaylandDmaBufBuffer *

View File

@ -652,11 +652,9 @@ meta_wayland_surface_apply_state (MetaWaylandSurface *surface,
if (state->buffer) if (state->buffer)
{ {
GError *error = NULL; GError *error = NULL;
gboolean changed_texture;
if (!meta_wayland_buffer_attach (state->buffer, if (!meta_wayland_buffer_attach (state->buffer,
&surface->texture, &surface->texture,
&changed_texture,
&error)) &error))
{ {
g_warning ("Could not import pending buffer: %s", error->message); g_warning ("Could not import pending buffer: %s", error->message);
@ -667,24 +665,6 @@ meta_wayland_surface_apply_state (MetaWaylandSurface *surface,
g_error_free (error); g_error_free (error);
goto cleanup; goto cleanup;
} }
if (changed_texture && meta_wayland_surface_get_actor (surface))
{
MetaShapedTexture *stex;
CoglTexture *texture;
CoglSnippet *snippet;
gboolean is_y_inverted;
stex = meta_surface_actor_get_texture (meta_wayland_surface_get_actor (surface));
texture = surface->texture;
snippet = meta_wayland_buffer_create_snippet (state->buffer);
is_y_inverted = meta_wayland_buffer_is_y_inverted (state->buffer);
meta_shaped_texture_set_texture (stex, texture);
meta_shaped_texture_set_snippet (stex, snippet);
meta_shaped_texture_set_is_y_inverted (stex, is_y_inverted);
g_clear_pointer (&snippet, cogl_object_unref);
}
} }
else else
{ {