compositor: Add utility function to convert region to cairo_t path
We were relying on gdk_cairo_region() to convert a cairo_region_t into a path ready to fill/stroke in a cairo_t. This is a small and detached helper that we can do ourselves, so put it together with all other region helper functions. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
This commit is contained in:
parent
ab9ea61d3d
commit
1fbbb73343
@ -812,7 +812,7 @@ build_and_scan_frame_mask (MetaWindowActorX11 *actor_x11,
|
||||
stride);
|
||||
cr = cairo_create (image);
|
||||
|
||||
gdk_cairo_region (cr, shape_region);
|
||||
meta_region_to_cairo_path (shape_region, cr);
|
||||
cairo_fill (cr);
|
||||
|
||||
if (window->frame)
|
||||
@ -843,7 +843,7 @@ build_and_scan_frame_mask (MetaWindowActorX11 *actor_x11,
|
||||
frame_paint_region = cairo_region_create_rectangle (&rect);
|
||||
cairo_region_subtract_rectangle (frame_paint_region, &client_area);
|
||||
|
||||
gdk_cairo_region (cr, frame_paint_region);
|
||||
meta_region_to_cairo_path (frame_paint_region, cr);
|
||||
cairo_clip (cr);
|
||||
|
||||
meta_frame_get_mask (window->frame, &frame_rect, cr);
|
||||
|
@ -456,3 +456,19 @@ meta_region_crop_and_scale (cairo_region_t *region,
|
||||
|
||||
return viewport_region;
|
||||
}
|
||||
|
||||
void
|
||||
meta_region_to_cairo_path (cairo_region_t *region,
|
||||
cairo_t *cr)
|
||||
{
|
||||
cairo_rectangle_int_t rect;
|
||||
int n_rects, i;
|
||||
|
||||
n_rects = cairo_region_num_rectangles (region);
|
||||
|
||||
for (i = 0; i < n_rects; i++)
|
||||
{
|
||||
cairo_region_get_rectangle (region, i, &rect);
|
||||
cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height);
|
||||
}
|
||||
}
|
||||
|
@ -116,4 +116,7 @@ cairo_region_t * meta_region_crop_and_scale (cairo_region_t *region,
|
||||
int dst_width,
|
||||
int dst_height);
|
||||
|
||||
void meta_region_to_cairo_path (cairo_region_t *region,
|
||||
cairo_t *cr);
|
||||
|
||||
#endif /* __META_REGION_UTILS_H__ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user