cairo 1.6.1-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of cairo might be problematic. Click here for more details.

Files changed (418) hide show
  1. data/AUTHORS +4 -0
  2. data/COPYING +59 -0
  3. data/ChangeLog +1320 -0
  4. data/GPL +340 -0
  5. data/NEWS +98 -0
  6. data/README +70 -0
  7. data/Rakefile +215 -0
  8. data/cairo/bin/libcairo-2.dll +0 -0
  9. data/cairo/bin/libpng13.dll +0 -0
  10. data/cairo/bin/zlib1.dll +0 -0
  11. data/cairo/include/cairo/cairo-deprecated.h +142 -0
  12. data/cairo/include/cairo/cairo-features.h +35 -0
  13. data/cairo/include/cairo/cairo-pdf.h +68 -0
  14. data/cairo/include/cairo/cairo-ps.h +114 -0
  15. data/cairo/include/cairo/cairo-svg.h +82 -0
  16. data/cairo/include/cairo/cairo-win32.h +104 -0
  17. data/cairo/include/cairo/cairo.h +1945 -0
  18. data/cairo/include/libpng13/png.h +3419 -0
  19. data/cairo/include/libpng13/pngconf.h +1437 -0
  20. data/cairo/lib/cairo.def +251 -0
  21. data/cairo/lib/cairo.lib +0 -0
  22. data/cairo/lib/libcairo.dll.a +0 -0
  23. data/cairo/lib/libpng.def +372 -0
  24. data/cairo/lib/libpng13.dll.a +0 -0
  25. data/cairo/lib/pkgconfig/cairo-pdf.pc +12 -0
  26. data/cairo/lib/pkgconfig/cairo-png.pc +12 -0
  27. data/cairo/lib/pkgconfig/cairo-ps.pc +12 -0
  28. data/cairo/lib/pkgconfig/cairo-svg.pc +12 -0
  29. data/cairo/lib/pkgconfig/cairo-win32-font.pc +12 -0
  30. data/cairo/lib/pkgconfig/cairo-win32.pc +12 -0
  31. data/cairo/lib/pkgconfig/cairo.pc +13 -0
  32. data/cairo/lib/pkgconfig/libpng.pc +14 -0
  33. data/cairo/lib/pkgconfig/libpng13.pc +14 -0
  34. data/cairo/make/cairo-1.6.4-1.sh +55 -0
  35. data/cairo/manifest/cairo-1.6.4-1.mft +6 -0
  36. data/cairo/manifest/cairo-dev-1.6.4-1.mft +72 -0
  37. data/cairo/manifest/libpng-dev-1.2.8.mft +7 -0
  38. data/cairo/share/doc/cairo-1.6.4-1/COPYING +32 -0
  39. data/cairo/share/doc/cairo-1.6.4-1/COPYING-LGPL-2.1 +510 -0
  40. data/cairo/share/doc/cairo-1.6.4-1/COPYING-MPL-1.1 +470 -0
  41. data/cairo/share/gtk-doc/html/cairo/Drawing.html +53 -0
  42. data/cairo/share/gtk-doc/html/cairo/Fonts.html +56 -0
  43. data/cairo/share/gtk-doc/html/cairo/Support.html +50 -0
  44. data/cairo/share/gtk-doc/html/cairo/Surfaces.html +65 -0
  45. data/cairo/share/gtk-doc/html/cairo/bindings-errors.html +128 -0
  46. data/cairo/share/gtk-doc/html/cairo/bindings-fonts.html +59 -0
  47. data/cairo/share/gtk-doc/html/cairo/bindings-memory.html +129 -0
  48. data/cairo/share/gtk-doc/html/cairo/bindings-overloading.html +127 -0
  49. data/cairo/share/gtk-doc/html/cairo/bindings-path.html +123 -0
  50. data/cairo/share/gtk-doc/html/cairo/bindings-patterns.html +63 -0
  51. data/cairo/share/gtk-doc/html/cairo/bindings-return-values.html +126 -0
  52. data/cairo/share/gtk-doc/html/cairo/bindings-streams.html +98 -0
  53. data/cairo/share/gtk-doc/html/cairo/bindings-surfaces.html +99 -0
  54. data/cairo/share/gtk-doc/html/cairo/cairo-Error-Handling.html +328 -0
  55. data/cairo/share/gtk-doc/html/cairo/cairo-Font-Options.html +720 -0
  56. data/cairo/share/gtk-doc/html/cairo/cairo-FreeType-Fonts.html +297 -0
  57. data/cairo/share/gtk-doc/html/cairo/cairo-Image-Surfaces.html +484 -0
  58. data/cairo/share/gtk-doc/html/cairo/cairo-PDF-Surfaces.html +246 -0
  59. data/cairo/share/gtk-doc/html/cairo/cairo-PNG-Support.html +345 -0
  60. data/cairo/share/gtk-doc/html/cairo/cairo-Paths.html +1336 -0
  61. data/cairo/share/gtk-doc/html/cairo/cairo-Patterns.html +1560 -0
  62. data/cairo/share/gtk-doc/html/cairo/cairo-PostScript-Surfaces.html +656 -0
  63. data/cairo/share/gtk-doc/html/cairo/cairo-Quartz-Fonts.html +161 -0
  64. data/cairo/share/gtk-doc/html/cairo/cairo-Quartz-Surfaces.html +232 -0
  65. data/cairo/share/gtk-doc/html/cairo/cairo-SVG-Surfaces.html +337 -0
  66. data/cairo/share/gtk-doc/html/cairo/cairo-Scaled-Fonts.html +823 -0
  67. data/cairo/share/gtk-doc/html/cairo/cairo-Text.html +836 -0
  68. data/cairo/share/gtk-doc/html/cairo/cairo-Transformations.html +462 -0
  69. data/cairo/share/gtk-doc/html/cairo/cairo-Types.html +143 -0
  70. data/cairo/share/gtk-doc/html/cairo/cairo-Version-Information.html +325 -0
  71. data/cairo/share/gtk-doc/html/cairo/cairo-Win32-Fonts.html +381 -0
  72. data/cairo/share/gtk-doc/html/cairo/cairo-Win32-Surfaces.html +331 -0
  73. data/cairo/share/gtk-doc/html/cairo/cairo-XLib-Surfaces.html +525 -0
  74. data/cairo/share/gtk-doc/html/cairo/cairo-cairo-font-face-t.html +427 -0
  75. data/cairo/share/gtk-doc/html/cairo/cairo-cairo-matrix-t.html +626 -0
  76. data/cairo/share/gtk-doc/html/cairo/cairo-cairo-surface-t.html +995 -0
  77. data/cairo/share/gtk-doc/html/cairo/cairo-cairo-t.html +2795 -0
  78. data/cairo/share/gtk-doc/html/cairo/cairo.devhelp +432 -0
  79. data/cairo/share/gtk-doc/html/cairo/cairo.devhelp2 +432 -0
  80. data/cairo/share/gtk-doc/html/cairo/home.png +0 -0
  81. data/cairo/share/gtk-doc/html/cairo/index-1.2.html +137 -0
  82. data/cairo/share/gtk-doc/html/cairo/index-1.4.html +105 -0
  83. data/cairo/share/gtk-doc/html/cairo/index-1.6.html +65 -0
  84. data/cairo/share/gtk-doc/html/cairo/index.html +134 -0
  85. data/cairo/share/gtk-doc/html/cairo/index.sgml +466 -0
  86. data/cairo/share/gtk-doc/html/cairo/ix01.html +693 -0
  87. data/cairo/share/gtk-doc/html/cairo/language-bindings.html +79 -0
  88. data/cairo/share/gtk-doc/html/cairo/left.png +0 -0
  89. data/cairo/share/gtk-doc/html/cairo/right.png +0 -0
  90. data/cairo/share/gtk-doc/html/cairo/style.css +148 -0
  91. data/cairo/share/gtk-doc/html/cairo/up.png +0 -0
  92. data/doc/doc.css +91 -0
  93. data/doc/en/cairo-antialias.html +41 -0
  94. data/doc/en/cairo-antialias.rd +16 -0
  95. data/doc/en/cairo-clip-not-representable-error.html +50 -0
  96. data/doc/en/cairo-clip-not-representable-error.rd +17 -0
  97. data/doc/en/cairo-color-base.html +72 -0
  98. data/doc/en/cairo-color-base.rd +38 -0
  99. data/doc/en/cairo-color-cmyk.html +160 -0
  100. data/doc/en/cairo-color-cmyk.rd +107 -0
  101. data/doc/en/cairo-color-hsv.html +140 -0
  102. data/doc/en/cairo-color-hsv.rd +91 -0
  103. data/doc/en/cairo-color-rgb.html +145 -0
  104. data/doc/en/cairo-color-rgb.rd +95 -0
  105. data/doc/en/cairo-color-x11.html +176 -0
  106. data/doc/en/cairo-color-x11.rd +151 -0
  107. data/doc/en/cairo-color.html +241 -0
  108. data/doc/en/cairo-color.rd +213 -0
  109. data/doc/en/cairo-content.html +40 -0
  110. data/doc/en/cairo-content.rd +15 -0
  111. data/doc/en/cairo-context-blur.html +42 -0
  112. data/doc/en/cairo-context-blur.rd +15 -0
  113. data/doc/en/cairo-context-circle.html +42 -0
  114. data/doc/en/cairo-context-circle.rd +15 -0
  115. data/doc/en/cairo-context-color.html +42 -0
  116. data/doc/en/cairo-context-color.rd +15 -0
  117. data/doc/en/cairo-context-path.html +47 -0
  118. data/doc/en/cairo-context-path.rd +19 -0
  119. data/doc/en/cairo-context-rectangle.html +42 -0
  120. data/doc/en/cairo-context-rectangle.rd +15 -0
  121. data/doc/en/cairo-context-triangle.html +42 -0
  122. data/doc/en/cairo-context-triangle.rd +15 -0
  123. data/doc/en/cairo-context.html +636 -0
  124. data/doc/en/cairo-context.rd +491 -0
  125. data/doc/en/cairo-error.html +47 -0
  126. data/doc/en/cairo-error.rd +16 -0
  127. data/doc/en/cairo-extend.html +41 -0
  128. data/doc/en/cairo-extend.rd +16 -0
  129. data/doc/en/cairo-file-not-found.html +50 -0
  130. data/doc/en/cairo-file-not-found.rd +17 -0
  131. data/doc/en/cairo-fill-rule.html +39 -0
  132. data/doc/en/cairo-fill-rule.rd +14 -0
  133. data/doc/en/cairo-filter.html +43 -0
  134. data/doc/en/cairo-filter.rd +18 -0
  135. data/doc/en/cairo-font-extents.html +74 -0
  136. data/doc/en/cairo-font-extents.rd +40 -0
  137. data/doc/en/cairo-font-face.html +41 -0
  138. data/doc/en/cairo-font-face.rd +14 -0
  139. data/doc/en/cairo-font-options.html +142 -0
  140. data/doc/en/cairo-font-options.rd +94 -0
  141. data/doc/en/cairo-font-slant.html +40 -0
  142. data/doc/en/cairo-font-slant.rd +15 -0
  143. data/doc/en/cairo-font-weight.html +39 -0
  144. data/doc/en/cairo-font-weight.rd +14 -0
  145. data/doc/en/cairo-format.html +49 -0
  146. data/doc/en/cairo-format.rd +22 -0
  147. data/doc/en/cairo-glyph.html +102 -0
  148. data/doc/en/cairo-glyph.rd +62 -0
  149. data/doc/en/cairo-gradient-pattern.html +77 -0
  150. data/doc/en/cairo-gradient-pattern.rd +41 -0
  151. data/doc/en/cairo-hint-metrics.html +40 -0
  152. data/doc/en/cairo-hint-metrics.rd +15 -0
  153. data/doc/en/cairo-hint-style.html +42 -0
  154. data/doc/en/cairo-hint-style.rd +17 -0
  155. data/doc/en/cairo-image-surface.html +85 -0
  156. data/doc/en/cairo-image-surface.rd +47 -0
  157. data/doc/en/cairo-invalid-content-error.html +50 -0
  158. data/doc/en/cairo-invalid-content-error.rd +17 -0
  159. data/doc/en/cairo-invalid-dash-error.html +50 -0
  160. data/doc/en/cairo-invalid-dash-error.rd +17 -0
  161. data/doc/en/cairo-invalid-dsc-comment-error.html +50 -0
  162. data/doc/en/cairo-invalid-dsc-comment-error.rd +17 -0
  163. data/doc/en/cairo-invalid-format-error.html +50 -0
  164. data/doc/en/cairo-invalid-format-error.rd +17 -0
  165. data/doc/en/cairo-invalid-index-error.html +50 -0
  166. data/doc/en/cairo-invalid-index-error.rd +17 -0
  167. data/doc/en/cairo-invalid-matrix-error.html +50 -0
  168. data/doc/en/cairo-invalid-matrix-error.rd +17 -0
  169. data/doc/en/cairo-invalid-path-data-error.html +50 -0
  170. data/doc/en/cairo-invalid-path-data-error.rd +17 -0
  171. data/doc/en/cairo-invalid-pop-group-error.html +50 -0
  172. data/doc/en/cairo-invalid-pop-group-error.rd +17 -0
  173. data/doc/en/cairo-invalid-restore-error.html +50 -0
  174. data/doc/en/cairo-invalid-restore-error.rd +17 -0
  175. data/doc/en/cairo-invalid-status-error.html +50 -0
  176. data/doc/en/cairo-invalid-status-error.rd +17 -0
  177. data/doc/en/cairo-invalid-stride-error.html +50 -0
  178. data/doc/en/cairo-invalid-stride-error.rd +17 -0
  179. data/doc/en/cairo-invalid-string-error.html +50 -0
  180. data/doc/en/cairo-invalid-string-error.rd +17 -0
  181. data/doc/en/cairo-invalid-visual-error.html +50 -0
  182. data/doc/en/cairo-invalid-visual-error.rd +17 -0
  183. data/doc/en/cairo-line-cap.html +40 -0
  184. data/doc/en/cairo-line-cap.rd +15 -0
  185. data/doc/en/cairo-line-join.html +40 -0
  186. data/doc/en/cairo-line-join.rd +15 -0
  187. data/doc/en/cairo-linear-pattern.html +63 -0
  188. data/doc/en/cairo-linear-pattern.rd +28 -0
  189. data/doc/en/cairo-matrix.html +257 -0
  190. data/doc/en/cairo-matrix.rd +186 -0
  191. data/doc/en/cairo-no-current-point-error.html +50 -0
  192. data/doc/en/cairo-no-current-point-error.rd +17 -0
  193. data/doc/en/cairo-null-pointer-error.html +50 -0
  194. data/doc/en/cairo-null-pointer-error.rd +17 -0
  195. data/doc/en/cairo-operator.html +51 -0
  196. data/doc/en/cairo-operator.rd +26 -0
  197. data/doc/en/cairo-paper-parse-error.html +50 -0
  198. data/doc/en/cairo-paper-parse-error.rd +17 -0
  199. data/doc/en/cairo-paper-unknown-paper-name.html +69 -0
  200. data/doc/en/cairo-paper-unknown-paper-name.rd +30 -0
  201. data/doc/en/cairo-paper-unknown-unit.html +69 -0
  202. data/doc/en/cairo-paper-unknown-unit.rd +30 -0
  203. data/doc/en/cairo-paper-unrecognized-paper-description.html +69 -0
  204. data/doc/en/cairo-paper-unrecognized-paper-description.rd +30 -0
  205. data/doc/en/cairo-paper.html +187 -0
  206. data/doc/en/cairo-paper.rd +141 -0
  207. data/doc/en/cairo-path-close-path.html +52 -0
  208. data/doc/en/cairo-path-close-path.rd +21 -0
  209. data/doc/en/cairo-path-curve-to.html +52 -0
  210. data/doc/en/cairo-path-curve-to.rd +21 -0
  211. data/doc/en/cairo-path-data-type.html +41 -0
  212. data/doc/en/cairo-path-data-type.rd +16 -0
  213. data/doc/en/cairo-path-data.html +101 -0
  214. data/doc/en/cairo-path-data.rd +62 -0
  215. data/doc/en/cairo-path-line-to.html +52 -0
  216. data/doc/en/cairo-path-line-to.rd +21 -0
  217. data/doc/en/cairo-path-move-to.html +52 -0
  218. data/doc/en/cairo-path-move-to.rd +21 -0
  219. data/doc/en/cairo-path.html +158 -0
  220. data/doc/en/cairo-path.rd +109 -0
  221. data/doc/en/cairo-pattern-type-mismatch-error.html +50 -0
  222. data/doc/en/cairo-pattern-type-mismatch-error.rd +17 -0
  223. data/doc/en/cairo-pattern.html +102 -0
  224. data/doc/en/cairo-pattern.rd +62 -0
  225. data/doc/en/cairo-pdf-surface.html +60 -0
  226. data/doc/en/cairo-pdf-surface.rd +27 -0
  227. data/doc/en/cairo-point.html +77 -0
  228. data/doc/en/cairo-point.rd +42 -0
  229. data/doc/en/cairo-ps-level.html +52 -0
  230. data/doc/en/cairo-ps-level.rd +24 -0
  231. data/doc/en/cairo-ps-surface.html +95 -0
  232. data/doc/en/cairo-ps-surface.rd +55 -0
  233. data/doc/en/cairo-quartz-image-surface.html +60 -0
  234. data/doc/en/cairo-quartz-image-surface.rd +27 -0
  235. data/doc/en/cairo-quartz-surface.html +60 -0
  236. data/doc/en/cairo-quartz-surface.rd +27 -0
  237. data/doc/en/cairo-radial-pattern.html +63 -0
  238. data/doc/en/cairo-radial-pattern.rd +28 -0
  239. data/doc/en/cairo-read-error.html +50 -0
  240. data/doc/en/cairo-read-error.rd +17 -0
  241. data/doc/en/cairo-rectangle.html +92 -0
  242. data/doc/en/cairo-rectangle.rd +54 -0
  243. data/doc/en/cairo-scaled-font.html +87 -0
  244. data/doc/en/cairo-scaled-font.rd +50 -0
  245. data/doc/en/cairo-solid-pattern.html +65 -0
  246. data/doc/en/cairo-solid-pattern.rd +31 -0
  247. data/doc/en/cairo-subpixel-order.html +42 -0
  248. data/doc/en/cairo-subpixel-order.rd +17 -0
  249. data/doc/en/cairo-surface-finished-error.html +50 -0
  250. data/doc/en/cairo-surface-finished-error.rd +17 -0
  251. data/doc/en/cairo-surface-pattern.html +60 -0
  252. data/doc/en/cairo-surface-pattern.rd +27 -0
  253. data/doc/en/cairo-surface-type-mismatch-error.html +50 -0
  254. data/doc/en/cairo-surface-type-mismatch-error.rd +17 -0
  255. data/doc/en/cairo-surface.html +114 -0
  256. data/doc/en/cairo-surface.rd +72 -0
  257. data/doc/en/cairo-svg-surface.html +80 -0
  258. data/doc/en/cairo-svg-surface.rd +44 -0
  259. data/doc/en/cairo-svg-version.html +52 -0
  260. data/doc/en/cairo-svg-version.rd +24 -0
  261. data/doc/en/cairo-temp-file-error.html +50 -0
  262. data/doc/en/cairo-temp-file-error.rd +17 -0
  263. data/doc/en/cairo-text-extents.html +79 -0
  264. data/doc/en/cairo-text-extents.rd +44 -0
  265. data/doc/en/cairo-win32-printing-surface.html +60 -0
  266. data/doc/en/cairo-win32-printing-surface.rd +27 -0
  267. data/doc/en/cairo-win32-surface.html +65 -0
  268. data/doc/en/cairo-win32-surface.rd +31 -0
  269. data/doc/en/cairo-write-error.html +50 -0
  270. data/doc/en/cairo-write-error.rd +17 -0
  271. data/doc/en/cairo.html +123 -0
  272. data/doc/en/cairo.rd +95 -0
  273. data/doc/en/index.html +1080 -0
  274. data/doc/en/index.rd +1051 -0
  275. data/doc/index.html +18 -0
  276. data/doc/ja/cairo-antialias.html +57 -0
  277. data/doc/ja/cairo-clip-not-representable-error.html +56 -0
  278. data/doc/ja/cairo-color-base.html +75 -0
  279. data/doc/ja/cairo-color-cmyk.html +152 -0
  280. data/doc/ja/cairo-color-hsv.html +135 -0
  281. data/doc/ja/cairo-color-rgb.html +145 -0
  282. data/doc/ja/cairo-color-x11.html +183 -0
  283. data/doc/ja/cairo-color.html +317 -0
  284. data/doc/ja/cairo-content.html +51 -0
  285. data/doc/ja/cairo-context-blur.html +53 -0
  286. data/doc/ja/cairo-context-circle.html +54 -0
  287. data/doc/ja/cairo-context-color.html +52 -0
  288. data/doc/ja/cairo-context-path.html +77 -0
  289. data/doc/ja/cairo-context-rectangle.html +60 -0
  290. data/doc/ja/cairo-context-triangle.html +47 -0
  291. data/doc/ja/cairo-context.html +1449 -0
  292. data/doc/ja/cairo-error.html +56 -0
  293. data/doc/ja/cairo-extend.html +56 -0
  294. data/doc/ja/cairo-file-not-found.html +51 -0
  295. data/doc/ja/cairo-fill-rule.html +58 -0
  296. data/doc/ja/cairo-filter.html +43 -0
  297. data/doc/ja/cairo-font-extents.html +110 -0
  298. data/doc/ja/cairo-font-face.html +55 -0
  299. data/doc/ja/cairo-font-options.html +186 -0
  300. data/doc/ja/cairo-font-slant.html +50 -0
  301. data/doc/ja/cairo-font-weight.html +47 -0
  302. data/doc/ja/cairo-format.html +81 -0
  303. data/doc/ja/cairo-glyph.html +115 -0
  304. data/doc/ja/cairo-gradient-pattern.html +119 -0
  305. data/doc/ja/cairo-hint-metrics.html +57 -0
  306. data/doc/ja/cairo-hint-style.html +64 -0
  307. data/doc/ja/cairo-image-surface.html +131 -0
  308. data/doc/ja/cairo-invalid-content-error.html +54 -0
  309. data/doc/ja/cairo-invalid-dash-error.html +54 -0
  310. data/doc/ja/cairo-invalid-dsc-comment-error.html +54 -0
  311. data/doc/ja/cairo-invalid-format-error.html +54 -0
  312. data/doc/ja/cairo-invalid-index-error.html +54 -0
  313. data/doc/ja/cairo-invalid-matrix-error.html +54 -0
  314. data/doc/ja/cairo-invalid-path-data-error.html +54 -0
  315. data/doc/ja/cairo-invalid-pop-group-error.html +54 -0
  316. data/doc/ja/cairo-invalid-restore-error.html +55 -0
  317. data/doc/ja/cairo-invalid-status-error.html +55 -0
  318. data/doc/ja/cairo-invalid-stride-error.html +55 -0
  319. data/doc/ja/cairo-invalid-string-error.html +54 -0
  320. data/doc/ja/cairo-invalid-visual-error.html +57 -0
  321. data/doc/ja/cairo-line-cap.html +50 -0
  322. data/doc/ja/cairo-line-join.html +53 -0
  323. data/doc/ja/cairo-linear-pattern.html +87 -0
  324. data/doc/ja/cairo-matrix.html +343 -0
  325. data/doc/ja/cairo-no-current-point-error.html +54 -0
  326. data/doc/ja/cairo-null-pointer-error.html +54 -0
  327. data/doc/ja/cairo-operator.html +51 -0
  328. data/doc/ja/cairo-paper-parse-error.html +55 -0
  329. data/doc/ja/cairo-paper-unknown-paper-name.html +76 -0
  330. data/doc/ja/cairo-paper-unknown-unit.html +75 -0
  331. data/doc/ja/cairo-paper-unrecognized-paper-description.html +76 -0
  332. data/doc/ja/cairo-paper.html +357 -0
  333. data/doc/ja/cairo-path-close-path.html +57 -0
  334. data/doc/ja/cairo-path-curve-to.html +70 -0
  335. data/doc/ja/cairo-path-data-type.html +53 -0
  336. data/doc/ja/cairo-path-data.html +127 -0
  337. data/doc/ja/cairo-path-line-to.html +62 -0
  338. data/doc/ja/cairo-path-move-to.html +62 -0
  339. data/doc/ja/cairo-path.html +144 -0
  340. data/doc/ja/cairo-pattern-type-mismatch-error.html +56 -0
  341. data/doc/ja/cairo-pattern.html +128 -0
  342. data/doc/ja/cairo-pdf-surface.html +86 -0
  343. data/doc/ja/cairo-point.html +90 -0
  344. data/doc/ja/cairo-ps-level.html +62 -0
  345. data/doc/ja/cairo-ps-surface.html +214 -0
  346. data/doc/ja/cairo-quartz-image-surface.html +75 -0
  347. data/doc/ja/cairo-quartz-surface.html +93 -0
  348. data/doc/ja/cairo-radial-pattern.html +93 -0
  349. data/doc/ja/cairo-read-error.html +55 -0
  350. data/doc/ja/cairo-rectangle.html +109 -0
  351. data/doc/ja/cairo-scaled-font.html +144 -0
  352. data/doc/ja/cairo-solid-pattern.html +87 -0
  353. data/doc/ja/cairo-subpixel-order.html +57 -0
  354. data/doc/ja/cairo-surface-finished-error.html +54 -0
  355. data/doc/ja/cairo-surface-pattern.html +68 -0
  356. data/doc/ja/cairo-surface-type-mismatch-error.html +56 -0
  357. data/doc/ja/cairo-surface.html +191 -0
  358. data/doc/ja/cairo-svg-surface.html +114 -0
  359. data/doc/ja/cairo-svg-version.html +66 -0
  360. data/doc/ja/cairo-temp-file-error.html +50 -0
  361. data/doc/ja/cairo-text-extents.html +101 -0
  362. data/doc/ja/cairo-win32-printing-surface.html +80 -0
  363. data/doc/ja/cairo-win32-surface.html +100 -0
  364. data/doc/ja/cairo-write-error.html +55 -0
  365. data/doc/ja/cairo.html +148 -0
  366. data/doc/ja/index.html +1080 -0
  367. data/extconf.rb +153 -0
  368. data/misc/update-colors.rb +143 -0
  369. data/pkg-config.rb +278 -0
  370. data/samples/agg/README +4 -0
  371. data/samples/agg/aa_demo.rb +47 -0
  372. data/samples/agg/aa_test.rb +304 -0
  373. data/samples/blur.rb +47 -0
  374. data/samples/pac.rb +99 -0
  375. data/samples/pac2.rb +171 -0
  376. data/samples/png.rb +45 -0
  377. data/samples/scalable.rb +56 -0
  378. data/samples/text-on-path.rb +60 -0
  379. data/samples/text2.rb +131 -0
  380. data/src/cairo.def +96 -0
  381. data/src/cairo.so +0 -0
  382. data/src/lib/cairo.rb +141 -0
  383. data/src/lib/cairo/color.rb +255 -0
  384. data/src/lib/cairo/colors.rb +656 -0
  385. data/src/lib/cairo/constants.rb +21 -0
  386. data/src/lib/cairo/context.rb +29 -0
  387. data/src/lib/cairo/context/blur.rb +45 -0
  388. data/src/lib/cairo/context/circle.rb +9 -0
  389. data/src/lib/cairo/context/color.rb +11 -0
  390. data/src/lib/cairo/context/path.rb +116 -0
  391. data/src/lib/cairo/context/rectangle.rb +33 -0
  392. data/src/lib/cairo/context/triangle.rb +12 -0
  393. data/src/lib/cairo/paper.rb +183 -0
  394. data/src/lib/cairo/papers.rb +41 -0
  395. data/src/lib/cairo/path.rb +15 -0
  396. data/src/lib/cairo/point.rb +7 -0
  397. data/src/libruby-cairo.a +0 -0
  398. data/src/rb_cairo.c +82 -0
  399. data/src/rb_cairo.h +264 -0
  400. data/src/rb_cairo_constants.c +456 -0
  401. data/src/rb_cairo_context.c +1548 -0
  402. data/src/rb_cairo_exception.c +214 -0
  403. data/src/rb_cairo_font_extents.c +125 -0
  404. data/src/rb_cairo_font_face.c +56 -0
  405. data/src/rb_cairo_font_options.c +197 -0
  406. data/src/rb_cairo_glyph.c +159 -0
  407. data/src/rb_cairo_matrix.c +350 -0
  408. data/src/rb_cairo_path.c +459 -0
  409. data/src/rb_cairo_pattern.c +540 -0
  410. data/src/rb_cairo_private.c +78 -0
  411. data/src/rb_cairo_private.h +72 -0
  412. data/src/rb_cairo_scaled_font.c +177 -0
  413. data/src/rb_cairo_surface.c +1252 -0
  414. data/src/rb_cairo_text_extents.c +138 -0
  415. data/test/run-test.rb +15 -0
  416. data/test/test_paper.rb +81 -0
  417. data/test/test_pkg_config.rb +122 -0
  418. metadata +490 -0
