mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-06 10:28:01 +02:00
[region] Add a cairo_region_overlap_t type
This commit is contained in:
parent
ebd0e685ae
commit
df883aa937
3 changed files with 33 additions and 12 deletions
|
|
@ -215,7 +215,7 @@ _add_operation (cairo_analysis_surface_t *surface,
|
|||
* region there is no benefit in emitting a native operation as
|
||||
* the fallback image will be painted on top.
|
||||
*/
|
||||
if (_cairo_region_contains_rectangle (surface->fallback_region, rect) == PIXMAN_REGION_IN)
|
||||
if (_cairo_region_contains_rectangle (surface->fallback_region, rect) == CAIRO_REGION_OVERLAP_IN)
|
||||
return CAIRO_INT_STATUS_IMAGE_FALLBACK;
|
||||
|
||||
if (backend_status == CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY) {
|
||||
|
|
@ -226,7 +226,7 @@ _add_operation (cairo_analysis_surface_t *surface,
|
|||
* natively supported and the backend will blend the
|
||||
* transparency into the white background.
|
||||
*/
|
||||
if (_cairo_region_contains_rectangle (surface->supported_region, rect) == PIXMAN_REGION_OUT)
|
||||
if (_cairo_region_contains_rectangle (surface->supported_region, rect) == CAIRO_REGION_OVERLAP_OUT)
|
||||
backend_status = CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,12 @@ struct _cairo_region {
|
|||
pixman_region32_t rgn;
|
||||
};
|
||||
|
||||
typedef enum _cairo_region_overlap {
|
||||
CAIRO_REGION_OVERLAP_IN, /* completely inside region */
|
||||
CAIRO_REGION_OVERLAP_OUT, /* completely outside region */
|
||||
CAIRO_REGION_OVERLAP_PART, /* partly inside region */
|
||||
} cairo_region_overlap_t;
|
||||
|
||||
cairo_private cairo_region_t *
|
||||
_cairo_region_create (void);
|
||||
|
||||
|
|
@ -105,7 +111,7 @@ cairo_private void
|
|||
_cairo_region_translate (cairo_region_t *region,
|
||||
int x, int y);
|
||||
|
||||
cairo_private pixman_region_overlap_t
|
||||
cairo_private cairo_region_overlap_t
|
||||
_cairo_region_contains_rectangle (cairo_region_t *region,
|
||||
const cairo_rectangle_int_t *rect);
|
||||
|
||||
|
|
|
|||
|
|
@ -279,19 +279,34 @@ _cairo_region_translate (cairo_region_t *region,
|
|||
pixman_region32_translate (®ion->rgn, x, y);
|
||||
}
|
||||
|
||||
pixman_region_overlap_t
|
||||
cairo_region_overlap_t
|
||||
_cairo_region_contains_rectangle (cairo_region_t *region,
|
||||
const cairo_rectangle_int_t *rect)
|
||||
{
|
||||
pixman_box32_t pbox;
|
||||
pixman_region_overlap_t poverlap;
|
||||
|
||||
if (region->status)
|
||||
return PIXMAN_REGION_OUT;
|
||||
|
||||
pbox.x1 = rect->x;
|
||||
pbox.y1 = rect->y;
|
||||
pbox.x2 = rect->x + rect->width;
|
||||
pbox.y2 = rect->y + rect->height;
|
||||
if (!region->status)
|
||||
{
|
||||
pbox.x1 = rect->x;
|
||||
pbox.y1 = rect->y;
|
||||
pbox.x2 = rect->x + rect->width;
|
||||
pbox.y2 = rect->y + rect->height;
|
||||
|
||||
poverlap = pixman_region32_contains_rectangle (®ion->rgn, &pbox);
|
||||
|
||||
switch (poverlap)
|
||||
{
|
||||
case PIXMAN_REGION_OUT:
|
||||
return CAIRO_REGION_OVERLAP_OUT;
|
||||
|
||||
case PIXMAN_REGION_IN:
|
||||
return CAIRO_REGION_OVERLAP_IN;
|
||||
|
||||
case PIXMAN_REGION_PART:
|
||||
return CAIRO_REGION_OVERLAP_PART;
|
||||
}
|
||||
}
|
||||
|
||||
return pixman_region32_contains_rectangle (®ion->rgn, &pbox);
|
||||
return CAIRO_REGION_OVERLAP_OUT;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue