cgdebug.h 5.1 KB

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