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-debug.c
Go to the documentation of this file.
1 /* cairo - a vector graphics library with display and print output
2  *
3  * Copyright © 2005 Red Hat, Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it either under the terms of the GNU Lesser General Public
7  * License version 2.1 as published by the Free Software Foundation
8  * (the "LGPL") or, at your option, under the terms of the Mozilla
9  * Public License Version 1.1 (the "MPL"). If you do not alter this
10  * notice, a recipient may use your version of this file under either
11  * the MPL or the LGPL.
12  *
13  * You should have received a copy of the LGPL along with this library
14  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
16  * You should have received a copy of the MPL along with this library
17  * in the file COPYING-MPL-1.1
18  *
19  * The contents of this file are subject to the Mozilla Public License
20  * Version 1.1 (the "License"); you may not use this file except in
21  * compliance with the License. You may obtain a copy of the License at
22  * http://www.mozilla.org/MPL/
23  *
24  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
26  * the specific language governing rights and limitations.
27  *
28  * The Original Code is the cairo graphics library.
29  *
30  * The Initial Developer of the Original Code is Red Hat, Inc.
31  *
32  * Contributor(s):
33  * Carl D. Worth <cworth@cworth.org>
34  */
35 
36 #include "cairoint.h"
38 
39 /**
40  * cairo_debug_reset_static_data:
41  *
42  * Resets all static data within cairo to its original state,
43  * (ie. identical to the state at the time of program invocation). For
44  * example, all caches within cairo will be flushed empty.
45  *
46  * This function is intended to be useful when using memory-checking
47  * tools such as valgrind. When valgrind's memcheck analyzes a
48  * cairo-using program without a call to cairo_debug_reset_static_data(),
49  * it will report all data reachable via cairo's static objects as
50  * "still reachable". Calling cairo_debug_reset_static_data() just prior
51  * to program termination will make it easier to get squeaky clean
52  * reports from valgrind.
53  *
54  * WARNING: It is only safe to call this function when there are no
55  * active cairo objects remaining, (ie. the appropriate destroy
56  * functions have been called as necessary). If there are active cairo
57  * objects, this call is likely to cause a crash, (eg. an assertion
58  * failure due to a hash table being destroyed when non-empty).
59  *
60  * Since: 1.0
61  **/
62 void
64 {
66 
68 
70 
71 #if CAIRO_HAS_FT_FONT
73 #endif
74 
75 #if CAIRO_HAS_WIN32_FONT
77 #endif
78 
80 
82 
84 
86 
88 
90 
91 #if CAIRO_HAS_DRM_SURFACE
93 #endif
94 
96 
97 #if CAIRO_HAS_COGL_SURFACE
99 #endif
100 
102 }
103 
104 #if HAVE_VALGRIND
105 void
107 {
109  const uint8_t *bits;
110  int row, width;
111 
112  if (surface == NULL)
113  return;
114 
115  if (! RUNNING_ON_VALGRIND)
116  return;
117 
118  bits = image->data;
119  switch (image->format) {
120  case CAIRO_FORMAT_A1:
121  width = (image->width + 7)/8;
122  break;
123  case CAIRO_FORMAT_A8:
124  width = image->width;
125  break;
127  width = image->width*2;
128  break;
129  case CAIRO_FORMAT_RGB24:
130  case CAIRO_FORMAT_RGB30:
131  case CAIRO_FORMAT_ARGB32:
132  width = image->width*4;
133  break;
135  default:
136  /* XXX compute width from pixman bpp */
137  return;
138  }
139 
140  for (row = 0; row < image->height; row++) {
141  VALGRIND_CHECK_MEM_IS_DEFINED (bits, width);
142  /* and then silence any future valgrind warnings */
143  VALGRIND_MAKE_MEM_DEFINED (bits, width);
144  bits += image->stride;
145  }
146 }
147 #endif
148 
149 
150 #if 0
151 void
152 _cairo_image_surface_write_to_ppm (cairo_image_surface_t *isurf, const char *fn)
153 {
154  char *fmt;
155  if (isurf->format == CAIRO_FORMAT_ARGB32 || isurf->format == CAIRO_FORMAT_RGB24)
156  fmt = "P6";
157  else if (isurf->format == CAIRO_FORMAT_A8)
158  fmt = "P5";
159  else
160  return;
161 
162  FILE *fp = fopen(fn, "wb");
163  if (!fp)
164  return;
165 
166  fprintf (fp, "%s %d %d 255\n", fmt,isurf->width, isurf->height);
167  for (int j = 0; j < isurf->height; j++) {
168  unsigned char *row = isurf->data + isurf->stride * j;
169  for (int i = 0; i < isurf->width; i++) {
170  if (isurf->format == CAIRO_FORMAT_ARGB32 || isurf->format == CAIRO_FORMAT_RGB24) {
171  unsigned char r = *row++;
172  unsigned char g = *row++;
173  unsigned char b = *row++;
174  *row++;
175  putc(r, fp);
176  putc(g, fp);
177  putc(b, fp);
178  } else {
179  unsigned char a = *row++;
180  putc(a, fp);
181  }
182  }
183  }
184 
185  fclose (fp);
186 
187  fprintf (stderr, "Wrote %s\n", fn);
188 }
189 #endif
190 
191 static cairo_status_t
193  const cairo_point_t *point)
194 {
195  fprintf (closure,
196  " %f %f m",
199 
200  return CAIRO_STATUS_SUCCESS;
201 }
202 
203 static cairo_status_t
205  const cairo_point_t *point)
206 {
207  fprintf (closure,
208  " %f %f l",
211 
212  return CAIRO_STATUS_SUCCESS;
213 }
214 
215 static cairo_status_t
217  const cairo_point_t *p1,
218  const cairo_point_t *p2,
219  const cairo_point_t *p3)
220 {
221  fprintf (closure,
222  " %f %f %f %f %f %f c",
228  _cairo_fixed_to_double (p3->y));
229 
230  return CAIRO_STATUS_SUCCESS;
231 }
232 
233 static cairo_status_t
235 {
236  fprintf (closure, " h");
237 
238  return CAIRO_STATUS_SUCCESS;
239 }
240 
241 void
243 {
246 
247  fprintf (stream,
248  "path: extents=(%f, %f), (%f, %f)\n",
249  _cairo_fixed_to_double (path->extents.p1.x),
250  _cairo_fixed_to_double (path->extents.p1.y),
251  _cairo_fixed_to_double (path->extents.p2.x),
252  _cairo_fixed_to_double (path->extents.p2.y));
253 
258  _print_close,
259  stream);
261 
263  fprintf (stream, "[box (%d, %d), (%d, %d)]",
264  box.p1.x, box.p1.y, box.p2.x, box.p2.y);
265  }
266 
267  fprintf (stream, "\n");
268 }
269 
270 void
272 {
273  int n;
274 
275  fprintf (stream,
276  "polygon: extents=(%f, %f), (%f, %f)\n",
277  _cairo_fixed_to_double (polygon->extents.p1.x),
278  _cairo_fixed_to_double (polygon->extents.p1.y),
279  _cairo_fixed_to_double (polygon->extents.p2.x),
280  _cairo_fixed_to_double (polygon->extents.p2.y));
281  if (polygon->num_limits) {
282  fprintf (stream,
283  " : limit=(%f, %f), (%f, %f) x %d\n",
284  _cairo_fixed_to_double (polygon->limit.p1.x),
285  _cairo_fixed_to_double (polygon->limit.p1.y),
286  _cairo_fixed_to_double (polygon->limit.p2.x),
287  _cairo_fixed_to_double (polygon->limit.p2.y),
288  polygon->num_limits);
289  }
290 
291  for (n = 0; n < polygon->num_edges; n++) {
293 
294  fprintf (stream,
295  " [%d] = [(%f, %f), (%f, %f)], top=%f, bottom=%f, dir=%d\n",
296  n,
297  _cairo_fixed_to_double (edge->line.p1.x),
298  _cairo_fixed_to_double (edge->line.p1.y),
299  _cairo_fixed_to_double (edge->line.p2.x),
300  _cairo_fixed_to_double (edge->line.p2.y),
302  _cairo_fixed_to_double (edge->bottom),
303  edge->dir);
304 
305  }
306 }
307 
308 void
310 {
311  fprintf (file, "[%g %g %g %g %g %g]\n",
312  matrix->xx, matrix->yx,
313  matrix->xy, matrix->yy,
314  matrix->x0, matrix->y0);
315 }
316 
317 void
319 {
320  fprintf (file, "x: %d y: %d width: %d height: %d\n",
321  rect->x, rect->y,
322  rect->width, rect->height);
323 }
#define width(a)
Definition: aptex-macros.h:198
#define box(a)
Definition: aptex-macros.h:675
char * p2
Definition: bmpfont.h:62
char * p1
Definition: bmpfont.h:62
void _cairo_clip_reset_static_data(void)
Definition: cairo-clip.c:834
void _cairo_cogl_context_reset_static_data(void)
void cairo_debug_reset_static_data(void)
Definition: cairo-debug.c:63
void _cairo_debug_print_rect(FILE *file, const cairo_rectangle_int_t *rect)
Definition: cairo-debug.c:318
void _cairo_debug_print_polygon(FILE *stream, cairo_polygon_t *polygon)
Definition: cairo-debug.c:271
void _cairo_debug_print_matrix(FILE *file, const cairo_matrix_t *matrix)
Definition: cairo-debug.c:309
void _cairo_debug_print_path(FILE *stream, const cairo_path_fixed_t *path)
Definition: cairo-debug.c:242
void _cairo_default_context_reset_static_data(void)
static double _cairo_fixed_to_double(cairo_fixed_t f)
void _cairo_ft_font_reset_static_data(void)
void _cairo_image_compositor_reset_static_data(void)
void _cairo_image_reset_static_data(void)
void _cairo_intern_string_reset_static_data(void)
Definition: cairo-misc.c:1107
#define CAIRO_MUTEX_FINALIZE
#define CAIRO_MUTEX_INITIALIZE
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_bool_t _cairo_path_fixed_is_box(const cairo_path_fixed_t *path, cairo_box_t *box)
void _cairo_pattern_reset_static_data(void)
void _cairo_scaled_font_reset_static_data(void)
void _cairo_scaled_font_map_destroy(void)
void _cairo_toy_font_face_reset_static_data(void)
@ CAIRO_STATUS_SUCCESS
Definition: cairo.h:315
enum _cairo_status cairo_status_t
@ CAIRO_FORMAT_RGB30
Definition: cairo.h:423
@ CAIRO_FORMAT_A8
Definition: cairo.h:420
@ CAIRO_FORMAT_RGB24
Definition: cairo.h:419
@ CAIRO_FORMAT_INVALID
Definition: cairo.h:417
@ CAIRO_FORMAT_ARGB32
Definition: cairo.h:418
@ CAIRO_FORMAT_RGB16_565
Definition: cairo.h:422
@ CAIRO_FORMAT_A1
Definition: cairo.h:421
void _cairo_win32_font_reset_static_data(void)
#define _cairo_debug_check_image_surface_is_defined(X)
Definition: cairoint.h:2125
void _cairo_drm_device_reset_static_data(void)
Definition: cairo-drm.c:335
static cairo_status_t _print_line_to(void *closure, const cairo_point_t *point)
Definition: cairo-debug.c:204
static cairo_status_t _print_close(void *closure)
Definition: cairo-debug.c:234
static cairo_status_t _print_curve_to(void *closure, const cairo_point_t *p1, const cairo_point_t *p2, const cairo_point_t *p3)
Definition: cairo-debug.c:216
static cairo_status_t _print_move_to(void *closure, const cairo_point_t *point)
Definition: cairo-debug.c:192
#define n
Definition: t4ht.c:1290
#define b
Definition: jpegint.h:372
#define fopen
Definition: xxstdio.h:21
#define a(n)
Definition: gpos-common.c:148
assert(pcxLoadImage24((char *)((void *) 0), fp, pinfo, hdr))
#define putc
Definition: jbib.h:20
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
#define bits
Definition: infblock.c:15
unsigned char uint8_t
Definition: stdint.h:78
#define fclose
Definition: debug.h:100
#define fprintf
Definition: mendex.h:64
char * closure
Definition: font.h:85
string fn
Definition: fc-lang.py:335
static cairo_surface_t * surface
Definition: pdftocairo.cc:234
float ** matrix()
#define fp
int g
Definition: ppmqvga.c:68
int r
Definition: ppmqvga.c:68
static int row
Definition: ps2pk.c:587
struct stream_s stream
Definition: pts_fax.h:93
#define status
Definition: namelist.c:170
Definition: jquant2.c:258
struct quorem x
Definition: filedef.h:30
Definition: sd.h:76
Definition: tpic.c:45
double x
Definition: tpic.c:46
double y
Definition: tpic.c:46
Definition: mpost.c:238
double y
Definition: mpost.c:239
double x
Definition: mpost.c:239
struct edge * edges
Definition: dvipdfm.c:55
double height
Definition: dvipdfm.c:57
double width
Definition: dvipdfm.c:56
#define FILE
Definition: t1stdio.h:34
int j
Definition: t4ht.c:1589
char fmt[256]
Definition: tex4ht.c:3925