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 38... Line 38...
38
#define CAIRO_FIXED_PRIVATE_H
38
#define CAIRO_FIXED_PRIVATE_H
Line 39... Line 39...
39
 
39
 
Line 40... Line 40...
40
#include "cairo-fixed-type-private.h"
40
#include "cairo-fixed-type-private.h"
-
 
41
 
Line 41... Line 42...
41
 
42
#include "cairo-wideint-private.h"
Line 42... Line 43...
42
#include "cairo-wideint-private.h"
43
#include "cairoint.h"
43
 
44
 
Line 50... Line 51...
50
 
51
 
51
#define CAIRO_FIXED_ONE        ((cairo_fixed_t)(1 << CAIRO_FIXED_FRAC_BITS))
52
#define CAIRO_FIXED_ONE        ((cairo_fixed_t)(1 << CAIRO_FIXED_FRAC_BITS))
52
#define CAIRO_FIXED_ONE_DOUBLE ((double)(1 << CAIRO_FIXED_FRAC_BITS))
53
#define CAIRO_FIXED_ONE_DOUBLE ((double)(1 << CAIRO_FIXED_FRAC_BITS))
Line -... Line 54...
-
 
54
#define CAIRO_FIXED_EPSILON    ((cairo_fixed_t)(1))
-
 
55
 
53
#define CAIRO_FIXED_EPSILON    ((cairo_fixed_t)(1))
56
#define CAIRO_FIXED_ERROR_DOUBLE (1. / (2 * CAIRO_FIXED_ONE_DOUBLE))
54
 
57
 
Line 55... Line 58...
55
#define CAIRO_FIXED_FRAC_MASK  ((cairo_fixed_t)(((cairo_fixed_unsigned_t)(-1)) >> (CAIRO_FIXED_BITS - CAIRO_FIXED_FRAC_BITS)))
58
#define CAIRO_FIXED_FRAC_MASK  ((cairo_fixed_t)(((cairo_fixed_unsigned_t)(-1)) >> (CAIRO_FIXED_BITS - CAIRO_FIXED_FRAC_BITS)))
56
#define CAIRO_FIXED_WHOLE_MASK (~CAIRO_FIXED_FRAC_MASK)
59
#define CAIRO_FIXED_WHOLE_MASK (~CAIRO_FIXED_FRAC_MASK)
Line 162... Line 165...
162
{
165
{
163
    return f & ~CAIRO_FIXED_FRAC_MASK;
166
    return f & ~CAIRO_FIXED_FRAC_MASK;
164
}
167
}
Line 165... Line 168...
165
 
168
 
-
 
169
static inline cairo_fixed_t
-
 
170
_cairo_fixed_ceil (cairo_fixed_t f)
-
 
171
{
-
 
172
    return _cairo_fixed_floor (f + CAIRO_FIXED_FRAC_MASK);
-
 
173
}
-
 
174
 
166
static inline cairo_fixed_t
175
static inline cairo_fixed_t
167
_cairo_fixed_round (cairo_fixed_t f)
176
_cairo_fixed_round (cairo_fixed_t f)
168
{
177
{
169
    return _cairo_fixed_floor (f + (CAIRO_FIXED_FRAC_MASK+1)/2);
178
    return _cairo_fixed_floor (f + (CAIRO_FIXED_FRAC_MASK+1)/2);
Line 342... Line 351...
342
	x += _cairo_fixed_mul_div_floor (y - p1->y, p2->x - p1->x, dy);
351
	x += _cairo_fixed_mul_div_floor (y - p1->y, p2->x - p1->x, dy);
Line 343... Line 352...
343
 
352
 
344
    return x;
353
    return x;
Line -... Line 354...
-
 
354
}
-
 
355
 
-
 
356
/* Intersect two segments based on the algorithm described at
-
 
357
 * http://paulbourke.net/geometry/pointlineplane/. This implementation
-
 
358
 * uses floating point math. */
-
 
359
static inline cairo_bool_t
-
 
360
_slow_segment_intersection (const cairo_point_t *seg1_p1,
-
 
361
			    const cairo_point_t *seg1_p2,
-
 
362
			    const cairo_point_t *seg2_p1,
-
 
363
			    const cairo_point_t *seg2_p2,
-
 
364
			    cairo_point_t *intersection)
-
 
365
{
-
 
366
    double denominator, u_a, u_b;
-
 
367
    double seg1_dx, seg1_dy, seg2_dx, seg2_dy, seg_start_dx, seg_start_dy;
-
 
368
 
-
 
369
    seg1_dx = _cairo_fixed_to_double (seg1_p2->x - seg1_p1->x);
-
 
370
    seg1_dy = _cairo_fixed_to_double (seg1_p2->y - seg1_p1->y);
-
 
371
    seg2_dx = _cairo_fixed_to_double (seg2_p2->x - seg2_p1->x);
-
 
372
    seg2_dy = _cairo_fixed_to_double (seg2_p2->y - seg2_p1->y);
-
 
373
    denominator = (seg2_dy * seg1_dx) - (seg2_dx * seg1_dy);
-
 
374
    if (denominator == 0)
-
 
375
	return FALSE;
-
 
376
 
-
 
377
    seg_start_dx = _cairo_fixed_to_double (seg1_p1->x - seg2_p1->x);
-
 
378
    seg_start_dy = _cairo_fixed_to_double (seg1_p1->y - seg2_p1->y);
-
 
379
    u_a = ((seg2_dx * seg_start_dy) - (seg2_dy * seg_start_dx)) / denominator;
-
 
380
    u_b = ((seg1_dx * seg_start_dy) - (seg1_dy * seg_start_dx)) / denominator;
-
 
381
 
-
 
382
    if (u_a <= 0 || u_a >= 1 || u_b <= 0 || u_b >= 1)
-
 
383
	return FALSE;
-
 
384
 
-
 
385
    intersection->x = seg1_p1->x + _cairo_fixed_from_double ((u_a * seg1_dx));
-
 
386
    intersection->y = seg1_p1->y + _cairo_fixed_from_double ((u_a * seg1_dy));
-
 
387
    return TRUE;
345
}
388
}
346
 
389
 
347
#else
390
#else
Line 348... Line 391...
348
# error Please define multiplication and other operands for your fixed-point type size
391
# error Please define multiplication and other operands for your fixed-point type size