/src/compiler/android-ndk/jni/freetype/include/freetype/ftsystem.h

http://ftk.googlecode.com/ · C++ Header · 346 lines · 51 code · 43 blank · 252 comment · 0 complexity · 0f2c543fda9e5e69ac855b52e5a16a5b MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* ftsystem.h */
  4. /* */
  5. /* FreeType low-level system interface definition (specification). */
  6. /* */
  7. /* Copyright 1996-2001, 2002, 2005 by */
  8. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  9. /* */
  10. /* This file is part of the FreeType project, and may only be used, */
  11. /* modified, and distributed under the terms of the FreeType project */
  12. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  13. /* this file you indicate that you have read the license and */
  14. /* understand and accept it fully. */
  15. /* */
  16. /***************************************************************************/
  17. #ifndef __FTSYSTEM_H__
  18. #define __FTSYSTEM_H__
  19. #include <ft2build.h>
  20. FT_BEGIN_HEADER
  21. /*************************************************************************/
  22. /* */
  23. /* <Section> */
  24. /* system_interface */
  25. /* */
  26. /* <Title> */
  27. /* System Interface */
  28. /* */
  29. /* <Abstract> */
  30. /* How FreeType manages memory and i/o. */
  31. /* */
  32. /* <Description> */
  33. /* This section contains various definitions related to memory */
  34. /* management and i/o access. You need to understand this */
  35. /* information if you want to use a custom memory manager or you own */
  36. /* i/o streams. */
  37. /* */
  38. /*************************************************************************/
  39. /*************************************************************************/
  40. /* */
  41. /* M E M O R Y M A N A G E M E N T */
  42. /* */
  43. /*************************************************************************/
  44. /*************************************************************************
  45. *
  46. * @type:
  47. * FT_Memory
  48. *
  49. * @description:
  50. * A handle to a given memory manager object, defined with an
  51. * @FT_MemoryRec structure.
  52. *
  53. */
  54. typedef struct FT_MemoryRec_* FT_Memory;
  55. /*************************************************************************
  56. *
  57. * @functype:
  58. * FT_Alloc_Func
  59. *
  60. * @description:
  61. * A function used to allocate `size' bytes from `memory'.
  62. *
  63. * @input:
  64. * memory ::
  65. * A handle to the source memory manager.
  66. *
  67. * size ::
  68. * The size in bytes to allocate.
  69. *
  70. * @return:
  71. * Address of new memory block. 0~in case of failure.
  72. *
  73. */
  74. typedef void*
  75. (*FT_Alloc_Func)( FT_Memory memory,
  76. long size );
  77. /*************************************************************************
  78. *
  79. * @functype:
  80. * FT_Free_Func
  81. *
  82. * @description:
  83. * A function used to release a given block of memory.
  84. *
  85. * @input:
  86. * memory ::
  87. * A handle to the source memory manager.
  88. *
  89. * block ::
  90. * The address of the target memory block.
  91. *
  92. */
  93. typedef void
  94. (*FT_Free_Func)( FT_Memory memory,
  95. void* block );
  96. /*************************************************************************
  97. *
  98. * @functype:
  99. * FT_Realloc_Func
  100. *
  101. * @description:
  102. * A function used to re-allocate a given block of memory.
  103. *
  104. * @input:
  105. * memory ::
  106. * A handle to the source memory manager.
  107. *
  108. * cur_size ::
  109. * The block's current size in bytes.
  110. *
  111. * new_size ::
  112. * The block's requested new size.
  113. *
  114. * block ::
  115. * The block's current address.
  116. *
  117. * @return:
  118. * New block address. 0~in case of memory shortage.
  119. *
  120. * @note:
  121. * In case of error, the old block must still be available.
  122. *
  123. */
  124. typedef void*
  125. (*FT_Realloc_Func)( FT_Memory memory,
  126. long cur_size,
  127. long new_size,
  128. void* block );
  129. /*************************************************************************
  130. *
  131. * @struct:
  132. * FT_MemoryRec
  133. *
  134. * @description:
  135. * A structure used to describe a given memory manager to FreeType~2.
  136. *
  137. * @fields:
  138. * user ::
  139. * A generic typeless pointer for user data.
  140. *
  141. * alloc ::
  142. * A pointer type to an allocation function.
  143. *
  144. * free ::
  145. * A pointer type to an memory freeing function.
  146. *
  147. * realloc ::
  148. * A pointer type to a reallocation function.
  149. *
  150. */
  151. struct FT_MemoryRec_
  152. {
  153. void* user;
  154. FT_Alloc_Func alloc;
  155. FT_Free_Func free;
  156. FT_Realloc_Func realloc;
  157. };
  158. /*************************************************************************/
  159. /* */
  160. /* I / O M A N A G E M E N T */
  161. /* */
  162. /*************************************************************************/
  163. /*************************************************************************
  164. *
  165. * @type:
  166. * FT_Stream
  167. *
  168. * @description:
  169. * A handle to an input stream.
  170. *
  171. */
  172. typedef struct FT_StreamRec_* FT_Stream;
  173. /*************************************************************************
  174. *
  175. * @struct:
  176. * FT_StreamDesc
  177. *
  178. * @description:
  179. * A union type used to store either a long or a pointer. This is used
  180. * to store a file descriptor or a `FILE*' in an input stream.
  181. *
  182. */
  183. typedef union FT_StreamDesc_
  184. {
  185. long value;
  186. void* pointer;
  187. } FT_StreamDesc;
  188. /*************************************************************************
  189. *
  190. * @functype:
  191. * FT_Stream_IoFunc
  192. *
  193. * @description:
  194. * A function used to seek and read data from a given input stream.
  195. *
  196. * @input:
  197. * stream ::
  198. * A handle to the source stream.
  199. *
  200. * offset ::
  201. * The offset of read in stream (always from start).
  202. *
  203. * buffer ::
  204. * The address of the read buffer.
  205. *
  206. * count ::
  207. * The number of bytes to read from the stream.
  208. *
  209. * @return:
  210. * The number of bytes effectively read by the stream.
  211. *
  212. * @note:
  213. * This function might be called to perform a seek or skip operation
  214. * with a `count' of~0.
  215. *
  216. */
  217. typedef unsigned long
  218. (*FT_Stream_IoFunc)( FT_Stream stream,
  219. unsigned long offset,
  220. unsigned char* buffer,
  221. unsigned long count );
  222. /*************************************************************************
  223. *
  224. * @functype:
  225. * FT_Stream_CloseFunc
  226. *
  227. * @description:
  228. * A function used to close a given input stream.
  229. *
  230. * @input:
  231. * stream ::
  232. * A handle to the target stream.
  233. *
  234. */
  235. typedef void
  236. (*FT_Stream_CloseFunc)( FT_Stream stream );
  237. /*************************************************************************
  238. *
  239. * @struct:
  240. * FT_StreamRec
  241. *
  242. * @description:
  243. * A structure used to describe an input stream.
  244. *
  245. * @input:
  246. * base ::
  247. * For memory-based streams, this is the address of the first stream
  248. * byte in memory. This field should always be set to NULL for
  249. * disk-based streams.
  250. *
  251. * size ::
  252. * The stream size in bytes.
  253. *
  254. * pos ::
  255. * The current position within the stream.
  256. *
  257. * descriptor ::
  258. * This field is a union that can hold an integer or a pointer. It is
  259. * used by stream implementations to store file descriptors or `FILE*'
  260. * pointers.
  261. *
  262. * pathname ::
  263. * This field is completely ignored by FreeType. However, it is often
  264. * useful during debugging to use it to store the stream's filename
  265. * (where available).
  266. *
  267. * read ::
  268. * The stream's input function.
  269. *
  270. * close ::
  271. * The stream;s close function.
  272. *
  273. * memory ::
  274. * The memory manager to use to preload frames. This is set
  275. * internally by FreeType and shouldn't be touched by stream
  276. * implementations.
  277. *
  278. * cursor ::
  279. * This field is set and used internally by FreeType when parsing
  280. * frames.
  281. *
  282. * limit ::
  283. * This field is set and used internally by FreeType when parsing
  284. * frames.
  285. *
  286. */
  287. typedef struct FT_StreamRec_
  288. {
  289. unsigned char* base;
  290. unsigned long size;
  291. unsigned long pos;
  292. FT_StreamDesc descriptor;
  293. FT_StreamDesc pathname;
  294. FT_Stream_IoFunc read;
  295. FT_Stream_CloseFunc close;
  296. FT_Memory memory;
  297. unsigned char* cursor;
  298. unsigned char* limit;
  299. } FT_StreamRec;
  300. /* */
  301. FT_END_HEADER
  302. #endif /* __FTSYSTEM_H__ */
  303. /* END */