DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 1 | // |
| 2 | // "$Id: cgdebug.h 7913 2010-11-29 18:18:27Z greg.ercolano $" |
| 3 | // |
| 4 | // OS X Core Graphics debugging help for the Fast Light Tool Kit (FLTK). |
| 5 | // |
| 6 | // Copyright 1998-2010 by Bill Spitzak and others. |
| 7 | // |
| 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. |
| 12 | // |
| 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. |
| 17 | // |
| 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 |
| 21 | // USA. |
| 22 | // |
| 23 | // Please report all bugs and problems on the following page: |
| 24 | // |
| 25 | // http://www.fltk.org/str.php |
| 26 | // |
| 27 | |
| 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 |
| 32 | // more bugs show up. |
| 33 | // |
| 34 | // This header is activated by adding the following |
| 35 | // line to "config.h" |
| 36 | // #include "src/cgdebug.h" |
| 37 | // |
| 38 | // Running "./configure" will remove this line from "config.h". |
| 39 | // |
| 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. |
| 45 | // |
| 46 | // Matthias |
| 47 | |
| 48 | #ifndef CGDEBUG |
| 49 | #define CGDEBUG |
| 50 | |
| 51 | #include <stdio.h> |
| 52 | #include <Carbon/Carbon.h> |
| 53 | |
| 54 | //+BitmapContextCreate |
| 55 | //+BitmapContextGetData |
| 56 | // ClipCGContextToRegion |
| 57 | // QDBeginCGContext |
| 58 | // QDEndCGContext |
| 59 | |
| 60 | //+AddArc |
| 61 | //+AddLineToPoint |
| 62 | // ClipToRect |
| 63 | // ClosePath |
| 64 | //+ConcatCTM |
| 65 | //+DrawImage |
| 66 | // FillPath |
| 67 | // FillRect |
| 68 | // Flush |
| 69 | //+GetCTM |
| 70 | // MoveToPoint |
| 71 | //+Release |
| 72 | // RestoreGState |
| 73 | // SaveGState |
| 74 | //+ScaleCTM |
| 75 | //+SetLineCap |
| 76 | //+SetLineDash |
| 77 | //+SetLineJoin |
| 78 | //+SetLineWidth |
| 79 | //+SetRGBFillColor |
| 80 | //+SetRGBStrokeColor |
| 81 | //+SetShouldAntialias |
| 82 | //+SetTextMatrix |
| 83 | //+StrokePath |
| 84 | //+TranslateCTM |
| 85 | |
| 86 | inline OSStatus dbgLocation(const char *file, int line) |
| 87 | { |
| 88 | fprintf(stderr, "%s:%d ", file, line); |
| 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | inline OSStatus dbgEndl() |
| 93 | { |
| 94 | fprintf(stderr, "\n"); |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | |
| 99 | inline void dbgCGContextClipToRect(CGContextRef a, CGRect b) |
| 100 | { |
| 101 | CGContextClipToRect(a, b); |
| 102 | } |
| 103 | |
| 104 | #define CGContextClipToRect(a, b) { \ |
| 105 | fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \ |
| 106 | dbgCGContextClipToRect(a, b); \ |
| 107 | fprintf(stderr, "\n"); } |
| 108 | |
| 109 | inline void dbgCGContextFillRect(CGContextRef a, CGRect b) |
| 110 | { |
| 111 | CGContextFillRect(a, b); |
| 112 | } |
| 113 | |
| 114 | #define CGContextFillRect(a, b) { \ |
| 115 | fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \ |
| 116 | dbgCGContextFillRect(a, b); \ |
| 117 | fprintf(stderr, "\n"); } |
| 118 | |
| 119 | inline OSStatus dbgQDEndCGContext(CGrafPtr a, CGContextRef *b) |
| 120 | { |
| 121 | return QDEndCGContext(a, b); |
| 122 | } |
| 123 | |
| 124 | #define QDEndCGContext(a, b) ( \ |
| 125 | dbgLocation(__FILE__, __LINE__) + \ |
| 126 | dbgQDEndCGContext(a, b) + \ |
| 127 | dbgEndl() ) |
| 128 | |
| 129 | inline OSStatus dbgQDBeginCGContext(CGrafPtr a, CGContextRef *b) |
| 130 | { |
| 131 | return QDBeginCGContext(a, b); |
| 132 | } |
| 133 | |
| 134 | #define QDBeginCGContext(a, b) ( \ |
| 135 | dbgLocation(__FILE__, __LINE__) + \ |
| 136 | dbgQDBeginCGContext(a, b) + \ |
| 137 | dbgEndl() ) |
| 138 | |
| 139 | inline void dbgClipCGContextToRegion(CGContextRef a, const Rect *b, RgnHandle c) |
| 140 | { |
| 141 | ClipCGContextToRegion(a, b, c); |
| 142 | } |
| 143 | |
| 144 | #define ClipCGContextToRegion(a, b, c) { \ |
| 145 | fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \ |
| 146 | dbgClipCGContextToRegion(a, b, c); \ |
| 147 | fprintf(stderr, "\n"); } |
| 148 | |
| 149 | inline void dbgCGContextMoveToPoint(CGContextRef context, float x, float y) |
| 150 | { |
| 151 | CGContextMoveToPoint(context, x, y); |
| 152 | } |
| 153 | |
| 154 | #define CGContextMoveToPoint(a, b, c) { \ |
| 155 | fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \ |
| 156 | dbgCGContextMoveToPoint(a, b, c); \ |
| 157 | fprintf(stderr, "\n"); } |
| 158 | |
| 159 | inline void dbgCGContextFillPath(CGContextRef context) |
| 160 | { |
| 161 | CGContextFillPath(context); |
| 162 | } |
| 163 | |
| 164 | #define CGContextFillPath(a) { \ |
| 165 | fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \ |
| 166 | dbgCGContextFillPath(a); \ |
| 167 | fprintf(stderr, "\n"); } |
| 168 | |
| 169 | inline void dbgCGContextClosePath(CGContextRef context) |
| 170 | { |
| 171 | CGContextClosePath(context); |
| 172 | } |
| 173 | |
| 174 | #define CGContextClosePath(a) { \ |
| 175 | fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \ |
| 176 | dbgCGContextClosePath(a); \ |
| 177 | fprintf(stderr, "\n"); } |
| 178 | |
| 179 | inline void dbgCGContextFlush(CGContextRef context) |
| 180 | { |
| 181 | CGContextFlush(context); |
| 182 | } |
| 183 | |
| 184 | #define CGContextFlush(a) { \ |
| 185 | fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \ |
| 186 | dbgCGContextFlush(a); \ |
| 187 | fprintf(stderr, "\n"); } |
| 188 | |
| 189 | inline void dbgCGContextSaveGState(CGContextRef context) |
| 190 | { |
| 191 | CGContextSaveGState(context); |
| 192 | } |
| 193 | |
| 194 | #define CGContextSaveGState(a) { \ |
| 195 | fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \ |
| 196 | dbgCGContextSaveGState(a); \ |
| 197 | fprintf(stderr, "\n"); } |
| 198 | |
| 199 | inline void dbgCGContextRestoreGState(CGContextRef context) |
| 200 | { |
| 201 | CGContextRestoreGState(context); |
| 202 | } |
| 203 | |
| 204 | #define CGContextRestoreGState(a) { \ |
| 205 | fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \ |
| 206 | dbgCGContextRestoreGState(a); \ |
| 207 | fprintf(stderr, "\n"); } |
| 208 | |
| 209 | |
| 210 | #endif |
| 211 | |
| 212 | // |
| 213 | // End of "$Id: cgdebug.h 7913 2010-11-29 18:18:27Z greg.ercolano $". |
| 214 | // |
| 215 | |