2 // "$Id: cgdebug.h 7913 2010-11-29 18:18:27Z greg.ercolano $"
4 // OS X Core Graphics debugging help for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2010 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
28 // This file allows easier debugging of Mac OS X Core Graphics
29 // code. This file is normally not included into any FLTK builds,
30 // but since it has proven to be tremendously useful in debugging
31 // the FLTK port to "Quartz", I decided to add this file in case
34 // This header is activated by adding the following
36 // #include "src/cgdebug.h"
38 // Running "./configure" will remove this line from "config.h".
40 // When used erreanously, Core Graphics prints warnings to
41 // stderr. This is helpful, however it is not possible to
42 // associate a line number or source file with the warning message.
43 // This headr file outputs a trace of CG calls, interweaveing
44 // them with CG warnings.
52 #include <Carbon/Carbon.h>
54 //+BitmapContextCreate
55 //+BitmapContextGetData
56 // ClipCGContextToRegion
86 inline OSStatus
dbgLocation(const char *file
, int line
)
88 fprintf(stderr
, "%s:%d ", file
, line
);
92 inline OSStatus
dbgEndl()
94 fprintf(stderr
, "\n");
99 inline void dbgCGContextClipToRect(CGContextRef a
, CGRect b
)
101 CGContextClipToRect(a
, b
);
104 #define CGContextClipToRect(a, b) { \
105 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
106 dbgCGContextClipToRect(a, b); \
107 fprintf(stderr, "\n"); }
109 inline void dbgCGContextFillRect(CGContextRef a
, CGRect b
)
111 CGContextFillRect(a
, b
);
114 #define CGContextFillRect(a, b) { \
115 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
116 dbgCGContextFillRect(a, b); \
117 fprintf(stderr, "\n"); }
119 inline OSStatus
dbgQDEndCGContext(CGrafPtr a
, CGContextRef
*b
)
121 return QDEndCGContext(a
, b
);
124 #define QDEndCGContext(a, b) ( \
125 dbgLocation(__FILE__, __LINE__) + \
126 dbgQDEndCGContext(a, b) + \
129 inline OSStatus
dbgQDBeginCGContext(CGrafPtr a
, CGContextRef
*b
)
131 return QDBeginCGContext(a
, b
);
134 #define QDBeginCGContext(a, b) ( \
135 dbgLocation(__FILE__, __LINE__) + \
136 dbgQDBeginCGContext(a, b) + \
139 inline void dbgClipCGContextToRegion(CGContextRef a
, const Rect
*b
, RgnHandle c
)
141 ClipCGContextToRegion(a
, b
, c
);
144 #define ClipCGContextToRegion(a, b, c) { \
145 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
146 dbgClipCGContextToRegion(a, b, c); \
147 fprintf(stderr, "\n"); }
149 inline void dbgCGContextMoveToPoint(CGContextRef context
, float x
, float y
)
151 CGContextMoveToPoint(context
, x
, y
);
154 #define CGContextMoveToPoint(a, b, c) { \
155 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
156 dbgCGContextMoveToPoint(a, b, c); \
157 fprintf(stderr, "\n"); }
159 inline void dbgCGContextFillPath(CGContextRef context
)
161 CGContextFillPath(context
);
164 #define CGContextFillPath(a) { \
165 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
166 dbgCGContextFillPath(a); \
167 fprintf(stderr, "\n"); }
169 inline void dbgCGContextClosePath(CGContextRef context
)
171 CGContextClosePath(context
);
174 #define CGContextClosePath(a) { \
175 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
176 dbgCGContextClosePath(a); \
177 fprintf(stderr, "\n"); }
179 inline void dbgCGContextFlush(CGContextRef context
)
181 CGContextFlush(context
);
184 #define CGContextFlush(a) { \
185 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
186 dbgCGContextFlush(a); \
187 fprintf(stderr, "\n"); }
189 inline void dbgCGContextSaveGState(CGContextRef context
)
191 CGContextSaveGState(context
);
194 #define CGContextSaveGState(a) { \
195 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
196 dbgCGContextSaveGState(a); \
197 fprintf(stderr, "\n"); }
199 inline void dbgCGContextRestoreGState(CGContextRef context
)
201 CGContextRestoreGState(context
);
204 #define CGContextRestoreGState(a) { \
205 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
206 dbgCGContextRestoreGState(a); \
207 fprintf(stderr, "\n"); }
213 // End of "$Id: cgdebug.h 7913 2010-11-29 18:18:27Z greg.ercolano $".