/work/workdir/UnpackedTarball/cairo/src/cairo-box-inline.h
Line | Count | Source |
1 | | /* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */ |
2 | | /* cairo - a vector graphics library with display and print output |
3 | | * |
4 | | * Copyright © 2010 Andrea Canciani |
5 | | * |
6 | | * This library is free software; you can redistribute it and/or |
7 | | * modify it either under the terms of the GNU Lesser General Public |
8 | | * License version 2.1 as published by the Free Software Foundation |
9 | | * (the "LGPL") or, at your option, under the terms of the Mozilla |
10 | | * Public License Version 1.1 (the "MPL"). If you do not alter this |
11 | | * notice, a recipient may use your version of this file under either |
12 | | * the MPL or the LGPL. |
13 | | * |
14 | | * You should have received a copy of the LGPL along with this library |
15 | | * in the file COPYING-LGPL-2.1; if not, write to the Free Software |
16 | | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA |
17 | | * You should have received a copy of the MPL along with this library |
18 | | * in the file COPYING-MPL-1.1 |
19 | | * |
20 | | * The contents of this file are subject to the Mozilla Public License |
21 | | * Version 1.1 (the "License"); you may not use this file except in |
22 | | * compliance with the License. You may obtain a copy of the License at |
23 | | * http://www.mozilla.org/MPL/ |
24 | | * |
25 | | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY |
26 | | * OF ANY KIND, either express or implied. See the LGPL or the MPL for |
27 | | * the specific language governing rights and limitations. |
28 | | * |
29 | | * The Original Code is the cairo graphics library. |
30 | | * |
31 | | * Contributor(s): |
32 | | * Andrea Canciani <ranma42@gmail.com> |
33 | | */ |
34 | | |
35 | | #ifndef CAIRO_BOX_H |
36 | | #define CAIRO_BOX_H |
37 | | |
38 | | #include "cairo-types-private.h" |
39 | | #include "cairo-compiler-private.h" |
40 | | #include "cairo-fixed-private.h" |
41 | | |
42 | | static inline void |
43 | | _cairo_box_set (cairo_box_t *box, |
44 | | const cairo_point_t *p1, |
45 | | const cairo_point_t *p2) |
46 | 13.0M | { |
47 | 13.0M | box->p1 = *p1; |
48 | 13.0M | box->p2 = *p2; |
49 | 13.0M | } Unexecuted instantiation: cairo-rectangle.c:_cairo_box_set Unexecuted instantiation: cairo-spline.c:_cairo_box_set Unexecuted instantiation: cairo-traps.c:_cairo_box_set Unexecuted instantiation: cairo-analysis-surface.c:_cairo_box_set Unexecuted instantiation: cairo-boxes.c:_cairo_box_set Unexecuted instantiation: cairo-clip-boxes.c:_cairo_box_set Unexecuted instantiation: cairo-path-bounds.c:_cairo_box_set cairo-path-fixed.c:_cairo_box_set Line | Count | Source | 46 | 13.0M | { | 47 | 13.0M | box->p1 = *p1; | 48 | 13.0M | box->p2 = *p2; | 49 | 13.0M | } |
Unexecuted instantiation: cairo-path-stroke-boxes.c:_cairo_box_set Unexecuted instantiation: cairo-path-stroke-polygon.c:_cairo_box_set Unexecuted instantiation: cairo-path-stroke.c:_cairo_box_set Unexecuted instantiation: cairo-traps-compositor.c:_cairo_box_set Unexecuted instantiation: cairo-path-stroke-traps.c:_cairo_box_set |
50 | | |
51 | | static inline void |
52 | | _cairo_box_from_integers (cairo_box_t *box, int x, int y, int w, int h) |
53 | 0 | { |
54 | 0 | box->p1.x = _cairo_fixed_from_int (x); |
55 | 0 | box->p1.y = _cairo_fixed_from_int (y); |
56 | 0 | box->p2.x = _cairo_fixed_from_int (x + w); |
57 | 0 | box->p2.y = _cairo_fixed_from_int (y + h); |
58 | 0 | } Unexecuted instantiation: cairo-rectangle.c:_cairo_box_from_integers Unexecuted instantiation: cairo-spline.c:_cairo_box_from_integers Unexecuted instantiation: cairo-traps.c:_cairo_box_from_integers Unexecuted instantiation: cairo-analysis-surface.c:_cairo_box_from_integers Unexecuted instantiation: cairo-boxes.c:_cairo_box_from_integers Unexecuted instantiation: cairo-clip-boxes.c:_cairo_box_from_integers Unexecuted instantiation: cairo-path-bounds.c:_cairo_box_from_integers Unexecuted instantiation: cairo-path-fixed.c:_cairo_box_from_integers Unexecuted instantiation: cairo-path-stroke-boxes.c:_cairo_box_from_integers Unexecuted instantiation: cairo-path-stroke-polygon.c:_cairo_box_from_integers Unexecuted instantiation: cairo-path-stroke.c:_cairo_box_from_integers Unexecuted instantiation: cairo-traps-compositor.c:_cairo_box_from_integers Unexecuted instantiation: cairo-path-stroke-traps.c:_cairo_box_from_integers |
59 | | |
60 | | static inline void |
61 | | _cairo_box_from_rectangle_int (cairo_box_t *box, |
62 | | const cairo_rectangle_int_t *rect) |
63 | 6.01M | { |
64 | 6.01M | box->p1.x = _cairo_fixed_from_int (rect->x); |
65 | 6.01M | box->p1.y = _cairo_fixed_from_int (rect->y); |
66 | 6.01M | box->p2.x = _cairo_fixed_from_int (rect->x + rect->width); |
67 | 6.01M | box->p2.y = _cairo_fixed_from_int (rect->y + rect->height); |
68 | 6.01M | } Unexecuted instantiation: cairo-rectangle.c:_cairo_box_from_rectangle_int Unexecuted instantiation: cairo-spline.c:_cairo_box_from_rectangle_int Unexecuted instantiation: cairo-traps.c:_cairo_box_from_rectangle_int Unexecuted instantiation: cairo-analysis-surface.c:_cairo_box_from_rectangle_int Unexecuted instantiation: cairo-boxes.c:_cairo_box_from_rectangle_int cairo-clip-boxes.c:_cairo_box_from_rectangle_int Line | Count | Source | 63 | 6.01M | { | 64 | 6.01M | box->p1.x = _cairo_fixed_from_int (rect->x); | 65 | 6.01M | box->p1.y = _cairo_fixed_from_int (rect->y); | 66 | 6.01M | box->p2.x = _cairo_fixed_from_int (rect->x + rect->width); | 67 | 6.01M | box->p2.y = _cairo_fixed_from_int (rect->y + rect->height); | 68 | 6.01M | } |
Unexecuted instantiation: cairo-path-bounds.c:_cairo_box_from_rectangle_int Unexecuted instantiation: cairo-path-fixed.c:_cairo_box_from_rectangle_int Unexecuted instantiation: cairo-path-stroke-boxes.c:_cairo_box_from_rectangle_int Unexecuted instantiation: cairo-path-stroke-polygon.c:_cairo_box_from_rectangle_int Unexecuted instantiation: cairo-path-stroke.c:_cairo_box_from_rectangle_int Unexecuted instantiation: cairo-traps-compositor.c:_cairo_box_from_rectangle_int Unexecuted instantiation: cairo-path-stroke-traps.c:_cairo_box_from_rectangle_int |
69 | | |
70 | | /* assumes box->p1 is top-left, p2 bottom-right */ |
71 | | static inline void |
72 | | _cairo_box_add_point (cairo_box_t *box, |
73 | | const cairo_point_t *point) |
74 | 65.1M | { |
75 | 65.1M | if (point->x < box->p1.x) |
76 | 1.75M | box->p1.x = point->x; |
77 | 63.3M | else if (point->x > box->p2.x) |
78 | 15.1M | box->p2.x = point->x; |
79 | | |
80 | 65.1M | if (point->y < box->p1.y) |
81 | 4.92M | box->p1.y = point->y; |
82 | 60.2M | else if (point->y > box->p2.y) |
83 | 12.1M | box->p2.y = point->y; |
84 | 65.1M | } cairo-rectangle.c:_cairo_box_add_point Line | Count | Source | 74 | 6.10M | { | 75 | 6.10M | if (point->x < box->p1.x) | 76 | 17.3k | box->p1.x = point->x; | 77 | 6.09M | else if (point->x > box->p2.x) | 78 | 1.71M | box->p2.x = point->x; | 79 | | | 80 | 6.10M | if (point->y < box->p1.y) | 81 | 1.05M | box->p1.y = point->y; | 82 | 5.05M | else if (point->y > box->p2.y) | 83 | 1.06M | box->p2.y = point->y; | 84 | 6.10M | } |
cairo-spline.c:_cairo_box_add_point Line | Count | Source | 74 | 362k | { | 75 | 362k | if (point->x < box->p1.x) | 76 | 121k | box->p1.x = point->x; | 77 | 240k | else if (point->x > box->p2.x) | 78 | 117k | box->p2.x = point->x; | 79 | | | 80 | 362k | if (point->y < box->p1.y) | 81 | 116k | box->p1.y = point->y; | 82 | 245k | else if (point->y > box->p2.y) | 83 | 114k | box->p2.y = point->y; | 84 | 362k | } |
Unexecuted instantiation: cairo-traps.c:_cairo_box_add_point Unexecuted instantiation: cairo-analysis-surface.c:_cairo_box_add_point Unexecuted instantiation: cairo-boxes.c:_cairo_box_add_point Unexecuted instantiation: cairo-clip-boxes.c:_cairo_box_add_point Unexecuted instantiation: cairo-path-bounds.c:_cairo_box_add_point cairo-path-fixed.c:_cairo_box_add_point Line | Count | Source | 74 | 58.6M | { | 75 | 58.6M | if (point->x < box->p1.x) | 76 | 1.62M | box->p1.x = point->x; | 77 | 57.0M | else if (point->x > box->p2.x) | 78 | 13.3M | box->p2.x = point->x; | 79 | | | 80 | 58.6M | if (point->y < box->p1.y) | 81 | 3.75M | box->p1.y = point->y; | 82 | 54.9M | else if (point->y > box->p2.y) | 83 | 10.9M | box->p2.y = point->y; | 84 | 58.6M | } |
Unexecuted instantiation: cairo-path-stroke-boxes.c:_cairo_box_add_point Unexecuted instantiation: cairo-path-stroke-polygon.c:_cairo_box_add_point Unexecuted instantiation: cairo-path-stroke.c:_cairo_box_add_point Unexecuted instantiation: cairo-traps-compositor.c:_cairo_box_add_point Unexecuted instantiation: cairo-path-stroke-traps.c:_cairo_box_add_point |
85 | | |
86 | | static inline void |
87 | | _cairo_box_add_box (cairo_box_t *box, |
88 | | const cairo_box_t *add) |
89 | 0 | { |
90 | 0 | if (add->p1.x < box->p1.x) |
91 | 0 | box->p1.x = add->p1.x; |
92 | 0 | if (add->p2.x > box->p2.x) |
93 | 0 | box->p2.x = add->p2.x; |
94 | |
|
95 | 0 | if (add->p1.y < box->p1.y) |
96 | 0 | box->p1.y = add->p1.y; |
97 | 0 | if (add->p2.y > box->p2.y) |
98 | 0 | box->p2.y = add->p2.y; |
99 | 0 | } Unexecuted instantiation: cairo-rectangle.c:_cairo_box_add_box Unexecuted instantiation: cairo-spline.c:_cairo_box_add_box Unexecuted instantiation: cairo-traps.c:_cairo_box_add_box Unexecuted instantiation: cairo-analysis-surface.c:_cairo_box_add_box Unexecuted instantiation: cairo-boxes.c:_cairo_box_add_box Unexecuted instantiation: cairo-clip-boxes.c:_cairo_box_add_box Unexecuted instantiation: cairo-path-bounds.c:_cairo_box_add_box Unexecuted instantiation: cairo-path-fixed.c:_cairo_box_add_box Unexecuted instantiation: cairo-path-stroke-boxes.c:_cairo_box_add_box Unexecuted instantiation: cairo-path-stroke-polygon.c:_cairo_box_add_box Unexecuted instantiation: cairo-path-stroke.c:_cairo_box_add_box Unexecuted instantiation: cairo-traps-compositor.c:_cairo_box_add_box Unexecuted instantiation: cairo-path-stroke-traps.c:_cairo_box_add_box |
100 | | |
101 | | /* assumes box->p1 is top-left, p2 bottom-right */ |
102 | | static inline cairo_bool_t |
103 | | _cairo_box_contains_point (const cairo_box_t *box, |
104 | | const cairo_point_t *point) |
105 | 12.6M | { |
106 | 12.6M | return box->p1.x <= point->x && point->x <= box->p2.x && |
107 | 12.1M | box->p1.y <= point->y && point->y <= box->p2.y; |
108 | 12.6M | } cairo-rectangle.c:_cairo_box_contains_point Line | Count | Source | 105 | 11.9M | { | 106 | 11.9M | return box->p1.x <= point->x && point->x <= box->p2.x && | 107 | 11.8M | box->p1.y <= point->y && point->y <= box->p2.y; | 108 | 11.9M | } |
cairo-spline.c:_cairo_box_contains_point Line | Count | Source | 105 | 766k | { | 106 | 766k | return box->p1.x <= point->x && point->x <= box->p2.x && | 107 | 292k | box->p1.y <= point->y && point->y <= box->p2.y; | 108 | 766k | } |
Unexecuted instantiation: cairo-traps.c:_cairo_box_contains_point Unexecuted instantiation: cairo-analysis-surface.c:_cairo_box_contains_point Unexecuted instantiation: cairo-boxes.c:_cairo_box_contains_point Unexecuted instantiation: cairo-clip-boxes.c:_cairo_box_contains_point Unexecuted instantiation: cairo-path-bounds.c:_cairo_box_contains_point Unexecuted instantiation: cairo-path-fixed.c:_cairo_box_contains_point Unexecuted instantiation: cairo-path-stroke-boxes.c:_cairo_box_contains_point cairo-path-stroke-polygon.c:_cairo_box_contains_point Line | Count | Source | 105 | 3.29k | { | 106 | 3.29k | return box->p1.x <= point->x && point->x <= box->p2.x && | 107 | 1.81k | box->p1.y <= point->y && point->y <= box->p2.y; | 108 | 3.29k | } |
Unexecuted instantiation: cairo-path-stroke.c:_cairo_box_contains_point Unexecuted instantiation: cairo-traps-compositor.c:_cairo_box_contains_point Unexecuted instantiation: cairo-path-stroke-traps.c:_cairo_box_contains_point |
109 | | |
110 | | static inline cairo_bool_t |
111 | | _cairo_box_is_pixel_aligned (const cairo_box_t *box) |
112 | 6.24M | { |
113 | | #if CAIRO_FIXED_FRAC_BITS <= 8 && 0 |
114 | | return ((cairo_fixed_unsigned_t)(box->p1.x & CAIRO_FIXED_FRAC_MASK) << 24 | |
115 | | (box->p1.y & CAIRO_FIXED_FRAC_MASK) << 16 | |
116 | | (box->p2.x & CAIRO_FIXED_FRAC_MASK) << 8 | |
117 | | (box->p2.y & CAIRO_FIXED_FRAC_MASK) << 0) == 0; |
118 | | #else /* GCC on i7 prefers this variant (bizarrely according to the profiler) */ |
119 | 6.24M | cairo_fixed_t f; |
120 | | |
121 | 6.24M | f = 0; |
122 | 6.24M | f |= box->p1.x & CAIRO_FIXED_FRAC_MASK; |
123 | 6.24M | f |= box->p1.y & CAIRO_FIXED_FRAC_MASK; |
124 | 6.24M | f |= box->p2.x & CAIRO_FIXED_FRAC_MASK; |
125 | 6.24M | f |= box->p2.y & CAIRO_FIXED_FRAC_MASK; |
126 | | |
127 | 6.24M | return f == 0; |
128 | 6.24M | #endif |
129 | 6.24M | } Unexecuted instantiation: cairo-rectangle.c:_cairo_box_is_pixel_aligned Unexecuted instantiation: cairo-spline.c:_cairo_box_is_pixel_aligned Unexecuted instantiation: cairo-traps.c:_cairo_box_is_pixel_aligned Unexecuted instantiation: cairo-analysis-surface.c:_cairo_box_is_pixel_aligned cairo-boxes.c:_cairo_box_is_pixel_aligned Line | Count | Source | 112 | 411k | { | 113 | | #if CAIRO_FIXED_FRAC_BITS <= 8 && 0 | 114 | | return ((cairo_fixed_unsigned_t)(box->p1.x & CAIRO_FIXED_FRAC_MASK) << 24 | | 115 | | (box->p1.y & CAIRO_FIXED_FRAC_MASK) << 16 | | 116 | | (box->p2.x & CAIRO_FIXED_FRAC_MASK) << 8 | | 117 | | (box->p2.y & CAIRO_FIXED_FRAC_MASK) << 0) == 0; | 118 | | #else /* GCC on i7 prefers this variant (bizarrely according to the profiler) */ | 119 | 411k | cairo_fixed_t f; | 120 | | | 121 | 411k | f = 0; | 122 | 411k | f |= box->p1.x & CAIRO_FIXED_FRAC_MASK; | 123 | 411k | f |= box->p1.y & CAIRO_FIXED_FRAC_MASK; | 124 | 411k | f |= box->p2.x & CAIRO_FIXED_FRAC_MASK; | 125 | 411k | f |= box->p2.y & CAIRO_FIXED_FRAC_MASK; | 126 | | | 127 | 411k | return f == 0; | 128 | 411k | #endif | 129 | 411k | } |
cairo-clip-boxes.c:_cairo_box_is_pixel_aligned Line | Count | Source | 112 | 5.83M | { | 113 | | #if CAIRO_FIXED_FRAC_BITS <= 8 && 0 | 114 | | return ((cairo_fixed_unsigned_t)(box->p1.x & CAIRO_FIXED_FRAC_MASK) << 24 | | 115 | | (box->p1.y & CAIRO_FIXED_FRAC_MASK) << 16 | | 116 | | (box->p2.x & CAIRO_FIXED_FRAC_MASK) << 8 | | 117 | | (box->p2.y & CAIRO_FIXED_FRAC_MASK) << 0) == 0; | 118 | | #else /* GCC on i7 prefers this variant (bizarrely according to the profiler) */ | 119 | 5.83M | cairo_fixed_t f; | 120 | | | 121 | 5.83M | f = 0; | 122 | 5.83M | f |= box->p1.x & CAIRO_FIXED_FRAC_MASK; | 123 | 5.83M | f |= box->p1.y & CAIRO_FIXED_FRAC_MASK; | 124 | 5.83M | f |= box->p2.x & CAIRO_FIXED_FRAC_MASK; | 125 | 5.83M | f |= box->p2.y & CAIRO_FIXED_FRAC_MASK; | 126 | | | 127 | 5.83M | return f == 0; | 128 | 5.83M | #endif | 129 | 5.83M | } |
Unexecuted instantiation: cairo-path-bounds.c:_cairo_box_is_pixel_aligned Unexecuted instantiation: cairo-path-fixed.c:_cairo_box_is_pixel_aligned Unexecuted instantiation: cairo-path-stroke-boxes.c:_cairo_box_is_pixel_aligned Unexecuted instantiation: cairo-path-stroke-polygon.c:_cairo_box_is_pixel_aligned Unexecuted instantiation: cairo-path-stroke.c:_cairo_box_is_pixel_aligned Unexecuted instantiation: cairo-traps-compositor.c:_cairo_box_is_pixel_aligned Unexecuted instantiation: cairo-path-stroke-traps.c:_cairo_box_is_pixel_aligned |
130 | | |
131 | | #endif /* CAIRO_BOX_H */ |