Rev 1892 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1892 | Rev 3959 | ||
---|---|---|---|
Line 50... | Line 50... | ||
50 | * @Short_Description: Representing a pixel-aligned area |
50 | * @Short_Description: Representing a pixel-aligned area |
51 | * |
51 | * |
52 | * Regions are a simple graphical data type representing an area of |
52 | * Regions are a simple graphical data type representing an area of |
53 | * integer-aligned rectangles. They are often used on raster surfaces |
53 | * integer-aligned rectangles. They are often used on raster surfaces |
54 | * to track areas of interest, such as change or clip areas. |
54 | * to track areas of interest, such as change or clip areas. |
55 | */ |
55 | **/ |
Line 56... | Line 56... | ||
56 | 56 | ||
57 | static const cairo_region_t _cairo_region_nil = { |
57 | static const cairo_region_t _cairo_region_nil = { |
58 | CAIRO_REFERENCE_COUNT_INVALID, /* ref_count */ |
58 | CAIRO_REFERENCE_COUNT_INVALID, /* ref_count */ |
59 | CAIRO_STATUS_NO_MEMORY, /* status */ |
59 | CAIRO_STATUS_NO_MEMORY, /* status */ |
Line 102... | Line 102... | ||
102 | case CAIRO_STATUS_NEGATIVE_COUNT: |
102 | case CAIRO_STATUS_NEGATIVE_COUNT: |
103 | case CAIRO_STATUS_INVALID_CLUSTERS: |
103 | case CAIRO_STATUS_INVALID_CLUSTERS: |
104 | case CAIRO_STATUS_INVALID_SLANT: |
104 | case CAIRO_STATUS_INVALID_SLANT: |
105 | case CAIRO_STATUS_INVALID_WEIGHT: |
105 | case CAIRO_STATUS_INVALID_WEIGHT: |
106 | case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED: |
106 | case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED: |
- | 107 | case CAIRO_STATUS_INVALID_MESH_CONSTRUCTION: |
|
- | 108 | case CAIRO_STATUS_DEVICE_FINISHED: |
|
107 | default: |
109 | default: |
108 | _cairo_error_throw (CAIRO_STATUS_NO_MEMORY); |
110 | _cairo_error_throw (CAIRO_STATUS_NO_MEMORY); |
109 | return (cairo_region_t *) &_cairo_region_nil; |
111 | return (cairo_region_t *) &_cairo_region_nil; |
110 | } |
112 | } |
111 | } |
113 | } |
Line 132... | Line 134... | ||
132 | **/ |
134 | **/ |
133 | static cairo_status_t |
135 | static cairo_status_t |
134 | _cairo_region_set_error (cairo_region_t *region, |
136 | _cairo_region_set_error (cairo_region_t *region, |
135 | cairo_status_t status) |
137 | cairo_status_t status) |
136 | { |
138 | { |
137 | if (! _cairo_status_is_error (status)) |
139 | if (status == CAIRO_STATUS_SUCCESS) |
138 | return status; |
140 | return CAIRO_STATUS_SUCCESS; |
Line 139... | Line 141... | ||
139 | 141 | ||
140 | /* Don't overwrite an existing error. This preserves the first |
142 | /* Don't overwrite an existing error. This preserves the first |
141 | * error, which is the most significant. */ |
143 | * error, which is the most significant. */ |
Line 232... | Line 234... | ||
232 | 234 | ||
233 | region = _cairo_malloc (sizeof (cairo_region_t)); |
235 | region = _cairo_malloc (sizeof (cairo_region_t)); |
234 | if (unlikely (region == NULL)) |
236 | if (unlikely (region == NULL)) |
Line -... | Line 237... | ||
- | 237 | return _cairo_region_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); |
|
- | 238 | ||
- | 239 | CAIRO_REFERENCE_COUNT_INIT (®ion->ref_count, 1); |
|
- | 240 | region->status = CAIRO_STATUS_SUCCESS; |
|
- | 241 | ||
- | 242 | if (count == 1) { |
|
- | 243 | pixman_region32_init_rect (®ion->rgn, |
|
- | 244 | rects->x, rects->y, |
|
- | 245 | rects->width, rects->height); |
|
- | 246 | ||
- | 247 | return region; |
|
235 | return _cairo_region_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); |
248 | } |
236 | 249 | ||
237 | if (count > ARRAY_LENGTH (stack_pboxes)) { |
250 | if (count > ARRAY_LENGTH (stack_pboxes)) { |
238 | pboxes = _cairo_malloc_ab (count, sizeof (pixman_box32_t)); |
251 | pboxes = _cairo_malloc_ab (count, sizeof (pixman_box32_t)); |
239 | if (unlikely (pboxes == NULL)) { |
252 | if (unlikely (pboxes == NULL)) { |
Line 257... | Line 270... | ||
257 | if (unlikely (i == 0)) { |
270 | if (unlikely (i == 0)) { |
258 | free (region); |
271 | free (region); |
259 | return _cairo_region_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); |
272 | return _cairo_region_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); |
260 | } |
273 | } |
Line -... | Line 274... | ||
- | 274 | ||
- | 275 | return region; |
|
- | 276 | } |
|
- | 277 | slim_hidden_def (cairo_region_create_rectangles); |
|
- | 278 | ||
- | 279 | cairo_region_t * |
|
- | 280 | _cairo_region_create_from_boxes (const cairo_box_t *boxes, int count) |
|
- | 281 | { |
|
- | 282 | cairo_region_t *region; |
|
- | 283 | ||
- | 284 | region = _cairo_malloc (sizeof (cairo_region_t)); |
|
- | 285 | if (unlikely (region == NULL)) |
|
- | 286 | return _cairo_region_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); |
|
261 | 287 | ||
262 | CAIRO_REFERENCE_COUNT_INIT (®ion->ref_count, 1); |
288 | CAIRO_REFERENCE_COUNT_INIT (®ion->ref_count, 1); |
- | 289 | region->status = CAIRO_STATUS_SUCCESS; |
|
- | 290 | ||
- | 291 | if (! pixman_region32_init_rects (®ion->rgn, |
|
- | 292 | (pixman_box32_t *)boxes, count)) { |
|
- | 293 | free (region); |
|
- | 294 | return _cairo_region_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); |
|
- | 295 | } |
|
263 | region->status = CAIRO_STATUS_SUCCESS; |
296 | |
264 | return region; |
297 | return region; |
- | 298 | } |
|
- | 299 | ||
265 | } |
300 | cairo_box_t * |
- | 301 | _cairo_region_get_boxes (const cairo_region_t *region, int *nbox) |
|
- | 302 | { |
|
- | 303 | if (region->status) { |
|
- | 304 | nbox = 0; |
|
- | 305 | return NULL; |
|
- | 306 | } |
|
- | 307 | ||
- | 308 | return (cairo_box_t *) pixman_region32_rectangles (CONST_CAST ®ion->rgn, nbox); |
|
Line 266... | Line 309... | ||
266 | slim_hidden_def (cairo_region_create_rectangles); |
309 | } |
267 | 310 | ||
268 | /** |
311 | /** |
269 | * cairo_region_create_rectangle: |
312 | * cairo_region_create_rectangle: |
Line 471... | Line 514... | ||
471 | 514 | ||
472 | /** |
515 | /** |
473 | * cairo_region_status: |
516 | * cairo_region_status: |
474 | * @region: a #cairo_region_t |
517 | * @region: a #cairo_region_t |
475 | * |
518 | * |
476 | * Checks whether an error has previous occured for this |
519 | * Checks whether an error has previous occurred for this |
477 | * region object. |
520 | * region object. |
478 | * |
521 | * |
479 | * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY |
522 | * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY |
480 | * |
523 | * |
Line 797... | Line 840... | ||
797 | } |
840 | } |
798 | slim_hidden_def (cairo_region_translate); |
841 | slim_hidden_def (cairo_region_translate); |
Line 799... | Line 842... | ||
799 | 842 | ||
800 | /** |
843 | /** |
801 | * cairo_region_overlap_t: |
844 | * cairo_region_overlap_t: |
802 | * @CAIRO_REGION_OVERLAP_IN: The contents are entirely inside the region |
845 | * @CAIRO_REGION_OVERLAP_IN: The contents are entirely inside the region. (Since 1.10) |
803 | * @CAIRO_REGION_OVERLAP_OUT: The contents are entirely outside the region |
846 | * @CAIRO_REGION_OVERLAP_OUT: The contents are entirely outside the region. (Since 1.10) |
804 | * @CAIRO_REGION_OVERLAP_PART: The contents are partially inside and |
847 | * @CAIRO_REGION_OVERLAP_PART: The contents are partially inside and |
805 | * partially outside the region. |
848 | * partially outside the region. (Since 1.10) |
806 | * |
849 | * |
- | 850 | * Used as the return value for cairo_region_contains_rectangle(). |
|
- | 851 | * |
|
807 | * Used as the return value for cairo_region_contains_rectangle(). |
852 | * Since: 1.10 |
Line 808... | Line 853... | ||
808 | */ |
853 | **/ |
809 | 854 | ||
810 | /** |
855 | /** |
811 | * cairo_region_contains_rectangle: |
856 | * cairo_region_contains_rectangle: |