w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

cairo-path-bounds.c
Go to the documentation of this file.
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 © 2003 University of Southern California
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  * The Initial Developer of the Original Code is University of Southern
32  * California.
33  *
34  * Contributor(s):
35  * Carl D. Worth <cworth@cworth.org>
36  */
37 
38 #include "cairoint.h"
39 #include "cairo-box-inline.h"
40 #include "cairo-error-private.h"
42 
43 typedef struct _cairo_path_bounder {
48 
49 static cairo_status_t
51  const cairo_point_t *point)
52 {
53  cairo_path_bounder_t *bounder = closure;
54 
55  bounder->current_point = *point;
56 
57  if (likely (bounder->has_extents)) {
58  _cairo_box_add_point (&bounder->extents, point);
59  } else {
60  bounder->has_extents = TRUE;
61  _cairo_box_set (&bounder->extents, point, point);
62  }
63 
64  return CAIRO_STATUS_SUCCESS;
65 }
66 
67 static cairo_status_t
69  const cairo_point_t *point)
70 {
71  cairo_path_bounder_t *bounder = closure;
72 
73  bounder->current_point = *point;
74  _cairo_box_add_point (&bounder->extents, point);
75 
76  return CAIRO_STATUS_SUCCESS;
77 }
78 
79 static cairo_status_t
81  const cairo_point_t *b,
82  const cairo_point_t *c,
83  const cairo_point_t *d)
84 {
85  cairo_path_bounder_t *bounder = closure;
86 
88  &bounder->current_point,
89  b, c, d);
90  bounder->current_point = *d;
91 
92  return CAIRO_STATUS_SUCCESS;
93 }
94 
95 static cairo_status_t
97 {
98  return CAIRO_STATUS_SUCCESS;
99 }
100 
104 {
105  cairo_path_bounder_t bounder;
107 
108  bounder.has_extents = FALSE;
114  &bounder);
115  assert (!status);
116 
117  if (bounder.has_extents)
118  *extents = bounder.extents;
119 
120  return bounder.has_extents;
121 }
122 
123 void
126 {
128 }
129 
130 void
133 {
135 }
136 
137 void
139  cairo_fill_rule_t fill_rule,
140  double tolerance,
142 {
143  if (path->extents.p1.x < path->extents.p2.x &&
144  path->extents.p1.y < path->extents.p2.y) {
146  } else {
147  extents->x = extents->y = 0;
148  extents->width = extents->height = 0;
149  }
150 }
151 
152 /* Adjusts the fill extents (above) by the device-space pen. */
153 void
156  const cairo_matrix_t *ctm,
157  cairo_bool_t is_vector,
159 {
160  if (path->has_extents) {
161  cairo_box_t box_extents;
162  double dx, dy;
163 
165  if (is_vector)
166  {
167  /* When calculating extents for vector surfaces, ensure lines thinner
168  * than the fixed point resolution are not optimized away. */
170  if (dx < min)
171  dx = min;
172 
173  if (dy < min)
174  dy = min;
175  }
176 
177  box_extents = path->extents;
178  box_extents.p1.x -= _cairo_fixed_from_double (dx);
179  box_extents.p1.y -= _cairo_fixed_from_double (dy);
180  box_extents.p2.x += _cairo_fixed_from_double (dx);
181  box_extents.p2.y += _cairo_fixed_from_double (dy);
182 
183  _cairo_box_round_to_rectangle (&box_extents, extents);
184  } else {
185  extents->x = extents->y = 0;
186  extents->width = extents->height = 0;
187  }
188 }
189 
192  const cairo_stroke_style_t *stroke_style,
193  const cairo_matrix_t *ctm,
194  const cairo_matrix_t *ctm_inverse,
195  double tolerance,
197 {
201 
202  /* When calculating extents for vector surfaces, ensure lines thinner
203  * than one point are not optimized away. */
204  double min_line_width = _cairo_matrix_transformed_circle_major_axis (ctm_inverse, 1.0);
205  if (stroke_style->line_width < min_line_width)
206  {
207  style = *stroke_style;
208  style.line_width = min_line_width;
209  stroke_style = &style;
210  }
211 
214  stroke_style,
215  ctm, ctm_inverse,
216  tolerance,
217  &polygon);
220 
221  return status;
222 }
223 
226  cairo_box_t *box)
227 {
228  *box = path->extents;
229  return path->has_extents;
230 }
#define tolerance
Definition: aptex-macros.h:786
static void _cairo_box_add_point(cairo_box_t *box, const cairo_point_t *point)
static void _cairo_box_set(cairo_box_t *box, const cairo_point_t *p1, const cairo_point_t *p2)
static cairo_fixed_t _cairo_fixed_from_double(double d)
static double _cairo_fixed_to_double(cairo_fixed_t f)
#define CAIRO_FIXED_EPSILON
double _cairo_matrix_transformed_circle_major_axis(const cairo_matrix_t *matrix, double radius)
Definition: cairo-matrix.c:914
struct _cairo_path_bounder cairo_path_bounder_t
void _cairo_path_fixed_approximate_clip_extents(const cairo_path_fixed_t *path, cairo_rectangle_int_t *extents)
void _cairo_path_fixed_approximate_stroke_extents(const cairo_path_fixed_t *path, const cairo_stroke_style_t *style, const cairo_matrix_t *ctm, cairo_bool_t is_vector, cairo_rectangle_int_t *extents)
cairo_status_t _cairo_path_fixed_stroke_extents(const cairo_path_fixed_t *path, const cairo_stroke_style_t *stroke_style, const cairo_matrix_t *ctm, const cairo_matrix_t *ctm_inverse, double tolerance, cairo_rectangle_int_t *extents)
cairo_bool_t _cairo_path_fixed_extents(const cairo_path_fixed_t *path, cairo_box_t *box)
cairo_bool_t _cairo_path_bounder_extents(const cairo_path_fixed_t *path, cairo_box_t *extents)
void _cairo_path_fixed_approximate_fill_extents(const cairo_path_fixed_t *path, cairo_rectangle_int_t *extents)
void _cairo_path_fixed_fill_extents(const cairo_path_fixed_t *path, cairo_fill_rule_t fill_rule, double tolerance, cairo_rectangle_int_t *extents)
cairo_status_t _cairo_path_fixed_interpret(const cairo_path_fixed_t *path, cairo_path_fixed_move_to_func_t *move_to, cairo_path_fixed_line_to_func_t *line_to, cairo_path_fixed_curve_to_func_t *curve_to, cairo_path_fixed_close_path_func_t *close_path, void *closure)
cairo_status_t _cairo_path_fixed_stroke_to_polygon(const cairo_path_fixed_t *path, const cairo_stroke_style_t *style, const cairo_matrix_t *ctm, const cairo_matrix_t *ctm_inverse, double tolerance, cairo_polygon_t *polygon)
void _cairo_polygon_init(cairo_polygon_t *polygon, const cairo_box_t *limits, int num_limits)
void _cairo_polygon_fini(cairo_polygon_t *polygon)
void _cairo_box_round_to_rectangle(const cairo_box_t *box, cairo_rectangle_int_t *rectangle)
void _cairo_box_add_curve_to(cairo_box_t *extents, const cairo_point_t *a, const cairo_point_t *b, const cairo_point_t *c, const cairo_point_t *d)
void _cairo_stroke_style_max_distance_from_path(const cairo_stroke_style_t *style, const cairo_path_fixed_t *path, const cairo_matrix_t *ctm, double *dx, double *dy)
enum _cairo_fill_rule cairo_fill_rule_t
int cairo_bool_t
Definition: cairo.h:107
@ CAIRO_STATUS_SUCCESS
Definition: cairo.h:315
enum _cairo_status cairo_status_t
@ CAIRO_FILL_RULE_WINDING
Definition: cairo.h:754
static cairo_status_t _cairo_path_bounder_move_to(void *closure, const cairo_point_t *point)
static cairo_status_t _cairo_path_bounder_line_to(void *closure, const cairo_point_t *point)
static cairo_status_t _cairo_path_bounder_close_path(void *closure)
static cairo_status_t _cairo_path_bounder_curve_to(void *closure, const cairo_point_t *b, const cairo_point_t *c, const cairo_point_t *d)
#define b
Definition: jpegint.h:372
@ FALSE
Definition: dd.h:101
@ TRUE
Definition: dd.h:102
#define c(n)
Definition: gpos-common.c:150
#define d(n)
Definition: gpos-common.c:151
assert(pcxLoadImage24((char *)((void *) 0), fp, pinfo, hdr))
#define likely(x)
Definition: jbig2arith.cc:115
#define NULL
Definition: ftobjs.h:61
Arabic default style
Definition: afstyles.h:94
char * closure
Definition: font.h:85
#define min(a, b)
Definition: pbmplus.h:223
#define status
cairo_point_t p2
cairo_point_t p1
cairo_bool_t has_extents
cairo_point_t current_point
Definition: jquant2.c:258
Definition: tpic.c:45
double x
Definition: tpic.c:46
double y
Definition: tpic.c:46
Definition: mpost.c:238