source: libcaca/trunk/caca/caca_internals.h @ 3993

Last change on this file since 3993 was 3905, checked in by Sam Hocevar, 11 years ago

Start working on profiling.

  • Property svn:keywords set to Id
File size: 5.8 KB
RevLine 
[159]1/*
[672]2 *  libcaca       Colour ASCII-Art library
[3570]3 *  Copyright (c) 2002-2006 Sam Hocevar <sam@hocevar.net>
[268]4 *                All Rights Reserved
[159]5 *
[769]6 *  $Id: caca_internals.h 3905 2009-11-16 01:15:25Z sam $
7 *
[1462]8 *  This library is free software. It comes without any warranty, to
[1452]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
[522]12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
[159]13 */
14
[193]15#ifndef __CACA_INTERNALS_H__
16#define __CACA_INTERNALS_H__
[159]17
[2896]18#include "caca_stubs.h"
[3904]19#include "caca_debug.h"
[3905]20#include "caca_prof.h"
[540]21
[777]22typedef struct caca_timer caca_timer_t;
[2049]23typedef struct caca_privevent caca_privevent_t;
[2821]24typedef struct caca_figfont caca_figfont_t;
[777]25
[541]26#if !defined(_DOXYGEN_SKIP_ME)
27#   define EVENTBUF_LEN 10
[3580]28#   define MAX_DIRTY_COUNT 8
[541]29#endif
30
[2821]31struct caca_frame
32{
33    /* Frame size */
34    int width, height;
35
36    /* Cell information */
37    uint32_t *chars;
38    uint32_t *attrs;
39
40    /* Painting context */
41    int x, y;
42    int handlex, handley;
43    uint32_t curattr;
44
45    /* Frame name */
46    char *name;
47};
48
49struct caca_canvas
50{
51    /* XXX: look at caca_set_canvas_boundaries() before adding anything
52     * to this structure. The function is quite hacky. */
53
54    /* Frame information */
55    int frame, framecount;
56    struct caca_frame *frames;
57
58    /* Canvas management */
59    int refcount;
60    int autoinc;
61    int (*resize_callback)(void *);
62    void *resize_data;
63
[3471]64    /* Dirty rectangles */
[3583]65    int ndirty, dirty_disabled;
[3568]66    struct
67    {
[3580]68        int xmin, ymin, xmax, ymax;
[3568]69    }
[3580]70    dirty[MAX_DIRTY_COUNT + 1];
[3448]71
[2821]72    /* Shortcut to the active frame information */
73    int width, height;
74    uint32_t *chars;
75    uint32_t *attrs;
76    uint32_t curattr;
77
78    /* FIGfont management */
79    caca_figfont_t *ff;
80};
81
[265]82/* Graphics driver */
83enum caca_driver
84{
[3570]85    CACA_DRIVER_NULL = 0,
[699]86    CACA_DRIVER_RAW = 1,
[1396]87#if defined(USE_COCOA)
88    CACA_DRIVER_COCOA = 2,
89#endif
[265]90#if defined(USE_CONIO)
[1396]91    CACA_DRIVER_CONIO = 3,
[265]92#endif
[699]93#if defined(USE_GL)
[1396]94    CACA_DRIVER_GL = 4,
[699]95#endif
[265]96#if defined(USE_NCURSES)
[1396]97    CACA_DRIVER_NCURSES = 5,
[265]98#endif
99#if defined(USE_SLANG)
[1396]100    CACA_DRIVER_SLANG = 6,
[265]101#endif
[699]102#if defined(USE_VGA)
[1396]103    CACA_DRIVER_VGA = 7,
[265]104#endif
[335]105#if defined(USE_WIN32)
[1396]106    CACA_DRIVER_WIN32 = 8,
[335]107#endif
[699]108#if defined(USE_X11)
[1396]109    CACA_DRIVER_X11 = 9,
[483]110#endif
[265]111};
112
[699]113/* Available external drivers */
[1396]114#if defined(USE_COCOA)
115int cocoa_install(caca_display_t *);
116#endif
[539]117#if defined(USE_CONIO)
[811]118int conio_install(caca_display_t *);
[539]119#endif
120#if defined(USE_GL)
[811]121int gl_install(caca_display_t *);
[539]122#endif
123#if defined(USE_NCURSES)
[811]124int ncurses_install(caca_display_t *);
[539]125#endif
[3570]126int null_install(caca_display_t *);
[811]127int raw_install(caca_display_t *);
[539]128#if defined(USE_SLANG)
[811]129int slang_install(caca_display_t *);
[539]130#endif
[699]131#if defined(USE_VGA)
[811]132int vga_install(caca_display_t *);
[699]133#endif
[539]134#if defined(USE_WIN32)
[811]135int win32_install(caca_display_t *);
[539]136#endif
137#if defined(USE_X11)
[811]138int x11_install(caca_display_t *);
[539]139#endif
[684]140
[331]141/* Timer structure */
142struct caca_timer
143{
144    int last_sec, last_usec;
145};
146
[2049]147/* Private event structure */
148struct caca_privevent
149{
150    enum caca_event_type type;
151
152    union
153    {
[2305]154        struct { int x, y, button; } mouse;
155        struct { int w, h; } resize;
156        struct { int ch; uint32_t utf32; char utf8[8]; } key;
[2049]157    } data;
158};
159
[811]160/* Internal caca display context */
161struct caca_display
[524]162{
[2821]163    /* A link to our caca canvas */
164    caca_canvas_t *cv;
[2061]165    int autorelease;
[265]166
[1208]167#if defined(USE_PLUGINS)
168    void *plugin;
169#endif
170
[551]171    /* Device-specific functions */
[550]172    struct drv
[539]173    {
[2138]174        char const * driver;
175        enum caca_driver id;
[550]176        struct driver_private *p;
[539]177
[811]178        int (* init_graphics) (caca_display_t *);
179        int (* end_graphics) (caca_display_t *);
[819]180        int (* set_display_title) (caca_display_t *, char const *);
[2305]181        int (* get_display_width) (caca_display_t const *);
182        int (* get_display_height) (caca_display_t const *);
[811]183        void (* display) (caca_display_t *);
184        void (* handle_resize) (caca_display_t *);
[2049]185        int (* get_event) (caca_display_t *, caca_privevent_t *);
[811]186        void (* set_mouse) (caca_display_t *, int);
[1430]187        void (* set_cursor) (caca_display_t *, int);
[550]188    } drv;
[539]189
[551]190    /* Mouse position */
191    struct mouse
192    {
[2305]193        int x, y;
[551]194    } mouse;
[524]195
[551]196    /* Window resize handling */
[553]197    struct resize
198    {
199        int resized;   /* A resize event was requested */
[2055]200        int allow;     /* The display driver allows resizing */
[2305]201        int w, h; /* Requested width and height */
[553]202    } resize;
[524]203
[551]204    /* Framerate handling */
[2305]205    int delay, rendertime;
[777]206    caca_timer_t timer;
[527]207    int lastticks;
[524]208
[527]209    struct events
210    {
[681]211#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
[2049]212        caca_privevent_t buf[EVENTBUF_LEN];
[541]213        int queue;
214#endif
[527]215#if defined(USE_SLANG) || defined(USE_NCURSES)
[777]216        caca_timer_t key_timer;
[2305]217        int last_key_ticks;
218        int autorepeat_ticks;
[2049]219        caca_privevent_t last_key_event;
[527]220#endif
[775]221#if defined(USE_WIN32)
[2305]222        uint8_t not_empty_struct;
[775]223#endif
[527]224    } events;
[524]225};
226
[3568]227/* Dirty rectangle functions */
228extern void _caca_clip_dirty_rect_list(caca_canvas_t *);
229
[2821]230/* Colour functions */
231extern uint32_t _caca_attr_to_rgb24fg(uint32_t);
232extern uint32_t _caca_attr_to_rgb24bg(uint32_t);
233
234/* Frames functions */
235extern void _caca_save_frame_info(caca_canvas_t *);
236extern void _caca_load_frame_info(caca_canvas_t *);
237
[645]238/* Internal timer functions */
[2305]239extern void _caca_sleep(int);
240extern int _caca_getticks(caca_timer_t *);
[331]241
[645]242/* Internal event functions */
[811]243extern void _caca_handle_resize(caca_display_t *);
[681]244#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
[2049]245extern void _push_event(caca_display_t *, caca_privevent_t *);
246extern int _pop_event(caca_display_t *, caca_privevent_t *);
[645]247#endif
248
[1392]249/* Internal window functions */
250extern void _caca_set_term_title(char const *);
251
[193]252#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.