Initial Commit
[packages] / xemacs-packages / oo-browser / tree-x / dbl.h
1 /* ----------------------------------------------------------------------------
2  *     Double buffering code
3  * ----------------------------------------------------------------------------
4  */
5
6 #include <stdio.h>
7 #include <X11/Xlib.h>
8
9 #define DBL_MAX_SURFACES 2
10 #define DBL_MIN_PLANES   2
11 #define DBL_MAX_PLANES   6
12 #define DBL_MAX_COLORS   (1 << (DBL_MAX_PLANES >> 1))
13
14 typedef struct _surface {
15     int          mask;          /* mask to use this surface           */
16     int        offset;          /* offset within colormap             */
17     int    num_colors;          /* number of colors in color array    */
18     XColor   color[1];          /* the actual color array             */
19 } Surface;
20
21 typedef struct _doublebuffer {
22     Display     *display;       /* X display for windows and pixmaps  */
23     Screen      *screen;        /* X screen                           */
24     Window       window;        /* X window for this double buffer    */
25
26     int          width;         /* width of window                    */
27     int          height;        /* height of window                   */
28
29     Pixmap       frame;         /* pixmap for frame buffer            */
30     Pixmap       backing;       /* pixmap for backing store           */
31     Drawable     drawable;      /* copy of window/pixmap we draw in   */
32
33     GC           gc;            /* GC used to draw the drawable       */
34     Visual      *visual;        /* X visual                           */
35     Colormap     colormap;      /* X colormap identifier              */
36     int          depth;         /* depth of screen in planes          */
37     int          num_planes;    /* number of planes used              */
38
39 /* surface information is used to do double buffering                 */
40
41    int       num_surfaces;
42    int       current_surface;
43    Surface  *surface[DBL_MAX_SURFACES];
44
45 /* we need to remember which pixels and planes we allocated           */
46
47    int           mask;
48    unsigned long pixels[DBL_MAX_COLORS];
49    unsigned long planes[DBL_MAX_PLANES];
50
51 /* the pixel values one should use when drawing to the viewports      */
52
53    int       num_colors;
54    int       colors[DBL_MAX_COLORS];
55 } DoubleBuffer;
56
57
58 void            DBLend_frame(DoubleBuffer *db, short init);
59 void            DBLbegin_frame (DoubleBuffer *db);
60 void            DBLdelete_double_buffer(DoubleBuffer *db);
61 unsigned long   DBLinq_background(DoubleBuffer *db);
62
63 DoubleBuffer *
64 DBLcreate_double_buffer (Display *display,
65                          Window   window,
66                          int      backing_store,
67                          XColor  *colors,
68                          int      num_colors);