@@ -0,0 +1,78 @@
1
+ /* -*- c-file-style: "gnu"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Ruby Cairo Binding
4
+ *
5
+ * $Author: kou $
6
+ * $Date: 2007/05/18 14:07:48 $
7
+ *
8
+ * Copyright 2005 Kouhei Sutou <kou@cozmixng.org>
9
+ *
10
+ * This file is made available under the same terms as Ruby
11
+ *
12
+ */
13
+
14
+ #include "rb_cairo.h"
15
+ #include "rb_cairo_private.h"
16
+
17
+ static ID id_normalize_const_name;
18
+
19
+ VALUE
20
+ rb_cairo__float_array (double *values, unsigned count)
21
+ {
22
+ VALUE result;
23
+ int i;
24
+
25
+ result = rb_ary_new2 (count);
26
+ for (i = 0; i < count; i++)
27
+ {
28
+ rb_ary_push (result, rb_float_new (values[i]));
29
+ }
30
+ return result;
31
+ }
32
+
33
+ void
34
+ rb_cairo__glyphs_to_array (VALUE rb_array, cairo_glyph_t *glyphs, int length)
35
+ {
36
+ int i;
37
+
38
+ for (i = 0; i < length; i++)
39
+ {
40
+ memcpy ((char *) &glyphs[i],
41
+ (char *) RVAL2CRGLYPH (rb_ary_entry (rb_array, i)),
42
+ sizeof (cairo_glyph_t));
43
+ }
44
+ }
45
+
46
+ VALUE
47
+ rb_cairo__const_get (VALUE name, const char *prefix)
48
+ {
49
+ VALUE rb_normalized_name;
50
+ char *const_name, *normalized_name;
51
+ size_t prefix_len, normalized_name_len;
52
+
53
+ rb_normalized_name = rb_funcall (rb_mCairo, id_normalize_const_name, 1, name);
54
+ normalized_name = RVAL2CSTR (rb_normalized_name);
55
+
56
+ prefix_len = strlen (prefix);
57
+ normalized_name_len = strlen (normalized_name);
58
+
59
+ const_name = ALLOCA_N (char, prefix_len + normalized_name_len + 1);
60
+ strncpy (const_name, prefix, prefix_len);
61
+ strncpy (const_name + prefix_len, normalized_name, normalized_name_len);
62
+ const_name[prefix_len + normalized_name_len] = '\0';
63
+
64
+ return rb_const_get (rb_mCairo, rb_intern (const_name));
65
+ }
66
+
67
+ cairo_bool_t
68
+ rb_cairo__is_kind_of (VALUE object, VALUE klass)
69
+ {
70
+ return RVAL2CBOOL (rb_obj_is_kind_of (object, klass));
71
+ }
72
+
73
+
74
+ void
75
+ Init_cairo_private (void)
76
+ {
77
+ id_normalize_const_name = rb_intern ("normalize_const_name");
78
+ }
@@ -0,0 +1,72 @@
1
+ /* -*- c-file-style: "gnu"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Ruby Cairo Binding
4
+ *
5
+ * $Author: kou $
6
+ * $Date: 2008-01-11 08:03:39 $
7
+ *
8
+ * Copyright 2005 Kouhei Sutou <kou@cozmixng.org>
9
+ *
10
+ * This file is made available under the same terms as Ruby
11
+ *
12
+ */
13
+
14
+ #ifndef RB_CAIRO_PRIVATE_H
15
+ #define RB_CAIRO_PRIVATE_H
16
+
17
+ #define CR_TRUE 1
18
+ #define CR_FALSE 0
19
+
20
+ #define CSTR2RVAL(str) rb_str_new2(str)
21
+ #define RVAL2CSTR(str) StringValueCStr(str)
22
+
23
+ #define CBOOL2RVAL(bool) (bool ? Qtrue : Qfalse)
24
+ #define RVAL2CBOOL(bool) RTEST(bool)
25
+
26
+ #ifndef RSTRING_LEN
27
+ # define RSTRING_LEN(string) (RSTRING(string)->len)
28
+ #endif
29
+
30
+ #ifdef HAVE_RB_ERRINFO
31
+ # define RB_ERRINFO (rb_errinfo())
32
+ #else
33
+ # define RB_ERRINFO (ruby_errinfo)
34
+ #endif
35
+
36
+ extern void Init_cairo_private (void);
37
+ extern void Init_cairo_constants (void);
38
+
39
+ extern void Init_cairo_context (void);
40
+ extern void Init_cairo_path (void);
41
+ extern void Init_cairo_matrix (void);
42
+ extern void Init_cairo_surface (void);
43
+ extern void Init_cairo_quartz_surface (void);
44
+ extern void Init_cairo_exception (void);
45
+ extern void Init_cairo_font (void);
46
+ extern void Init_cairo_font_extents (void);
47
+ extern void Init_cairo_font_options (void);
48
+ extern void Init_cairo_scaled_font (void);
49
+ extern void Init_cairo_text_extents (void);
50
+ extern void Init_cairo_pattern (void);
51
+ extern void Init_cairo_glyph (void);
52
+
53
+ #define RB_CAIRO__GLYPHS_TO_ARRAY(rb_array, glyphs, length) \
54
+ do \
55
+ { \
56
+ Check_Type (rb_array, T_ARRAY); \
57
+ length = RARRAY (rb_array)->len; \
58
+ glyphs = ALLOCA_N (cairo_glyph_t, length); \
59
+ \
60
+ if (!glyphs) \
61
+ rb_cairo_check_status (CAIRO_STATUS_NO_MEMORY); \
62
+ \
63
+ rb_cairo__glyphs_to_array (rb_array, glyphs, length); \
64
+ } while (0)
65
+
66
+ VALUE rb_cairo__float_array (double *values, unsigned count);
67
+ void rb_cairo__glyphs_to_array (VALUE rb_array, cairo_glyph_t *glyphs, int length);
68
+
69
+ VALUE rb_cairo__const_get (VALUE name, const char *prefix);
70
+ cairo_bool_t rb_cairo__is_kind_of (VALUE object, VALUE klass);
71
+
72
+ #endif
@@ -0,0 +1,177 @@
1
+ /* -*- c-file-style: "gnu"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Ruby Cairo Binding
4
+ *
5
+ * $Author: kou $
6
+ * $Date: 2007/05/20 09:18:49 $
7
+ *
8
+ * Copyright 2005 Kouhei Sutou <kou@cozmixng.org>
9
+ *
10
+ * This file is made available under the same terms as Ruby
11
+ *
12
+ */
13
+
14
+
15
+ #include "rb_cairo.h"
16
+ #include "rb_cairo_private.h"
17
+
18
+ VALUE rb_cCairo_ScaledFont;
19
+
20
+ #define _SELF(self) (RVAL2CRSCALEDFONT(self))
21
+
22
+ static inline void
23
+ cr_scaled_font_check_status (cairo_scaled_font_t *font)
24
+ {
25
+ rb_cairo_check_status (cairo_scaled_font_status (font));
26
+ }
27
+
28
+ cairo_scaled_font_t *
29
+ rb_cairo_scaled_font_from_ruby_object (VALUE obj)
30
+ {
31
+ cairo_scaled_font_t *font;
32
+ if (!rb_cairo__is_kind_of (obj, rb_cCairo_ScaledFont))
33
+ {
34
+ rb_raise (rb_eTypeError, "not a cairo scaled font");
35
+ }
36
+ Data_Get_Struct (obj, cairo_scaled_font_t, font);
37
+ return font;
38
+ }
39
+
40
+ static void
41
+ cr_scaled_font_free (void *ptr)
42
+ {
43
+ if (ptr)
44
+ {
45
+ cairo_scaled_font_destroy ((cairo_scaled_font_t *) ptr);
46
+ }
47
+ }
48
+
49
+ VALUE
50
+ rb_cairo_scaled_font_to_ruby_object (cairo_scaled_font_t *font)
51
+ {
52
+ if (font)
53
+ {
54
+ cairo_scaled_font_reference (font);
55
+ return Data_Wrap_Struct (rb_cCairo_ScaledFont, NULL,
56
+ cr_scaled_font_free, font);
57
+ }
58
+ else
59
+ {
60
+ return Qnil;
61
+ }
62
+ }
63
+
64
+ static VALUE
65
+ cr_scaled_font_allocate (VALUE klass)
66
+ {
67
+ return Data_Wrap_Struct (klass, NULL, cr_scaled_font_free, NULL);
68
+ }
69
+
70
+ static VALUE
71
+ cr_scaled_font_initialize (VALUE self, VALUE face, VALUE matrix,
72
+ VALUE ctm, VALUE options)
73
+ {
74
+ cairo_scaled_font_t *font;
75
+
76
+ font = cairo_scaled_font_create (RVAL2CRFONTFACE (face),
77
+ RVAL2CRMATRIX (matrix),
78
+ RVAL2CRMATRIX (ctm),
79
+ RVAL2CRFONTOPTIONS (options));
80
+ cr_scaled_font_check_status (font);
81
+ DATA_PTR (self) = font;
82
+ return Qnil;
83
+ }
84
+
85
+ static VALUE
86
+ cr_scaled_font_extents (VALUE self)
87
+ {
88
+ cairo_font_extents_t extents;
89
+ cairo_scaled_font_extents (_SELF (self), &extents);
90
+ cr_scaled_font_check_status (_SELF (self));
91
+ return CRFONTEXTENTS2RVAL (&extents);
92
+ }
93
+
94
+ static VALUE
95
+ cr_scaled_font_text_extents (VALUE self, VALUE utf8)
96
+ {
97
+ cairo_text_extents_t extents;
98
+ cairo_scaled_font_text_extents (_SELF (self), StringValueCStr (utf8),
99
+ &extents);
100
+ cr_scaled_font_check_status (_SELF (self));
101
+ return CRTEXTEXTENTS2RVAL (&extents);
102
+ }
103
+
104
+ static VALUE
105
+ cr_scaled_font_glyph_extents (VALUE self, VALUE rb_glyphs)
106
+ {
107
+ cairo_text_extents_t extents;
108
+ cairo_glyph_t *glyphs;
109
+ int count;
110
+
111
+ RB_CAIRO__GLYPHS_TO_ARRAY (rb_glyphs, glyphs, count);
112
+ cairo_scaled_font_glyph_extents (_SELF (self), glyphs, count, &extents);
113
+ cr_scaled_font_check_status (_SELF (self));
114
+ return CRTEXTEXTENTS2RVAL (&extents);
115
+ }
116
+
117
+ static VALUE
118
+ cr_scaled_font_get_font_face (VALUE self)
119
+ {
120
+ cairo_font_face_t *face;
121
+ face = cairo_scaled_font_get_font_face (_SELF (self));
122
+ cr_scaled_font_check_status (_SELF (self));
123
+ return CRFONTFACE2RVAL (face);
124
+ }
125
+
126
+ static VALUE
127
+ cr_scaled_font_get_font_matrix (VALUE self)
128
+ {
129
+ cairo_matrix_t font_matrix;
130
+ cairo_scaled_font_get_font_matrix (_SELF (self), &font_matrix);
131
+ cr_scaled_font_check_status (_SELF (self));
132
+ return CRMATRIX2RVAL (&font_matrix);
133
+ }
134
+
135
+ static VALUE
136
+ cr_scaled_font_get_ctm (VALUE self)
137
+ {
138
+ cairo_matrix_t ctm;
139
+ cairo_scaled_font_get_font_matrix (_SELF (self), &ctm);
140
+ cr_scaled_font_check_status (_SELF (self));
141
+ return CRMATRIX2RVAL (&ctm);
142
+ }
143
+
144
+ static VALUE
145
+ cr_scaled_font_get_font_options (VALUE self)
146
+ {
147
+ cairo_font_options_t *options = cairo_font_options_create();
148
+ cairo_scaled_font_get_font_options (_SELF (self), options);
149
+ cr_scaled_font_check_status (_SELF (self));
150
+ rb_cairo_check_status (cairo_font_options_status (options));
151
+ return CRFONTOPTIONS2RVAL (options);
152
+ }
153
+
154
+ void
155
+ Init_cairo_scaled_font (void)
156
+ {
157
+ rb_cCairo_ScaledFont =
158
+ rb_define_class_under (rb_mCairo, "ScaledFont", rb_cObject);
159
+
160
+ rb_define_alloc_func (rb_cCairo_ScaledFont, cr_scaled_font_allocate);
161
+
162
+ rb_define_method (rb_cCairo_ScaledFont, "initialize",
163
+ cr_scaled_font_initialize, 4);
164
+
165
+ rb_define_method (rb_cCairo_ScaledFont, "extents", cr_scaled_font_extents, 0);
166
+ rb_define_method (rb_cCairo_ScaledFont, "text_extents",
167
+ cr_scaled_font_text_extents, 1);
168
+ rb_define_method (rb_cCairo_ScaledFont, "glyph_extents",
169
+ cr_scaled_font_glyph_extents, 1);
170
+ rb_define_method (rb_cCairo_ScaledFont, "font_face",
171
+ cr_scaled_font_get_font_face, 0);
172
+ rb_define_method (rb_cCairo_ScaledFont, "font_matrix",
173
+ cr_scaled_font_get_font_matrix, 0);
174
+ rb_define_method (rb_cCairo_ScaledFont, "ctm", cr_scaled_font_get_ctm, 0);
175
+ rb_define_method (rb_cCairo_ScaledFont, "font_options",
176
+ cr_scaled_font_get_font_options, 0);
177
+ }
@@ -0,0 +1,1252 @@
1
+ /* -*- c-file-style: "gnu"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Ruby Cairo Binding
4
+ *
5
+ * $Author: kou $
6
+ * $Date: 2008-04-16 14:48:23 $
7
+ *
8
+ * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
9
+ * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
10
+ *
11
+ * This file is made available under the same terms as Ruby
12
+ *
13
+ */
14
+
15
+ #include "rb_cairo.h"
16
+ #include "rb_cairo_private.h"
17
+
18
+ #include "rubyio.h"
19
+
20
+ #if CAIRO_HAS_PS_SURFACE || CAIRO_HAS_PDF_SURFACE || CAIRO_HAS_SVG_SURFACE
21
+ # define HAS_CREATE_CR_CLOSURE_SURFACE 1
22
+ #else
23
+ # define HAS_CREATE_CR_CLOSURE_SURFACE 0
24
+ #endif
25
+
26
+
27
+ VALUE rb_cCairo_Surface;
28
+ VALUE rb_cCairo_ImageSurface;
29
+ VALUE rb_cCairo_PDFSurface = Qnil;
30
+ VALUE rb_cCairo_PSSurface = Qnil;
31
+ VALUE rb_cCairo_SVGSurface = Qnil;
32
+ VALUE rb_cCairo_Win32Surface = Qnil;
33
+ VALUE rb_cCairo_Win32PrintingSurface = Qnil;
34
+ VALUE rb_cCairo_QuartzSurface = Qnil;
35
+ VALUE rb_cCairo_QuartzImageSurface = Qnil;
36
+
37
+ static ID cr_id_target;
38
+ static ID cr_id_read;
39
+ static ID cr_id_write;
40
+ static ID cr_id_inspect;
41
+ static ID cr_id_parse;
42
+ static ID cr_id_size;
43
+ static ID cr_id_set_unit;
44
+ static cairo_user_data_key_t cr_closure_key;
45
+
46
+ #define _SELF (RVAL2CRSURFACE(self))
47
+
48
+ static VALUE
49
+ cr_paper_parse (VALUE paper_description)
50
+ {
51
+ return rb_funcall (rb_cCairo_Paper, cr_id_parse, 2, paper_description, Qtrue);
52
+ }
53
+
54
+ static void
55
+ cr_paper_to_size_in_points (VALUE paper_description, VALUE *width, VALUE *height)
56
+ {
57
+ VALUE paper, size;
58
+
59
+ paper = cr_paper_parse (paper_description);
60
+ size = rb_funcall (paper, cr_id_size, 1, rb_str_new2 ("pt"));
61
+ *width = RARRAY_PTR (size)[0];
62
+ *height = RARRAY_PTR (size)[1];
63
+ }
64
+
65
+ static inline void
66
+ cr_surface_check_status (cairo_surface_t *surface)
67
+ {
68
+ rb_cairo_check_status (cairo_surface_status (surface));
69
+ }
70
+
71
+ static VALUE
72
+ cr_surface_get_klass (cairo_surface_t *surface)
73
+ {
74
+ VALUE klass;
75
+ cairo_surface_type_t type;
76
+
77
+ type = cairo_surface_get_type (surface);
78
+ switch (type)
79
+ {
80
+ case CAIRO_SURFACE_TYPE_IMAGE:
81
+ klass = rb_cCairo_ImageSurface;
82
+ break;
83
+ case CAIRO_SURFACE_TYPE_PDF:
84
+ klass = rb_cCairo_PDFSurface;
85
+ break;
86
+ case CAIRO_SURFACE_TYPE_PS:
87
+ klass = rb_cCairo_PSSurface;
88
+ break;
89
+ case CAIRO_SURFACE_TYPE_QUARTZ:
90
+ klass = rb_cCairo_QuartzSurface;
91
+ break;
92
+ case CAIRO_SURFACE_TYPE_WIN32:
93
+ klass = rb_cCairo_Win32Surface;
94
+ break;
95
+ case CAIRO_SURFACE_TYPE_SVG:
96
+ klass = rb_cCairo_SVGSurface;
97
+ break;
98
+ #if CAIRO_CHECK_VERSION(1, 5, 2)
99
+ case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
100
+ klass = rb_cCairo_Win32PrintingSurface;
101
+ break;
102
+ #endif
103
+ #if CAIRO_CHECK_VERSION(1, 5, 12)
104
+ case CAIRO_SURFACE_TYPE_QUARTZ_IMAGE:
105
+ klass = rb_cCairo_QuartzImageSurface;
106
+ break;
107
+ #endif
108
+ default:
109
+ rb_raise (rb_eArgError, "unknown source type: %d", type);
110
+ break;
111
+ }
112
+
113
+ if (NIL_P (klass))
114
+ rb_raise (rb_eArgError, "unknown source type: %d", type);
115
+
116
+ return klass;
117
+ }
118
+
119
+ static char *
120
+ inspect (VALUE object)
121
+ {
122
+ VALUE inspected;
123
+ inspected = rb_funcall (object, cr_id_inspect, 0);
124
+ return StringValueCStr(inspected);
125
+ }
126
+
127
+ /* read/write callback */
128
+ typedef struct cr_io_callback_closure {
129
+ VALUE target;
130
+ VALUE error;
131
+ unsigned char *data;
132
+ unsigned int length;
133
+ } cr_io_callback_closure_t;
134
+
135
+ #if HAS_CREATE_CR_CLOSURE_SURFACE
136
+ static cr_io_callback_closure_t *
137
+ cr_closure_new (VALUE target)
138
+ {
139
+ cr_io_callback_closure_t *closure;
140
+ closure = ALLOC (cr_io_callback_closure_t);
141
+
142
+ closure->target = target;
143
+ closure->error = Qnil;
144
+
145
+ return closure;
146
+ }
147
+
148
+ static void
149
+ cr_closure_destroy (cr_io_callback_closure_t *closure)
150
+ {
151
+ free (closure);
152
+ }
153
+
154
+ static void
155
+ cr_closure_free (void *closure)
156
+ {
157
+ cr_closure_destroy ((cr_io_callback_closure_t *) closure);
158
+ }
159
+ #endif
160
+
161
+ static VALUE
162
+ cr_surface_io_func_rescue (VALUE io_closure)
163
+ {
164
+ cr_io_callback_closure_t *closure;
165
+ closure = (cr_io_callback_closure_t *)io_closure;
166
+ closure->error = RB_ERRINFO;
167
+ return Qnil;
168
+ }
169
+
170
+ /* write callback */
171
+ static VALUE
172
+ cr_surface_write_func_invoke (VALUE write_closure)
173
+ {
174
+ VALUE output, data;
175
+ long written_bytes;
176
+ cr_io_callback_closure_t *closure;
177
+ unsigned int length;
178
+
179
+ closure = (cr_io_callback_closure_t *)write_closure;
180
+
181
+ output = closure->target;
182
+ data = rb_str_new ((const char *)closure->data, closure->length);
183
+
184
+ length = RSTRING_LEN (data);
185
+ while (length != 0)
186
+ {
187
+ VALUE rb_written_bytes = rb_funcall (output, cr_id_write, 1, data);
188
+ written_bytes = NUM2LONG (rb_written_bytes);
189
+ data = rb_str_substr (data, written_bytes,
190
+ RSTRING_LEN (data) - written_bytes);
191
+ length -= written_bytes;
192
+ }
193
+
194
+ return Qnil;
195
+ }
196
+
197
+ static cairo_status_t
198
+ cr_surface_write_func (void *write_closure,
199
+ const unsigned char *data, unsigned int length)
200
+ {
201
+ cr_io_callback_closure_t *closure;
202
+
203
+ closure = (cr_io_callback_closure_t *)write_closure;
204
+ closure->data = (unsigned char *)data;
205
+ closure->length = length;
206
+
207
+ rb_rescue2 (cr_surface_write_func_invoke, (VALUE) closure,
208
+ cr_surface_io_func_rescue, (VALUE) closure, rb_eException,
209
+ (VALUE)0);
210
+
211
+ if (NIL_P (closure->error))
212
+ return CAIRO_STATUS_SUCCESS;
213
+ else
214
+ return CAIRO_STATUS_WRITE_ERROR;
215
+ }
216
+
217
+ /* read callback */
218
+ static VALUE
219
+ cr_surface_read_func_invoke (VALUE read_closure)
220
+ {
221
+ VALUE input, result;
222
+ cr_io_callback_closure_t *closure;
223
+ unsigned int length, rest;
224
+
225
+ closure = (cr_io_callback_closure_t *)read_closure;
226
+ input = closure->target;
227
+ length = closure->length;
228
+
229
+ result = rb_str_new2 ("");
230
+
231
+ for (rest = length; rest != 0; rest = length - RSTRING_LEN (result))
232
+ {
233
+ rb_str_concat (result, rb_funcall (input, cr_id_read, 1, INT2NUM (rest)));
234
+ }
235
+
236
+ memcpy ((void *)closure->data, (const void *)StringValuePtr (result), length);
237
+
238
+ return Qnil;
239
+ }
240
+
241
+ static cairo_status_t
242
+ cr_surface_read_func (void *read_closure,
243
+ unsigned char *data, unsigned int length)
244
+ {
245
+ cr_io_callback_closure_t *closure;
246
+
247
+ closure = (cr_io_callback_closure_t *)read_closure;
248
+ closure->data = data;
249
+ closure->length = length;
250
+ rb_rescue2 (cr_surface_read_func_invoke, (VALUE) closure,
251
+ cr_surface_io_func_rescue, (VALUE) closure, rb_eException,
252
+ (VALUE)0);
253
+
254
+ if (NIL_P (closure->error))
255
+ return CAIRO_STATUS_SUCCESS;
256
+ else
257
+ return CAIRO_STATUS_READ_ERROR;
258
+ }
259
+
260
+ /* constructor/de-constructor */
261
+ cairo_surface_t *
262
+ rb_cairo_surface_from_ruby_object (VALUE obj)
263
+ {
264
+ cairo_surface_t *surface;
265
+ if (!rb_cairo__is_kind_of (obj, rb_cCairo_Surface))
266
+ {
267
+ rb_raise (rb_eTypeError, "not a cairo surface");
268
+ }
269
+ Data_Get_Struct (obj, cairo_surface_t, surface);
270
+ return surface;
271
+ }
272
+
273
+ static void
274
+ cr_surface_free (void *ptr)
275
+ {
276
+ if (ptr)
277
+ {
278
+ cairo_surface_destroy ((cairo_surface_t *) ptr);
279
+ }
280
+ }
281
+
282
+ VALUE
283
+ rb_cairo_surface_to_ruby_object (cairo_surface_t *surface)
284
+ {
285
+ if (surface)
286
+ {
287
+ VALUE klass;
288
+ klass = cr_surface_get_klass (surface);
289
+ cairo_surface_reference (surface);
290
+ return Data_Wrap_Struct (klass, NULL, cr_surface_free, surface);
291
+ }
292
+ else
293
+ {
294
+ return Qnil;
295
+ }
296
+ }
297
+
298
+ VALUE
299
+ rb_cairo_surface_to_ruby_object_with_destroy (cairo_surface_t *surface)
300
+ {
301
+ VALUE rb_surface;
302
+ rb_surface = rb_cairo_surface_to_ruby_object (surface);
303
+ if (surface)
304
+ cairo_surface_destroy (surface);
305
+ return rb_surface;
306
+ }
307
+
308
+ static VALUE
309
+ cr_surface_allocate (VALUE klass)
310
+ {
311
+ return Data_Wrap_Struct (klass, NULL, cr_surface_free, NULL);
312
+ }
313
+
314
+ /* Surface manipulation */
315
+ static void
316
+ yield_and_finish (VALUE self)
317
+ {
318
+ cairo_surface_t *surface;
319
+ cairo_status_t status;
320
+
321
+ rb_yield (self);
322
+
323
+ surface = _SELF;
324
+ if (cairo_surface_status (surface))
325
+ return;
326
+ cairo_surface_finish (surface);
327
+ status = cairo_surface_status (surface);
328
+ if (status == CAIRO_STATUS_SUCCESS || status == CAIRO_STATUS_SURFACE_FINISHED)
329
+ return;
330
+
331
+ cr_surface_check_status (surface);
332
+ }
333
+
334
+ static VALUE
335
+ cr_surface_create_similar (VALUE self, VALUE content, VALUE width, VALUE height)
336
+ {
337
+ cairo_surface_t *surface;
338
+
339
+ surface = cairo_surface_create_similar (RVAL2CRSURFACE (self),
340
+ RVAL2CRCONTENT (content),
341
+ NUM2INT (width), NUM2INT (height));
342
+ cr_surface_check_status (surface);
343
+ return CRSURFACE2RVAL_WITH_DESTROY (surface);
344
+ }
345
+
346
+ static VALUE
347
+ cr_surface_finish (VALUE self)
348
+ {
349
+ cr_io_callback_closure_t *closure;
350
+ closure = cairo_surface_get_user_data (_SELF, &cr_closure_key);
351
+
352
+ cairo_surface_finish (_SELF);
353
+
354
+ if (closure && !NIL_P (closure->error))
355
+ rb_exc_raise (closure->error);
356
+
357
+ cr_surface_check_status (_SELF);
358
+ return self;
359
+ }
360
+
361
+ static VALUE
362
+ cr_surface_get_content (VALUE self)
363
+ {
364
+ return INT2NUM (cairo_surface_get_content (_SELF));
365
+ }
366
+
367
+
368
+ #if CAIRO_HAS_PNG_FUNCTIONS
369
+ static VALUE
370
+ cr_surface_write_to_png_stream (VALUE self, VALUE target)
371
+ {
372
+ cairo_status_t status;
373
+ cr_io_callback_closure_t closure;
374
+
375
+ closure.target = target;
376
+ closure.error = Qnil;
377
+
378
+ status = cairo_surface_write_to_png_stream (_SELF, cr_surface_write_func,
379
+ (void *)&closure);
380
+ if (!NIL_P (closure.error))
381
+ rb_exc_raise (closure.error);
382
+
383
+ rb_cairo_check_status (status);
384
+ return self;
385
+ }
386
+
387
+ static VALUE
388
+ cr_surface_write_to_png (VALUE self, VALUE filename)
389
+ {
390
+ cairo_status_t status;
391
+ status = cairo_surface_write_to_png (_SELF, StringValueCStr (filename));
392
+ rb_cairo_check_status (status);
393
+ return self;
394
+ }
395
+
396
+ static VALUE
397
+ cr_surface_write_to_png_generic (VALUE self, VALUE target)
398
+ {
399
+ if (rb_respond_to (target, cr_id_write))
400
+ return cr_surface_write_to_png_stream (self, target);
401
+ else
402
+ return cr_surface_write_to_png (self, target);
403
+ }
404
+ #endif
405
+
406
+ static VALUE
407
+ cr_surface_get_font_options (VALUE self)
408
+ {
409
+ cairo_font_options_t *options = cairo_font_options_create();
410
+ cairo_surface_get_font_options (_SELF, options);
411
+ cr_surface_check_status (_SELF);
412
+ rb_cairo_check_status (cairo_font_options_status (options));
413
+ return CRFONTOPTIONS2RVAL (options);
414
+ }
415
+
416
+ static VALUE
417
+ cr_surface_flush (VALUE self)
418
+ {
419
+ cairo_surface_flush (_SELF);
420
+ cr_surface_check_status (_SELF);
421
+ return self;
422
+ }
423
+
424
+ static VALUE
425
+ cr_surface_mark_dirty (int argc, VALUE *argv, VALUE self)
426
+ {
427
+ VALUE x, y, width, height;
428
+ int n;
429
+
430
+ n = rb_scan_args (argc, argv, "04", &x, &y, &width, &height);
431
+
432
+ if (n == 0)
433
+ {
434
+ cairo_surface_mark_dirty (_SELF);
435
+ }
436
+ else if (n == 4)
437
+ {
438
+ cairo_surface_mark_dirty_rectangle (_SELF,
439
+ NUM2INT (x), NUM2INT (y),
440
+ NUM2INT (width), NUM2INT (height));
441
+ }
442
+ else
443
+ {
444
+ int i;
445
+ VALUE args;
446
+
447
+ args = rb_ary_new2 (n);
448
+ for (i = 0; i < n; i++)
449
+ {
450
+ rb_ary_push (args, argv[i]);
451
+ }
452
+
453
+ rb_raise (rb_eArgError,
454
+ "invalid argument (expect () or (x, y, width, height)): %s",
455
+ inspect (args));
456
+ }
457
+
458
+ cr_surface_check_status (_SELF);
459
+ return self;
460
+ }
461
+
462
+ static VALUE
463
+ cr_surface_set_device_offset (VALUE self, VALUE x_offset, VALUE y_offset)
464
+ {
465
+ cairo_surface_set_device_offset (_SELF,
466
+ NUM2DBL (x_offset),
467
+ NUM2DBL (y_offset));
468
+ cr_surface_check_status (_SELF);
469
+ return self;
470
+ }
471
+
472
+ static VALUE
473
+ cr_surface_get_device_offset (VALUE self)
474
+ {
475
+ double x_offset, y_offset;
476
+
477
+ cairo_surface_get_device_offset (_SELF, &x_offset, &y_offset);
478
+ cr_surface_check_status (_SELF);
479
+ return rb_ary_new3 (2, rb_float_new (x_offset), rb_float_new (y_offset));
480
+ }
481
+
482
+ static VALUE
483
+ cr_surface_set_fallback_resolution (VALUE self,
484
+ VALUE x_pixels_per_inch,
485
+ VALUE y_pixels_per_inch)
486
+ {
487
+ cairo_surface_set_fallback_resolution (_SELF,
488
+ NUM2DBL (x_pixels_per_inch),
489
+ NUM2DBL (y_pixels_per_inch));
490
+ cr_surface_check_status (_SELF);
491
+ return self;
492
+ }
493
+
494
+ #if CAIRO_CHECK_VERSION(1, 5, 2)
495
+ static VALUE
496
+ cr_surface_copy_page (VALUE self)
497
+ {
498
+ cairo_surface_copy_page (_SELF);
499
+ cr_surface_check_status (_SELF);
500
+ return self;
501
+ }
502
+
503
+ static VALUE
504
+ cr_surface_show_page (VALUE self)
505
+ {
506
+ cairo_surface_show_page (_SELF);
507
+ cr_surface_check_status (_SELF);
508
+ return self;
509
+ }
510
+ #endif
511
+
512
+ /* Image-surface functions */
513
+ #if CAIRO_HAS_PNG_FUNCTIONS
514
+ static cairo_surface_t *
515
+ cr_image_surface_create_from_png_stream (VALUE target)
516
+ {
517
+ cr_io_callback_closure_t closure;
518
+ cairo_surface_t *surface;
519
+
520
+ closure.target = target;
521
+ closure.error = Qnil;
522
+
523
+ surface = cairo_image_surface_create_from_png_stream (cr_surface_read_func,
524
+ (void *)&closure);
525
+ if (!NIL_P (closure.error))
526
+ rb_exc_raise (closure.error);
527
+
528
+ return surface;
529
+ }
530
+
531
+ static cairo_surface_t *
532
+ cr_image_surface_create_from_png (VALUE filename)
533
+ {
534
+ return cairo_image_surface_create_from_png (StringValueCStr (filename));
535
+ }
536
+
537
+ static VALUE
538
+ cr_image_surface_create_from_png_generic (VALUE klass, VALUE target)
539
+ {
540
+ VALUE rb_surface;
541
+ cairo_surface_t *surface;
542
+
543
+ if (rb_respond_to (target, cr_id_read))
544
+ surface = cr_image_surface_create_from_png_stream (target);
545
+ else
546
+ surface = cr_image_surface_create_from_png (target);
547
+
548
+ cr_surface_check_status (surface);
549
+ rb_surface = cr_surface_allocate (klass);
550
+ DATA_PTR (rb_surface) = surface;
551
+ return rb_surface;
552
+ }
553
+ #endif
554
+
555
+ static cairo_surface_t *
556
+ cr_image_surface_create (VALUE self, VALUE format, VALUE width, VALUE height)
557
+ {
558
+ cairo_format_t cr_format;
559
+ cr_format = NIL_P (format) ? CAIRO_FORMAT_ARGB32 : RVAL2CRFORMAT (format);
560
+ return cairo_image_surface_create (cr_format,
561
+ NUM2INT (width),
562
+ NUM2INT (height));
563
+ }
564
+
565
+ static cairo_surface_t *
566
+ cr_image_surface_create_for_data (VALUE self, VALUE rb_data, VALUE format,
567
+ VALUE width, VALUE height, VALUE stride)
568
+ {
569
+ unsigned char *data;
570
+
571
+ data = (unsigned char *)StringValuePtr (rb_data);
572
+
573
+ return cairo_image_surface_create_for_data (data,
574
+ RVAL2CRFORMAT (format),
575
+ NUM2INT (width),
576
+ NUM2INT (height),
577
+ NUM2INT (stride));
578
+ }
579
+
580
+ static VALUE
581
+ cr_image_surface_initialize (int argc, VALUE *argv, VALUE self)
582
+ {
583
+ cairo_surface_t *surface;
584
+ VALUE arg1, arg2, arg3, arg4, arg5;
585
+ int n;
586
+
587
+ n = rb_scan_args (argc, argv, "23", &arg1, &arg2, &arg3, &arg4, &arg5);
588
+
589
+ if (n == 2)
590
+ surface = cr_image_surface_create (self, Qnil, arg1, arg2);
591
+ else if (n == 3)
592
+ surface = cr_image_surface_create (self, arg1, arg2, arg3);
593
+ else if (n == 5)
594
+ surface =
595
+ cr_image_surface_create_for_data (self, arg1, arg2, arg3, arg4, arg5);
596
+ else
597
+ rb_raise (rb_eArgError,
598
+ "invalid argument (expect "
599
+ "(width, height) or "
600
+ "(format, width, height) or "
601
+ "(data, format, width, height, stride)): %s",
602
+ inspect (rb_ary_new3 (4, arg1, arg2, arg3, arg4)));
603
+
604
+ cr_surface_check_status (surface);
605
+ DATA_PTR (self) = surface;
606
+ if (rb_block_given_p ())
607
+ yield_and_finish (self);
608
+ return Qnil;
609
+ }
610
+
611
+ static VALUE
612
+ cr_image_surface_get_data (VALUE self)
613
+ {
614
+ unsigned char *data;
615
+ cairo_surface_t *surface;
616
+
617
+ surface = _SELF;
618
+ data = cairo_image_surface_get_data (surface);
619
+
620
+ if (data)
621
+ return rb_str_new ((const char *)data,
622
+ cairo_image_surface_get_stride (surface) *
623
+ cairo_image_surface_get_height (surface));
624
+ else
625
+ return Qnil;
626
+ }
627
+
628
+ static VALUE
629
+ cr_image_surface_get_format (VALUE self)
630
+ {
631
+ return INT2NUM (cairo_image_surface_get_format (_SELF));
632
+ }
633
+
634
+ static VALUE
635
+ cr_image_surface_get_width (VALUE self)
636
+ {
637
+ return INT2NUM (cairo_image_surface_get_width (_SELF));
638
+ }
639
+
640
+ static VALUE
641
+ cr_image_surface_get_height (VALUE self)
642
+ {
643
+ return INT2NUM (cairo_image_surface_get_height (_SELF));
644
+ }
645
+
646
+ static VALUE
647
+ cr_image_surface_get_stride (VALUE self)
648
+ {
649
+ return INT2NUM (cairo_image_surface_get_stride (_SELF));
650
+ }
651
+
652
+
653
+ /* Printing surfaces */
654
+ #define DEFINE_SURFACE(type) \
655
+ static VALUE \
656
+ cr_ ## type ## _surface_initialize (int argc, VALUE *argv, VALUE self) \
657
+ { \
658
+ VALUE target, rb_width_in_points, rb_height_in_points; \
659
+ VALUE arg2, arg3; \
660
+ cairo_surface_t *surface; \
661
+ double width_in_points, height_in_points; \
662
+ \
663
+ rb_scan_args (argc, argv, "21", &target, &arg2, &arg3); \
664
+ if (argc == 2) \
665
+ { \
666
+ VALUE paper; \
667
+ \
668
+ paper = arg2; \
669
+ cr_paper_to_size_in_points (paper, \
670
+ &rb_width_in_points, \
671
+ &rb_height_in_points); \
672
+ } \
673
+ else \
674
+ { \
675
+ rb_width_in_points = arg2; \
676
+ rb_height_in_points = arg3; \
677
+ } \
678
+ \
679
+ width_in_points = NUM2DBL (rb_width_in_points); \
680
+ height_in_points = NUM2DBL (rb_height_in_points); \
681
+ \
682
+ if (rb_respond_to (target, cr_id_write)) \
683
+ { \
684
+ cr_io_callback_closure_t *closure; \
685
+ \
686
+ closure = cr_closure_new (target); \
687
+ surface = \
688
+ cairo_ ## type ## _surface_create_for_stream ( \
689
+ cr_surface_write_func, \
690
+ (void *) closure, \
691
+ width_in_points, \
692
+ height_in_points); \
693
+ \
694
+ if (cairo_surface_status (surface)) \
695
+ { \
696
+ cr_closure_destroy (closure); \
697
+ } \
698
+ else \
699
+ { \
700
+ rb_ivar_set (self, cr_id_target, target); \
701
+ cairo_surface_set_user_data (surface, &cr_closure_key, \
702
+ closure, cr_closure_free); \
703
+ } \
704
+ } \
705
+ else \
706
+ { \
707
+ surface = \
708
+ cairo_ ## type ## _surface_create (StringValueCStr (target), \
709
+ width_in_points, \
710
+ height_in_points); \
711
+ } \
712
+ \
713
+ cr_surface_check_status (surface); \
714
+ DATA_PTR (self) = surface; \
715
+ if (rb_block_given_p ()) \
716
+ yield_and_finish (self); \
717
+ return Qnil; \
718
+ }
719
+
720
+ #define DEFINE_SURFACE_SET_SIZE(type) \
721
+ static VALUE \
722
+ cr_ ## type ## _surface_set_size (int argc, VALUE *argv, VALUE self) \
723
+ { \
724
+ VALUE arg1, arg2; \
725
+ VALUE width_in_points, height_in_points; \
726
+ \
727
+ rb_scan_args(argc, argv, "11", &arg1, &arg2); \
728
+ if (argc == 1) \
729
+ { \
730
+ VALUE paper; \
731
+ \
732
+ paper = arg1; \
733
+ cr_paper_to_size_in_points (paper, \
734
+ &width_in_points, \
735
+ &height_in_points); \
736
+ } \
737
+ else \
738
+ { \
739
+ width_in_points = arg1; \
740
+ height_in_points = arg2; \
741
+ } \
742
+ \
743
+ cairo_ ## type ## _surface_set_size (_SELF, \
744
+ NUM2DBL (width_in_points), \
745
+ NUM2DBL (height_in_points)); \
746
+ cr_surface_check_status (_SELF); \
747
+ return Qnil; \
748
+ }
749
+
750
+ #if CAIRO_HAS_PS_SURFACE
751
+ /* PS-surface functions */
752
+ DEFINE_SURFACE(ps)
753
+ DEFINE_SURFACE_SET_SIZE(ps)
754
+
755
+ static VALUE
756
+ cr_ps_surface_dsc_comment (VALUE self, VALUE comment)
757
+ {
758
+ cairo_ps_surface_dsc_comment (_SELF, StringValueCStr (comment));
759
+ cr_surface_check_status (_SELF);
760
+ return Qnil;
761
+ }
762
+
763
+ static VALUE
764
+ cr_ps_surface_dsc_begin_setup (VALUE self)
765
+ {
766
+ cairo_ps_surface_dsc_begin_setup (_SELF);
767
+ cr_surface_check_status (_SELF);
768
+ if (rb_block_given_p ())
769
+ return rb_yield (self);
770
+ else
771
+ return Qnil;
772
+ }
773
+
774
+ static VALUE
775
+ cr_ps_surface_dsc_begin_page_setup (VALUE self)
776
+ {
777
+ cairo_ps_surface_dsc_begin_page_setup (_SELF);
778
+ cr_surface_check_status (_SELF);
779
+ if (rb_block_given_p ())
780
+ return rb_yield (self);
781
+ else
782
+ return Qnil;
783
+ }
784
+
785
+ # if CAIRO_CHECK_VERSION(1, 5, 2)
786
+ static VALUE
787
+ cr_ps_surface_restrict_to_level (VALUE self, VALUE level)
788
+ {
789
+ cairo_ps_surface_restrict_to_level (_SELF, RVAL2CRPSLEVEL (level));
790
+ cr_surface_check_status (_SELF);
791
+ return Qnil;
792
+ }
793
+
794
+ static VALUE
795
+ cr_ps_surface_get_eps (VALUE self)
796
+ {
797
+ return cairo_ps_surface_get_eps (_SELF) ? Qtrue : Qfalse;
798
+ }
799
+
800
+ static VALUE
801
+ cr_ps_surface_set_eps (VALUE self, VALUE eps)
802
+ {
803
+ cairo_ps_surface_set_eps (_SELF, RTEST (eps));
804
+ cr_surface_check_status (_SELF);
805
+ return Qnil;
806
+ }
807
+ # endif
808
+ #endif
809
+
810
+ #if CAIRO_HAS_PDF_SURFACE
811
+ /* PDF-surface functions */
812
+ DEFINE_SURFACE(pdf)
813
+ DEFINE_SURFACE_SET_SIZE(pdf)
814
+ #endif
815
+
816
+ #if CAIRO_HAS_SVG_SURFACE
817
+ /* SVG-surface functions */
818
+ DEFINE_SURFACE(svg)
819
+
820
+ static VALUE
821
+ cr_svg_surface_restrict_to_version (VALUE self, VALUE version)
822
+ {
823
+ cairo_svg_surface_restrict_to_version (_SELF, RVAL2CRSVGVERSION (version));
824
+ cr_surface_check_status (_SELF);
825
+ return Qnil;
826
+ }
827
+ #endif
828
+
829
+ #if CAIRO_HAS_WIN32_SURFACE
830
+ /* WIN32-surface functions */
831
+
832
+ /* from dl/dl.h (ruby 1.9) */
833
+ #if SIZEOF_LONG == SIZEOF_VOIDP
834
+ # define PTR2NUM(x) (ULONG2NUM((unsigned long)(x)))
835
+ # define NUM2PTR(x) ((void *)(NUM2ULONG(x)))
836
+ #else
837
+ # define PTR2NUM(x) (ULL2NUM((unsigned long long)(x)))
838
+ # define NUM2PTR(x) ((void *)(NUM2ULL(x)))
839
+ #endif
840
+
841
+ static VALUE
842
+ cr_win32_surface_initialize (int argc, VALUE *argv, VALUE self)
843
+ {
844
+ cairo_surface_t *surface = NULL;
845
+ VALUE arg1, arg2, arg3, arg4;
846
+ VALUE hdc, format, width, height;
847
+
848
+ rb_scan_args (argc, argv, "13", &arg1, &arg2, &arg3, &arg4);
849
+
850
+ switch (argc)
851
+ {
852
+ case 1:
853
+ hdc = arg1;
854
+ surface = cairo_win32_surface_create (NUM2PTR (hdc));
855
+ break;
856
+ case 2:
857
+ width = arg1;
858
+ height = arg2;
859
+ surface = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32,
860
+ NUM2INT (width),
861
+ NUM2INT (height));
862
+ break;
863
+ case 3:
864
+ if (NIL_P (arg1) ||
865
+ (rb_cairo__is_kind_of (arg1, rb_cNumeric) &&
866
+ NUM2INT (arg1) != CAIRO_FORMAT_RGB24))
867
+ {
868
+ # if CAIRO_CHECK_VERSION(1, 4, 0)
869
+ HDC win32_hdc;
870
+ hdc = arg1;
871
+ width = arg2;
872
+ height = arg3;
873
+ win32_hdc = NIL_P (hdc) ? NULL : NUM2PTR (hdc);
874
+ surface = cairo_win32_surface_create_with_ddb (win32_hdc,
875
+ CAIRO_FORMAT_RGB24,
876
+ NUM2INT (width),
877
+ NUM2INT (height));
878
+ # else
879
+ rb_raise (rb_eArgError,
880
+ "Cairo::Win32Surface.new(hdc, width, height) "
881
+ "is available since cairo >= 1.4.0");
882
+ # endif
883
+ }
884
+ else
885
+ {
886
+ format = arg1;
887
+ width = arg2;
888
+ height = arg3;
889
+ surface = cairo_win32_surface_create_with_dib (RVAL2CRFORMAT (format),
890
+ NUM2INT (width),
891
+ NUM2INT (height));
892
+ }
893
+ break;
894
+ case 4:
895
+ {
896
+ # if CAIRO_CHECK_VERSION(1, 4, 0)
897
+ HDC win32_hdc;
898
+ hdc = arg1;
899
+ format = arg2;
900
+ width = arg3;
901
+ height = arg4;
902
+ win32_hdc = NIL_P (hdc) ? NULL : (HDC) NUM2UINT (hdc);
903
+ surface = cairo_win32_surface_create_with_ddb (win32_hdc,
904
+ RVAL2CRFORMAT (format),
905
+ NUM2INT (width),
906
+ NUM2INT (height));
907
+ # else
908
+ rb_raise (rb_eArgError,
909
+ "Cairo::Win32Surface.new(hdc, format, width, height) "
910
+ "is available since cairo >= 1.4.0");
911
+ # endif
912
+ }
913
+ break;
914
+ }
915
+
916
+ if (!surface)
917
+ rb_cairo_check_status (CAIRO_STATUS_INVALID_FORMAT);
918
+ cr_surface_check_status (surface);
919
+ DATA_PTR (self) = surface;
920
+ if (rb_block_given_p ())
921
+ yield_and_finish (self);
922
+ return Qnil;
923
+ }
924
+
925
+ # if CAIRO_CHECK_VERSION(1, 5, 2)
926
+ static VALUE
927
+ cr_win32_printing_surface_initialize (VALUE self, VALUE hdc)
928
+ {
929
+ cairo_surface_t *surface = NULL;
930
+
931
+ surface = cairo_win32_printing_surface_create (NUM2PTR (hdc));
932
+ cr_surface_check_status (surface);
933
+ DATA_PTR (self) = surface;
934
+ if (rb_block_given_p ())
935
+ yield_and_finish (self);
936
+ return Qnil;
937
+ }
938
+ # endif
939
+
940
+ static VALUE
941
+ cr_win32_surface_get_hdc (VALUE self)
942
+ {
943
+ HDC hdc;
944
+
945
+ hdc = cairo_win32_surface_get_dc (_SELF);
946
+ if (!hdc)
947
+ return Qnil;
948
+ else
949
+ return PTR2NUM (hdc);
950
+ }
951
+
952
+ # if CAIRO_CHECK_VERSION(1, 4, 0)
953
+ static VALUE
954
+ cr_win32_surface_get_image (VALUE self)
955
+ {
956
+ cairo_surface_t *surface;
957
+
958
+ surface = cairo_win32_surface_get_image (_SELF);
959
+ if (!surface)
960
+ return Qnil;
961
+ cr_surface_check_status (surface);
962
+ return CRSURFACE2RVAL (surface);
963
+ }
964
+ # endif
965
+ #endif
966
+
967
+ #if CAIRO_HAS_QUARTZ_SURFACE && defined(HAVE_RUBY_COCOA)
968
+ /* Quartz-surface functions */
969
+
970
+ #include <objc/objc-runtime.h>
971
+
972
+ BOOL rbobj_to_nsobj (VALUE obj, id* nsobj);
973
+ VALUE ocid_to_rbobj (VALUE context_obj, id ocid);
974
+
975
+ static VALUE
976
+ cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
977
+ {
978
+ id objc_object = nil;
979
+ CGContextRef context;
980
+ unsigned int width, height;
981
+ cairo_surface_t *surface = NULL;
982
+ cairo_format_t format = CAIRO_FORMAT_ARGB32;
983
+ VALUE arg1, arg2, arg3, rb_width, rb_height;
984
+ static VALUE rb_cOSXCGContextRef = Qnil;
985
+
986
+ rb_scan_args (argc, argv, "21", &arg1, &arg2, &arg3);
987
+
988
+ if (argc == 2)
989
+ {
990
+ rb_width = arg1;
991
+ rb_height = arg2;
992
+ }
993
+ else
994
+ {
995
+ switch (TYPE (arg1))
996
+ {
997
+ case T_NIL:
998
+ break;
999
+ case T_STRING:
1000
+ case T_SYMBOL:
1001
+ case T_FIXNUM:
1002
+ format = RVAL2CRFORMAT (arg1);
1003
+ break;
1004
+ default:
1005
+ if (NIL_P (rb_cOSXCGContextRef))
1006
+ rb_cOSXCGContextRef =
1007
+ rb_const_get (rb_const_get (rb_cObject, rb_intern ("OSX")),
1008
+ rb_intern ("CGContextRef"));
1009
+
1010
+ if (RTEST (rb_obj_is_kind_of (arg1, rb_cOSXCGContextRef)))
1011
+ rbobj_to_nsobj (arg1, &objc_object);
1012
+ else
1013
+ rb_raise (rb_eArgError,
1014
+ "invalid argument (expect "
1015
+ "(width, height), "
1016
+ "(format, width, height) or "
1017
+ "(cg_context, width, height)): %s",
1018
+ inspect (rb_ary_new3 (3, arg1, arg2, arg3)));
1019
+ break;
1020
+ }
1021
+
1022
+ rb_width = arg2;
1023
+ rb_height = arg3;
1024
+ }
1025
+
1026
+ width = NUM2UINT (rb_width);
1027
+ height = NUM2UINT (rb_height);
1028
+
1029
+ if (objc_object == nil)
1030
+ {
1031
+ surface = cairo_quartz_surface_create (format, width, height);
1032
+ }
1033
+ else
1034
+ {
1035
+ context = (CGContextRef)objc_object;
1036
+ surface =
1037
+ cairo_quartz_surface_create_for_cg_context (context, width, height);
1038
+ }
1039
+
1040
+ cr_surface_check_status (surface);
1041
+ DATA_PTR (self) = surface;
1042
+ if (rb_block_given_p ())
1043
+ yield_and_finish (self);
1044
+ return Qnil;
1045
+ }
1046
+
1047
+ static VALUE
1048
+ cr_quartz_surface_get_cg_context (VALUE self)
1049
+ {
1050
+ CGContextRef context;
1051
+ id objc_object;
1052
+
1053
+ context = cairo_quartz_surface_get_cg_context (_SELF);
1054
+ objc_object = (id)context;
1055
+ return ocid_to_rbobj (Qnil, objc_object);
1056
+ }
1057
+
1058
+ # if CAIRO_CHECK_VERSION(1, 5, 12)
1059
+ static VALUE
1060
+ cr_quartz_image_surface_initialize (VALUE self, VALUE image_surface)
1061
+ {
1062
+ cairo_surface_t *surface;
1063
+
1064
+ surface = cairo_quartz_image_surface_create (RVAL2CRSURFACE (image_surface));
1065
+ cr_surface_check_status (surface);
1066
+ DATA_PTR (self) = surface;
1067
+ if (rb_block_given_p ())
1068
+ yield_and_finish (self);
1069
+ return Qnil;
1070
+ }
1071
+
1072
+ static VALUE
1073
+ cr_quartz_image_surface_get_image (VALUE self)
1074
+ {
1075
+ cairo_surface_t *surface;
1076
+
1077
+ surface = cairo_quartz_image_surface_get_image (_SELF);
1078
+ if (!surface)
1079
+ return Qnil;
1080
+ cr_surface_check_status (surface);
1081
+ return CRSURFACE2RVAL (surface);
1082
+ }
1083
+ # endif
1084
+ #endif
1085
+
1086
+
1087
+ void
1088
+ Init_cairo_surface (void)
1089
+ {
1090
+ cr_id_target = rb_intern ("target");
1091
+ cr_id_read = rb_intern ("read");
1092
+ cr_id_write = rb_intern ("write");
1093
+ cr_id_inspect = rb_intern ("inspect");
1094
+ cr_id_parse = rb_intern ("parse");
1095
+ cr_id_size = rb_intern ("size");
1096
+ cr_id_set_unit = rb_intern ("unit=");
1097
+
1098
+ rb_cCairo_Surface =
1099
+ rb_define_class_under (rb_mCairo, "Surface", rb_cObject);
1100
+ rb_define_alloc_func (rb_cCairo_Surface, cr_surface_allocate);
1101
+
1102
+ rb_define_method (rb_cCairo_Surface, "create_similar",
1103
+ cr_surface_create_similar, 3);
1104
+ rb_define_method (rb_cCairo_Surface, "finish", cr_surface_finish, 0);
1105
+ rb_define_method (rb_cCairo_Surface, "content", cr_surface_get_content, 0);
1106
+
1107
+ rb_define_method (rb_cCairo_Surface, "font_options",
1108
+ cr_surface_get_font_options, 0);
1109
+ rb_define_method (rb_cCairo_Surface, "flush", cr_surface_flush, 0);
1110
+ rb_define_method (rb_cCairo_Surface, "mark_dirty", cr_surface_mark_dirty, -1);
1111
+ rb_define_method (rb_cCairo_Surface, "set_device_offset",
1112
+ cr_surface_set_device_offset, 2);
1113
+ rb_define_method (rb_cCairo_Surface, "device_offset",
1114
+ cr_surface_get_device_offset, 0);
1115
+ rb_define_method (rb_cCairo_Surface, "set_fallback_resolution",
1116
+ cr_surface_set_fallback_resolution, 2);
1117
+ #if CAIRO_CHECK_VERSION(1, 5, 2)
1118
+ rb_define_method (rb_cCairo_Surface, "copy_page",
1119
+ cr_surface_copy_page, 2);
1120
+ rb_define_method (rb_cCairo_Surface, "show_page",
1121
+ cr_surface_show_page, 2);
1122
+ #endif
1123
+
1124
+ #if CAIRO_HAS_PNG_FUNCTIONS
1125
+ rb_define_method (rb_cCairo_Surface, "write_to_png",
1126
+ cr_surface_write_to_png_generic, 1);
1127
+ #endif
1128
+
1129
+ RB_CAIRO_DEF_SETTERS (rb_cCairo_Surface);
1130
+
1131
+ /* Image-surface */
1132
+ rb_cCairo_ImageSurface =
1133
+ rb_define_class_under (rb_mCairo, "ImageSurface", rb_cCairo_Surface);
1134
+
1135
+ #if CAIRO_HAS_PNG_FUNCTIONS
1136
+ rb_define_singleton_method (rb_cCairo_ImageSurface, "from_png",
1137
+ cr_image_surface_create_from_png_generic, 1);
1138
+ #endif
1139
+
1140
+ rb_define_method (rb_cCairo_ImageSurface, "initialize",
1141
+ cr_image_surface_initialize, -1);
1142
+
1143
+ rb_define_method (rb_cCairo_ImageSurface, "data",
1144
+ cr_image_surface_get_data, 0);
1145
+ rb_define_method (rb_cCairo_ImageSurface, "format",
1146
+ cr_image_surface_get_format, 0);
1147
+ rb_define_method (rb_cCairo_ImageSurface, "width",
1148
+ cr_image_surface_get_width, 0);
1149
+ rb_define_method (rb_cCairo_ImageSurface, "height",
1150
+ cr_image_surface_get_height, 0);
1151
+ rb_define_method (rb_cCairo_ImageSurface, "stride",
1152
+ cr_image_surface_get_stride, 0);
1153
+
1154
+ #define INIT_SURFACE(type, name) \
1155
+ rb_cCairo_ ## name ## Surface = \
1156
+ rb_define_class_under (rb_mCairo, # name "Surface", \
1157
+ rb_cCairo_Surface); \
1158
+ \
1159
+ rb_define_method (rb_cCairo_ ## name ## Surface, "initialize", \
1160
+ cr_ ## type ## _surface_initialize, -1);
1161
+
1162
+ #if CAIRO_HAS_PS_SURFACE
1163
+ /* PS-surface */
1164
+ INIT_SURFACE(ps, PS)
1165
+
1166
+ rb_define_method (rb_cCairo_PSSurface, "set_size", cr_ps_surface_set_size, -1);
1167
+ rb_define_method (rb_cCairo_PSSurface, "dsc_comment",
1168
+ cr_ps_surface_dsc_comment, 1);
1169
+ rb_define_method (rb_cCairo_PSSurface, "dsc_begin_setup",
1170
+ cr_ps_surface_dsc_begin_setup, 0);
1171
+ rb_define_method (rb_cCairo_PSSurface, "dsc_begin_page_setup",
1172
+ cr_ps_surface_dsc_begin_page_setup, 0);
1173
+
1174
+ #if CAIRO_CHECK_VERSION(1, 5, 2)
1175
+ rb_define_method (rb_cCairo_PSSurface, "restrict_to_level",
1176
+ cr_ps_surface_restrict_to_level, 1);
1177
+ rb_define_method (rb_cCairo_PSSurface, "eps?", cr_ps_surface_get_eps, 0);
1178
+ rb_define_method (rb_cCairo_PSSurface, "set_eps", cr_ps_surface_set_eps, 1);
1179
+ #endif
1180
+
1181
+ RB_CAIRO_DEF_SETTERS (rb_cCairo_PSSurface);
1182
+ #endif
1183
+
1184
+ #if CAIRO_HAS_PDF_SURFACE
1185
+ /* PDF-surface */
1186
+ INIT_SURFACE(pdf, PDF)
1187
+
1188
+ rb_define_method (rb_cCairo_PDFSurface, "set_size",
1189
+ cr_pdf_surface_set_size, -1);
1190
+
1191
+ RB_CAIRO_DEF_SETTERS (rb_cCairo_PDFSurface);
1192
+ #endif
1193
+
1194
+ #if CAIRO_HAS_SVG_SURFACE
1195
+ /* SVG-surface */
1196
+ INIT_SURFACE(svg, SVG)
1197
+
1198
+ rb_define_method (rb_cCairo_SVGSurface, "restrict_to_version",
1199
+ cr_svg_surface_restrict_to_version, 1);
1200
+
1201
+ RB_CAIRO_DEF_SETTERS (rb_cCairo_SVGSurface);
1202
+ #endif
1203
+
1204
+ #if CAIRO_HAS_WIN32_SURFACE
1205
+ /* Win32-surface */
1206
+ rb_cCairo_Win32Surface =
1207
+ rb_define_class_under (rb_mCairo, "Win32Surface", rb_cCairo_Surface);
1208
+
1209
+ rb_define_method (rb_cCairo_Win32Surface, "initialize",
1210
+ cr_win32_surface_initialize, -1);
1211
+ rb_define_method (rb_cCairo_Win32Surface, "hdc",
1212
+ cr_win32_surface_get_hdc, 0);
1213
+ # if CAIRO_CHECK_VERSION(1, 4, 0)
1214
+ rb_define_method (rb_cCairo_Win32Surface, "image",
1215
+ cr_win32_surface_get_image, 0);
1216
+ # endif
1217
+
1218
+ # if CAIRO_CHECK_VERSION(1, 5, 2)
1219
+ rb_cCairo_Win32PrintingSurface =
1220
+ rb_define_class_under (rb_mCairo, "Win32PrintingSurface", rb_cCairo_Surface);
1221
+
1222
+ rb_define_method (rb_cCairo_Win32PrintingSurface, "initialize",
1223
+ cr_win32_printing_surface_initialize, -1);
1224
+ rb_define_method (rb_cCairo_Win32PrintingSurface, "hdc",
1225
+ cr_win32_surface_get_hdc, 0);
1226
+ # endif
1227
+
1228
+ #endif
1229
+
1230
+ #if CAIRO_HAS_QUARTZ_SURFACE && defined(HAVE_RUBY_COCOA)
1231
+ /* Quartz-surface */
1232
+
1233
+ rb_cCairo_QuartzSurface =
1234
+ rb_define_class_under (rb_mCairo, "QuartzSurface", rb_cCairo_Surface);
1235
+
1236
+ rb_define_method (rb_cCairo_QuartzSurface, "initialize",
1237
+ cr_quartz_surface_initialize, -1);
1238
+ rb_define_method (rb_cCairo_QuartzSurface, "cg_context",
1239
+ cr_quartz_surface_get_cg_context, 0);
1240
+
1241
+ # if CAIRO_CHECK_VERSION(1, 5, 12)
1242
+ rb_cCairo_QuartzImageSurface =
1243
+ rb_define_class_under (rb_mCairo, "QuartzImageSurface", rb_cCairo_Surface);
1244
+
1245
+ rb_define_method (rb_cCairo_QuartzImageSurface, "initialize",
1246
+ cr_quartz_image_surface_initialize, 1);
1247
+ rb_define_method (rb_cCairo_QuartzImageSurface, "image",
1248
+ cr_quartz_image_surface_get_image, 0);
1249
+ # endif
1250
+
1251
+ #endif
1252
+ }