frame: Pass the frame area for get_mask()

Currently, `meta_frame_get_mask()` and `meta_ui_frame_get_mask()` will
return the frame mask applied to the current frame size, by querying the
frame themselves.

To be able to get the frame mask at an arbitrary size, change the API to
take a rectangle representing the size at which the frame mask should be
rendered.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1009
This commit is contained in:
Olivier Fourdan 2020-01-16 11:42:04 +01:00 committed by Robert Mader
parent 7dbb4bc3f5
commit c0321c7b21
5 changed files with 20 additions and 16 deletions

View File

@ -890,6 +890,9 @@ build_and_scan_frame_mask (MetaWindowActorX11 *actor_x11,
{ {
cairo_region_t *frame_paint_region, *scanned_region; cairo_region_t *frame_paint_region, *scanned_region;
cairo_rectangle_int_t rect = { 0, 0, tex_width, tex_height }; cairo_rectangle_int_t rect = { 0, 0, tex_width, tex_height };
cairo_rectangle_int_t frame_rect;
meta_window_get_frame_rect (window, &frame_rect);
/* Make sure we don't paint the frame over the client window. */ /* Make sure we don't paint the frame over the client window. */
frame_paint_region = cairo_region_create_rectangle (&rect); frame_paint_region = cairo_region_create_rectangle (&rect);
@ -899,7 +902,7 @@ build_and_scan_frame_mask (MetaWindowActorX11 *actor_x11,
gdk_cairo_region (cr, frame_paint_region); gdk_cairo_region (cr, frame_paint_region);
cairo_clip (cr); cairo_clip (cr);
meta_frame_get_mask (window->frame, cr); meta_frame_get_mask (window->frame, &frame_rect, cr);
cairo_surface_flush (image); cairo_surface_flush (image);
scanned_region = scan_visible_region (mask_data, stride, frame_paint_region); scanned_region = scan_visible_region (mask_data, stride, frame_paint_region);

View File

@ -371,10 +371,11 @@ meta_frame_get_frame_bounds (MetaFrame *frame)
} }
void void
meta_frame_get_mask (MetaFrame *frame, meta_frame_get_mask (MetaFrame *frame,
cairo_t *cr) cairo_rectangle_int_t *frame_rect,
cairo_t *cr)
{ {
meta_ui_frame_get_mask (frame->ui_frame, cr); meta_ui_frame_get_mask (frame->ui_frame, frame_rect, cr);
} }
void void

View File

@ -72,8 +72,9 @@ void meta_frame_clear_cached_borders (MetaFrame *frame);
cairo_region_t *meta_frame_get_frame_bounds (MetaFrame *frame); cairo_region_t *meta_frame_get_frame_bounds (MetaFrame *frame);
void meta_frame_get_mask (MetaFrame *frame, void meta_frame_get_mask (MetaFrame *frame,
cairo_t *cr); cairo_rectangle_int_t *frame_rect,
cairo_t *cr);
void meta_frame_set_screen_cursor (MetaFrame *frame, void meta_frame_set_screen_cursor (MetaFrame *frame,
MetaCursor cursor); MetaCursor cursor);

View File

@ -1423,22 +1423,20 @@ get_visible_frame_border_region (MetaUIFrame *frame)
* frame's alpha channel, as a mask to be applied to an opaque pixmap. * frame's alpha channel, as a mask to be applied to an opaque pixmap.
* *
* @frame: This frame * @frame: This frame
* @xwindow: The X window for the frame, which has the client window as a child * @frame_rect: The frame rect
* @cr: Used to draw the resulting mask * @cr: Used to draw the resulting mask
*/ */
void void
meta_ui_frame_get_mask (MetaUIFrame *frame, meta_ui_frame_get_mask (MetaUIFrame *frame,
cairo_t *cr) cairo_rectangle_int_t *frame_rect,
cairo_t *cr)
{ {
MetaFrameBorders borders; MetaFrameBorders borders;
MetaFrameFlags flags; MetaFrameFlags flags;
MetaRectangle frame_rect;
cairo_surface_t *surface; cairo_surface_t *surface;
double xscale, yscale; double xscale, yscale;
int scale; int scale;
meta_window_get_frame_rect (frame->meta_window, &frame_rect);
flags = meta_frame_get_flags (frame->meta_window->frame); flags = meta_frame_get_flags (frame->meta_window->frame);
meta_style_info_set_flags (frame->style_info, flags); meta_style_info_set_flags (frame->style_info, flags);
@ -1453,11 +1451,11 @@ meta_ui_frame_get_mask (MetaUIFrame *frame,
gtk_render_background (frame->style_info->styles[META_STYLE_ELEMENT_FRAME], cr, gtk_render_background (frame->style_info->styles[META_STYLE_ELEMENT_FRAME], cr,
borders.invisible.left / scale, borders.invisible.left / scale,
borders.invisible.top / scale, borders.invisible.top / scale,
frame_rect.width / scale, frame_rect.height / scale); frame_rect->width / scale, frame_rect->height / scale);
gtk_render_background (frame->style_info->styles[META_STYLE_ELEMENT_TITLEBAR], cr, gtk_render_background (frame->style_info->styles[META_STYLE_ELEMENT_TITLEBAR], cr,
borders.invisible.left / scale, borders.invisible.left / scale,
borders.invisible.top / scale, borders.invisible.top / scale,
frame_rect.width / scale, borders.total.top / scale); frame_rect->width / scale, borders.total.top / scale);
cairo_surface_set_device_scale (surface, xscale, yscale); cairo_surface_set_device_scale (surface, xscale, yscale);
} }

View File

@ -135,8 +135,9 @@ void meta_ui_frame_get_borders (MetaUIFrame *frame,
cairo_region_t * meta_ui_frame_get_bounds (MetaUIFrame *frame); cairo_region_t * meta_ui_frame_get_bounds (MetaUIFrame *frame);
void meta_ui_frame_get_mask (MetaUIFrame *frame, void meta_ui_frame_get_mask (MetaUIFrame *frame,
cairo_t *cr); cairo_rectangle_int_t *frame_rect,
cairo_t *cr);
void meta_ui_frame_move_resize (MetaUIFrame *frame, void meta_ui_frame_move_resize (MetaUIFrame *frame,
int x, int y, int width, int height); int x, int y, int width, int height);