BRL-CAD
if_null.c
Go to the documentation of this file.
1 /* I F _ N U L L . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1989-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 /** @addtogroup if */
21 /** @{ */
22 /** @file if_null.c
23  *
24  * A Null Frame Buffer.
25  * Useful for benchmarking or debugging.
26  *
27  */
28 /** @} */
29 
30 #include "common.h"
31 
32 #include <stdlib.h>
33 #include <stdio.h>
34 
35 #include "bu/log.h"
36 #include "fb_private.h"
37 #include "fb.h"
38 
39 
40 HIDDEN int
41 null_open(fb *ifp, const char *UNUSED(file), int width, int height)
42 {
43  FB_CK_FB(ifp);
44 
45  if (width > 0)
46  ifp->if_width = width;
47  if (height > 0)
48  ifp->if_height = height;
49 
50  return 0;
51 }
52 
55 {
56  return NULL;
57 }
58 
59 
60 HIDDEN void
62 {
63  return;
64 }
65 
66 HIDDEN int
67 null_open_existing(fb *UNUSED(ifp), int UNUSED(width), int UNUSED(height), struct fb_platform_specific *UNUSED(fb_p))
68 {
69  return 0;
70 }
71 
72 HIDDEN int
74 {
75  return 0;
76 }
77 
78 HIDDEN int
79 null_configure_window(fb *UNUSED(ifp), int UNUSED(width), int UNUSED(height))
80 {
81  return 0;
82 }
83 
84 HIDDEN int
85 null_refresh(fb *UNUSED(ifp), int UNUSED(x), int UNUSED(y), int UNUSED(w), int UNUSED(h))
86 {
87  return 0;
88 }
89 
90 HIDDEN int
92 {
93  FB_CK_FB(ifp);
94 
95  return 0;
96 }
97 
98 
99 HIDDEN int
100 null_clear(fb *ifp, unsigned char *UNUSED(pp))
101 {
102  FB_CK_FB(ifp);
103 
104  return 0;
105 }
106 
107 
109 null_read(fb *ifp, int UNUSED(x), int UNUSED(y), unsigned char *UNUSED(pixelp), size_t count)
110 {
111  FB_CK_FB(ifp);
112 
113  return count;
114 }
115 
116 
118 null_write(fb *ifp, int UNUSED(x), int UNUSED(y), const unsigned char *UNUSED(pixelp), size_t count)
119 {
120  FB_CK_FB(ifp);
121 
122  return count;
123 }
124 
125 
126 HIDDEN int
128 {
129  FB_CK_FB(ifp);
130 
131  return 0;
132 }
133 
134 
135 HIDDEN int
136 null_wmap(fb *ifp, const ColorMap *UNUSED(cmp))
137 {
138  FB_CK_FB(ifp);
139 
140  return 0;
141 }
142 
143 
144 HIDDEN int
145 null_view(fb *ifp, int UNUSED(xcenter), int UNUSED(ycenter), int UNUSED(xzoom), int UNUSED(yzoom))
146 {
147  FB_CK_FB(ifp);
148 
149  /*fb_sim_view(ifp, xcenter, ycenter, xzoom, yzoom);*/
150  return 0;
151 }
152 
153 
154 HIDDEN int
155 null_getview(fb *ifp, int *UNUSED(xcenter), int *UNUSED(ycenter), int *UNUSED(xzoom), int *UNUSED(yzoom))
156 {
157  FB_CK_FB(ifp);
158 
159  /*fb_sim_getview(ifp, xcenter, ycenter, xzoom, yzoom);*/
160  return 0;
161 }
162 
163 
164 HIDDEN int
165 null_setcursor(fb *ifp, const unsigned char *UNUSED(bits), int UNUSED(xbits), int UNUSED(ybits), int UNUSED(xorig), int UNUSED(yorig))
166 {
167  FB_CK_FB(ifp);
168 
169  return 0;
170 }
171 
172 
173 HIDDEN int
174 null_cursor(fb *ifp, int UNUSED(mode), int UNUSED(x), int UNUSED(y))
175 {
176  FB_CK_FB(ifp);
177 
178  /*fb_sim_cursor(ifp, mode, x, y);*/
179  return 0;
180 }
181 
182 
183 HIDDEN int
184 null_getcursor(fb *ifp, int *UNUSED(mode), int *UNUSED(x), int *UNUSED(y))
185 {
186  FB_CK_FB(ifp);
187 
188  /*fb_sim_getcursor(ifp, mode, x, y);*/
189  return 0;
190 }
191 
192 
193 HIDDEN int
194 null_readrect(fb *ifp, int UNUSED(xmin), int UNUSED(ymin), int width, int height, unsigned char *UNUSED(pp))
195 {
196  FB_CK_FB(ifp);
197 
198  return width*height;
199 }
200 
201 
202 HIDDEN int
203 null_writerect(fb *ifp, int UNUSED(xmin), int UNUSED(ymin), int width, int height, const unsigned char *UNUSED(pp))
204 {
205  FB_CK_FB(ifp);
206 
207  return width*height;
208 }
209 
210 
211 HIDDEN int
213 {
214  FB_CK_FB(ifp);
215 
216  return 0;
217 }
218 
219 
220 HIDDEN int
222 {
223  FB_CK_FB(ifp);
224 
225  return 0;
226 }
227 
228 
229 HIDDEN int
231 {
232  FB_CK_FB(ifp);
233 
234  return 0;
235 }
236 
237 
238 HIDDEN int
240 {
241  FB_CK_FB(ifp);
242 
243  fb_log("Description: %s\n", null_interface.if_type);
244  fb_log("Device: %s\n", ifp->if_name);
245  fb_log("Max width/height: %d %d\n",
248  fb_log("Default width/height: %d %d\n",
251  fb_log("Useful for Benchmarking/Debugging\n");
252  return 0;
253 }
254 
255 
256 /* This is the ONLY thing that we normally "export" */
258  0,
260  null_open, /* device_open */
261  null_open_existing, /* existing device_open */
262  null_close_existing,/* existing device_close */
265  null_close, /* device_close */
266  null_clear, /* device_clear */
267  null_read, /* buffer_read */
268  null_write, /* buffer_write */
269  null_rmap, /* colormap_read */
270  null_wmap, /* colormap_write */
271  null_view, /* set view */
272  null_getview, /* get view */
273  null_setcursor, /* define cursor */
274  null_cursor, /* set cursor */
275  null_getcursor, /* get cursor */
276  null_readrect, /* rectangle read */
277  null_writerect, /* rectangle write */
278  null_readrect, /* bw rectangle read */
279  null_writerect, /* bw rectangle write */
281  null_refresh,
282  null_poll, /* handle events */
283  null_flush, /* flush output */
284  null_free, /* free resources */
285  null_help, /* help message */
286  "Null Device", /* device description */
287  32*1024, /* max width */
288  32*1024, /* max height */
289  "/dev/null", /* short device name */
290  512, /* default/current width */
291  512, /* default/current height */
292  -1, /* select fd */
293  -1, /* file descriptor */
294  1, 1, /* zoom */
295  256, 256, /* window center */
296  0, 0, 0, /* cursor */
297  PIXEL_NULL, /* page_base */
298  PIXEL_NULL, /* page_curp */
299  PIXEL_NULL, /* page_endp */
300  -1, /* page_no */
301  0, /* page_dirty */
302  0L, /* page_curpos */
303  0L, /* page_pixels */
304  0, /* debug */
305  0, /* refresh rate */
306  {0}, /* u1 */
307  {0}, /* u2 */
308  {0}, /* u3 */
309  {0}, /* u4 */
310  {0}, /* u5 */
311  {0} /* u6 */
312 };
313 
314 
315 /*
316  * Local Variables:
317  * mode: C
318  * tab-width: 8
319  * indent-tabs-mode: t
320  * c-file-style: "stroustrup"
321  * End:
322  * ex: shiftwidth=4 tabstop=8
323  */
ptrdiff_t ssize_t
Definition: common.h:119
HIDDEN int null_poll(fb *ifp)
Definition: if_null.c:212
void fb_log(const char *fmt,...) _BU_ATTR_PRINTF12
Definition: fb_log.c:42
HIDDEN int null_setcursor(fb *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig)
Definition: if_null.c:165
HIDDEN int null_configure_window(fb *ifp, int width, int height)
Definition: if_null.c:79
HIDDEN int null_help(fb *ifp)
Definition: if_null.c:239
HIDDEN int null_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
Definition: if_null.c:145
HIDDEN int null_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
Definition: if_null.c:155
#define PIXEL_NULL
Definition: fb.h:89
HIDDEN int null_close_existing(fb *ifp)
Definition: if_null.c:73
Header file for the BRL-CAD common definitions.
int if_max_width
max device width
Definition: fb_private.h:111
ustring width
#define HIDDEN
Definition: common.h:86
char * if_type
what "open" calls it
Definition: fb_private.h:110
HIDDEN struct fb_platform_specific * null_get_fbps(uint32_t magic)
Definition: if_null.c:54
fb null_interface
Definition: if_null.c:257
HIDDEN int null_readrect(fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
Definition: if_null.c:194
#define FB_CK_FB(_p)
Definition: fb.h:100
HIDDEN int null_open_existing(fb *ifp, int width, int height, struct fb_platform_specific *fb_p)
Definition: if_null.c:67
HIDDEN int null_clear(fb *ifp, unsigned char *pp)
Definition: if_null.c:100
HIDDEN int null_rmap(fb *ifp, ColorMap *cmp)
Definition: if_null.c:127
int if_max_height
max device height
Definition: fb_private.h:112
HIDDEN int null_writerect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
Definition: if_null.c:203
oldeumate l2 magic
Definition: nmg_mod.c:3843
#define UNUSED(parameter)
Definition: common.h:239
HIDDEN int null_wmap(fb *ifp, const ColorMap *cmp)
Definition: if_null.c:136
HIDDEN int null_cursor(fb *ifp, int mode, int x, int y)
Definition: if_null.c:174
HIDDEN int null_getcursor(fb *ifp, int *mode, int *x, int *y)
Definition: if_null.c:184
HIDDEN void null_put_fbps(struct fb_platform_specific *fbps)
Definition: if_null.c:61
Definition: fb.h:82
HIDDEN ssize_t null_write(fb *ifp, int x, int y, const unsigned char *pixelp, size_t count)
Definition: if_null.c:118
HIDDEN int null_open(fb *ifp, const char *file, int width, int height)
Definition: if_null.c:41
#define FB_NULL_MAGIC
Definition: magic.h:191
HIDDEN int null_flush(fb *ifp)
Definition: if_null.c:221
HIDDEN int null_free(fb *ifp)
Definition: if_null.c:230
HIDDEN int null_refresh(fb *ifp, int x, int y, int w, int h)
Definition: if_null.c:85
A frame-buffer IO structure.
Definition: fb_private.h:80
int if_width
current values
Definition: fb_private.h:115
HIDDEN ssize_t null_read(fb *ifp, int x, int y, unsigned char *pixelp, size_t count)
Definition: if_null.c:109
char * if_name
what the user called it
Definition: fb_private.h:114
HIDDEN int null_close(fb *ifp)
Definition: if_null.c:91