forked from AuroraMiddleware/gtk
Add internal gdk_cairo_region_from_clip helper
This extract the current cairo clip region if possible and returns it as a cairo_region_T. It will be needed by later code.
This commit is contained in:
parent
892c6bd6f9
commit
ceeed1c48d
@ -525,3 +525,38 @@ gdk_cairo_region_create_from_surface (cairo_surface_t *surface)
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
cairo_region_t *
|
||||
gdk_cairo_region_from_clip (cairo_t *cr)
|
||||
{
|
||||
cairo_rectangle_list_t *rectangles;
|
||||
cairo_region_t *region;
|
||||
int i;
|
||||
|
||||
rectangles = cairo_copy_clip_rectangle_list (cr);
|
||||
|
||||
if (rectangles->status != CAIRO_STATUS_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
region = cairo_region_create ();
|
||||
for (i = 0; i < rectangles->num_rectangles; i++)
|
||||
{
|
||||
cairo_rectangle_int_t clip_rect;
|
||||
cairo_rectangle_t *rect;
|
||||
|
||||
rect = &rectangles->rectangles[i];
|
||||
|
||||
/* Here we assume clip rects are ints for direct targets, which
|
||||
is true for cairo */
|
||||
clip_rect.x = (int)rect->x;
|
||||
clip_rect.y = (int)rect->y;
|
||||
clip_rect.width = (int)rect->width;
|
||||
clip_rect.height = (int)rect->height;
|
||||
|
||||
cairo_region_union_rectangle (region, &clip_rect);
|
||||
}
|
||||
|
||||
cairo_rectangle_list_destroy (rectangles);
|
||||
|
||||
return region;
|
||||
}
|
||||
|
@ -319,8 +319,10 @@ void _gdk_windowing_event_data_free (GdkEvent *event);
|
||||
void _gdk_set_window_state (GdkWindow *window,
|
||||
GdkWindowState new_state);
|
||||
|
||||
gboolean _gdk_cairo_surface_extents (cairo_surface_t *surface,
|
||||
GdkRectangle *extents);
|
||||
gboolean _gdk_cairo_surface_extents (cairo_surface_t *surface,
|
||||
GdkRectangle *extents);
|
||||
cairo_region_t *gdk_cairo_region_from_clip (cairo_t *cr);
|
||||
|
||||
|
||||
/*************************************
|
||||
* Interfaces used by windowing code *
|
||||
|
Loading…
Reference in New Issue
Block a user