1
0
Fork 0

surface-actor: Pass damage area as MtkRectangle

All the corresponding calls ends up creating a rectangle anyways

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3945>
This commit is contained in:
Bilal Elmoussaoui 2024-08-13 11:16:38 +02:00
parent cbe88c8e71
commit 4ea693bc20
10 changed files with 47 additions and 81 deletions

View file

@ -1157,10 +1157,7 @@ cogl_texture_pixmap_x11_new_right (CoglTexturePixmapX11 *tfp_left)
void
cogl_texture_pixmap_x11_update_area (CoglTexturePixmapX11 *tex_pixmap,
int x,
int y,
int width,
int height)
const MtkRectangle *area)
{
/* We'll queue the update for both the GLX texture and the regular
texture because we can't determine which will be needed until we
@ -1176,7 +1173,7 @@ cogl_texture_pixmap_x11_update_area (CoglTexturePixmapX11 *tex_pixmap,
winsys->texture_pixmap_x11_damage_notify (tex_pixmap);
}
mtk_rectangle_union (&tex_pixmap->damage_rect,
&MTK_RECTANGLE_INIT (x, y, width, height),
area,
&tex_pixmap->damage_rect);
}

View file

@ -183,10 +183,7 @@ cogl_texture_pixmap_x11_new_right (CoglTexturePixmapX11 *left_texture);
/**
* cogl_texture_pixmap_x11_update_area:
* @texture: A #CoglTexturePixmapX11 instance
* @x: x coordinate of the area to update
* @y: y coordinate of the area to update
* @width: width of the area to update
* @height: height of the area to update
* @area: The area to update
*
* Forces an update of the given @texture so that it is refreshed with
* the contents of the pixmap that was given to
@ -194,10 +191,7 @@ cogl_texture_pixmap_x11_new_right (CoglTexturePixmapX11 *left_texture);
*/
COGL_EXPORT void
cogl_texture_pixmap_x11_update_area (CoglTexturePixmapX11 *texture,
int x,
int y,
int width,
int height);
const MtkRectangle *area);
/**
* cogl_texture_pixmap_x11_is_using_tfp_extension:

View file

@ -55,12 +55,9 @@ void meta_shaped_texture_reset_viewport_dst_size (MetaShapedTexture *stex);
void meta_shaped_texture_set_buffer_scale (MetaShapedTexture *stex,
int buffer_scale);
gboolean meta_shaped_texture_update_area (MetaShapedTexture *stex,
int x,
int y,
int width,
int height,
MtkRectangle *clip);
gboolean meta_shaped_texture_update_area (MetaShapedTexture *stex,
const MtkRectangle *area,
MtkRectangle *clip);
int meta_shaped_texture_get_width (MetaShapedTexture *stex);
int meta_shaped_texture_get_height (MetaShapedTexture *stex);

View file

@ -1204,12 +1204,9 @@ meta_shaped_texture_set_mask_texture (MetaShapedTexture *stex,
* Return value: Whether a redraw have been queued or not
*/
gboolean
meta_shaped_texture_update_area (MetaShapedTexture *stex,
int x,
int y,
int width,
int height,
MtkRectangle *clip)
meta_shaped_texture_update_area (MetaShapedTexture *stex,
const MtkRectangle *area,
MtkRectangle *clip)
{
MtkMonitorTransform inverted_transform;
MtkRectangle buffer_rect;
@ -1221,10 +1218,10 @@ meta_shaped_texture_update_area (MetaShapedTexture *stex,
/* Pad the actor clip to ensure that pixels affected by linear scaling are accounted for */
*clip = (MtkRectangle) {
.x = x - 1,
.y = y - 1,
.width = width + 2,
.height = height + 2
.x = area->x - 1,
.y = area->y - 1,
.width = area->width + 2,
.height = area->height + 2
};
buffer_rect = (MtkRectangle) {

View file

@ -48,13 +48,10 @@ G_DEFINE_TYPE (MetaSurfaceActorWayland,
META_TYPE_SURFACE_ACTOR)
static void
meta_surface_actor_wayland_process_damage (MetaSurfaceActor *actor,
int x,
int y,
int width,
int height)
meta_surface_actor_wayland_process_damage (MetaSurfaceActor *actor,
const MtkRectangle *area)
{
meta_surface_actor_update_area (actor, x, y, width, height);
meta_surface_actor_update_area (actor, area);
}
static gboolean

View file

@ -190,11 +190,8 @@ meta_surface_actor_x11_is_visible (MetaSurfaceActorX11 *self)
}
static void
meta_surface_actor_x11_process_damage (MetaSurfaceActor *actor,
int x,
int y,
int width,
int height)
meta_surface_actor_x11_process_damage (MetaSurfaceActor *actor,
const MtkRectangle *area)
{
MetaSurfaceActorX11 *self = META_SURFACE_ACTOR_X11 (actor);
CoglTexturePixmapX11 *pixmap;
@ -206,10 +203,10 @@ meta_surface_actor_x11_process_damage (MetaSurfaceActor *actor,
MtkRectangle window_rect;
meta_window_get_frame_rect (self->window, &window_rect);
if (x == 0 &&
y == 0 &&
window_rect.width == width &&
window_rect.height == height)
if (area->x == 0 &&
area->y == 0 &&
window_rect.width == area->width &&
window_rect.height == area->height)
self->full_damage_frames_count++;
else
self->full_damage_frames_count = 0;
@ -226,8 +223,8 @@ meta_surface_actor_x11_process_damage (MetaSurfaceActor *actor,
return;
pixmap = COGL_TEXTURE_PIXMAP_X11 (meta_multi_texture_get_plane (self->texture, 0));
cogl_texture_pixmap_x11_update_area (pixmap, x, y, width, height);
meta_surface_actor_update_area (actor, x, y, width, height);
cogl_texture_pixmap_x11_update_area (pixmap, area);
meta_surface_actor_update_area (actor, area);
}
void

View file

@ -430,18 +430,15 @@ meta_surface_actor_schedule_update (MetaSurfaceActor *self)
}
void
meta_surface_actor_update_area (MetaSurfaceActor *self,
int x,
int y,
int width,
int height)
meta_surface_actor_update_area (MetaSurfaceActor *self,
const MtkRectangle *area)
{
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (self);
gboolean repaint_scheduled = FALSE;
MtkRectangle clip;
if (meta_shaped_texture_update_area (priv->texture, x, y, width, height, &clip))
if (meta_shaped_texture_update_area (priv->texture, area, &clip))
{
MtkRegion *unobscured_region;
@ -624,11 +621,8 @@ meta_surface_actor_get_opaque_region (MetaSurfaceActor *self)
}
void
meta_surface_actor_process_damage (MetaSurfaceActor *self,
int x,
int y,
int width,
int height)
meta_surface_actor_process_damage (MetaSurfaceActor *self,
const MtkRectangle *area)
{
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (self);
@ -648,16 +642,15 @@ meta_surface_actor_process_damage (MetaSurfaceActor *self,
* any drawing done to the window is always immediately reflected in the
* texture regardless of damage event handling.
*/
MtkRectangle rect = { .x = x, .y = y, .width = width, .height = height };
if (!priv->pending_damage)
priv->pending_damage = mtk_region_create_rectangle (&rect);
priv->pending_damage = mtk_region_create_rectangle (area);
else
mtk_region_union_rectangle (priv->pending_damage, &rect);
mtk_region_union_rectangle (priv->pending_damage, area);
return;
}
META_SURFACE_ACTOR_GET_CLASS (self)->process_damage (self, x, y, width, height);
META_SURFACE_ACTOR_GET_CLASS (self)->process_damage (self, area);
}
void
@ -685,8 +678,7 @@ meta_surface_actor_set_frozen (MetaSurfaceActor *self,
for (i = 0; i < n_rects; i++)
{
rect = mtk_region_get_rectangle (priv->pending_damage, i);
meta_surface_actor_process_damage (self, rect.x, rect.y,
rect.width, rect.height);
meta_surface_actor_process_damage (self, &rect);
}
g_clear_pointer (&priv->pending_damage, mtk_region_unref);
}

View file

@ -19,18 +19,15 @@ struct _MetaSurfaceActorClass
/*< private >*/
ClutterActorClass parent_class;
void (* process_damage) (MetaSurfaceActor *actor,
int x, int y, int width, int height);
gboolean (* is_opaque) (MetaSurfaceActor *actor);
void (* process_damage) (MetaSurfaceActor *actor,
const MtkRectangle *area);
gboolean (* is_opaque) (MetaSurfaceActor *actor);
};
MetaShapedTexture *meta_surface_actor_get_texture (MetaSurfaceActor *self);
void meta_surface_actor_update_area (MetaSurfaceActor *self,
int x,
int y,
int width,
int height);
void meta_surface_actor_update_area (MetaSurfaceActor *self,
const MtkRectangle *area);
gboolean meta_surface_actor_is_obscured (MetaSurfaceActor *self);
@ -51,8 +48,8 @@ MtkRegion * meta_surface_actor_get_opaque_region (MetaSurfaceActor *self);
void meta_surface_actor_schedule_update (MetaSurfaceActor *self);
void meta_surface_actor_process_damage (MetaSurfaceActor *actor,
int x, int y, int width, int height);
void meta_surface_actor_process_damage (MetaSurfaceActor *actor,
const MtkRectangle *area);
gboolean meta_surface_actor_is_opaque (MetaSurfaceActor *actor);

View file

@ -693,14 +693,14 @@ meta_window_actor_x11_process_damage (MetaWindowActorX11 *actor_x11,
XDamageNotifyEvent *event)
{
MetaSurfaceActor *surface;
MtkRectangle area = MTK_RECTANGLE_INIT (event->area.x,
event->area.y,
event->area.width,
event->area.height);
surface = meta_window_actor_get_surface (META_WINDOW_ACTOR (actor_x11));
if (surface)
meta_surface_actor_process_damage (surface,
event->area.x,
event->area.y,
event->area.width,
event->area.height);
meta_surface_actor_process_damage (surface, &area);
meta_window_actor_notify_damaged (META_WINDOW_ACTOR (actor_x11));
}

View file

@ -392,9 +392,7 @@ surface_process_damage (MetaWaylandSurface *surface,
MtkRectangle rect;
rect = mtk_region_get_rectangle (buffer_region, i);
meta_surface_actor_process_damage (actor,
rect.x, rect.y,
rect.width, rect.height);
meta_surface_actor_process_damage (actor, &rect);
}
}
}