Subversion Repositories Kolibri OS

Rev

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 37... Line 37...
37
 *	Carl D. Worth 
37
 *	Carl D. Worth 
38
 */
38
 */
Line 39... Line 39...
39
 
39
 
Line -... Line 40...
-
 
40
#include "cairoint.h"
-
 
41
 
-
 
42
#include "cairo-box-inline.h"
-
 
43
 
-
 
44
const cairo_rectangle_int_t _cairo_empty_rectangle = { 0, 0, 0, 0 };
-
 
45
const cairo_rectangle_int_t _cairo_unbounded_rectangle = {
-
 
46
     CAIRO_RECT_INT_MIN, CAIRO_RECT_INT_MIN,
-
 
47
     CAIRO_RECT_INT_MAX - CAIRO_RECT_INT_MIN,
-
 
48
     CAIRO_RECT_INT_MAX - CAIRO_RECT_INT_MIN,
40
#include "cairoint.h"
49
};
41
 
50
 
42
cairo_private void
51
cairo_private void
43
_cairo_box_from_doubles (cairo_box_t *box,
52
_cairo_box_from_doubles (cairo_box_t *box,
44
			 double *x1, double *y1,
53
			 double *x1, double *y1,
Line 74... Line 83...
74
void
83
void
75
_cairo_boxes_get_extents (const cairo_box_t *boxes,
84
_cairo_boxes_get_extents (const cairo_box_t *boxes,
76
			  int num_boxes,
85
			  int num_boxes,
77
			  cairo_box_t *extents)
86
			  cairo_box_t *extents)
78
{
87
{
79
    int n;
-
 
80
 
-
 
81
    assert (num_boxes > 0);
88
    assert (num_boxes > 0);
82
    *extents = *boxes;
89
    *extents = *boxes;
83
 
-
 
84
    for (n = 1; n < num_boxes; n++) {
90
    while (--num_boxes)
85
	if (boxes[n].p1.x < extents->p1.x)
-
 
86
	    extents->p1.x = boxes[n].p1.x;
-
 
87
	if (boxes[n].p2.x > extents->p2.x)
91
	_cairo_box_add_box (extents, ++boxes);
88
	    extents->p2.x = boxes[n].p2.x;
-
 
89
 
-
 
90
	if (boxes[n].p1.y < extents->p1.y)
-
 
91
	    extents->p1.y = boxes[n].p1.y;
-
 
92
	if (boxes[n].p2.y > extents->p2.y)
-
 
93
	    extents->p2.y = boxes[n].p2.y;
-
 
94
    }
-
 
95
}
92
}
Line 96... Line 93...
96
 
93
 
97
/* XXX We currently have a confusing mix of boxes and rectangles as
94
/* XXX We currently have a confusing mix of boxes and rectangles as
98
 * exemplified by this function.  A #cairo_box_t is a rectangular area
95
 * exemplified by this function.  A #cairo_box_t is a rectangular area
Line 147... Line 144...
147
 
144
 
148
	return TRUE;
145
	return TRUE;
149
    }
146
    }
Line -... Line 147...
-
 
147
}
-
 
148
 
-
 
149
/* Extends the dst rectangle to also contain src.
-
 
150
 * If one of the rectangles is empty, the result is undefined
-
 
151
 */
-
 
152
void
-
 
153
_cairo_rectangle_union (cairo_rectangle_int_t *dst,
-
 
154
			const cairo_rectangle_int_t *src)
-
 
155
{
-
 
156
    int x1, y1, x2, y2;
-
 
157
 
-
 
158
    x1 = MIN (dst->x, src->x);
-
 
159
    y1 = MIN (dst->y, src->y);
-
 
160
    /* Beware the unsigned promotion, fortunately we have bits to spare
-
 
161
     * as (CAIRO_RECT_INT_MAX - CAIRO_RECT_INT_MIN) < UINT_MAX
-
 
162
     */
-
 
163
    x2 = MAX (dst->x + (int) dst->width,  src->x + (int) src->width);
-
 
164
    y2 = MAX (dst->y + (int) dst->height, src->y + (int) src->height);
-
 
165
 
-
 
166
    dst->x = x1;
-
 
167
    dst->y = y1;
-
 
168
    dst->width  = x2 - x1;
-
 
169
    dst->height = y2 - y1;
150
}
170
}
151
 
171
 
152
#define P1x (line->p1.x)
172
#define P1x (line->p1.x)
153
#define P1y (line->p1.y)
173
#define P1y (line->p1.y)
154
#define P2x (line->p2.x)
174
#define P2x (line->p2.x)
Line 167... Line 187...
167
 * do the division -- we don't care about the actual intersection point, so
187
 * do the division -- we don't care about the actual intersection point, so
168
 * it's of no interest to us.
188
 * it's of no interest to us.
169
 */
189
 */
Line 170... Line 190...
170
 
190
 
171
cairo_bool_t
191
cairo_bool_t
172
_cairo_box_intersects_line_segment (cairo_box_t *box, cairo_line_t *line)
192
_cairo_box_intersects_line_segment (const cairo_box_t *box, cairo_line_t *line)
173
{
193
{
174
    cairo_fixed_t t1=0, t2=0, t3=0, t4=0;
194
    cairo_fixed_t t1=0, t2=0, t3=0, t4=0;
Line 175... Line 195...
175
    cairo_int64_t t1y, t2y, t3x, t4x;
195
    cairo_int64_t t1y, t2y, t3x, t4x;
Line 236... Line 256...
236
	return TRUE;
256
	return TRUE;
Line 237... Line 257...
237
 
257
 
238
    return FALSE;
258
    return FALSE;
Line 239... Line 259...
239
}
259
}
-
 
260
 
240
 
261
static cairo_status_t
-
 
262
_cairo_box_add_spline_point (void *closure,
241
cairo_bool_t
263
			     const cairo_point_t *point,
-
 
264
			     const cairo_slope_t *tangent)
-
 
265
{
-
 
266
    _cairo_box_add_point (closure, point);
-
 
267
 
-
 
268
    return CAIRO_STATUS_SUCCESS;
-
 
269
}
-
 
270
 
-
 
271
/* assumes a has been previously added */
-
 
272
void
-
 
273
_cairo_box_add_curve_to (cairo_box_t *extents,
-
 
274
			 const cairo_point_t *a,
-
 
275
			 const cairo_point_t *b,
-
 
276
			 const cairo_point_t *c,
-
 
277
			 const cairo_point_t *d)
242
_cairo_box_contains_point (cairo_box_t *box, const cairo_point_t *point)
278
{
243
{
279
    _cairo_box_add_point (extents, d);
-
 
280
    if (!_cairo_box_contains_point (extents, b) ||
244
    if (point->x < box->p1.x || point->x > box->p2.x ||
281
	!_cairo_box_contains_point (extents, c))
-
 
282
    {
-
 
283
	cairo_status_t status;
245
	point->y < box->p1.y || point->y > box->p2.y)
284
 
-
 
285
	status = _cairo_spline_bound (_cairo_box_add_spline_point,
-
 
286
				      extents, a, b, c, d);
-
 
287
	assert (status == CAIRO_STATUS_SUCCESS);
-
 
288
    }
-
 
289
}
-
 
290
 
-
 
291
void
-
 
292
_cairo_rectangle_int_from_double (cairo_rectangle_int_t *recti,
-
 
293
				  const cairo_rectangle_t *rectf)
-
 
294
{
-
 
295
	recti->x = floor (rectf->x);
-
 
296
	recti->y = floor (rectf->y);
246
	return FALSE;
297
	recti->width  = ceil (rectf->x + rectf->width) - floor (rectf->x);