You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 18 години
преди 15 години
преди 19 години
преди 19 години
преди 19 години
преди 19 години
преди 19 години
преди 19 години
преди 18 години
преди 18 години
преди 18 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*
  2. * libcaca Colour ASCII-Art library
  3. * Copyright (c) 2002-2009 Sam Hocevar <sam@hocevar.net>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This library is free software. It comes without any warranty, to
  9. * the extent permitted by applicable law. You can redistribute it
  10. * and/or modify it under the terms of the Do What The Fuck You Want
  11. * To Public License, Version 2, as published by Sam Hocevar. See
  12. * http://sam.zoy.org/wtfpl/COPYING for more details.
  13. */
  14. #ifndef __CACA_INTERNALS_H__
  15. #define __CACA_INTERNALS_H__
  16. #include "caca_stubs.h"
  17. #include "caca_debug.h"
  18. #include "caca_prof.h"
  19. typedef struct caca_timer caca_timer_t;
  20. typedef struct caca_privevent caca_privevent_t;
  21. typedef struct caca_figfont caca_figfont_t;
  22. #if !defined(_DOXYGEN_SKIP_ME)
  23. # define STAT_VALUES 32
  24. # define EVENTBUF_LEN 10
  25. # define MAX_DIRTY_COUNT 8
  26. #endif
  27. struct caca_frame
  28. {
  29. /* Frame size */
  30. int width, height;
  31. /* Cell information */
  32. uint32_t *chars;
  33. uint32_t *attrs;
  34. /* Painting context */
  35. int x, y;
  36. int handlex, handley;
  37. uint32_t curattr;
  38. /* Frame name */
  39. char *name;
  40. };
  41. struct caca_canvas
  42. {
  43. /* XXX: look at caca_set_canvas_boundaries() before adding anything
  44. * to this structure. The function is quite hacky. */
  45. /* Frame information */
  46. int frame, framecount;
  47. struct caca_frame *frames;
  48. /* Canvas management */
  49. int refcount;
  50. int autoinc;
  51. int (*resize_callback)(void *);
  52. void *resize_data;
  53. /* Dirty rectangles */
  54. int ndirty, dirty_disabled;
  55. struct
  56. {
  57. int xmin, ymin, xmax, ymax;
  58. }
  59. dirty[MAX_DIRTY_COUNT + 1];
  60. /* Shortcut to the active frame information */
  61. int width, height;
  62. uint32_t *chars;
  63. uint32_t *attrs;
  64. uint32_t curattr;
  65. /* FIGfont management */
  66. caca_figfont_t *ff;
  67. };
  68. /* Graphics driver */
  69. enum caca_driver
  70. {
  71. CACA_DRIVER_NULL = 0,
  72. CACA_DRIVER_RAW = 1,
  73. #if defined(USE_COCOA)
  74. CACA_DRIVER_COCOA = 2,
  75. #endif
  76. #if defined(USE_CONIO)
  77. CACA_DRIVER_CONIO = 3,
  78. #endif
  79. #if defined(USE_GL)
  80. CACA_DRIVER_GL = 4,
  81. #endif
  82. #if defined(USE_NCURSES)
  83. CACA_DRIVER_NCURSES = 5,
  84. #endif
  85. #if defined(USE_SLANG)
  86. CACA_DRIVER_SLANG = 6,
  87. #endif
  88. #if defined(USE_VGA)
  89. CACA_DRIVER_VGA = 7,
  90. #endif
  91. #if defined(USE_WIN32)
  92. CACA_DRIVER_WIN32 = 8,
  93. #endif
  94. #if defined(USE_X11)
  95. CACA_DRIVER_X11 = 9,
  96. #endif
  97. };
  98. /* Available external drivers */
  99. #if defined(USE_COCOA)
  100. int cocoa_install(caca_display_t *);
  101. #endif
  102. #if defined(USE_CONIO)
  103. int conio_install(caca_display_t *);
  104. #endif
  105. #if defined(USE_GL)
  106. int gl_install(caca_display_t *);
  107. #endif
  108. #if defined(USE_NCURSES)
  109. int ncurses_install(caca_display_t *);
  110. #endif
  111. int null_install(caca_display_t *);
  112. int raw_install(caca_display_t *);
  113. #if defined(USE_SLANG)
  114. int slang_install(caca_display_t *);
  115. #endif
  116. #if defined(USE_VGA)
  117. int vga_install(caca_display_t *);
  118. #endif
  119. #if defined(USE_WIN32)
  120. int win32_install(caca_display_t *);
  121. #endif
  122. #if defined(USE_X11)
  123. int x11_install(caca_display_t *);
  124. #endif
  125. /* Timer structure */
  126. struct caca_timer
  127. {
  128. int last_sec, last_usec;
  129. };
  130. /* Statistic structure for profiling */
  131. struct caca_stat
  132. {
  133. int itable[STAT_VALUES];
  134. int64_t imean;
  135. char *name;
  136. };
  137. /* Private event structure */
  138. struct caca_privevent
  139. {
  140. enum caca_event_type type;
  141. union
  142. {
  143. struct { int x, y, button; } mouse;
  144. struct { int w, h; } resize;
  145. struct { int ch; uint32_t utf32; char utf8[8]; } key;
  146. } data;
  147. };
  148. /* Internal caca display context */
  149. struct caca_display
  150. {
  151. /* A link to our caca canvas */
  152. caca_canvas_t *cv;
  153. int autorelease;
  154. #if defined(USE_PLUGINS)
  155. void *plugin;
  156. #endif
  157. /* Device-specific functions */
  158. struct drv
  159. {
  160. char const * driver;
  161. enum caca_driver id;
  162. struct driver_private *p;
  163. int (* init_graphics) (caca_display_t *);
  164. int (* end_graphics) (caca_display_t *);
  165. int (* set_display_title) (caca_display_t *, char const *);
  166. int (* get_display_width) (caca_display_t const *);
  167. int (* get_display_height) (caca_display_t const *);
  168. void (* display) (caca_display_t *);
  169. void (* handle_resize) (caca_display_t *);
  170. int (* get_event) (caca_display_t *, caca_privevent_t *);
  171. void (* set_mouse) (caca_display_t *, int);
  172. void (* set_cursor) (caca_display_t *, int);
  173. } drv;
  174. /* Mouse position */
  175. struct mouse
  176. {
  177. int x, y;
  178. } mouse;
  179. /* Window resize handling */
  180. struct resize
  181. {
  182. int resized; /* A resize event was requested */
  183. int allow; /* The display driver allows resizing */
  184. int w, h; /* Requested width and height */
  185. } resize;
  186. /* Framerate handling */
  187. int delay, rendertime;
  188. caca_timer_t timer;
  189. #if defined PROF
  190. struct caca_stat display_stat, wait_stat;
  191. struct caca_stat ev_sys_stat, ev_wait_stat;
  192. #endif
  193. int lastticks;
  194. struct events
  195. {
  196. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  197. caca_privevent_t buf[EVENTBUF_LEN];
  198. int queue;
  199. #endif
  200. #if defined(USE_SLANG) || defined(USE_NCURSES)
  201. caca_timer_t key_timer;
  202. int last_key_ticks;
  203. int autorepeat_ticks;
  204. caca_privevent_t last_key_event;
  205. #endif
  206. #if defined(USE_WIN32)
  207. uint8_t not_empty_struct;
  208. #endif
  209. } events;
  210. };
  211. /* Dirty rectangle functions */
  212. extern void _caca_clip_dirty_rect_list(caca_canvas_t *);
  213. /* Colour functions */
  214. extern uint32_t _caca_attr_to_rgb24fg(uint32_t);
  215. extern uint32_t _caca_attr_to_rgb24bg(uint32_t);
  216. /* Frames functions */
  217. extern void _caca_save_frame_info(caca_canvas_t *);
  218. extern void _caca_load_frame_info(caca_canvas_t *);
  219. /* Internal timer functions */
  220. extern void _caca_sleep(int);
  221. extern int _caca_getticks(caca_timer_t *);
  222. /* Internal event functions */
  223. extern void _caca_handle_resize(caca_display_t *);
  224. #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
  225. extern void _push_event(caca_display_t *, caca_privevent_t *);
  226. extern int _pop_event(caca_display_t *, caca_privevent_t *);
  227. #endif
  228. /* Internal window functions */
  229. extern void _caca_set_term_title(char const *);
  230. /* Profiling functions */
  231. #if defined PROF
  232. extern void _caca_dump_stats(void);
  233. extern void _caca_init_stat(struct caca_stat *, char const *, ...);
  234. extern void _caca_fini_stat(struct caca_stat *);
  235. #endif
  236. #endif /* __CACA_INTERNALS_H__ */