gdkgc: Draw clip mask with Cairo
This commit is contained in:
27
gdk/gdkgc.c
27
gdk/gdkgc.c
@ -612,23 +612,28 @@ _gdk_gc_add_drawable_clip (GdkGC *gc,
|
|||||||
overlap = cairo_region_contains_rectangle (region, &r);
|
overlap = cairo_region_contains_rectangle (region, &r);
|
||||||
if (overlap == CAIRO_REGION_OVERLAP_PART)
|
if (overlap == CAIRO_REGION_OVERLAP_PART)
|
||||||
{
|
{
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
/* The region and the mask intersect, create a new clip mask that
|
/* The region and the mask intersect, create a new clip mask that
|
||||||
includes both areas */
|
includes both areas */
|
||||||
priv->old_clip_mask = g_object_ref (priv->clip_mask);
|
priv->old_clip_mask = g_object_ref (priv->clip_mask);
|
||||||
new_mask = gdk_pixmap_new (priv->old_clip_mask, w, h, -1);
|
new_mask = gdk_pixmap_new (priv->old_clip_mask, w, h, -1);
|
||||||
tmp_gc = _gdk_drawable_get_scratch_gc ((GdkDrawable *)new_mask, FALSE);
|
|
||||||
|
|
||||||
gdk_gc_set_foreground (tmp_gc, &black);
|
cr = gdk_cairo_create (new_mask);
|
||||||
gdk_draw_rectangle (new_mask, tmp_gc, TRUE, 0, 0, -1, -1);
|
|
||||||
_gdk_gc_set_clip_region_internal (tmp_gc, region, TRUE); /* Takes ownership of region */
|
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
|
||||||
gdk_draw_drawable (new_mask,
|
cairo_paint (cr);
|
||||||
tmp_gc,
|
|
||||||
priv->old_clip_mask,
|
gdk_cairo_set_source_pixmap (cr, priv->old_clip_mask, 0, 0);
|
||||||
0, 0,
|
gdk_cairo_region (cr, region);
|
||||||
0, 0,
|
cairo_fill (cr);
|
||||||
-1, -1);
|
|
||||||
gdk_gc_set_clip_region (tmp_gc, NULL);
|
cairo_destroy (cr);
|
||||||
|
|
||||||
|
cairo_region_destroy (region);
|
||||||
|
|
||||||
gdk_gc_set_clip_mask (gc, new_mask);
|
gdk_gc_set_clip_mask (gc, new_mask);
|
||||||
|
|
||||||
g_object_unref (new_mask);
|
g_object_unref (new_mask);
|
||||||
}
|
}
|
||||||
else if (overlap == CAIRO_REGION_OVERLAP_OUT)
|
else if (overlap == CAIRO_REGION_OVERLAP_OUT)
|
||||||
|
|||||||
Reference in New Issue
Block a user