screen-cast-window: Use buffer bounds in place of frame bounds

The frame bounds as returned by `meta_window_actor_get_frame_bounds()`
would be used as cropping values when streaming a window content.

But, as its name implies, it returns the actual frame bounds, whereas we
may want to include the whole buffer, to include client side shadows for
example.

Rename the `get_frame_bounds()` API to `get_buffer_bounds()` (which was
previously partly removed with commit 11bd84789) and return the actual
buffer bounds to use as the cropping area when streaming a window.

Fixes: 931934511 - "Implement MetaScreenCastWindow interface"
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1022
Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1018
This commit is contained in:
Olivier Fourdan 2020-01-28 11:13:41 +01:00
parent ebc07871eb
commit 0f58c98386
4 changed files with 18 additions and 26 deletions

View File

@ -230,7 +230,7 @@ meta_screen_cast_window_stream_src_get_videocrop (MetaScreenCastStreamSrc *src,
META_SCREEN_CAST_WINDOW_STREAM_SRC (src);
MetaRectangle stream_rect;
meta_screen_cast_window_get_frame_bounds (window_src->screen_cast_window,
meta_screen_cast_window_get_buffer_bounds (window_src->screen_cast_window,
crop_rect);
stream_rect.x = 0;

View File

@ -30,10 +30,10 @@ meta_screen_cast_window_default_init (MetaScreenCastWindowInterface *iface)
}
void
meta_screen_cast_window_get_frame_bounds (MetaScreenCastWindow *screen_cast_window,
meta_screen_cast_window_get_buffer_bounds (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds)
{
META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window)->get_frame_bounds (screen_cast_window,
META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window)->get_buffer_bounds (screen_cast_window,
bounds);
}

View File

@ -37,7 +37,7 @@ struct _MetaScreenCastWindowInterface
{
GTypeInterface parent_iface;
void (*get_frame_bounds) (MetaScreenCastWindow *screen_cast_window,
void (*get_buffer_bounds) (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds);
void (*transform_relative_position) (MetaScreenCastWindow *screen_cast_window,
@ -59,7 +59,7 @@ struct _MetaScreenCastWindowInterface
gboolean (*has_damage) (MetaScreenCastWindow *screen_cast_window);
};
void meta_screen_cast_window_get_frame_bounds (MetaScreenCastWindow *screen_cast_window,
void meta_screen_cast_window_get_buffer_bounds (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds);
void meta_screen_cast_window_transform_relative_position (MetaScreenCastWindow *screen_cast_window,

View File

@ -1138,29 +1138,21 @@ meta_window_actor_get_geometry_scale (MetaWindowActor *window_actor)
}
static void
meta_window_actor_get_frame_bounds (MetaScreenCastWindow *screen_cast_window,
meta_window_actor_get_buffer_bounds (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds)
{
MetaWindowActor *window_actor = META_WINDOW_ACTOR (screen_cast_window);
MetaWindowActorPrivate *priv =
meta_window_actor_get_instance_private (window_actor);
MetaWindow *window;
MetaShapedTexture *stex;
MetaRectangle buffer_rect;
MetaRectangle frame_rect;
int buffer_scale;
stex = meta_surface_actor_get_texture (priv->surface);
buffer_scale = meta_shaped_texture_get_buffer_scale (stex);
window = priv->window;
meta_window_get_buffer_rect (window, &buffer_rect);
meta_window_get_frame_rect (window, &frame_rect);
bounds->x = (int) floor ((frame_rect.x - buffer_rect.x) / (float) buffer_scale);
bounds->y = (int) floor ((frame_rect.y - buffer_rect.y) / (float) buffer_scale);
bounds->width = (int) ceil (frame_rect.width / (float) buffer_scale);
bounds->height = (int) ceil (frame_rect.height / (float) buffer_scale);
*bounds = (MetaRectangle) {
.width = meta_shaped_texture_get_width (stex) * buffer_scale,
.height = meta_shaped_texture_get_height (stex) * buffer_scale,
};
}
static void
@ -1177,7 +1169,7 @@ meta_window_actor_transform_relative_position (MetaScreenCastWindow *screen_cast
MetaRectangle bounds;
graphene_point3d_t v1 = { 0.f, }, v2 = { 0.f, };
meta_window_actor_get_frame_bounds (screen_cast_window, &bounds);
meta_window_actor_get_buffer_bounds (screen_cast_window, &bounds);
v1.x = CLAMP ((float) x,
bounds.x,
@ -1302,7 +1294,7 @@ meta_window_actor_has_damage (MetaScreenCastWindow *screen_cast_window)
static void
screen_cast_window_iface_init (MetaScreenCastWindowInterface *iface)
{
iface->get_frame_bounds = meta_window_actor_get_frame_bounds;
iface->get_buffer_bounds = meta_window_actor_get_buffer_bounds;
iface->transform_relative_position = meta_window_actor_transform_relative_position;
iface->transform_cursor_position = meta_window_actor_transform_cursor_position;
iface->capture_into = meta_window_actor_capture_into;