зеркало из https://github.com/mozilla/pjs.git
Bug 327878. Add cairo_clip_extract_rectangles, to support native theme rendering patch. r=vlad
This commit is contained in:
Родитель
ec71379d49
Коммит
0053ce924f
|
@ -114,4 +114,13 @@ _cairo_clip_combine_to_surface (cairo_clip_t *clip,
|
|||
int dst_y,
|
||||
const cairo_rectangle_t *extents);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
_cairo_clip_has_clip (cairo_clip_t *clip);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
_cairo_clip_extract_rectangles (cairo_clip_t *clip,
|
||||
int max_rectangles,
|
||||
cairo_clip_rect_t *rectangles_out,
|
||||
int *num_rectangles_out);
|
||||
|
||||
#endif /* CAIRO_CLIP_PRIVATE_H */
|
||||
|
|
|
@ -459,3 +459,53 @@ _cairo_clip_clip (cairo_clip_t *clip,
|
|||
|
||||
return status;
|
||||
}
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_clip_has_clip (cairo_clip_t *clip)
|
||||
{
|
||||
return clip->region != NULL || clip->surface != NULL || clip->path != NULL;
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
_cairo_region_to_clip_rectangles (pixman_region16_t *region,
|
||||
int max_rectangles,
|
||||
cairo_clip_rect_t *rectangles_out,
|
||||
int *num_rectangles_out)
|
||||
{
|
||||
int n_boxes, i;
|
||||
pixman_box16_t *boxes;
|
||||
|
||||
/* no region -> we can't represent it as rectangles */
|
||||
if (region == NULL)
|
||||
return FALSE;
|
||||
|
||||
n_boxes = pixman_region_num_rects (region);
|
||||
*num_rectangles_out = n_boxes;
|
||||
if (n_boxes > max_rectangles)
|
||||
return FALSE;
|
||||
|
||||
boxes = pixman_region_rects (region);
|
||||
|
||||
for (i = 0; i < n_boxes; i++) {
|
||||
rectangles_out[i].x = boxes[i].x1;
|
||||
rectangles_out[i].y = boxes[i].y1;
|
||||
rectangles_out[i].width = boxes[i].x2 - boxes[i].x1;
|
||||
rectangles_out[i].height = boxes[i].y2 - boxes[i].y1;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_clip_extract_rectangles (cairo_clip_t *clip,
|
||||
int max_rectangles,
|
||||
cairo_clip_rect_t *rectangles_out,
|
||||
int *num_rectangles_out)
|
||||
{
|
||||
/* can't handle paths or surfaces for now */
|
||||
if (clip->path != NULL || clip->surface != NULL)
|
||||
return FALSE;
|
||||
|
||||
return _cairo_region_to_clip_rectangles (clip->region,
|
||||
max_rectangles, rectangles_out, num_rectangles_out);
|
||||
}
|
||||
|
|
|
@ -1183,6 +1183,24 @@ _cairo_gstate_clip (cairo_gstate_t *gstate, cairo_path_fixed_t *path)
|
|||
gstate->antialias, gstate->target);
|
||||
}
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_gstate_has_clip (cairo_gstate_t *gstate)
|
||||
{
|
||||
return _cairo_clip_has_clip (&gstate->clip);
|
||||
}
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_gstate_extract_clip_rectangles (cairo_gstate_t *gstate,
|
||||
int max_rectangles,
|
||||
cairo_clip_rect_t *rectangles_out,
|
||||
int *num_rectangles_out)
|
||||
{
|
||||
return _cairo_clip_extract_rectangles (&gstate->clip,
|
||||
max_rectangles,
|
||||
rectangles_out,
|
||||
num_rectangles_out);
|
||||
}
|
||||
|
||||
static void
|
||||
_cairo_gstate_unset_scaled_font (cairo_gstate_t *gstate)
|
||||
{
|
||||
|
|
|
@ -2583,6 +2583,45 @@ cairo_copy_path (cairo_t *cr)
|
|||
return _cairo_path_data_create (&cr->path, cr->gstate);
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_has_clip
|
||||
* @cr: a cairo context
|
||||
*
|
||||
* Returns TRUE if the cairo context has any clipping active, otherwise
|
||||
* FALSE.
|
||||
*/
|
||||
cairo_bool_t
|
||||
cairo_has_clip (cairo_t *cr)
|
||||
{
|
||||
if (cr->status)
|
||||
return FALSE;
|
||||
return _cairo_gstate_has_clip (cr->gstate);
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_extract_clip_rectangles
|
||||
* @cr: a cairo context
|
||||
* @max_rectangles: the maximum number of rectangles to be returned
|
||||
* @rectangles_out: the output buffer for the rectangles
|
||||
* @num_rectangles_out: the number of rectangles returned
|
||||
*
|
||||
* If the current clip can be expressed as the union of at most
|
||||
* 'max_rectangles' device-coordinate rectangles, then we fill in the array
|
||||
* with the rectangles, and return True. Otherwise we return False. When there
|
||||
* is no clipping active, we return False.
|
||||
*/
|
||||
cairo_bool_t
|
||||
cairo_extract_clip_rectangles (cairo_t *cr,
|
||||
int max_rectangles,
|
||||
cairo_clip_rect_t *rectangles_out,
|
||||
int *num_rectangles_out)
|
||||
{
|
||||
if (cr->status)
|
||||
return FALSE;
|
||||
return _cairo_gstate_extract_clip_rectangles (cr->gstate, max_rectangles,
|
||||
rectangles_out, num_rectangles_out);
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_copy_path_flat:
|
||||
* @cr: a cairo context
|
||||
|
|
|
@ -1138,6 +1138,24 @@ cairo_append_path (cairo_t *cr,
|
|||
cairo_public void
|
||||
cairo_path_destroy (cairo_path_t *path);
|
||||
|
||||
/**
|
||||
* cairo_clip_rect_t:
|
||||
*
|
||||
* A data structure for holding clip rectangles.
|
||||
*/
|
||||
typedef struct _cairo_clip_rect {
|
||||
double x, y, width, height;
|
||||
} cairo_clip_rect_t;
|
||||
|
||||
cairo_public cairo_bool_t
|
||||
cairo_has_clip (cairo_t *cr);
|
||||
|
||||
cairo_public cairo_bool_t
|
||||
cairo_extract_clip_rectangles (cairo_t *cr,
|
||||
int max_rectangles,
|
||||
cairo_clip_rect_t *rectangles_out,
|
||||
int *num_rectangles_out);
|
||||
|
||||
/* Error status queries */
|
||||
|
||||
cairo_public cairo_status_t
|
||||
|
|
|
@ -1238,6 +1238,15 @@ _cairo_gstate_clip (cairo_gstate_t *gstate, cairo_path_fixed_t *path);
|
|||
cairo_private cairo_status_t
|
||||
_cairo_gstate_reset_clip (cairo_gstate_t *gstate);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
_cairo_gstate_has_clip (cairo_gstate_t *gstate);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
_cairo_gstate_extract_clip_rectangles (cairo_gstate_t *gstate,
|
||||
int max_rectangles,
|
||||
cairo_clip_rect_t *rectangles_out,
|
||||
int *num_rectangles_out);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_gstate_show_surface (cairo_gstate_t *gstate,
|
||||
cairo_surface_t *surface,
|
||||
|
|
Загрузка…
Ссылка в новой задаче