FLTK 1.4.5: cgdebug.h Source File

FLTK 1.4.5

Loading...
Searching...
No Matches
cgdebug.h
1//
2// OS X Core Graphics debugging help for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2010 by Bill Spitzak and others.
5//
6// This library is free software. Distribution and use rights are outlined in
7// the file "COPYING" which should have been included with this file. If this
8// file is missing or damaged, see the license at:
9//
10// https://www.fltk.org/COPYING.php
11//
12// Please see the following page on how to report bugs and issues:
13//
14// https://www.fltk.org/bugs.php
15//
16
17// This file allows easier debugging of Mac OS X Core Graphics
18// code. This file is normally not included into any FLTK builds,
19// but since it has proven to be tremendously useful in debugging
20// the FLTK port to "Quartz", I decided to add this file in case
21// more bugs show up.
22//
23// This header is activated by adding the following
24// line to "config.h"
25// #include "src/cgdebug.h"
26//
27// Running "./configure" will remove this line from "config.h".
28//
29// When used erreanously, Core Graphics prints warnings to
30// stderr. This is helpful, however it is not possible to
31// associate a line number or source file with the warning message.
32// This headr file outputs a trace of CG calls, interweaveing
33// them with CG warnings.
34//
35// Matthias
36
37#ifndef CGDEBUG
38#define CGDEBUG
39
40#include <stdio.h>
41#include <Carbon/Carbon.h>
42
43//+BitmapContextCreate
44//+BitmapContextGetData
45// ClipCGContextToRegion
46// QDBeginCGContext
47// QDEndCGContext
48
49//+AddArc
50//+AddLineToPoint
51// ClipToRect
52// ClosePath
53//+ConcatCTM
54//+DrawImage
55// FillPath
56// FillRect
57// Flush
58//+GetCTM
59// MoveToPoint
60//+Release
61// RestoreGState
62// SaveGState
63//+ScaleCTM
64//+SetLineCap
65//+SetLineDash
66//+SetLineJoin
67//+SetLineWidth
68//+SetRGBFillColor
69//+SetRGBStrokeColor
70//+SetShouldAntialias
71//+SetTextMatrix
72//+StrokePath
73//+TranslateCTM
74
75inline OSStatus dbgLocation(const char *file, int line)
76{
77 fprintf(stderr, "%s:%d ", file, line);
78 return 0;
79}
80
81inline OSStatus dbgEndl()
82{
83 fprintf(stderr, "\n");
84 return 0;
85}
86
87
88inline void dbgCGContextClipToRect(CGContextRef a, CGRect b)
89{
90 CGContextClipToRect(a, b);
91}
92
93#define CGContextClipToRect(a, b) { \
94 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
95 dbgCGContextClipToRect(a, b); \
96 fprintf(stderr, "\n"); }
97
98inline void dbgCGContextFillRect(CGContextRef a, CGRect b)
99{
100 CGContextFillRect(a, b);
101}
102
103#define CGContextFillRect(a, b) { \
104 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
105 dbgCGContextFillRect(a, b); \
106 fprintf(stderr, "\n"); }
107
108inline OSStatus dbgQDEndCGContext(CGrafPtr a, CGContextRef *b)
109{
110 return QDEndCGContext(a, b);
111}
112
113#define QDEndCGContext(a, b) ( \
114 dbgLocation(__FILE__, __LINE__) + \
115 dbgQDEndCGContext(a, b) + \
116 dbgEndl() )
117
118inline OSStatus dbgQDBeginCGContext(CGrafPtr a, CGContextRef *b)
119{
120 return QDBeginCGContext(a, b);
121}
122
123#define QDBeginCGContext(a, b) ( \
124 dbgLocation(__FILE__, __LINE__) + \
125 dbgQDBeginCGContext(a, b) + \
126 dbgEndl() )
127
128inline void dbgClipCGContextToRegion(CGContextRef a, const Rect *b, RgnHandle c)
129{
130 ClipCGContextToRegion(a, b, c);
131}
132
133#define ClipCGContextToRegion(a, b, c) { \
134 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
135 dbgClipCGContextToRegion(a, b, c); \
136 fprintf(stderr, "\n"); }
137
138inline void dbgCGContextMoveToPoint(CGContextRef context, float x, float y)
139{
140 CGContextMoveToPoint(context, x, y);
141}
142
143#define CGContextMoveToPoint(a, b, c) { \
144 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
145 dbgCGContextMoveToPoint(a, b, c); \
146 fprintf(stderr, "\n"); }
147
148inline void dbgCGContextFillPath(CGContextRef context)
149{
150 CGContextFillPath(context);
151}
152
153#define CGContextFillPath(a) { \
154 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
155 dbgCGContextFillPath(a); \
156 fprintf(stderr, "\n"); }
157
158inline void dbgCGContextClosePath(CGContextRef context)
159{
160 CGContextClosePath(context);
161}
162
163#define CGContextClosePath(a) { \
164 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
165 dbgCGContextClosePath(a); \
166 fprintf(stderr, "\n"); }
167
168inline void dbgCGContextFlush(CGContextRef context)
169{
170 CGContextFlush(context);
171}
172
173#define CGContextFlush(a) { \
174 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
175 dbgCGContextFlush(a); \
176 fprintf(stderr, "\n"); }
177
178inline void dbgCGContextSaveGState(CGContextRef context)
179{
180 CGContextSaveGState(context);
181}
182
183#define CGContextSaveGState(a) { \
184 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
185 dbgCGContextSaveGState(a); \
186 fprintf(stderr, "\n"); }
187
188inline void dbgCGContextRestoreGState(CGContextRef context)
189{
190 CGContextRestoreGState(context);
191}
192
193#define CGContextRestoreGState(a) { \
194 fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \
195 dbgCGContextRestoreGState(a); \
196 fprintf(stderr, "\n"); }
197
198
199#endif
200