BRL-CAD
fb_private.h
Go to the documentation of this file.
1 /* F B _ P R I V A T E . H
2  * BRL-CAD
3  *
4  * Copyright (c) 2008-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @file fb_private.h
21  *
22  * Private header for libfb.
23  *
24  */
25 
26 #ifndef LIBFB_FB_PRIVATE_H
27 #define LIBFB_FB_PRIVATE_H
28 
29 #include "common.h"
30 
31 #include <limits.h> /* For INT_MAX */
32 #include <stdlib.h>
33 
34 #include "fb.h"
35 
36 /* declare all the possible interfaces */
37 #ifdef IF_X
38 FB_EXPORT extern fb X24_interface;
39 #endif
40 #ifdef IF_OGL
41 FB_EXPORT extern fb ogl_interface;
42 #endif
43 #ifdef IF_OSGL
44 FB_EXPORT extern fb osgl_interface;
45 #endif
46 #ifdef IF_WGL
47 FB_EXPORT extern fb wgl_interface;
48 #endif
49 #ifdef IF_TK
50 FB_EXPORT extern fb tk_interface;
51 #endif
52 #ifdef IF_QT
53 FB_EXPORT extern fb qt_interface;
54 #endif
55 #ifdef IF_REMOTE
56 FB_EXPORT extern fb remote_interface; /* not in list[] */
57 #endif
58 
59 /* Always included */
61 FB_EXPORT extern fb memory_interface, null_interface;
62 
63 
64 /* Shared memory (shmget et. al.) key common to multiple framebuffers */
65 #define SHMEM_KEY 42
66 
67 
69 
70 /**
71  *@brief
72  * A frame-buffer IO structure.
73  *
74  * One of these is allocated for each active framebuffer. A pointer
75  * to this structure is the first argument to all the library
76  * routines. The details of the structure are hidden behind function
77  * calls in the fb.h API - no code external to libfb should work
78  * directly with structure members.
79  */
80 struct fb_internal {
81  uint32_t if_magic;
82  uint32_t type_magic;
83  /* Static information: per device TYPE. */
84  int (*if_open)(struct fb_internal *ifp, const char *file, int _width, int _height); /**< @brief open device */
85  int (*if_open_existing)(struct fb_internal *ifp, int width, int height, struct fb_platform_specific *fb_p); /**< @brief open device */
86  int (*if_close_existing)(struct fb_internal *ifp); /**< @brief close embedded fb */
87  struct fb_platform_specific *(*if_existing_get)(uint32_t magic); /**< @brief allocate memory for platform specific container*/
88  void (*if_existing_put)(struct fb_platform_specific *fb_p); /**< @brief free memory for platform specific container */
89  int (*if_close)(struct fb_internal *ifp); /**< @brief close device */
90  int (*if_clear)(struct fb_internal *ifp, unsigned char *pp); /**< @brief clear device */
91  ssize_t (*if_read)(struct fb_internal *ifp, int x, int y, unsigned char *pp, size_t count); /**< @brief read pixels */
92  ssize_t (*if_write)(struct fb_internal *ifp, int x, int y, const unsigned char *pp, size_t count); /**< @brief write pixels */
93  int (*if_rmap)(struct fb_internal *ifp, ColorMap *cmap); /**< @brief read colormap */
94  int (*if_wmap)(struct fb_internal *ifp, const ColorMap *cmap); /**< @brief write colormap */
95  int (*if_view)(struct fb_internal *ifp, int xcent, int ycent, int xzoom, int yzoom); /**< @brief set view */
96  int (*if_getview)(struct fb_internal *ifp, int *xcent, int *ycent, int *xzoom, int *yzoom); /**< @brief get view */
97  int (*if_setcursor)(struct fb_internal *ifp, const unsigned char *bits, int xb, int yb, int xo, int yo); /**< @brief define cursor */
98  int (*if_cursor)(struct fb_internal *ifp, int mode, int x, int y); /**< @brief set cursor */
99  int (*if_getcursor)(struct fb_internal *ifp, int *mode, int *x, int *y); /**< @brief get cursor */
100  int (*if_readrect)(struct fb_internal *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp); /**< @brief read rectangle */
101  int (*if_writerect)(struct fb_internal *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp); /**< @brief write rectangle */
102  int (*if_bwreadrect)(struct fb_internal *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp); /**< @brief read monochrome rectangle */
103  int (*if_bwwriterect)(struct fb_internal *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp); /**< @brief write rectangle */
104  int (*if_configure_window)(struct fb_internal *ifp, int width, int height); /**< @brief configure window */
105  int (*if_refresh)(struct fb_internal *ifp, int x, int y, int w, int h); /**< @brief refresh window */
106  int (*if_poll)(struct fb_internal *ifp); /**< @brief handle events */
107  int (*if_flush)(struct fb_internal *ifp); /**< @brief flush output */
108  int (*if_free)(struct fb_internal *ifp); /**< @brief free resources */
109  int (*if_help)(struct fb_internal *ifp); /**< @brief print useful info */
110  char *if_type; /**< @brief what "open" calls it */
111  int if_max_width; /**< @brief max device width */
112  int if_max_height; /**< @brief max device height */
113  /* Dynamic information: per device INSTANCE. */
114  char *if_name; /**< @brief what the user called it */
115  int if_width; /**< @brief current values */
117  int if_selfd; /**< @brief select(fd) for input events if >= 0 */
118  /* Internal information: needed by the library. */
119  int if_fd; /**< @brief internal file descriptor */
120  int if_xzoom; /**< @brief zoom factors */
121  int if_yzoom;
122  int if_xcenter; /**< @brief pan position */
124  int if_cursmode; /**< @brief cursor on/off */
125  int if_xcurs; /**< @brief cursor position */
126  int if_ycurs;
127  unsigned char *if_pbase;/**< @brief Address of malloc()ed page buffer. */
128  unsigned char *if_pcurp;/**< @brief Current pointer into page buffer. */
129  unsigned char *if_pendp;/**< @brief End of page buffer. */
130  int if_pno; /**< @brief Current "page" in memory. */
131  int if_pdirty; /**< @brief Page modified flag. */
132  long if_pixcur; /**< @brief Current pixel number in framebuffer. */
133  long if_ppixels; /**< @brief Sizeof page buffer (pixels). */
134  int if_debug; /**< @brief Buffered IO debug flag. */
135  long if_poll_refresh_rate; /**< @brief Recommended polling rate for interactive framebuffers in microseconds. */
136  /* State variables for individual interface modules */
137  union {
138  char *p;
139  size_t l;
140  } u1, u2, u3, u4, u5, u6;
141 };
142 
143 /*
144  * Some functions and variables we couldn't hide.
145  * Not for general consumption.
146  */
147 FB_EXPORT extern int _fb_disk_enable;
148 FB_EXPORT extern int fb_sim_readrect(fb *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp);
149 FB_EXPORT extern int fb_sim_writerect(fb *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp);
150 FB_EXPORT extern int fb_sim_bwreadrect(fb *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp);
151 FB_EXPORT extern int fb_sim_bwwriterect(fb *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp);
152 FB_EXPORT extern int fb_sim_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom);
153 FB_EXPORT extern int fb_sim_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom);
154 FB_EXPORT extern int fb_sim_cursor(fb *ifp, int mode, int x, int y);
155 FB_EXPORT extern int fb_sim_getcursor(fb *ifp, int *mode, int *x, int *y);
156 
158 
159 #endif /* LIBFB_FB_PRIVATE_H */
160 
161 /** @} */
162 /*
163  * Local Variables:
164  * mode: C
165  * tab-width: 8
166  * indent-tabs-mode: t
167  * c-file-style: "stroustrup"
168  * End:
169  * ex: shiftwidth=4 tabstop=8
170  */
long if_poll_refresh_rate
Recommended polling rate for interactive framebuffers in microseconds.
Definition: fb_private.h:135
ptrdiff_t ssize_t
Definition: common.h:119
union fb_internal::@15 u1
int(* if_readrect)(struct fb_internal *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp)
read rectangle
Definition: fb_private.h:100
int(* if_close_existing)(struct fb_internal *ifp)
close embedded fb
Definition: fb_private.h:86
union fb_internal::@15 u3
void(* if_existing_put)(struct fb_platform_specific *fb_p)
free memory for platform specific container
Definition: fb_private.h:88
int(* if_open_existing)(struct fb_internal *ifp, int width, int height, struct fb_platform_specific *fb_p)
open device
Definition: fb_private.h:85
int if_fd
internal file descriptor
Definition: fb_private.h:119
int(* if_view)(struct fb_internal *ifp, int xcent, int ycent, int xzoom, int yzoom)
set view
Definition: fb_private.h:95
int(* if_bwwriterect)(struct fb_internal *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp)
write rectangle
Definition: fb_private.h:103
int(* if_open)(struct fb_internal *ifp, const char *file, int _width, int _height)
open device
Definition: fb_private.h:84
int(* if_help)(struct fb_internal *ifp)
print useful info
Definition: fb_private.h:109
uint32_t if_magic
Definition: fb_private.h:81
int(* if_setcursor)(struct fb_internal *ifp, const unsigned char *bits, int xb, int yb, int xo, int yo)
define cursor
Definition: fb_private.h:97
int if_xzoom
zoom factors
Definition: fb_private.h:120
Header file for the BRL-CAD common definitions.
int fb_sim_bwreadrect(fb *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp)
Definition: fb_rect.c:102
int(* if_getview)(struct fb_internal *ifp, int *xcent, int *ycent, int *xzoom, int *yzoom)
get view
Definition: fb_private.h:96
int if_max_width
max device width
Definition: fb_private.h:111
ustring width
char * if_type
what "open" calls it
Definition: fb_private.h:110
int if_ycenter
Definition: fb_private.h:123
union fb_internal::@15 u2
long if_ppixels
Sizeof page buffer (pixels).
Definition: fb_private.h:133
int fb_sim_writerect(fb *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp)
Definition: fb_rect.c:78
int(* if_getcursor)(struct fb_internal *ifp, int *mode, int *x, int *y)
get cursor
Definition: fb_private.h:99
ssize_t(* if_read)(struct fb_internal *ifp, int x, int y, unsigned char *pp, size_t count)
read pixels
Definition: fb_private.h:91
int if_selfd
select(fd) for input events if >= 0
Definition: fb_private.h:117
int(* if_rmap)(struct fb_internal *ifp, ColorMap *cmap)
read colormap
Definition: fb_private.h:93
fb stk_interface
Definition: if_stack.c:435
int fb_sim_getcursor(fb *ifp, int *mode, int *x, int *y)
Definition: fb_util.c:96
int(* if_flush)(struct fb_internal *ifp)
flush output
Definition: fb_private.h:107
fb memory_interface
Definition: if_mem.c:471
#define __BEGIN_DECLS
Definition: common.h:73
unsigned char * if_pendp
End of page buffer.
Definition: fb_private.h:129
int(* if_configure_window)(struct fb_internal *ifp, int width, int height)
configure window
Definition: fb_private.h:104
fb null_interface
Definition: if_null.c:257
int if_max_height
max device height
Definition: fb_private.h:112
int fb_sim_bwwriterect(fb *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp)
Definition: fb_rect.c:132
oldeumate l2 magic
Definition: nmg_mod.c:3843
int(* if_bwreadrect)(struct fb_internal *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp)
read monochrome rectangle
Definition: fb_private.h:102
int fb_sim_cursor(fb *ifp, int mode, int x, int y)
Definition: fb_util.c:79
union fb_internal::@15 u6
int(* if_free)(struct fb_internal *ifp)
free resources
Definition: fb_private.h:108
size_t l
Definition: fb_private.h:139
int(* if_close)(struct fb_internal *ifp)
close device
Definition: fb_private.h:89
Definition: fb.h:82
int(* if_cursor)(struct fb_internal *ifp, int mode, int x, int y)
set cursor
Definition: fb_private.h:98
int if_cursmode
cursor on/off
Definition: fb_private.h:124
uint32_t type_magic
Definition: fb_private.h:82
int fb_sim_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
Definition: fb_util.c:61
int(* if_refresh)(struct fb_internal *ifp, int x, int y, int w, int h)
refresh window
Definition: fb_private.h:105
int _fb_disk_enable
Definition: fb_generic.c:353
unsigned char * if_pcurp
Current pointer into page buffer.
Definition: fb_private.h:128
int(* if_wmap)(struct fb_internal *ifp, const ColorMap *cmap)
write colormap
Definition: fb_private.h:94
int(* if_writerect)(struct fb_internal *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp)
write rectangle
Definition: fb_private.h:101
fb remote_interface
Definition: if_remote.c:788
int fb_sim_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
Definition: fb_util.c:43
char * p
Definition: fb_private.h:138
long if_pixcur
Current pixel number in framebuffer.
Definition: fb_private.h:132
int(* if_poll)(struct fb_internal *ifp)
handle events
Definition: fb_private.h:106
#define __END_DECLS
Definition: common.h:74
int if_xcurs
cursor position
Definition: fb_private.h:125
union fb_internal::@15 u4
int if_pno
Current "page" in memory.
Definition: fb_private.h:130
ssize_t(* if_write)(struct fb_internal *ifp, int x, int y, const unsigned char *pp, size_t count)
write pixels
Definition: fb_private.h:92
A frame-buffer IO structure.
Definition: fb_private.h:80
fb qt_interface
Definition: if_qt.cpp:1347
int if_width
current values
Definition: fb_private.h:115
fb disk_interface
Definition: if_disk.c:356
union fb_internal::@15 u5
int if_pdirty
Page modified flag.
Definition: fb_private.h:131
int(* if_clear)(struct fb_internal *ifp, unsigned char *pp)
clear device
Definition: fb_private.h:90
int fb_sim_readrect(fb *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp)
Definition: fb_rect.c:45
char * if_name
what the user called it
Definition: fb_private.h:114
fb debug_interface
Definition: if_debug.c:362
int if_debug
Buffered IO debug flag.
Definition: fb_private.h:134
unsigned char * if_pbase
Address of malloc()ed page buffer.
Definition: fb_private.h:127
int if_xcenter
pan position
Definition: fb_private.h:122