Revision: 38775
http://brlcad.svn.sourceforge.net/brlcad/?rev=38775&view=rev
Author: brlcad
Date: 2010-04-23 20:16:44 +0000 (Fri, 23 Apr 2010)
Log Message:
-----------
ws, style, indent, comment, consistency update
Modified Paths:
--------------
brlcad/trunk/src/libfb/asize.c
brlcad/trunk/src/libfb/dmdfb.h
brlcad/trunk/src/libfb/fb_generic.c
brlcad/trunk/src/libfb/fb_log.c
brlcad/trunk/src/libfb/fb_obj.c
brlcad/trunk/src/libfb/fb_paged_io.c
brlcad/trunk/src/libfb/fb_rect.c
brlcad/trunk/src/libfb/fb_util.c
brlcad/trunk/src/libfb/if_TEMPLATE.c
brlcad/trunk/src/libfb/if_X.c
brlcad/trunk/src/libfb/if_X24.c
brlcad/trunk/src/libfb/if_debug.c
brlcad/trunk/src/libfb/if_disk.c
brlcad/trunk/src/libfb/if_mem.c
brlcad/trunk/src/libfb/if_null.c
brlcad/trunk/src/libfb/if_ogl.c
brlcad/trunk/src/libfb/if_remote.c
brlcad/trunk/src/libfb/if_stack.c
brlcad/trunk/src/libfb/if_tk.c
brlcad/trunk/src/libfb/if_wgl.c
brlcad/trunk/src/libfb/tcl.c
brlcad/trunk/src/libfb/vers.c
Modified: brlcad/trunk/src/libfb/asize.c
===================================================================
--- brlcad/trunk/src/libfb/asize.c 2010-04-23 19:51:16 UTC (rev 38774)
+++ brlcad/trunk/src/libfb/asize.c 2010-04-23 20:16:44 UTC (rev 38775)
@@ -72,6 +72,7 @@
{ 0, 0 }
};
+
/*
* F B _ C O M M O N _ F I L E _ S I Z E
*
@@ -87,10 +88,10 @@
*/
int
fb_common_file_size(unsigned long int *widthp, unsigned long int *heightp, const char *filename, int pixel_size)
- /* pointer to returned width */
- /* pointer to returned height */
- /* image file to stat */
- /* bytes per pixel */
+/* pointer to returned width */
+/* pointer to returned height */
+/* image file to stat */
+/* bytes per pixel */
{
struct stat sbuf;
unsigned long int size;
@@ -102,27 +103,27 @@
return 0;
}
- if ( filename == NULL || *filename == '\0' ) {
+ if (filename == NULL || *filename == '\0') {
return 0;
}
/* Skip over directory names, if any */
- cp = strchr( filename, '/' );
- if ( cp ) {
+ cp = strchr(filename, '/');
+ if (cp) {
cp++; /* skip over slash */
} else {
cp = filename; /* no slash */
}
- if ( fb_common_name_size( widthp, heightp, cp ) )
+ if (fb_common_name_size(widthp, heightp, cp))
return 1;
- if ( stat( filename, &sbuf ) < 0 )
+ if (stat(filename, &sbuf) < 0)
return 0;
size = (unsigned long int)(sbuf.st_size / pixel_size);
- return fb_common_image_size( widthp, heightp, size );
+ return fb_common_image_size(widthp, heightp, size);
}
@@ -139,17 +140,17 @@
int
fb_common_name_size(unsigned long int *widthp, unsigned long int *heightp, const char *name)
- /* pointer to returned width */
- /* pointer to returned height */
- /* name to parse */
+/* pointer to returned width */
+/* pointer to returned height */
+/* name to parse */
{
register const char *cp = name;
/* File name may have several minus signs in it. Try repeatedly */
- while ( *cp ) {
- cp = strchr( cp, '-' ); /* Find a minus sign */
- if ( cp == NULL ) break;
- if ( sscanf(cp, "-w%lu-n%lu", widthp, heightp ) == 2 )
+ while (*cp) {
+ cp = strchr(cp, '-'); /* Find a minus sign */
+ if (cp == NULL) break;
+ if (sscanf(cp, "-w%lu-n%lu", widthp, heightp) == 2)
return 1;
cp++; /* skip over the minus */
}
@@ -172,19 +173,19 @@
*/
int
fb_common_image_size(unsigned long int *widthp, unsigned long int *heightp, unsigned long int npixels)
- /* pointer to returned width */
- /* pointer to returned height */
- /* Number of pixels */
+/* pointer to returned width */
+/* pointer to returned height */
+/* Number of pixels */
{
struct sizes *sp;
unsigned long int root;
- if ( npixels <= 0 )
+ if (npixels <= 0)
return 0;
sp = fb_common_sizes;
- while ( sp->width != 0 ) {
- if ( npixels == sp->width * sp->height ) {
+ while (sp->width != 0) {
+ if (npixels == sp->width * sp->height) {
*widthp = sp->width;
*heightp = sp->height;
return 1;
@@ -194,7 +195,7 @@
/* If the size is a perfect square, then use that. */
root = (long int)(sqrt((double)npixels)+0.999);
- if ( root*root == npixels ) {
+ if (root*root == npixels) {
*widthp = root;
*heightp = root;
return 1;
@@ -204,6 +205,7 @@
return 0;
}
+
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/libfb/dmdfb.h
===================================================================
--- brlcad/trunk/src/libfb/dmdfb.h 2010-04-23 19:51:16 UTC (rev 38774)
+++ brlcad/trunk/src/libfb/dmdfb.h 2010-04-23 20:16:44 UTC (rev 38775)
@@ -26,9 +26,9 @@
#define BLACK 0
#define WHITE 1
-#define CLR_BIT( word, bit ) word &= ~(bit)
-#define SET_BIT( word, bit ) word |= (bit)
-#define TST_BIT( word, bit ) ((word)&(bit))
+#define CLR_BIT(word, bit) word &= ~(bit)
+#define SET_BIT(word, bit) word |= (bit)
+#define TST_BIT(word, bit) ((word)&(bit))
#define PT_ANIMATE 'a'
#define PT_CLEAR 'e'
Modified: brlcad/trunk/src/libfb/fb_generic.c
===================================================================
--- brlcad/trunk/src/libfb/fb_generic.c 2010-04-23 19:51:16 UTC (rev 38774)
+++ brlcad/trunk/src/libfb/fb_generic.c 2010-04-23 20:16:44 UTC (rev 38775)
@@ -43,9 +43,9 @@
extern int wgl_close_existing(FBIO *ifp);
-#define Malloc_Bomb(_bytes_ ) \
- fb_log("\"%s\"(%d) : allocation of %d bytes failed.\n", \
- __FILE__, __LINE__, _bytes_ )
+#define Malloc_Bomb(_bytes_) \
+ fb_log("\"%s\"(%d) : allocation of %d bytes failed.\n", \
+ __FILE__, __LINE__, _bytes_)
static int fb_totally_numeric(register char *s);
@@ -109,7 +109,7 @@
&debug_interface,
/* never get any of the following by default */
- &stk_interface,
+ &stk_interface,
&memory_interface,
&null_interface,
(FBIO *) 0
@@ -125,17 +125,17 @@
register FBIO *ifp;
int i;
- if (width < 0 || height < 0 )
+ if (width < 0 || height < 0)
return FBIO_NULL;
ifp = (FBIO *) calloc(sizeof(FBIO), 1);
if (ifp == FBIO_NULL) {
- Malloc_Bomb(sizeof(FBIO) );
+ Malloc_Bomb(sizeof(FBIO));
return FBIO_NULL;
}
- if (file == NULL || *file == '\0' ) {
+ if (file == NULL || *file == '\0') {
/* No name given, check environment variable first. */
- if ((file = (char *)getenv("FB_FILE" )) == NULL || *file == '\0' ) {
+ if ((file = (char *)getenv("FB_FILE")) == NULL || *file == '\0') {
/* None set, use first device as default */
*ifp = *(_if_list[0]); /* struct copy */
file = ifp->if_name;
@@ -148,14 +148,14 @@
* "file" can in general look like: hostname:/pathname/devname#
*
* If we have a ':' assume the remote interface
- * (We don't check to see if it's us. Good for debugging.)
+ * (We don't check to see if it's us. Good for debugging.)
* else strip out "/path/devname" and try to look it up in the
* device array. If we don't find it assume it's a file.
*/
i = 0;
- while (_if_list[i] != (FBIO *)NULL ) {
+ while (_if_list[i] != (FBIO *)NULL) {
if (strncmp(file, _if_list[i]->if_name,
- strlen(_if_list[i]->if_name) ) == 0 ) {
+ strlen(_if_list[i]->if_name)) == 0) {
/* found it, copy its struct in */
*ifp = *(_if_list[i]);
goto found_interface;
@@ -165,14 +165,14 @@
/* Not in list, check special interfaces or disk files */
/* "/dev/" protection! */
- if (strncmp(file, "/dev/", 5) == 0 ) {
- fb_log("fb_open: no such device \"%s\".\n", file );
- free((void *) ifp );
+ if (strncmp(file, "/dev/", 5) == 0) {
+ fb_log("fb_open: no such device \"%s\".\n", file);
+ free((void *) ifp);
return FBIO_NULL;
}
#ifdef IF_REMOTE
- if (fb_totally_numeric(file) || strchr(file, ':' ) != NULL ) {
+ if (fb_totally_numeric(file) || strchr(file, ':') != NULL) {
/* We have a remote file name of the form <host>:<file>
* or a port number (which assumes localhost) */
*ifp = remote_interface;
@@ -180,54 +180,55 @@
}
#endif /* IF_REMOTE */
/* Assume it's a disk file */
- if (_fb_disk_enable ) {
+ if (_fb_disk_enable) {
*ifp = disk_interface;
} else {
- fb_log("fb_open: no such device \"%s\".\n", file );
- free((void *) ifp );
+ fb_log("fb_open: no such device \"%s\".\n", file);
+ free((void *) ifp);
return FBIO_NULL;
}
- found_interface:
+found_interface:
/* Copy over the name it was opened by. */
- ifp->if_name = (char*)malloc((unsigned) strlen(file ) + 1 );
+ ifp->if_name = (char*)malloc((unsigned) strlen(file) + 1);
if (ifp->if_name == (char *)NULL) {
- Malloc_Bomb(strlen(file ) + 1 );
- free((void *) ifp );
+ Malloc_Bomb(strlen(file) + 1);
+ free((void *) ifp);
return FBIO_NULL;
}
- bu_strlcpy(ifp->if_name, file, strlen(file)+1 );
+ bu_strlcpy(ifp->if_name, file, strlen(file)+1);
/* Mark OK by filling in magic number */
ifp->if_magic = FB_MAGIC;
- if ((i=(*ifp->if_open)(ifp, file, width, height )) <= -1 ) {
+ if ((i=(*ifp->if_open)(ifp, file, width, height)) <= -1) {
fb_log("fb_open: can't open device \"%s\", ret=%d.\n",
- file, i );
+ file, i);
ifp->if_magic = 0; /* sanity */
- free((void *) ifp->if_name );
- free((void *) ifp );
+ free((void *) ifp->if_name);
+ free((void *) ifp);
return FBIO_NULL;
}
return ifp;
}
+
int
fb_close(FBIO *ifp)
{
int i;
FB_CK_FBIO(ifp);
- fb_flush(ifp );
- if ((i=(*ifp->if_close)(ifp )) <= -1 ) {
+ fb_flush(ifp);
+ if ((i=(*ifp->if_close)(ifp)) <= -1) {
fb_log("fb_close: can not close device \"%s\", ret=%d.\n",
- ifp->if_name, i );
- return -1;
+ ifp->if_name, i);
+ return -1;
}
- if (ifp->if_pbase != PIXEL_NULL )
- free((void *) ifp->if_pbase );
- free((void *) ifp->if_name );
- free((void *) ifp );
+ if (ifp->if_pbase != PIXEL_NULL)
+ free((void *) ifp->if_pbase);
+ free((void *) ifp->if_name);
+ free((void *) ifp);
return 0;
}
@@ -347,10 +348,10 @@
int i;
i = 0;
- while (_if_list[i] != (FBIO *)NULL ) {
+ while (_if_list[i] != (FBIO *)NULL) {
fb_log("%-12s %s\n",
_if_list[i]->if_name,
- _if_list[i]->if_type );
+ _if_list[i]->if_type);
i++;
}
@@ -358,28 +359,29 @@
#ifdef IF_REMOTE
fb_log("%-12s %s\n",
remote_interface.if_name,
- remote_interface.if_type );
+ remote_interface.if_type);
#endif
- if (_fb_disk_enable ) {
+ if (_fb_disk_enable) {
fb_log("%-12s %s\n",
disk_interface.if_name,
- disk_interface.if_type );
+ disk_interface.if_type);
}
return 0;
}
+
/**
* True if the non-null string s is all digits
*/
static int
fb_totally_numeric(register char *s)
{
- if (s == (char *)0 || *s == 0 )
+ if (s == (char *)0 || *s == 0)
return 0;
- while (*s ) {
- if (*s < '0' || *s > '9' )
+ while (*s) {
+ if (*s < '0' || *s > '9')
return 0;
s++;
}
@@ -400,10 +402,10 @@
{
register int i;
- for (i=0; i<256; i++ ) {
- if (cmap->cm_red[i]>>8 != i ) return(0);
- if (cmap->cm_green[i]>>8 != i ) return(0);
- if (cmap->cm_blue[i]>>8 != i ) return(0);
+ for (i=0; i<256; i++) {
+ if (cmap->cm_red[i]>>8 != i) return(0);
+ if (cmap->cm_green[i]>>8 != i) return(0);
+ if (cmap->cm_blue[i]>>8 != i) return(0);
}
return(1);
}
@@ -417,13 +419,14 @@
{
register int i;
- for (i=0; i<256; i++ ) {
+ for (i=0; i<256; i++) {
cmap->cm_red[i] = i<<8;
cmap->cm_green[i] = i<<8;
cmap->cm_blue[i] = i<<8;
}
}
+
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/libfb/fb_log.c
===================================================================
--- brlcad/trunk/src/libfb/fb_log.c 2010-04-23 19:51:16 UTC (rev 38774)
+++ brlcad/trunk/src/libfb/fb_log.c 2010-04-23 20:16:44 UTC (rev 38775)
@@ -35,18 +35,18 @@
/*
- * F B _ L O G
+ * F B _ L O G
*
- * Log a framebuffer library event in the Standard way.
+ * Log a framebuffer library event in the Standard way.
*/
#if !defined(_WIN32) || defined(__CYGWIN__)
void
-fb_log( const char *fmt, ... )
+fb_log(const char *fmt, ...)
{
va_list ap;
- va_start( ap, fmt );
- (void)vfprintf( stderr, fmt, ap );
+ va_start(ap, fmt);
+ (void)vfprintf(stderr, fmt, ap);
va_end(ap);
}
#endif
Modified: brlcad/trunk/src/libfb/fb_obj.c
===================================================================
--- brlcad/trunk/src/libfb/fb_obj.c 2010-04-23 19:51:16 UTC (rev 38774)
+++ brlcad/trunk/src/libfb/fb_obj.c 2010-04-23 20:16:44 UTC (rev 38775)
@@ -22,7 +22,7 @@
/** @file fb_obj.c
*
* A framebuffer object contains the attributes and
- * methods for controlling framebuffers.
+ * methods for controlling framebuffers.
*
*/
/** @} */
@@ -59,15 +59,16 @@
static int fbo_coords_ok(Tcl_Interp *interp, FBIO *fbp, int x, int y);
static int fbo_tcllist2color(Tcl_Interp *interp, char *string, unsigned char *pixel);
-#define FBO_CONSTRAIN(_v, _a, _b)\
- ((_v > _a) ? (_v < _b ? _v : _b) : _a)
+#define FBO_CONSTRAIN(_v, _a, _b) \
+ ((_v > _a) ? (_v < _b ? _v : _b) : _a)
struct fb_obj {
- struct bu_list l;
- struct bu_vls fbo_name; /* framebuffer object name/cmd */
- struct fbserv_obj fbo_fbs; /* fbserv object */
+ struct bu_list l;
+ struct bu_vls fbo_name; /* framebuffer object name/cmd */
+ struct fbserv_obj fbo_fbs; /* fbserv object */
};
+
static struct fb_obj HeadFBObj; /* head of display manager object list */
static struct bu_cmdtab fbo_cmds[] = {
@@ -88,12 +89,13 @@
{(char *)0, (int (*)())0}
};
+
/*
- * F B O _ C M D
+ * F B O _ C M D
*
* Generic interface for framebuffer object routines.
* Usage:
- * procname cmd ?args?
+ * procname cmd ?args?
*
* Returns: result of FB command.
*/
@@ -103,6 +105,7 @@
return bu_cmd(clientData, interp, argc, argv, fbo_cmds, 1);
}
+
int
Fbo_Init(Tcl_Interp *interp)
{
@@ -113,6 +116,7 @@
return TCL_OK;
}
+
/*
* Called by Tcl when the object is destroyed.
*/
@@ -129,11 +133,12 @@
bu_free((genptr_t)fbop, "fbo_deleteProc: fbop");
}
+
/*
* Close a framebuffer object.
*
* Usage:
- * procname close
+ * procname close
*/
HIDDEN int
fbo_close_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **UNUSED(argv))
@@ -155,11 +160,12 @@
return TCL_OK;
}
+
/*
* Open/create a framebuffer object.
*
* Usage:
- * fb_open [name device [args]]
+ * fb_open [name device [args]]
*/
HIDDEN int
fbo_open_tcl(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, char **argv)
@@ -190,7 +196,7 @@
/* process args */
bu_optind = 3;
bu_opterr = 0;
- while ((c = bu_getopt(argc, argv, "w:W:s:S:n:N:")) != EOF) {
+ while ((c = bu_getopt(argc, argv, "w:W:s:S:n:N:")) != EOF) {
switch (c) {
case 'W':
case 'w':
@@ -246,12 +252,13 @@
return TCL_OK;
}
+
/*
* Clear the framebuffer with the specified color.
* Otherwise, clear the framebuffer with black.
*
* Usage:
- * procname clear [rgb]
+ * procname clear [rgb]
*/
HIDDEN int
fbo_clear_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
@@ -295,10 +302,11 @@
return TCL_OK;
}
+
/*
*
* Usage:
- * procname cursor mode x y
+ * procname cursor mode x y
*/
HIDDEN int
fbo_cursor_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
@@ -341,10 +349,11 @@
return TCL_ERROR;
}
+
/*
*
* Usage:
- * procname getcursor
+ * procname getcursor
*/
HIDDEN int
fbo_getcursor_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
@@ -378,11 +387,12 @@
return TCL_ERROR;
}
+
/*
* Refresh the entire framebuffer or that part specified by
* a rectangle (i.e. x y width height)
* Usage:
- * procname refresh [rect]
+ * procname refresh [rect]
*/
HIDDEN int
fbo_refresh_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
@@ -423,7 +433,7 @@
* Listen for framebuffer clients.
*
* Usage:
- * procname listen port
+ * procname listen port
*
* Returns the port number actually used.
*
@@ -480,11 +490,12 @@
return TCL_ERROR;
}
+
/*
* Set/get the pixel value at position (x, y).
*
* Usage:
- * procname pixel x y [rgb]
+ * procname pixel x y [rgb]
*/
HIDDEN int
fbo_pixel_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
@@ -548,7 +559,7 @@
return TCL_OK;
}
- error:
+error:
bu_vls_init(&vls);
bu_vls_printf(&vls, "helplib fb_pixel");
Tcl_Eval(interp, bu_vls_addr(&vls));
@@ -556,10 +567,11 @@
return TCL_ERROR;
}
+
/*
*
* Usage:
- * procname cell xmin ymin width height color
+ * procname cell xmin ymin width height color
*/
HIDDEN int
fbo_cell_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
@@ -594,7 +606,7 @@
return TCL_ERROR;
}
- /* check coordinates */
+ /* check coordinates */
if (!fbo_coords_ok(interp, fbop->fbo_fbs.fbs_fbp, xmin, ymin)) {
Tcl_AppendResult(interp,
"fb_cell: coordinates (", argv[2], ", ", argv[3],
@@ -643,10 +655,11 @@
return TCL_OK;
}
+
/*
*
* Usage:
- * procname flush
+ * procname flush
*/
HIDDEN int
fbo_flush_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
@@ -671,10 +684,11 @@
return TCL_OK;
}
+
/*
*
* Usage:
- * procname getheight
+ * procname getheight
*/
HIDDEN int
fbo_getheight_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
@@ -700,10 +714,11 @@
return TCL_OK;
}
+
/*
*
* Usage:
- * procname getwidth
+ * procname getwidth
*/
HIDDEN int
fbo_getwidth_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
@@ -729,10 +744,11 @@
return TCL_OK;
}
+
/*
*
* Usage:
- * procname getsize
+ * procname getsize
*/
HIDDEN int
fbo_getsize_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
@@ -762,10 +778,11 @@
return TCL_OK;
}
+
/*
*
* Usage:
- * procname cell xmin ymin width height color
+ * procname cell xmin ymin width height color
*/
HIDDEN int
fbo_rect_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
@@ -799,7 +816,7 @@
return TCL_ERROR;
}
- /* check coordinates */
+ /* check coordinates */
if (!fbo_coords_ok(interp, fbop->fbo_fbs.fbs_fbp, xmin, ymin)) {
Tcl_AppendResult(interp,
"fb_rect: coordinates (", argv[2], ", ", argv[3],
@@ -860,9 +877,10 @@
return TCL_OK;
}
+
/*
* Usage:
- * procname configure width height
+ * procname configure width height
*/
int
fbo_configure_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
@@ -899,11 +917,12 @@
return TCL_OK;
}
+
#if 0
/*
*
* Usage:
- * procname
+ * procname
*/
int
fbo__tcl(clientData, interp, argc, argv)
@@ -923,9 +942,9 @@
HIDDEN int
fbo_coords_ok(Tcl_Interp *interp, FBIO *fbp, int x, int y)
{
- int width;
- int height;
- int errors;
+ int width;
+ int height;
+ int errors;
width = fb_getwidth(fbp);
height = fb_getheight(fbp);
@@ -955,13 +974,14 @@
++errors;
}
- if ( errors ) {
+ if (errors) {
return 0;
} else {
return 1;
}
}
+
HIDDEN int
fbo_tcllist2color(Tcl_Interp *interp, char *string, unsigned char *pixel)
{
@@ -981,6 +1001,7 @@
return TCL_OK;
}
+
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/libfb/fb_paged_io.c
===================================================================
--- brlcad/trunk/src/libfb/fb_paged_io.c 2010-04-23 19:51:16 UTC (rev 38774)
+++ brlcad/trunk/src/libfb/fb_paged_io.c 2010-04-23 20:16:44 UTC (rev 38775)
@@ -34,16 +34,15 @@
#include "fb.h"
-#define PAGE_BYTES (63*1024L) /* Max # of bytes/dma. */
-#define PAGE_PIXELS (((PAGE_BYTES/sizeof(RGBpixel))/ifp->if_width) *ifp->if_width)
-#define PAGE_SCANS (ifp->if_ppixels/ifp->if_width)
+#define PAGE_BYTES (63*1024L) /* Max # of bytes/dma. */
+#define PAGE_PIXELS (((PAGE_BYTES/sizeof(RGBpixel))/ifp->if_width) *ifp->if_width)
+#define PAGE_SCANS (ifp->if_ppixels/ifp->if_width)
-#define Malloc_Bomb(_bytes_) \
- fb_log("\"%s\"(%d) : allocation of %d bytes failed.\n", \
- __FILE__, __LINE__, _bytes_)
+#define Malloc_Bomb(_bytes_) \
+ fb_log("\"%s\"(%d) : allocation of %d bytes failed.\n", \
+ __FILE__, __LINE__, _bytes_)
-
static int
_fb_pgout(register FBIO *ifp)
{
@@ -68,6 +67,7 @@
);
}
+
static int
_fb_pgin(register FBIO *ifp, int pageno)
{
@@ -94,6 +94,7 @@
);
}
+
static int
_fb_pgflush(register FBIO *ifp)
{
@@ -103,7 +104,7 @@
if (ifp->if_pdirty) {
if (_fb_pgout(ifp) <= -1)
- return -1;
+ return -1;
ifp->if_pdirty = 0;
}
@@ -134,7 +135,7 @@
if ((ifp->if_pbase = (unsigned char *)malloc(ifp->if_ppixels * sizeof(RGBpixel)))
== PIXEL_NULL) {
Malloc_Bomb(ifp->if_ppixels * sizeof(RGBpixel));
- return -1;
+ return -1;
}
}
ifp->if_pcurp = ifp->if_pbase; /* Initialize pointer. */
@@ -142,6 +143,7 @@
return 0;
}
+
int
fb_seek(register FBIO *ifp, int x, int y)
{
@@ -155,16 +157,16 @@
if (x < 0 || y < 0 || x >= ifp->if_width || y >= ifp->if_height) {
fb_log("fb_seek: illegal address <%d, %d>.\n", x, y);
- return -1;
+ return -1;
}
pixelnum = ((long) y * (long) ifp->if_width) + x;
pagepixel = (long) ifp->if_pno * ifp->if_ppixels;
if (pixelnum < pagepixel || pixelnum >= (pagepixel + ifp->if_ppixels)) {
if (ifp->if_pdirty)
if (_fb_pgout(ifp) == - 1)
- return -1;
+ return -1;
if (_fb_pgin(ifp, (int) (pixelnum / (long) ifp->if_ppixels)) <= -1)
- return -1;
+ return -1;
}
ifp->if_pixcur = pixelnum;
/* Compute new pixel pointer into page. */
@@ -173,6 +175,7 @@
return 0;
}
+
int
fb_tell(register FBIO *ifp, int *xp, int *yp)
{
@@ -187,12 +190,13 @@
return 0;
}
+
int
fb_wpixel(register FBIO *ifp, unsigned char *pixelp)
{
if (ifp->if_pno == -1)
if (_fb_pgin(ifp, ifp->if_pixcur / ifp->if_ppixels) <= -1)
- return -1;
+ return -1;
COPYRGB((ifp->if_pcurp), pixelp);
ifp->if_pcurp += sizeof(RGBpixel); /* position in page */
@@ -200,31 +204,33 @@
ifp->if_pdirty = 1; /* page referenced (dirty) */
if (ifp->if_pcurp >= ifp->if_pendp) {
if (_fb_pgout(ifp) <= -1)
- return -1;
+ return -1;
ifp->if_pno = -1;
}
return 0;
}
+
int
fb_rpixel(register FBIO *ifp, unsigned char *pixelp)
{
if (ifp->if_pno == -1)
if (_fb_pgin(ifp, ifp->if_pixcur / ifp->if_ppixels) <= -1)
- return -1;
+ return -1;
COPYRGB(pixelp, (ifp->if_pcurp));
ifp->if_pcurp += sizeof(RGBpixel); /* position in page */
ifp->if_pixcur++; /* position in framebuffer */
if (ifp->if_pcurp >= ifp->if_pendp) {
if (_fb_pgout(ifp) <= -1)
- return -1;
+ return -1;
ifp->if_pno = -1;
}
return 0;
}
+
int
fb_flush(register FBIO *ifp)
{
@@ -232,11 +238,12 @@
/* call device specific flush routine */
if ((*ifp->if_flush)(ifp) <= -1)
- return -1;
+ return -1;
return 0;
}
+
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/libfb/fb_rect.c
===================================================================
--- brlcad/trunk/src/libfb/fb_rect.c 2010-04-23 19:51:16 UTC (rev 38774)
+++ brlcad/trunk/src/libfb/fb_rect.c 2010-04-23 20:16:44 UTC (rev 38775)
@@ -21,8 +21,8 @@
/** @{ */
/** @file fb_rect.c
*
- * Subroutines to simulate the fb_readrect() and fb_writerect()
- * capabilities for displays that do not presently handle it.
+ * Subroutines to simulate the fb_readrect() and fb_writerect()
+ * capabilities for displays that do not presently handle it.
*
*/
/** @} */
@@ -35,29 +35,29 @@
/*
- * F B _ S I M _ R E A D R E C T
+ * F B _ S I M _ R E A D R E C T
*
- * A routine to simulate the effect of fb_readrect() when a
- * particular display does not handle it.
+ * A routine to simulate the effect of fb_readrect() when a
+ * particular display does not handle it.
*/
int
fb_sim_readrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
{
- register int y;
- register int tot;
- int got;
+ register int y;
+ register int tot;
+ int got;
tot = 0;
- for ( y=ymin; y < ymin+height; y++ ) {
- got = fb_read( ifp, xmin, y, pp, width );
- if ( got < 0 ) {
+ for (y=ymin; y < ymin+height; y++) {
+ got = fb_read(ifp, xmin, y, pp, width);
+ if (got < 0) {
fb_log("fb_sim_readrect() y=%d unexpected EOF\n", y);
break;
}
tot += got;
- if ( got != width ) {
+ if (got != width) {
fb_log("fb_sim_readrect() y=%d, read of %d got %d pixels, aborting\n",
- y, width, got );
+ y, width, got);
break;
}
pp += width * sizeof(RGBpixel);
@@ -65,113 +65,117 @@
return(tot);
}
+
/*
- * F B _ S I M _ W R I T E R E C T
+ * F B _ S I M _ W R I T E R E C T
*
- * A routine to simulate the effect of fb_writerect() when a
- * particular display does not handle it.
+ * A routine to simulate the effect of fb_writerect() when a
+ * particular display does not handle it.
*
- * Returns number of pixels actually written.
- * Clipping to the screen may reduce the total if caller was sloppy.
+ * Returns number of pixels actually written.
+ * Clipping to the screen may reduce the total if caller was sloppy.
*/
int
fb_sim_writerect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
{
- register int y;
- register int tot;
- int got;
- int xlen;
+ register int y;
+ register int tot;
+ int got;
+ int xlen;
xlen = width;
- if ( xmin + width > fb_getwidth(ifp) )
+ if (xmin + width > fb_getwidth(ifp))
xlen = fb_getwidth(ifp) - xmin;
tot = 0;
- for ( y=ymin; y < ymin+height; y++ ) {
- got = fb_write( ifp, xmin, y, pp, xlen );
+ for (y=ymin; y < ymin+height; y++) {
+ got = fb_write(ifp, xmin, y, pp, xlen);
tot += got;
- if ( got != xlen ) break;
+ if (got != xlen) break;
pp += width * sizeof(RGBpixel);
}
return(tot);
}
+
/*
- * F B _ S I M _ B W R E A D R E C T
+ * F B _ S I M _ B W R E A D R E C T
*/
-#define SIMBUF_SIZE (24*1024)
+#define SIMBUF_SIZE (24*1024)
int
fb_sim_bwreadrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
{
- register int y;
- register int tot;
- int got;
- unsigned char buf[SIMBUF_SIZE*3];
+ register int y;
+ register int tot;
+ int got;
+ unsigned char buf[SIMBUF_SIZE*3];
- if ( width > SIMBUF_SIZE ) {
+ if (width > SIMBUF_SIZE) {
fb_log("fb_sim_bwreadrect() width of %d exceeds internal buffer, aborting\n", width);
return -SIMBUF_SIZE; /* FAIL */
}
tot = 0;
- for ( y=ymin; y < ymin+height; y++ ) {
- register int x;
+ for (y=ymin; y < ymin+height; y++) {
+ register int x;
- got = fb_read( ifp, xmin, y, buf, width );
+ got = fb_read(ifp, xmin, y, buf, width);
/* Extract green chan */
- for ( x=0; x < width; x++ )
+ for (x=0; x < width; x++)
*pp++ = buf[x*3+GRN];
tot += got;
- if ( got != width ) break;
+ if (got != width) break;
}
return tot;
}
+
/*
- * F B _ S I M _ B W W R I T E R E C T
+ * F B _ S I M _ B W W R I T E R E C T
*/
int
fb_sim_bwwriterect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
{
- register int y;
- register int tot;
- int got;
- int xlen;
- unsigned char buf[SIMBUF_SIZE];
+ register int y;
+ register int tot;
+ int got;
+ int xlen;
+ unsigned char buf[SIMBUF_SIZE];
- if ( width > SIMBUF_SIZE ) {
+ if (width > SIMBUF_SIZE) {
fb_log("fb_sim_bwwriterect() width of %d exceeds internal buffer, aborting\n", width);
return -SIMBUF_SIZE; /* FAIL */
}
xlen = width;
- if ( xmin + width > fb_getwidth(ifp) )
+ if (xmin + width > fb_getwidth(ifp))
xlen = fb_getwidth(ifp) - xmin;
tot = 0;
- for ( y=ymin; y < ymin+height; y++ ) {
- register int x;
- register unsigned char *bp;
+ for (y=ymin; y < ymin+height; y++) {
+ register int x;
+ register unsigned char *bp;
/* Copy monochrome (b&w) intensity into all three chans */
bp = buf;
- for ( x=0; x < width; x++ ) {
- register unsigned char c = *pp++;
+ for (x=0; x < width; x++) {
+ register unsigned char c = *pp++;
bp[0] = c;
bp[1] = c;
bp[2] = c;
bp += 3;
}
- got = fb_write( ifp, xmin, y, buf, xlen );
+ got = fb_write(ifp, xmin, y, buf, xlen);
tot += got;
- if ( got != xlen ) break;
+ if (got != xlen) break;
}
return tot;
}
+
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/libfb/fb_util.c
===================================================================
--- brlcad/trunk/src/libfb/fb_util.c 2010-04-23 19:51:16 UTC (rev 38774)
+++ brlcad/trunk/src/libfb/fb_util.c 2010-04-23 20:16:44 UTC (rev 38775)
@@ -21,8 +21,8 @@
/** @{ */
/** @file fb_util.c
*
- * Subroutines to simulate device specific functions for simple
- * device interfaces to use, and backward compatibility routines.
+ * Subroutines to simulate device specific functions for simple
+ * device interfaces to use, and backward compatibility routines.
*
*/
/** @} */
@@ -35,10 +35,10 @@
/*
- * F B _ S I M _ V I E W
+ * F B _ S I M _ V I E W
*
- * A routine to simulate the effect of fb_view() by simply
- * storing this information into the FBIO structure.
+ * A routine to simulate the effect of fb_view() by simply
+ * storing this information into the FBIO structure.
*/
int
fb_sim_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
@@ -50,14 +50,15 @@
ifp->if_xzoom = xzoom;
ifp->if_yzoom = yzoom;
- return 0;
+ return 0;
}
+
/*
- * F B _ S I M _ G E T V I E W
+ * F B _ S I M _ G E T V I E W
*
- * A routine to simulate the effect of fb_getview() by simply
- * reading this information from the FBIO structure.
+ * A routine to simulate the effect of fb_getview() by simply
+ * reading this information from the FBIO structure.
*/
int
fb_sim_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
@@ -69,14 +70,15 @@
*xzoom = ifp->if_xzoom;
*yzoom = ifp->if_yzoom;
- return 0;
+ return 0;
}
+
/*
- * F B _ S I M _ C U R S O R
+ * F B _ S I M _ C U R S O R
*
- * A routine to simulate the effect of fb_cursor() by simply
- * storing this information into the FBIO structure.
+ * A routine to simulate the effect of fb_cursor() by simply
+ * storing this information into the FBIO structure.
*/
int
fb_sim_cursor(FBIO *ifp, int mode, int x, int y)
@@ -87,14 +89,15 @@
ifp->if_xcurs = x;
ifp->if_ycurs = y;
- return 0;
+ return 0;
}
+
/*
- * F B _ S I M _ G E T C U R S O R
+ * F B _ S I M _ G E T C U R S O R
*
- * A routine to simulate the effect of fb_getcursor() by simply
- * reading this information from the FBIO structure.
+ * A routine to simulate the effect of fb_getcursor() by simply
+ * reading this information from the FBIO structure.
*/
int
fb_sim_getcursor(FBIO *ifp, int *mode, int *x, int *y)
@@ -105,9 +108,10 @@
*x = ifp->if_xcurs;
*y = ifp->if_ycurs;
- return 0;
+ return 0;
}
+
/* Backward Compatibility Routines */
int
@@ -117,9 +121,10 @@
FB_CK_FBIO(ifp);
}
- return 0;
+ return 0;
}
+
int
fb_viewport(FBIO *ifp, int UNUSED(left), int UNUSED(top), int UNUSED(right), int UNUSED(bottom))
{
@@ -127,14 +132,15 @@
FB_CK_FBIO(ifp);
}
- return 0;
+ return 0;
}
+
int
fb_window(FBIO *ifp, int x, int y)
{
- int xcenter, ycenter;
- int xzoom, yzoom;
+ int xcenter, ycenter;
+ int xzoom, yzoom;
if (ifp) {
FB_CK_FBIO(ifp);
@@ -146,11 +152,12 @@
return fb_view(ifp, xcenter, ycenter, xzoom, yzoom);
}
+
int
fb_zoom(FBIO *ifp, int x, int y)
{
- int xcenter, ycenter;
- int xzoom, yzoom;
+ int xcenter, ycenter;
+ int xzoom, yzoom;
if (ifp) {
FB_CK_FBIO(ifp);
@@ -162,6 +169,7 @@
return fb_view(ifp, xcenter, ycenter, xzoom, yzoom);
}
+
int
fb_scursor(FBIO *ifp, int UNUSED(mode), int UNUSED(x), int UNUSED(y))
{
@@ -172,9 +180,10 @@
/* We could actually implement this but it
* is probably of no value.
*/
- return 0;
+ return 0;
}
+
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/libfb/if_TEMPLATE.c
===================================================================
--- brlcad/trunk/src/libfb/if_TEMPLATE.c 2010-04-23 19:51:16 UTC (rev 38774)
+++ brlcad/trunk/src/libfb/if_TEMPLATE.c 2010-04-23 20:16:44 UTC (rev 38775)
@@ -23,21 +23,28 @@
*
* How to add a new device interface:
*
- * Copy this file to if_devname.c
- * Do a global replace of DEVNAME with your devname.
- * (In the interest of non-flexnames, DEVNAME should be no more
- * than three characters; except perhaps for DEVNAME_interface)
- * Fill in the device description, max width and height,
- * default width and height, and shortname (what you will
- * look it up as).
- * Set the unimplemented functions to "fb_null"
- * (and remove the skeletons if you're tidy)
- * Set DEVNAME_readrect to fb_sim_readrect, and DEVNAME_writerect
- * to fb_sim_writerect, if not implemented.
- * Make DEVNAME_free call DEVNAME_close if not implemented.
- * Go add an "ifdef IF_DEVNAME" to fb_generic.c (two places).
- * Add defines to Makefile.am
- * Replace this header.
+ * Copy this file to if_devname.c
+ *
+ * Do a global replace of DEVNAME with your devname.
+ * (In the interest of non-flexnames, DEVNAME should be no more than
+ * three characters; except perhaps for DEVNAME_interface)
+ *
+ * Fill in the device description, max width and height, default width
+ * and height, and shortname (what you will look it up as).
+ *
+ * Set the unimplemented functions to "fb_null" (and remove the
+ * skeletons if you're tidy).
+ *
+ * Set DEVNAME_readrect to fb_sim_readrect, and DEVNAME_writerect to
+ * fb_sim_writerect, if not implemented.
+ *
+ * Make DEVNAME_free call DEVNAME_close if not implemented.
+ *
+ * Go add an "ifdef IF_DEVNAME" to fb_generic.c (two places).
+ *
+ * Add defines to Makefile.am
+ *
+ * Replace this header.
*/
/** @} */
@@ -55,160 +62,179 @@
return(0);
}
+
HIDDEN int
DEVNAME_close(FBIO *ifp)
{
return(0);
}
+
HIDDEN int
DEVNAME_clear(FBIO *ifp, unsigned char *pp)
{
return(0);
}
+
HIDDEN int
DEVNAME_read(FBIO *ifp, int x, int y, unsigned char *pixelp, int count)
{
return(count);
}
+
HIDDEN int
DEVNAME_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, int count)
{
return(count);
}
+
HIDDEN int
DEVNAME_rmap(FBIO *ifp, ColorMap *cmp)
{
return(0);
}
+
HIDDEN int
DEVNAME_wmap(FBIO *ifp, const ColorMap *cmp)
{
return(0);
}
+
HIDDEN int
DEVNAME_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
{
return(0);
}
+
HIDDEN int
DEVNAME_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
{
return(0);
}
+
HIDDEN int
DEVNAME_setcursor(FBIO *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig)
{
return(0);
}
+
HIDDEN int
DEVNAME_cursor(FBIO *ifp, int mode, int x, int y)
{
return(0);
}
+
HIDDEN int
DEVNAME_getcursor(FBIO *ifp, int *mode, int *x, int *y)
{
return(0);
}
+
HIDDEN int
DEVNAME_readrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
{
- return( width*height );
+ return(width*height);
}
+
HIDDEN int
DEVNAME_writerect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
{
- return( width*height );
+ return(width*height);
}
+
HIDDEN int
DEVNAME_poll(FBIO *ifp)
{
return(0);
}
+
HIDDEN int
DEVNAME_flush(FBIO *ifp)
{
return(0);
}
+
HIDDEN int
DEVNAME_free(FBIO *ifp)
{
return(0);
}
+
HIDDEN int
DEVNAME_help(FBIO *ifp)
{
- fb_log( "Description: %s\n", DEVNAME_interface.if_type );
- fb_log( "Device: %s\n", ifp->if_name );
- fb_log( "Max width/height: %d %d\n",
- DEVNAME_interface.if_max_width,
- DEVNAME_interface.if_max_height );
- fb_log( "Default width/height: %d %d\n",
- DEVNAME_interface.if_width,
- DEVNAME_interface.if_height );
+ fb_log("Description: %s\n", DEVNAME_interface.if_type);
+ fb_log("Device: %s\n", ifp->if_name);
+ fb_log("Max width/height: %d %d\n",
+ DEVNAME_interface.if_max_width,
+ DEVNAME_interface.if_max_height);
+ fb_log("Default width/height: %d %d\n",
+ DEVNAME_interface.if_width,
+ DEVNAME_interface.if_height);
return(0);
}
+
/* This is the ONLY thing that we normally "export" */
FBIO DEVNAME_interface = {
- 0, /* magic number slot */
- DEVNAME_open, /* open device */
- DEVNAME_close, /* close device */
- DEVNAME_clear, /* clear device */
- DEVNAME_read, /* read pixels */
- DEVNAME_write, /* write pixels */
- DEVNAME_rmap, /* read colormap */
- DEVNAME_wmap, /* write colormap */
- DEVNAME_view, /* set view */
- DEVNAME_getview, /* get view */
- DEVNAME_setcursor, /* define cursor */
- DEVNAME_cursor, /* set cursor */
- DEVNAME_getcursor, /* get cursor */
- DEVNAME_readrect, /* read rectangle */
- DEVNAME_writerect, /* write rectangle */
- DEVNAME_bwreadrect, /* read bw rectangle */
- DEVNAME_bwwriterect, /* write bw rectangle */
- DEVNAME_poll, /* process events */
- DEVNAME_flush, /* flush output */
- DEVNAME_free, /* free resources */
- DEVNAME_help, /* help message */
- "Device description", /* device description */
- 0, /* max width */
- 0, /* max height */
- "/dev/shortname", /* short device name */
- 0, /* default/current width */
+ 0, /* magic number slot */
+ DEVNAME_open, /* open device */
+ DEVNAME_close, /* close device */
+ DEVNAME_clear, /* clear device */
+ DEVNAME_read, /* read pixels */
+ DEVNAME_write, /* write pixels */
+ DEVNAME_rmap, /* read colormap */
+ DEVNAME_wmap, /* write colormap */
+ DEVNAME_view, /* set view */
+ DEVNAME_getview, /* get view */
+ DEVNAME_setcursor, /* define cursor */
+ DEVNAME_cursor, /* set cursor */
+ DEVNAME_getcursor, /* get cursor */
+ DEVNAME_readrect, /* read rectangle */
+ DEVNAME_writerect, /* write rectangle */
+ DEVNAME_bwreadrect, /* read bw rectangle */
+ DEVNAME_bwwriterect, /* write bw rectangle */
+ DEVNAME_poll, /* process events */
+ DEVNAME_flush, /* flush output */
+ DEVNAME_free, /* free resources */
+ DEVNAME_help, /* help message */
+ "Device description", /* device description */
+ 0, /* max width */
+ 0, /* max height */
+ "/dev/shortname", /* short device name */
+ 0, /* default/current width */
0, /* default/current height */
- -1, /* select file desc */
- -1, /* file descriptor */
- 1, 1, /* zoom */
- 0, 0, /* window center */
- 0, 0, 0, /* cursor */
- PIXEL_NULL, /* page_base */
- PIXEL_NULL, /* page_curp */
- PIXEL_NULL, /* page_endp */
- -1, /* page_no */
- 0, /* page_dirty */
- 0L, /* page_curpos */
- 0L, /* page_pixels */
- 0 /* debug */
+ -1, /* select file desc */
+ -1, /* file descriptor */
+ 1, 1, /* zoom */
+ 0, 0, /* window center */
+ 0, 0, 0, /* cursor */
+ PIXEL_NULL, /* page_base */
+ PIXEL_NULL, /* page_curp */
+ PIXEL_NULL, /* page_endp */
+ -1, /* page_no */
+ 0, /* page_dirty */
+ 0L, /* page_curpos */
+ 0L, /* page_pixels */
+ 0 /* debug */
};
+
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/libfb/if_X.c
===================================================================
--- brlcad/trunk/src/libfb/if_X.c 2010-04-23 19:51:16 UTC (rev 38774)
+++ brlcad/trunk/src/libfb/if_X.c 2010-04-23 20:16:44 UTC (rev 38775)
@@ -21,7 +21,7 @@
/** @{ */
/** @file if_X.c
*
- * X Window System (X11) libfb interface.
+ * X Window System (X11) libfb interface.
*
*/
/** @} */
@@ -30,8 +30,8 @@
#ifdef IF_X
-#define DEBUGX 0
-#define CURSOR 1
+#define DEBUGX 0
+#define CURSOR 1
#include <stdlib.h>
#include <ctype.h>
@@ -55,13 +55,13 @@
#include "fb.h"
-#define TMP_FILE "/tmp/x.cmap"
+#define TMP_FILE "/tmp/x.cmap"
/*
* Note: these return the "lower left corner" of a zoomed pixel
*/
-#define xIMG2SCR(x) (((x)-ifp->if_xcenter)*ifp->if_xzoom+w.width/2)
-#define yIMG2SCR(y) (((y)-ifp->if_ycenter)*ifp->if_yzoom+w.height/2)
+#define xIMG2SCR(x) (((x)-ifp->if_xcenter)*ifp->if_xzoom+w.width/2)
+#define yIMG2SCR(y) (((y)-ifp->if_ycenter)*ifp->if_yzoom+w.height/2)
#ifdef USE_PROTOTYPES
@@ -73,37 +73,37 @@
HIDDEN int X_scanwrite(FBIO *ifp, int x, int y, const unsigned char *pixelp, int count, int save);
HIDDEN int X_wmap(FBIO *ifp, const ColorMap *cmp);
#else
-HIDDEN void Monochrome();
-HIDDEN int X_do_event();
-HIDDEN void genmap();
+HIDDEN void Monochrome();
+HIDDEN int X_do_event();
+HIDDEN void genmap();
HIDDEN int X_scanwrite();
HIDDEN int X_wmap();
#endif
/*
* Per window state information.
*/
-struct xinfo {
- Display *dpy; /* Display and Screen(s) info */
- Window win; /* Window ID */
- int screen; /* Our screen selection */
- Visual *visual; /* Our visual selection */
- GC gc; /* current graphics context */
+struct xinfo {
+ Display *dpy; /* Display and Screen(s) info */
+ Window win; /* Window ID */
+ int screen; /* Our screen selection */
+ Visual *visual; /* Our visual selection */
+ GC gc; /* current graphics context */
Colormap cmap; /* 8bit X colormap */
- XImage *image;
- XImage *scanimage;
+ XImage *image;
+ XImage *scanimage;
unsigned char *bytebuf; /* 8bit image buffer */
unsigned char *bitbuf; /* 1bit image buffer */
unsigned char *scanbuf; /* single scan line image buffer */
unsigned char *mem; /* optional 24bit store */
- int method; /* bitmap conversion method */
- Window curswin; /* Cursor Window ID */
+ int method; /* bitmap conversion method */
+ Window curswin; /* Cursor Window ID */
- int depth; /* 1, 8, or 24bit */
- int mode; /* 0, 1, 2 */
+ int depth; /* 1, 8, or 24bit */
+ int mode; /* 0, 1, 2 */
ColorMap rgb_cmap; /* User's libfb colormap */
};
-#define XI(ptr) ((struct xinfo *)((ptr)->u1.p))
-#define XIL(ptr) ((ptr)->u1.p) /* left hand side version */
+#define XI(ptr) ((struct xinfo *)((ptr)->u1.p))
+#define XIL(ptr) ((ptr)->u1.p) /* left hand side version */
#define MODE_1MASK (1<<1)
#define MODE_1TRANSIENT (0<<1)
@@ -126,10 +126,10 @@
#define MODE_5INSTCMAP (1<<5)
static struct modeflags {
- char c;
- long mask;
- long value;
- char *help;
+ char c;
+ long mask;
+ long value;
+ char *help;
} modeflags[] = {
{ 'l', MODE_1MASK, MODE_1LINGERING,
"Lingering window" },
@@ -146,17 +146,18 @@
{ '\0', 0, 0, "" }
};
+
/*
- * Hardware colormap support
+ * Hardware colormap support
*
- * The color map is organized as a 6x6x6 colorcube, with 10 extra
- * entries each for the primary colors and grey values.
+ * The color map is organized as a 6x6x6 colorcube, with 10 extra
+ * entries each for the primary colors and grey values.
*
- * entries 0 -> 215 are the color cube
- * entries 216 -> 225 are extra "red" values
- * entries 226 -> 235 are extra "green" values
- * entries 236 -> 245 are extra "blue" values
- * entries 246 -> 255 are extra "grey" values
+ * entries 0 -> 215 are the color cube
+ * entries 216 -> 225 are extra "red" values
+ * entries 226 -> 235 are extra "green" values
+ * entries 236 -> 245 are extra "blue" values
+ * entries 246 -> 255 are extra "grey" values
*
*/
/* Our copy of the *hardware* colormap */
@@ -170,6 +171,7 @@
17, 34, 68, 85, 119, 136, 170, 187, 221, 238
};
+
/* Arrays containing the indicies of the primary colors and grey values
* in the color map
*/
@@ -186,38 +188,39 @@
0, 246, 247, 43, 248, 249, 86, 250, 251, 129, 252, 253, 172, 254, 255, 215
};
+
HIDDEN unsigned char convRGB(register const unsigned char *v);
-unsigned long *x_pixel_table;
-XColor *color_defs;
+unsigned long *x_pixel_table;
+XColor *color_defs;
/*
- * A given Display (i.e. Server) can have any number of Screens.
- * Each Screen can support one or more Visual types.
- * unix:0.1.2 => host:display.screen.visual
- * Typically the screen and visual default to 0 by being omitted.
+ * A given Display (i.e. Server) can have any number of Screens.
+ * Each Screen can support one or more Visual types.
+ * unix:0.1.2 => host:display.screen.visual
+ * Typically the screen and visual default to 0 by being omitted.
*/
void
x_print_display_info(Display *dpy)
{
- int i;
- int screen;
- Visual *visual;
+ int i;
+ int screen;
+ Visual *visual;
XVisualInfo *vp;
- int num;
- Window win = DefaultRootWindow(dpy);
+ int num;
+ Window win = DefaultRootWindow(dpy);
XStandardColormap cmap;
printf("Server \"%s\", release %d\n",
- ServerVendor(dpy), VendorRelease(dpy) );
+ ServerVendor(dpy), VendorRelease(dpy));
/* How many screens? */
screen = DefaultScreen(dpy);
printf("%d Screen(s), we connected to screen %d\n",
- ScreenCount(dpy), screen );
+ ScreenCount(dpy), screen);
/* How many visuals? */
- vp = XGetVisualInfo(dpy, VisualNoMask, NULL, &num );
- XFree( (char *)vp );
+ vp = XGetVisualInfo(dpy, VisualNoMask, NULL, &num);
+ XFree((char *)vp);
printf("%d Visual(s)\n", num);
printf("ImageByteOrder: %s\n",
ImageByteOrder(dpy) == MSBFirst ? "MSBFirst" : "LSBFirst");
@@ -226,17 +229,17 @@
printf("BitmapUnit: %d\n", BitmapUnit(dpy));
printf("BitmapPad: %d\n", BitmapPad(dpy));
- printf("==== Screen %d ====\n", screen );
+ printf("==== Screen %d ====\n", screen);
printf("%d x %d pixels, %d x %d mm, (%.2f x %.2f dpi)\n",
DisplayWidth(dpy, screen), DisplayHeight(dpy, screen),
DisplayWidthMM(dpy, screen), DisplayHeightMM(dpy, screen),
DisplayWidth(dpy, screen)*25.4/DisplayWidthMM(dpy, screen),
DisplayHeight(dpy, screen)*25.4/DisplayHeightMM(dpy, screen));
printf("%d DisplayPlanes (other Visuals, if any, may vary)\n",
- DisplayPlanes(dpy, screen) );
- printf("%d DisplayCells\n", DisplayCells(dpy, screen) );
- printf("BlackPixel = %lu\n", BlackPixel(dpy, screen) );
- printf("WhitePixel = %lu\n", WhitePixel(dpy, screen) );
+ DisplayPlanes(dpy, screen));
+ printf("%d DisplayCells\n", DisplayCells(dpy, screen));
+ printf("BlackPixel = %lu\n", BlackPixel(dpy, screen));
+ printf("WhitePixel = %lu\n", WhitePixel(dpy, screen));
printf("Save Unders: %s\n",
DoesSaveUnders(ScreenOfDisplay(dpy, screen)) ? "True" : "False");
i = DoesBackingStore(ScreenOfDisplay(dpy, screen));
@@ -244,11 +247,11 @@
(i == Always ? "Always" : "NotUseful"));
printf("Installed Colormaps: min %d, max %d\n",
MinCmapsOfScreen(ScreenOfDisplay(dpy, screen)),
- MaxCmapsOfScreen(ScreenOfDisplay(dpy, screen)) );
+ MaxCmapsOfScreen(ScreenOfDisplay(dpy, screen)));
printf("DefaultColormap: 0lx%lx\n", DefaultColormap(dpy, screen));
visual = DefaultVisual(dpy, screen);
- printf("---- Visual 0x%lx ----\n", (unsigned long int)visual );
+ printf("---- Visual 0x%lx ----\n", (unsigned long int)visual);
switch (visual->class) {
case DirectColor:
@@ -282,36 +285,37 @@
printf("Bits per RGB: %d\n", visual->bits_per_rgb);
printf("==== Standard Colormaps ====\n");
- if ( XGetStandardColormap( dpy, win, &cmap, XA_RGB_BEST_MAP ) ) {
- printf( "XA_RGB_BEST_MAP - Yes (0x%lx)\n", cmap.colormap);
- printf( "R[0..%lu] * %lu + G[0..%lu] * %lu + B[0..%lu] * %lu + %lu\n",
- cmap.red_max, cmap.red_mult, cmap.green_max, cmap.green_mult,
- cmap.blue_max, cmap.blue_mult, cmap.base_pixel);
+ if (XGetStandardColormap(dpy, win, &cmap, XA_RGB_BEST_MAP)) {
+ printf("XA_RGB_BEST_MAP - Yes (0x%lx)\n", cmap.colormap);
+ printf("R[0..%lu] * %lu + G[0..%lu] * %lu + B[0..%lu] * %lu + %lu\n",
+ cmap.red_max, cmap.red_mult, cmap.green_max, cmap.green_mult,
+ cmap.blue_max, cmap.blue_mult, cmap.base_pixel);
} else
- printf( "XA_RGB_BEST_MAP - No\n" );
- if ( XGetStandardColormap( dpy, win, &cmap, XA_RGB_DEFAULT_MAP ) ) {
- printf( "XA_RGB_DEFAULT_MAP - Yes (0x%lx)\n", cmap.colormap );
- printf( "R[0..%lu] * %lu + G[0..%lu] * %lu + B[0..%lu] * %lu + %lu\n",
- cmap.red_max, cmap.red_mult, cmap.green_max, cmap.green_mult,
- cmap.blue_max, cmap.blue_mult, cmap.base_pixel);
+ printf("XA_RGB_BEST_MAP - No\n");
+ if (XGetStandardColormap(dpy, win, &cmap, XA_RGB_DEFAULT_MAP)) {
+ printf("XA_RGB_DEFAULT_MAP - Yes (0x%lx)\n", cmap.colormap);
+ printf("R[0..%lu] * %lu + G[0..%lu] * %lu + B[0..%lu] * %lu + %lu\n",
+ cmap.red_max, cmap.red_mult, cmap.green_max, cmap.green_mult,
+ cmap.blue_max, cmap.blue_mult, cmap.base_pixel);
} else
- printf( "XA_RGB_DEFAULT_MAP - No\n" );
- if ( XGetStandardColormap( dpy, win, &cmap, XA_RGB_GRAY_MAP ) ) {
- printf( "XA_RGB_GRAY_MAP - Yes (0x%lx)\n", cmap.colormap );
- printf( "R[0..%lu] * %lu + %lu\n",
- cmap.red_max, cmap.red_mult, cmap.base_pixel);
+ printf("XA_RGB_DEFAULT_MAP - No\n");
+ if (XGetStandardColormap(dpy, win, &cmap, XA_RGB_GRAY_MAP)) {
+ printf("XA_RGB_GRAY_MAP - Yes (0x%lx)\n", cmap.colormap);
+ printf("R[0..%lu] * %lu + %lu\n",
+ cmap.red_max, cmap.red_mult, cmap.base_pixel);
} else
- printf( "XA_RGB_GRAY_MAP - No\n" );
+ printf("XA_RGB_GRAY_MAP - No\n");
}
+
HIDDEN int
x_make_colormap(FBIO *ifp)
{
- int tot_levels;
- int i;
- Colormap color_map;
- int tmp;
- long b, w; /* server black and white pixels */
+ int tot_levels;
+ int i;
+ Colormap color_map;
+ int tmp;
+ long b, w; /* server black and white pixels */
tot_levels = 256;
@@ -325,21 +329,21 @@
genmap(redmap, grnmap, blumap); /* generate hardware color_map */
- color_defs = (XColor *) malloc (256 * sizeof (XColor) );
+ color_defs = (XColor *) malloc (256 * sizeof (XColor));
x_pixel_table = (unsigned long *)
- malloc( tot_levels * sizeof( unsigned long) );
+ malloc(tot_levels * sizeof(unsigned long));
- color_map = XCreateColormap( XI(ifp)->dpy,
- XI(ifp)->win, XI(ifp)->visual, AllocNone);
+ color_map = XCreateColormap(XI(ifp)->dpy,
+ XI(ifp)->win, XI(ifp)->visual, AllocNone);
- if ( color_map == (Colormap)NULL)
+ if (color_map == (Colormap)NULL)
fprintf(stderr, "Warning: color map missing\n");
XI(ifp)->cmap = color_map;
/* Allocate the colors cells */
- if ( (XAllocColorCells( XI(ifp)->dpy, color_map, 0, NULL, 0,
- x_pixel_table, tot_levels )) == 0) {
+ if ((XAllocColorCells(XI(ifp)->dpy, color_map, 0, NULL, 0,
+ x_pixel_table, tot_levels)) == 0) {
fprintf(stderr, "XAllocColorCells died\n");
}
@@ -368,49 +372,50 @@
color_defs[i].blue = blumap[i]<<8;
color_defs[i].flags = DoRed | DoGreen | DoBlue;
}
- XStoreColors ( XI(ifp)->dpy, color_map, color_defs, tot_levels);
+ XStoreColors (XI(ifp)->dpy, color_map, color_defs, tot_levels);
/* assign this colormap to our window */
- XSetWindowColormap( XI(ifp)->dpy, XI(ifp)->win, XI(ifp)->cmap);
+ XSetWindowColormap(XI(ifp)->dpy, XI(ifp)->win, XI(ifp)->cmap);
/* If you are real anti-social, install it.
* This should be left to the window managers though. */
- /* XInstallColormap( XI(ifp)->dpy, color_map ); */
- if ( (XI(ifp)->mode&MODE_5MASK) == MODE_5INSTCMAP ) {
- XInstallColormap( XI(ifp)->dpy, color_map );
+ /* XInstallColormap(XI(ifp)->dpy, color_map); */
+ if ((XI(ifp)->mode&MODE_5MASK) == MODE_5INSTCMAP) {
+ XInstallColormap(XI(ifp)->dpy, color_map);
}
return 0;
}
+
HIDDEN
int
x_setup(FBIO *ifp, int width, int height)
{
- Display *dpy; /* local copy */
- int screen; /* local copy */
- Visual *visual; /* local copy */
- Window win; /* local copy */
- GC gc; /* local copy */
+ Display *dpy; /* local copy */
+ int screen; /* local copy */
+ Visual *visual; /* local copy */
+ Window win; /* local copy */
+ GC gc; /* local copy */
XGCValues gcv;
- XSizeHints xsh; /* part of the "standard" props */
- XWMHints xwmh; /* size guidelines for window mngr */
+ XSizeHints xsh; /* part of the "standard" props */
+ XWMHints xwmh; /* size guidelines for window mngr */
XSetWindowAttributes xswa;
/* Open the display - use the env variable DISPLAY */
- if ( (dpy = XOpenDisplay(NULL)) == NULL ) {
- fb_log( "if_X: Can't open X display \"%s\"\n",
- XDisplayName(NULL) );
- return -1;
+ if ((dpy = XOpenDisplay(NULL)) == NULL) {
+ fb_log("if_X: Can't open X display \"%s\"\n",
+ XDisplayName(NULL));
+ return -1;
}
/* Use the screen we connected to */
screen = DefaultScreen(dpy);
/*
- * Note: all Windows, Colormaps and XImages have a Visual
- * attribute which determines how pixel values are mapped
- * to displayed colors. We should eventually examine which
- * choices (if any) the current screen offers and pick a
- * "best" one. For now use the default. Most servers don't
- * offer a choice yet anyway.
+ * Note: all Windows, Colormaps and XImages have a Visual
+ * attribute which determines how pixel values are mapped
+ * to displayed colors. We should eventually examine which
+ * choices (if any) the current screen offers and pick a
+ * "best" one. For now use the default. Most servers don't
+ * offer a choice yet anyway.
*/
visual = DefaultVisual(dpy, screen);
@@ -419,7 +424,7 @@
XI(ifp)->screen = screen;
XI(ifp)->visual = visual;
XI(ifp)->depth = DisplayPlanes(dpy, screen);
- if ( DisplayCells(dpy, screen) != 256 )
+ if (DisplayCells(dpy, screen) != 256)
XI(ifp)->depth = 1; /*XXX - until cmap fix */
#if DEBUGX
@@ -444,22 +449,22 @@
#if DEBUGX
printf("Creating window\n");
#endif
- win = XCreateWindow( dpy, DefaultRootWindow(dpy),
- 0, 0, width, height, 3,
- DefaultDepth(dpy, screen), InputOutput, visual,
- CWEventMask |CWBackPixel |CWBorderPixel
- |CWBitGravity | CWBackingStore,
- /* |CWCursor, */
- &xswa );
+ win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+ 0, 0, width, height, 3,
+ DefaultDepth(dpy, screen), InputOutput, visual,
+ CWEventMask |CWBackPixel |CWBorderPixel
+ |CWBitGravity | CWBackingStore,
+ /* |CWCursor, */
+ &xswa);
XI(ifp)->win = win;
- if ( win == 0 ) {
- fb_log( "if_X: Can't create window\n" );
- return -1;
+ if (win == 0) {
+ fb_log("if_X: Can't create window\n");
+ return -1;
}
/* get or set a colormap for our window */
- if ( XI(ifp)->depth == 8 ) {
+ if (XI(ifp)->depth == 8) {
x_make_colormap(ifp);
} else {
XI(ifp)->cmap = DefaultColormap(dpy, screen);
@@ -478,44 +483,44 @@
#if DEBUGX
printf("Setting Standard Properties\n");
#endif
- XSetStandardProperties( dpy, win,
- "Frame buffer", /* window name */
- "Frame buffer", /* icon name */
- None, /* icon pixmap */
- NULL, 0, /* command (argv, argc) */
- &xsh ); /* size hints */
+ XSetStandardProperties(dpy, win,
+ "Frame buffer", /* window name */
+ "Frame buffer", /* icon name */
+ None, /* icon pixmap */
+ NULL, 0, /* command (argv, argc) */
+ &xsh); /* size hints */
#if DEBUGX
printf("Setting WM Hints\n");
#endif
xwmh.input = False; /* no terminal input? */
xwmh.initial_state = NormalState;
xwmh.flags = InputHint |StateHint;
- XSetWMHints( dpy, win, &xwmh );
+ XSetWMHints(dpy, win, &xwmh);
/* Create a Graphics Context for drawing */
- gcv.foreground = WhitePixel( dpy, screen );
- gcv.background = BlackPixel( dpy, screen );
+ gcv.foreground = WhitePixel(dpy, screen);
+ gcv.background = BlackPixel(dpy, screen);
#if DEBUGX
printf("Making graphics context\n");
#endif
- gc = XCreateGC( dpy, win, (GCForeground|GCBackground), &gcv );
+ gc = XCreateGC(dpy, win, (GCForeground|GCBackground), &gcv);
XI(ifp)->gc = gc;
- XSelectInput( dpy, win, ExposureMask );
- XMapWindow( dpy, win );
+ XSelectInput(dpy, win, ExposureMask);
+ XMapWindow(dpy, win);
XFlush(dpy);
- while ( 1 ) {
- XEvent event;
- XNextEvent( dpy, &event );
- if ( event.type == Expose && event.xexpose.count == 0 ) {
+ while (1) {
+ XEvent event;
+ XNextEvent(dpy, &event);
+ if (event.type == Expose && event.xexpose.count == 0) {
XWindowAttributes xwa;
/* remove other exposure events */
- while ( XCheckTypedEvent(dpy, Expose, &event) )
+ while (XCheckTypedEvent(dpy, Expose, &event))
;
- if ( XGetWindowAttributes( dpy, win, &xwa ) == 0 )
+ if (XGetWindowAttributes(dpy, win, &xwa) == 0)
break;
width = xwa.width;
@@ -523,17 +528,17 @@
break;
}
}
- XSelectInput( dpy, win, ExposureMask|ButtonPressMask );
+ XSelectInput(dpy, win, ExposureMask|ButtonPressMask);
- return 0;
+ return 0;
}
HIDDEN int
X_open_fb(FBIO *ifp, char *file, int width, int height)
{
- int fd;
- int mode;
+ int fd;
+ int mode;
unsigned char *bytebuf; /* local copy */
unsigned char *bitbuf; /* local copy */
unsigned char *scanbuf; /* local copy */
@@ -541,69 +546,68 @@
FB_CK_FBIO(ifp);
/*
- * First, attempt to determine operating mode for this open,
- * based upon the "unit number" or flags.
- * file = "/dev/xold###"
+ * First, attempt to determine operating mode for this open,
+ * based upon the "unit number" or flags.
+ * file = "/dev/xold###"
*/
mode = MODE_1LINGERING;
- if ( file != NULL ) {
+ if (file != NULL) {
register char *cp;
- char modebuf[80];
- char *mp;
- int alpha;
- struct modeflags *mfp;
+ char modebuf[80];
+ char *mp;
+ int alpha;
+ struct modeflags *mfp;
if (strncmp(file, ifp->if_name, strlen(ifp->if_name))) {
/* How did this happen?? */
mode = 0;
- }
- else {
+ } else {
/* Parse the options */
alpha = 0;
mp = &modebuf[0];
cp = &file[6];
- while ( *cp != '\0' && !isspace(*cp) ) {
+ while (*cp != '\0' && !isspace(*cp)) {
*mp++ = *cp; /* copy it to buffer */
- if ( isdigit(*cp) ) {
+ if (isdigit(*cp)) {
cp++;
continue;
}
alpha++;
- for ( mfp = modeflags; mfp->c != '\0'; mfp++ ) {
- if ( mfp->c == *cp ) {
+ for (mfp = modeflags; mfp->c != '\0'; mfp++) {
+ if (mfp->c == *cp) {
mode = (mode&~mfp->mask)|mfp->value;
break;
}
}
- if ( mfp->c == '\0' && *cp != '-' ) {
- fb_log( "if_X: unknown option '%c' ignored\n", *cp );
+ if (mfp->c == '\0' && *cp != '-') {
+ fb_log("if_X: unknown option '%c' ignored\n", *cp);
}
cp++;
}
*mp = '\0';
- if ( !alpha )
- mode |= atoi( modebuf );
+ if (!alpha)
+ mode |= atoi(modebuf);
}
}
- if ( width <= 0 )
+ if (width <= 0)
width = ifp->if_width;
- if ( height <= 0 )
+ if (height <= 0)
height = ifp->if_height;
- if ( width > ifp->if_max_width)
+ if (width > ifp->if_max_width)
width = ifp->if_max_width;
- if ( height > ifp->if_max_height)
+ if (height > ifp->if_max_height)
height = ifp->if_max_height;
/* round width up to a multiple of eight bits */
- if ( (width%8) != 0 )
+ if ((width%8) != 0)
width = ((width + 7)/8)*8;
ifp->if_width = width;
ifp->if_height = height;
/* create a struct of state information */
- if ( (XIL(ifp) = (char *)calloc( 1, sizeof(struct xinfo) )) == NULL ) {
+ if ((XIL(ifp) = (char *)calloc(1, sizeof(struct xinfo))) == NULL) {
fb_log("X_open_fb: xinfo malloc failed\n");
return(-1);
}
@@ -614,40 +618,40 @@
XI(ifp)->mode = mode;
/* set up an X window, graphics context, etc. */
- if ( x_setup( ifp, width, height ) < 0 ) {
+ if (x_setup(ifp, width, height) < 0) {
return(-1);
}
/* check for forced monochrome behavior */
- if ( (XI(ifp)->mode&MODE_3MASK) == MODE_3MONO )
+ if ((XI(ifp)->mode&MODE_3MASK) == MODE_3MONO)
XI(ifp)->depth = 1;
/* Init our internal, and possibly X's, colormap */
/* ColorMap File HACK */
- if ( (fd = open( TMP_FILE, 0 )) >= 0 ) {
+ if ((fd = open(TMP_FILE, 0)) >= 0) {
int readval;
/* restore it from a file */
- readval = read( fd, &(XI(ifp)->rgb_cmap), sizeof(XI(ifp)->rgb_cmap) );
+ readval = read(fd, &(XI(ifp)->rgb_cmap), sizeof(XI(ifp)->rgb_cmap));
if (readval < 0) {
perror(TMP_FILE);
}
close(fd);
- X_wmap( ifp, &(XI(ifp)->rgb_cmap) );
+ X_wmap(ifp, &(XI(ifp)->rgb_cmap));
} else {
/* use linear map */
- X_wmap( ifp, (ColorMap *)NULL );
+ X_wmap(ifp, (ColorMap *)NULL);
}
/* Allocate all of our working pixel/bit buffers */
- if ( (bytebuf = (unsigned char *)calloc( 1, width*height )) == NULL ) {
+ if ((bytebuf = (unsigned char *)calloc(1, width*height)) == NULL) {
fb_log("X_open_fb: bytebuf malloc failed\n");
return(-1);
}
- if ( (bitbuf = (unsigned char *)calloc( 1, (width*height)/8 )) == NULL ) {
+ if ((bitbuf = (unsigned char *)calloc(1, (width*height)/8)) == NULL) {
fb_log("X_open_fb: bitbuf malloc failed\n");
return(-1);
}
- if ( (scanbuf = (unsigned char *)calloc( 1, width )) == NULL ) {
+ if ((scanbuf = (unsigned char *)calloc(1, width)) == NULL) {
fb_log("X_open_fb: scanbuf malloc failed\n");
return(-1);
}
@@ -655,39 +659,39 @@
XI(ifp)->bitbuf = bitbuf;
XI(ifp)->scanbuf = scanbuf;
- if ( (XI(ifp)->mode&MODE_4MASK) == MODE_4MEM ) {
+ if ((XI(ifp)->mode&MODE_4MASK) == MODE_4MEM) {
/* allocate a full 24-bit deep buffer */
- XI(ifp)->mem = (unsigned char *)calloc( 3, width*height );
- if ( XI(ifp)->mem == NULL ) {
+ XI(ifp)->mem = (unsigned char *)calloc(3, width*height);
+ if (XI(ifp)->mem == NULL) {
fb_log("X_open_fb: 24-bit buffer malloc failed\n");
}
}
/*
- * Create an Image structure.
- * The image is our client resident copy which we
- * can get/put from/to a server resident Pixmap or
- * Window (i.e. a "Drawable").
+ * Create an Image structure.
+ * The image is our client resident copy which we
+ * can get/put from/to a server resident Pixmap or
+ * Window (i.e. a "Drawable").
*/
- if ( XI(ifp)->depth == 8 ) {
- XI(ifp)->image = XCreateImage( XI(ifp)->dpy,
- XI(ifp)->visual, 8, ZPixmap, 0,
- (char *)bytebuf, width, height, 32, 0);
- XI(ifp)->scanimage = XCreateImage( XI(ifp)->dpy,
- XI(ifp)->visual, 8, ZPixmap, 0,
- (char *)scanbuf, width, 1, 32, 0);
+ if (XI(ifp)->depth == 8) {
+ XI(ifp)->image = XCreateImage(XI(ifp)->dpy,
+ XI(ifp)->visual, 8, ZPixmap, 0,
+ (char *)bytebuf, width, height, 32, 0);
+ XI(ifp)->scanimage = XCreateImage(XI(ifp)->dpy,
+ XI(ifp)->visual, 8, ZPixmap, 0,
+ (char *)scanbuf, width, 1, 32, 0);
} else {
/* An XYBitmap can be used on any depth display.
* The GC of the XPutImage provides fg and bg
* pixels for each 1 and 0 bit respectively.
* (This may be very slow however for depth != 1)
*/
- XI(ifp)->image = XCreateImage( XI(ifp)->dpy,
- XI(ifp)->visual, 1, XYBitmap, 0,
- (char *)bitbuf, width, height, 8, 0);
- XI(ifp)->scanimage = XCreateImage( XI(ifp)->dpy,
- XI(ifp)->visual, 1, XYBitmap, 0,
- (char *)scanbuf, width, 1, 8, 0);
+ XI(ifp)->image = XCreateImage(XI(ifp)->dpy,
+ XI(ifp)->visual, 1, XYBitmap, 0,
+ (char *)bitbuf, width, height, 8, 0);
+ XI(ifp)->scanimage = XCreateImage(XI(ifp)->dpy,
+ XI(ifp)->visual, 1, XYBitmap, 0,
+ (char *)scanbuf, width, 1, 8, 0);
XI(ifp)->depth = 1;
}
@@ -698,41 +702,44 @@
return(0);
}
+
static int alive = 1;
HIDDEN
int x_linger(FBIO *ifp)
{
#if 0
- if ( fork() != 0 )
+ if (fork() != 0)
return 1; /* release the parent */
#endif
- XSelectInput( XI(ifp)->dpy, XI(ifp)->win,
- ExposureMask|ButtonPressMask );
+ XSelectInput(XI(ifp)->dpy, XI(ifp)->win,
+ ExposureMask|ButtonPressMask);
- while ( alive ) {
+ while (alive) {
X_do_event(ifp);
}
return 0;
}
+
HIDDEN int
X_close_fb(FBIO *ifp)
{
- XFlush( XI(ifp)->dpy );
- if ( (XI(ifp)->mode & MODE_1MASK) == MODE_1LINGERING ) {
- if ( x_linger(ifp) ) {
+ XFlush(XI(ifp)->dpy);
+ if ((XI(ifp)->mode & MODE_1MASK) == MODE_1LINGERING) {
+ if (x_linger(ifp)) {
return(0); /* parent leaves the display */
}
}
- if ( XIL(ifp) != NULL ) {
- XCloseDisplay( XI(ifp)->dpy );
- (void)free( (char *)XIL(ifp) );
+ if (XIL(ifp) != NULL) {
+ XCloseDisplay(XI(ifp)->dpy);
+ (void)free((char *)XIL(ifp));
}
return(0);
}
+
HIDDEN int
X_clear(FBIO *ifp, unsigned char *pp)
{
@@ -741,51 +748,52 @@
#ifdef XXX
RGBpixel v;
- if ( pp == RGBPIXEL_NULL ) {
+ if (pp == RGBPIXEL_NULL) {
v[RED] = v[GRN] = v[BLU] = 0;
} else {
v[RED] = (pp)[RED];
v[GRN] = (pp)[GRN];
v[BLU] = (pp)[BLU];
}
- if ( v[RED] == v[GRN] && v[RED] == v[BLU] ) {
- int bytes = ifp->if_width*ifp->if_height*3;
- if ( v[RED] == 0 )
+ if (v[RED] == v[GRN] && v[RED] == v[BLU]) {
+ int bytes = ifp->if_width*ifp->if_height*3;
+ if (v[RED] == 0)
memset(cp, 0, bytes); /* all black */
else
memset(cp, v[RED], bytes); /* all grey */
} else {
- for ( n = ifp->if_width*ifp->if_height; n; n-- ) {
+ for (n = ifp->if_width*ifp->if_height; n; n--) {
*cp++ = v[RED];
*cp++ = v[GRN];
*cp++ = v[BLU];
}
}
#endif
- if ( pp == (unsigned char *)NULL
- || ((pp)[RED] == 0 && (pp)[GRN] == 0 && (pp)[BLU] == 0) ) {
+ if (pp == (unsigned char *)NULL
+ || ((pp)[RED] == 0 && (pp)[GRN] == 0 && (pp)[BLU] == 0)) {
memset((char *)bitbuf, 0, (ifp->if_width * ifp->if_height)/8);
memset((char *)bytebuf, 0, (ifp->if_width * ifp->if_height));
- XClearWindow( XI(ifp)->dpy, XI(ifp)->win );
+ XClearWindow(XI(ifp)->dpy, XI(ifp)->win);
}
/*XXX*/
return(0);
}
+
HIDDEN int
X_read(FBIO *ifp, int x, int y, unsigned char *pixelp, int count)
{
unsigned char *bytebuf = XI(ifp)->bytebuf;
- register unsigned char *cp;
- register int i;
+ register unsigned char *cp;
+ register int i;
- if ( x < 0 || x >= ifp->if_width || y < 0 || y >= ifp->if_height )
- return -1;
+ if (x < 0 || x >= ifp->if_width || y < 0 || y >= ifp->if_height)
+ return -1;
/* return 24bit store if available */
- if ( XI(ifp)->mem ) {
+ if (XI(ifp)->mem) {
memcpy(pixelp, &(XI(ifp)->mem[(y*ifp->if_width+x)*sizeof(RGBpixel)]), count*sizeof(RGBpixel));
- return count;
+ return count;
}
/* 1st -> 4th quadrant */
@@ -793,14 +801,15 @@
/* give then gray scale pixels - XXX - may be pseudo color */
cp = &bytebuf[y*ifp->if_width + x];
- for ( i = 0; i < count; i++ ) {
+ for (i = 0; i < count; i++) {
*pixelp++ = *cp;
*pixelp++ = *cp;
*pixelp++ = *cp++;
}
- return count;
+ return count;
}
+
/*
* Dithering
*/
@@ -826,22 +835,23 @@
int dither_bw(unsigned int pixel, register int count, register int line)
{
- if ( pixel > (unsigned)dm[((line%ditherPeriod)*ditherPeriod) + (count%ditherPeriod)])
+ if (pixel > (unsigned)dm[((line%ditherPeriod)*ditherPeriod) + (count%ditherPeriod)])
return(1);
else
return(0);
}
+
/*
* Floyd Steinberg error distribution algorithm
*/
int
fs_bw(unsigned int pixel, register int count)
{
- int onoff;
- int intensity, error;
+ int onoff;
+ int intensity, error;
- if ( count == 0 ) {
+ if (count == 0) {
int *tmp;
tmp = error1;
error1 = error2;
@@ -850,7 +860,7 @@
}
intensity = pixel + error1[count];
- if ( intensity < 128 ) {
+ if (intensity < 128) {
onoff = 0;
error = intensity;
} else {
@@ -864,14 +874,15 @@
return(onoff);
}
+
/*
* Modified Floyd Steinberg algorithm
*/
int
mfs_bw(unsigned int pixel, register int count)
{
- int onoff;
- int intensity, error;
+ int onoff;
+ int intensity, error;
if (count == 0) {
int *tmp;
@@ -897,33 +908,34 @@
return(onoff);
}
+
/*
* Repaint a (pre clipped) rectangle from the image onto the screen.
*/
HIDDEN void
slowrect(FBIO *ifp, int xmin, int xmax, int ymin, int ymax)
- /* image bounds */
+/* image bounds */
{
- int sxmin; /* screen versions of above */
- int symin;
- int xlen, ylen; /* number of image pixels in x, y */
- int sxlen, sylen; /* screen pixels in x, y */
- int ix, iy; /* image x, y */
- int sy; /* screen x, y */
- int x, y; /* dummys */
+ int sxmin; /* screen versions of above */
+ int symin;
+ int xlen, ylen; /* number of image pixels in x, y */
+ int sxlen, sylen; /* screen pixels in x, y */
+ int ix, iy; /* image x, y */
+ int sy; /* screen x, y */
+ int x, y; /* dummys */
/* window height, width, and center */
- struct {
- int width;
- int height;
- int xcenter;
- int ycenter;
+ struct {
+ int width;
+ int height;
+ int xcenter;
+ int ycenter;
} w;
/*XXX-HACK VERSION-Depend on 24bit memory buffer and use scanwrite! */
RGBpixel scanbuf[1024];
RGBpixel *pp;
- if ( XI(ifp)->mem == NULL )
+ if (XI(ifp)->mem == NULL)
return;
/*
@@ -943,25 +955,26 @@
sxmin = xIMG2SCR(xmin);
symin = yIMG2SCR(ymin);
- for ( y = 0; y < sylen; y++ ) {
+ for (y = 0; y < sylen; y++) {
sy = symin + y;
iy = ymin + y/ifp->if_yzoom;
- for ( x = 0; x < sxlen; x++ ) {
+ for (x = 0; x < sxlen; x++) {
ix = xmin + x/ifp->if_xzoom;
#if 0
sx = sxmin + x;
- printf("S(%3d,%3d) <- I(%3d,%3d)\n", sx, sy, ix, iy);
+ printf("S(%3d, %3d) <- I(%3d, %3d)\n", sx, sy, ix, iy);
#endif
pp = (RGBpixel *)&(XI(ifp)->mem[(iy*ifp->if_width+ix)*3]);
scanbuf[x][RED] = (*pp)[RED];
scanbuf[x][GRN] = (*pp)[GRN];
scanbuf[x][BLU] = (*pp)[BLU];
}
- /*printf("Write Scan %d pixels @ S(%d,%d)\n", sxlen, sxmin, sy);*/
- X_scanwrite( ifp, sxmin, sy, &scanbuf[0][0], sxlen, 0 );
+ /*printf("Write Scan %d pixels @ S(%d, %d)\n", sxlen, sxmin, sy);*/
+ X_scanwrite(ifp, sxmin, sy, &scanbuf[0][0], sxlen, 0);
}
}
+
/*
* This function converts a single scan line of (pre color mapped) pixels
* into displayable form. It will either save this data into our X image
@@ -974,35 +987,35 @@
unsigned char *bitbuf = XI(ifp)->bitbuf;
unsigned char *bytebuf = XI(ifp)->bytebuf;
unsigned char *scanbuf = XI(ifp)->scanbuf;
- register unsigned char *cp;
- register int i;
+ register unsigned char *cp;
+ register int i;
static unsigned char MSB[8] = { 0x80, 0x40, 0x20, 0x10, 8, 4, 2, 1 };
static unsigned char LSB[8] = { 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80 };
register unsigned char *bits = MSB;
unsigned char tmpbuf[1280]; /*XXX*/
- int sy; /* 4th quad y */
+ int sy; /* 4th quad y */
/* 1st -> 4th quadrant */
sy = ifp->if_height - 1 - y;
- if ( save ) {
+ if (save) {
cp = &bytebuf[sy*ifp->if_width + x];
} else {
- if ( XI(ifp)->depth == 1 )
+ if (XI(ifp)->depth == 1)
cp = tmpbuf; /* save scanbuf for 1bit output */
else
cp = scanbuf;
}
- if ( XI(ifp)->depth == 8 ) {
+ if (XI(ifp)->depth == 8) {
/* Gray Scale Mode */
- if ( (XI(ifp)->mode&MODE_2MASK) == MODE_2_8BIT ) {
- for ( i=0; i<count; i++ ) {
+ if ((XI(ifp)->mode&MODE_2MASK) == MODE_2_8BIT) {
+ for (i=0; i<count; i++) {
cp[i] = pixelp[3*i+RED];
}
goto done;
}
/* PseudoColor Mode */
- for ( i = 0; i < count; i++ ) {
+ for (i = 0; i < count; i++) {
int value;
value = convRGB(&pixelp[3*i]);
cp[i] = (unsigned char) x_pixel_table[value];
@@ -1014,12 +1027,12 @@
/* save the 8bit black and white version of it */
/* XXX - note replication of Gray Scale Mode above... */
- if ( (XI(ifp)->mode&MODE_2MASK) == MODE_2_8BIT ) {
- for ( i = 0; i < count; i++ ) {
+ if ((XI(ifp)->mode&MODE_2MASK) == MODE_2_8BIT) {
+ for (i = 0; i < count; i++) {
cp[i] = pixelp[3*i+RED];
}
} else {
- for ( i = 0; i < count; i++ ) {
+ for (i = 0; i < count; i++) {
/* Best possible 8-bit NTSC weights */
/* Use three tables if this gets to be a bottleneck */
cp[i] = (77*(int)pixelp[3*i+RED] + 150*(int)pixelp[3*i+GRN]
@@ -1033,29 +1046,29 @@
}
{
- int row, col, bit;
- int byte, rem;
- unsigned char mvalue;
- unsigned char *mbuffer; /* = &buffer[(sy*ifp->if_width + x)/8]; */
+ int row, col, bit;
+ int byte, rem;
+ unsigned char mvalue;
+ unsigned char *mbuffer; /* = &buffer[(sy*ifp->if_width + x)/8]; */
byte = sy * ifp->if_width + x;
rem = byte % 8;
byte /= 8;
- if ( save )
+ if (save)
mbuffer = &bitbuf[byte];
else
mbuffer = scanbuf;
- for ( row = sy; row < sy+1; row++ ) {
- for ( col=x; col < x+count; ) {
+ for (row = sy; row < sy+1; row++) {
+ for (col=x; col < x+count;) {
/*mvalue = 0x00;*/
/* pre-read the byte */
mvalue = *mbuffer;
/* diddle its bit */
- for ( bit=rem; (bit < 8) && (col < x+count); bit++, col++ ) {
+ for (bit=rem; (bit < 8) && (col < x+count); bit++, col++) {
/*val = (30*(pixelp)[RED] + 59*(pixelp)[GRN] + 11*(pixelp)[BLU] + 200) / 400;*/
/*pixelp++;*/
- /*if( dither_bw(val, col, row) ) {*/
- if ( (int)*cp++ > (dm[((row&7)<<3)+(col&7)]<<2)+1 ) {
+ /*if (dither_bw(val, col, row)) {*/
+ if ((int)*cp++ > (dm[((row&7)<<3)+(col&7)]<<2)+1) {
mvalue |= bits[bit];
} else {
mvalue &= ~bits[bit];
@@ -1068,33 +1081,34 @@
}
}
- done:
+done:
/* XXX - Determine how much of the scan line is displayed in
* the window (if any) including pan & zoom, and display that
* portion.
*/
- if ( save && (ifp->if_xzoom != 1) ) {
+ if (save && (ifp->if_xzoom != 1)) {
/* note: slowrect never asks us to save */
- slowrect( ifp, x, x+count-1, y, y );
- } else if ( save ) {
+ slowrect(ifp, x, x+count-1, y, y);
+ } else if (save) {
XPutImage(XI(ifp)->dpy, XI(ifp)->win, XI(ifp)->gc,
XI(ifp)->image,
x, sy, x, sy,
- count, 1 );
+ count, 1);
} else {
XPutImage(XI(ifp)->dpy, XI(ifp)->win, XI(ifp)->gc,
XI(ifp)->scanimage,
0, 0, x, sy,
- count, 1 );
+ count, 1);
}
/* XXX - until we get something better */
- if ( count > 1 )
+ if (count > 1)
XFlush(XI(ifp)->dpy);
- return count;
+ return count;
}
+
/*
* Decompose a write of more than one scanline into multiple single
* scanline writes.
@@ -1102,40 +1116,41 @@
HIDDEN int
X_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, int count)
{
- int maxcount;
- int todo;
- int num;
+ int maxcount;
+ int todo;
+ int num;
/* check origin bounds */
- if ( x < 0 || x >= ifp->if_width || y < 0 || y >= ifp->if_height )
- return -1;
+ if (x < 0 || x >= ifp->if_width || y < 0 || y >= ifp->if_height)
+ return -1;
/* check write length */
maxcount = ifp->if_width * (ifp->if_height - y) - x;
- if ( count > maxcount )
+ if (count > maxcount)
count = maxcount;
/* save it in 24bit store if available */
- if ( XI(ifp)->mem ) {
+ if (XI(ifp)->mem) {
memcpy(&(XI(ifp)->mem[(y*ifp->if_width+x)*sizeof(RGBpixel)]), pixelp, count*sizeof(RGBpixel));
}
todo = count;
- while ( todo > 0 ) {
- if ( x + todo > ifp->if_width )
+ while (todo > 0) {
+ if (x + todo > ifp->if_width)
num = ifp->if_width - x;
else
num = todo;
- if ( X_scanwrite( ifp, x, y, pixelp, num, 1 ) == 0 )
- return( 0 );
+ if (X_scanwrite(ifp, x, y, pixelp, num, 1) == 0)
+ return(0);
x = 0;
y++;
todo -= num;
pixelp += num;
}
- return( count );
+ return(count);
}
+
HIDDEN int
X_rmap(FBIO *ifp, ColorMap *cmp)
{
@@ -1143,14 +1158,15 @@
return(0);
}
+
HIDDEN int
X_wmap(FBIO *ifp, const ColorMap *cmp)
{
register int i;
- int is_linear = 1;
+ int is_linear = 1;
- if ( cmp == (ColorMap *)NULL ) {
- fb_make_linear_cmap( &(XI(ifp)->rgb_cmap) );
+ if (cmp == (ColorMap *)NULL) {
+ fb_make_linear_cmap(&(XI(ifp)->rgb_cmap));
is_linear = 1;
} else {
XI(ifp)->rgb_cmap = *cmp; /* struct copy */
@@ -1158,14 +1174,14 @@
}
/* Hack to save it into a file - this may go away */
- if ( is_linear ) {
+ if (is_linear) {
/* no file => linear map */
- (void) unlink( TMP_FILE );
+ (void) unlink(TMP_FILE);
} else {
/* save map for later */
i=creat(TMP_FILE, 0666);
- if ( i >= 0 ) {
- int ret = write( i, cmp, sizeof(*cmp) );
+ if (i >= 0) {
+ int ret = write(i, cmp, sizeof(*cmp));
close(i);
} else {
fprintf(stderr, "if_X: couldn't save color map\n");
@@ -1173,12 +1189,12 @@
}
}
- if ( XI(ifp)->depth != 8 )
+ if (XI(ifp)->depth != 8)
return(0); /* no X colormap allocated - XXX */
/* If MODE_2_8BIT, load it in the real window colormap */
- if ( (XI(ifp)->mode&MODE_2MASK) == MODE_2_8BIT ) {
- for ( i = 0; i < 256; i++ ) {
+ if ((XI(ifp)->mode&MODE_2MASK) == MODE_2_8BIT) {
+ for (i = 0; i < 256; i++) {
/* Both sides expect 16-bit left-justified maps */
color_defs[i].pixel = i;
color_defs[i].red = cmp->cm_red[i];
@@ -1186,12 +1202,13 @@
color_defs[i].blue = cmp->cm_blue[i];
color_defs[i].flags = DoRed | DoGreen | DoBlue;
}
- XStoreColors( XI(ifp)->dpy, XI(ifp)->cmap, color_defs, 256 );
+ XStoreColors(XI(ifp)->dpy, XI(ifp)->cmap, color_defs, 256);
}
return(0);
}
+
/* Repaint.
* Zooming an image can also be viewed as shrinking our "window" of
* currently displayed data. We then drop that window down over the
@@ -1206,17 +1223,17 @@
repaint(FBIO *ifp)
{
/* 1st and last image pixel coordinates *within* the window */
- int xmin, xmax;
- int ymin, ymax;
+ int xmin, xmax;
+ int ymin, ymax;
/* screen pixel coordinates corresponding to above */
- int sleft, sright;
- int sbottom, stop;
+ int sleft, sright;
+ int sbottom, stop;
/* window height, width, and center */
- struct {
- int width;
- int height;
- int xcenter;
- int ycenter;
+ struct {
+ int width;
+ int height;
+ int xcenter;
+ int ycenter;
} w;
/*
@@ -1240,13 +1257,13 @@
/*
* Clip these against the actual image dimensions.
*/
- if ( xmin < 0 )
+ if (xmin < 0)
xmin = 0;
- if ( xmax > ifp->if_width-1 )
+ if (xmax > ifp->if_width-1)
xmax = ifp->if_width-1;
- if ( ymin < 0 )
+ if (ymin < 0)
ymin = 0;
- if ( ymax > ifp->if_height-1 )
+ if (ymax > ifp->if_height-1)
ymax = ifp->if_height-1;
/*
@@ -1260,75 +1277,76 @@
/*
* if (sleft || sbottom || sright != w.width-1 || stop != w.height-1)
- * then the image rectangle does not completely fill the screen
- * window rectangle. I tried clearing the entire window first
- * and then repainting the image part, but this produced a nasty
- * flashing of the screen. It is debatable whether we should clear
- * the borders before or after painting. Ultimately it would be
- * nice if we could optimize with an in server XCopyArea bitblit
- * for the part of the image already displayed (if any).
+ * then the image rectangle does not completely fill the screen
+ * window rectangle. I tried clearing the entire window first
+ * and then repainting the image part, but this produced a nasty
+ * flashing of the screen. It is debatable whether we should clear
+ * the borders before or after painting. Ultimately it would be
+ * nice if we could optimize with an in server XCopyArea bitblit
+ * for the part of the image already displayed (if any).
*/
/*
- printf("window(%3d,%3d) zoom(%3d,%3d)\n\r",
+ printf("window(%3d, %3d) zoom(%3d, %3d)\n\r",
ifp->if_xcenter, ifp->if_ycenter,
ifp->if_xzoom, ifp->if_yzoom);
- printf("Image ([%3d %3d],[%3d %3d]) Screen ([%3d %3d],[%3d %3d])\n\r",
+ printf("Image ([%3d %3d], [%3d %3d]) Screen ([%3d %3d], [%3d %3d])\n\r",
xmin, xmax, ymin, ymax, sleft, sright, sbottom, stop);
*/
/* Display our image rectangle */
- if ( (ifp->if_xzoom == 1) && (ifp->if_yzoom == 1 ) ) {
+ if ((ifp->if_xzoom == 1) && (ifp->if_yzoom == 1)) {
/* Note quadrant reversal */
XPutImage(XI(ifp)->dpy, XI(ifp)->win, XI(ifp)->gc,
XI(ifp)->image,
xmin, w.width-1-ymax,
sleft, w.height-1-stop,
- xmax-xmin+1, ymax-ymin+1 );
+ xmax-xmin+1, ymax-ymin+1);
} else {
- slowrect( ifp, xmin, xmax, ymin, ymax );
+ slowrect(ifp, xmin, xmax, ymin, ymax);
}
/* Clear any empty borders */
- if ( sleft != 0 )
- XClearArea( XI(ifp)->dpy, XI(ifp)->win,
- 0, 0,
- sleft, w.height,
- False);
- if ( sright != w.width-1 )
- XClearArea( XI(ifp)->dpy, XI(ifp)->win,
- sright+1, 0,
- w.width-1-sright, w.height,
- False);
+ if (sleft != 0)
+ XClearArea(XI(ifp)->dpy, XI(ifp)->win,
+ 0, 0,
+ sleft, w.height,
+ False);
+ if (sright != w.width-1)
+ XClearArea(XI(ifp)->dpy, XI(ifp)->win,
+ sright+1, 0,
+ w.width-1-sright, w.height,
+ False);
/* could optimize bottom and top to clip sleft to sright */
- if ( sbottom != 0 )
- XClearArea( XI(ifp)->dpy, XI(ifp)->win,
- 0, w.height-sbottom, /* (height-1)-(bottom-1) */
- w.width, sbottom,
- False);
- if ( stop != w.height-1 )
- XClearArea( XI(ifp)->dpy, XI(ifp)->win,
- 0, 0,
- w.width, w.height-1-stop,
- False);
+ if (sbottom != 0)
+ XClearArea(XI(ifp)->dpy, XI(ifp)->win,
+ 0, w.height-sbottom, /* (height-1)-(bottom-1) */
+ w.width, sbottom,
+ False);
+ if (stop != w.height-1)
+ XClearArea(XI(ifp)->dpy, XI(ifp)->win,
+ 0, 0,
+ w.width, w.height-1-stop,
+ False);
- XFlush( XI(ifp)->dpy );
+ XFlush(XI(ifp)->dpy);
}
+
HIDDEN int
X_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
{
/* bypass if no change */
- if ( ifp->if_xcenter == xcenter && ifp->if_ycenter == ycenter
- && ifp->if_xzoom == xcenter && ifp->if_yzoom == ycenter )
- return 0;
+ if (ifp->if_xcenter == xcenter && ifp->if_ycenter == ycenter
+ && ifp->if_xzoom == xcenter && ifp->if_yzoom == ycenter)
+ return 0;
/* check bounds */
- if ( xcenter < 0 || xcenter >= ifp->if_width
- || ycenter < 0 || ycenter >= ifp->if_height )
- return -1;
- if ( xzoom <= 0 || xzoom >= ifp->if_width/2
- || yzoom <= 0 || yzoom >= ifp->if_height/2 )
- return -1;
+ if (xcenter < 0 || xcenter >= ifp->if_width
+ || ycenter < 0 || ycenter >= ifp->if_height)
+ return -1;
+ if (xzoom <= 0 || xzoom >= ifp->if_width/2
+ || yzoom <= 0 || yzoom >= ifp->if_height/2)
+ return -1;
ifp->if_xcenter = xcenter;
ifp->if_ycenter = ycenter;
@@ -1336,9 +1354,10 @@
ifp->if_yzoom = yzoom;
/* XXX - repaint */
repaint(ifp);
- return 0;
+ return 0;
}
+
HIDDEN int
X_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
{
@@ -1347,9 +1366,10 @@
*xzoom = ifp->if_xzoom;
*yzoom = ifp->if_yzoom;
- return 0;
+ return 0;
}
+
HIDDEN int
X_setcursor(FBIO *ifp, const unsigned char *UNUSED(bits), int UNUSED(xbits), int UNUSED(ybits), int UNUSED(xorig), int UNUSED(yorig))
{
@@ -1357,23 +1377,24 @@
FB_CK_FBIO(ifp);
}
- return 0;
+ return 0;
}
+
HIDDEN int
x_make_cursor(FBIO *ifp)
{
- XSetWindowAttributes xswa;
+ XSetWindowAttributes xswa;
if (ifp) {
FB_CK_FBIO(ifp);
}
xswa.save_under = True;
- XI(ifp)->curswin = XCreateWindow( XI(ifp)->dpy, XI(ifp)->win,
- ifp->if_xcenter, ifp->if_ycenter, 1, 1, 3,
- CopyFromParent, InputOutput, CopyFromParent,
- CWSaveUnder, &xswa );
+ XI(ifp)->curswin = XCreateWindow(XI(ifp)->dpy, XI(ifp)->win,
+ ifp->if_xcenter, ifp->if_ycenter, 1, 1, 3,
+ CopyFromParent, InputOutput, CopyFromParent,
+ CWSaveUnder, &xswa);
return 0;
}
@@ -1387,73 +1408,75 @@
x = (x-ifp->if_xcenter)*ifp->if_xzoom+ifp->if_width/2;
y = (y-ifp->if_ycenter)*ifp->if_yzoom+ifp->if_height/2;
- if ( XI(ifp)->curswin == 0 )
+ if (XI(ifp)->curswin == 0)
x_make_cursor(ifp);
y = ifp->if_height - 1 - y; /* 1st -> 4th quadrant */
x -= 3;
y -= 3;
- if ( mode ) {
- XMoveWindow( XI(ifp)->dpy, XI(ifp)->curswin, x, y );
- XMapWindow( XI(ifp)->dpy, XI(ifp)->curswin );
+ if (mode) {
+ XMoveWindow(XI(ifp)->dpy, XI(ifp)->curswin, x, y);
+ XMapWindow(XI(ifp)->dpy, XI(ifp)->curswin);
} else {
- XUnmapWindow( XI(ifp)->dpy, XI(ifp)->curswin );
+ XUnmapWindow(XI(ifp)->dpy, XI(ifp)->curswin);
}
- XFlush( XI(ifp)->dpy );
+ XFlush(XI(ifp)->dpy);
- return 0;
+ return 0;
}
+
HIDDEN int
X_getcursor(FBIO *ifp, int *mode, int *x, int *y)
{
return fb_sim_getcursor(ifp, mode, x, y);
}
+
HIDDEN int
X_do_event(FBIO *ifp)
{
- XEvent event;
- XExposeEvent *expose;
- int button;
+ XEvent event;
+ XExposeEvent *expose;
+ int button;
unsigned char *bitbuf = XI(ifp)->bitbuf;
unsigned char *bytebuf = XI(ifp)->bytebuf;
#if CURSOR
- Cursor watch = XCreateFontCursor(XI(ifp)->dpy, XC_watch);
+ Cursor watch = XCreateFontCursor(XI(ifp)->dpy, XC_watch);
#endif
expose = (XExposeEvent *)&event;
- XNextEvent( XI(ifp)->dpy, &event );
- switch ( (int)event.type ) {
+ XNextEvent(XI(ifp)->dpy, &event);
+ switch ((int)event.type) {
case Expose:
/*XXXfprintf(stderr,
"expose event x= %d y= %d width= %d height= %d\n",
expose->x, expose->y, expose->width, expose->height);*/
XPutImage(XI(ifp)->dpy, XI(ifp)->win, XI(ifp)->gc, XI(ifp)->image,
expose->x, expose->y, expose->x, expose->y,
- expose->width, expose->height );
+ expose->width, expose->height);
break;
case ButtonPress:
button = (int)event.xbutton.button;
- if ( button == Button1 ) {
+ if (button == Button1) {
/* Check for single button mouse remap.
* ctrl-1 => 2
* meta-1 => 3
*/
- if ( event.xbutton.state & ControlMask )
+ if (event.xbutton.state & ControlMask)
button = Button2;
- else if ( event.xbutton.state & Mod1Mask )
+ else if (event.xbutton.state & Mod1Mask)
button = Button3;
}
- switch ( button ) {
+ switch (button) {
case Button1:
/* monochrome only for now */
- if ( XI(ifp)->depth != 1 )
+ if (XI(ifp)->depth != 1)
break;
/* bump method */
- if ( ++(XI(ifp)->method) > 3 )
+ if (++(XI(ifp)->method) > 3)
XI(ifp)->method = 0;
#if CURSOR
XDefineCursor(XI(ifp)->dpy, XI(ifp)->win, watch);
@@ -1466,35 +1489,35 @@
#endif
XPutImage(XI(ifp)->dpy, XI(ifp)->win, XI(ifp)->gc, XI(ifp)->image,
0, 0, 0, 0,
- ifp->if_width, ifp->if_height );
+ ifp->if_width, ifp->if_height);
break;
case Button2:
- {
- int x, y, sy;
- unsigned char *cp;
- x = event.xbutton.x;
- sy = event.xbutton.y;
- /* quadrant reverse y */
- y = ifp->if_height - 1 - sy;
- cp = &bytebuf[sy*ifp->if_width + x];
- fb_log("(%4d,%4d) index=%3d ", x, y, *cp);
- if ( XI(ifp)->depth == 8 ) {
- /*XXX color_defs may not be allocated here */
- fb_log("rgb=(%3d %3d %3d) ",
- color_defs[*cp].red>>8,
- color_defs[*cp].green>>8,
- color_defs[*cp].blue>>8 );
+ {
+ int x, y, sy;
+ unsigned char *cp;
+ x = event.xbutton.x;
+ sy = event.xbutton.y;
+ /* quadrant reverse y */
+ y = ifp->if_height - 1 - sy;
+ cp = &bytebuf[sy*ifp->if_width + x];
+ fb_log("(%4d, %4d) index=%3d ", x, y, *cp);
+ if (XI(ifp)->depth == 8) {
+ /*XXX color_defs may not be allocated here */
+ fb_log("rgb=(%3d %3d %3d) ",
+ color_defs[*cp].red>>8,
+ color_defs[*cp].green>>8,
+ color_defs[*cp].blue>>8);
+ }
+ if (XI(ifp)->mem) {
+ /* 24bit buffer */
+ cp = &(XI(ifp)->mem[(y*ifp->if_width + x)*3]);
+ fb_log("Real RGB=(%3d %3d %3d)\n",
+ cp[RED], cp[GRN], cp[BLU]);
+ } else {
+ fb_log("\n");
+ }
}
- if ( XI(ifp)->mem ) {
- /* 24bit buffer */
- cp = &(XI(ifp)->mem[(y*ifp->if_width + x)*3]);
- fb_log("Real RGB=(%3d %3d %3d)\n",
- cp[RED], cp[GRN], cp[BLU] );
- } else {
- fb_log("\n");
- }
- }
- break;
+ break;
case Button3:
alive = 0;
break;
@@ -1508,6 +1531,7 @@
return 0;
}
+
/*
* Monochrome to Bitmap conversion
* Convert width x height 8bit grey scale bytes in bytebuf to
@@ -1532,25 +1556,25 @@
mpbuffer = bytebuf;
mbuffer = bitbuf;
- for ( row = 0; row < height; row++ ) {
- for ( col=0; col < width; ) {
+ for (row = 0; row < height; row++) {
+ for (col=0; col < width;) {
mvalue = 0x00;
- for ( bit=0; (bit < 8) && (col < width); bit++, col++ ) {
- /*if( dither_bw(val, col, row) ) {*/
- if ( method == 0 ) {
- if ( (int)*mpbuffer > (dm[((row&7)<<3)+(col&7)]<<2)+1 ) {
+ for (bit=0; (bit < 8) && (col < width); bit++, col++) {
+ /*if (dither_bw(val, col, row)) {*/
+ if (method == 0) {
+ if ((int)*mpbuffer > (dm[((row&7)<<3)+(col&7)]<<2)+1) {
mvalue |= bits[bit];
}
- } else if ( method == 1 ) {
- if ( fs_bw(*mpbuffer, col) ) {
+ } else if (method == 1) {
+ if (fs_bw(*mpbuffer, col)) {
mvalue |= bits[bit];
}
- } else if ( method == 2 ) {
- if ( mfs_bw(*mpbuffer, col) ) {
+ } else if (method == 2) {
+ if (mfs_bw(*mpbuffer, col)) {
mvalue |= bits[bit];
}
- } else if ( method == 3 ) {
- if ( (int)*mpbuffer > (dm4[(row&3)][(col&3)]<<4)+7 ) {
+ } else if (method == 3) {
+ if ((int)*mpbuffer > (dm4[(row&3)][(col&3)]<<4)+7) {
mvalue |= bits[bit];
}
}
@@ -1564,89 +1588,88 @@
free((char *)error2);
}
+
HIDDEN int
X_poll(FBIO *ifp)
{
- XFlush( XI(ifp)->dpy );
- while ( XPending(XI(ifp)->dpy) > 0 )
+ XFlush(XI(ifp)->dpy);
+ while (XPending(XI(ifp)->dpy) > 0)
X_do_event(ifp);
return(0);
}
+
HIDDEN int
X_flush(FBIO *ifp)
{
- XFlush( XI(ifp)->dpy );
- while ( XPending(XI(ifp)->dpy) > 0 )
+ XFlush(XI(ifp)->dpy);
+ while (XPending(XI(ifp)->dpy) > 0)
X_do_event(ifp);
return(0);
}
+
HIDDEN int
X_help(FBIO *ifp)
{
- struct modeflags *mfp;
+ struct modeflags *mfp;
- fb_log( "Description: %s\n", X_interface.if_type );
- fb_log( "Device: %s\n", ifp->if_name );
- fb_log( "Max width/height: %d %d\n",
- X_interface.if_max_width,
- X_interface.if_max_height );
- fb_log( "Default width/height: %d %d\n",
- X_interface.if_width,
- X_interface.if_height );
- fb_log( "Usage: /dev/X[options]\n" );
- for ( mfp = modeflags; mfp->c != '\0'; mfp++ ) {
- fb_log( " %c %s\n", mfp->c, mfp->help );
+ fb_log("Description: %s\n", X_interface.if_type);
+ fb_log("Device: %s\n", ifp->if_name);
+ fb_log("Max width/height: %d %d\n",
+ X_interface.if_max_width,
+ X_interface.if_max_height);
+ fb_log("Default width/height: %d %d\n",
+ X_interface.if_width,
+ X_interface.if_height);
+ fb_log("Usage: /dev/X[options]\n");
+ for (mfp = modeflags; mfp->c != '\0'; mfp++) {
+ fb_log(" %c %s\n", mfp->c, mfp->help);
}
return(0);
}
+
/*
- * c o n v R G B
+ * c o n v R G B
*
- * convert a single RGBpixel to its corresponding entry in the Sun
- * colormap.
+ * convert a single RGBpixel to its corresponding entry in the Sun
+ * colormap.
*/
HIDDEN unsigned char convRGB(register const unsigned char *v)
{
register int r, g, b;
- r = (int)( (v)[RED]+26 ) / 51;
- g = (int)( (v)[GRN]+26 ) / 51;
- b = (int)( (v)[BLU]+26 ) / 51;
+ r = (int)((v)[RED]+26) / 51;
+ g = (int)((v)[GRN]+26) / 51;
+ b = (int)((v)[BLU]+26) / 51;
- /*printf("Pixel r = %d, g = %d, b = %d\n",(v)[RED],(v)[GRN],(v)[BLU]);*/
- if ( r == g ) {
- if ( r == b ) {
+ /*printf("Pixel r = %d, g = %d, b = %d\n", (v)[RED], (v)[GRN], (v)[BLU]);*/
+ if (r == g) {
+ if (r == b) {
/* all grey, take average */
- return greyvec[( ((int)(v)[RED]+(int)(v)[GRN]+(int)(v)[BLU]) / 3 ) /16];
- }
- else if (r == 0) {
+ return greyvec[(((int)(v)[RED]+(int)(v)[GRN]+(int)(v)[BLU]) / 3) /16];
+ } else if (r == 0) {
/* r=g=0, all blue */
return bluvec[((v)[BLU])/16];
- }
- else return r + g * 6 + b * 36;
- }
- else if (g == b && g == 0) {
+ } else return r + g * 6 + b * 36;
+ } else if (g == b && g == 0) {
/* all red */
return redvec[((v)[RED])/16];
- }
- else if (r == b && r == 0) {
+ } else if (r == b && r == 0) {
/* all green */
return grnvec[((v)[GRN])/16];
- }
- else
+ } else
return r + g * 6 + b * 36;
}
/*
- * G E N M A P
+ * G E N M A P
*
- * initialize the Sun harware colormap
+ * initialize the Sun harware colormap
*/
HIDDEN void genmap(unsigned char *rmap, unsigned char *gmap, unsigned char *bmap)
{
@@ -1688,45 +1711,45 @@
/* This is the ONLY thing that we normally "export" */
FBIO X_interface = {
0,
- X_open_fb, /* device_open */
- X_close_fb, /* device_close */
- X_clear, /* device_clear */
- X_read, /* buffer_read */
- X_write, /* buffer_write */
- X_rmap, /* colormap_read */
- X_wmap, /* colormap_write */
- X_view, /* set view */
- X_getview, /* get view */
- X_setcursor, /* define cursor */
- X_cursor, /* set cursor */
- X_getcursor, /* get cursor */
- fb_sim_readrect, /* read rectangle */
- fb_sim_writerect, /* write rectangle */
+ X_open_fb, /* device_open */
+ X_close_fb, /* device_close */
+ X_clear, /* device_clear */
+ X_read, /* buffer_read */
+ X_write, /* buffer_write */
+ X_rmap, /* colormap_read */
+ X_wmap, /* colormap_write */
+ X_view, /* set view */
+ X_getview, /* get view */
+ X_setcursor, /* define cursor */
+ X_cursor, /* set cursor */
+ X_getcursor, /* get cursor */
+ fb_sim_readrect, /* read rectangle */
+ fb_sim_writerect, /* write rectangle */
fb_sim_bwreadrect,
fb_sim_bwwriterect,
- X_poll, /* handle events */
- X_flush, /* flush */
- X_close_fb, /* free */
- X_help, /* help message */
+ X_poll, /* handle events */
+ X_flush, /* flush */
+ X_close_fb, /* free */
+ X_help, /* help message */
"X Window System (X11) 8-bit and 1-bit visuals only",
- 2048, /* max width */
- 2048, /* max height */
- "/dev/xold", /* short device name */
- 512, /* default/current width */
+ 2048, /* max width */
+ 2048, /* max height */
+ "/dev/xold", /* short device name */
+ 512, /* default/current width */
512, /* default/current height */
- -1, /* select file desc */
- -1, /* file descriptor */
- 1, 1, /* zoom */
- 256, 256, /* window center */
- 0, 0, 0, /* cursor */
- PIXEL_NULL, /* page_base */
- PIXEL_NULL, /* page_curp */
- PIXEL_NULL, /* page_endp */
- -1, /* page_no */
- 0, /* page_dirty */
- 0L, /* page_curpos */
- 0L, /* page_pixels */
- 0, /* debug */
+ -1, /* select file desc */
+ -1, /* file descriptor */
+ 1, 1, /* zoom */
+ 256, 256, /* window center */
+ 0, 0, 0, /* cursor */
+ PIXEL_NULL, /* page_base */
+ PIXEL_NULL, /* page_curp */
+ PIXEL_NULL, /* page_endp */
+ -1, /* page_no */
+ 0, /* page_dirty */
+ 0L, /* page_curpos */
+ 0L, /* page_pixels */
+ 0, /* debug */
{0}, /* u1 */
{0}, /* u2 */
{0}, /* u3 */
Modified: brlcad/trunk/src/libfb/if_X24.c
===================================================================
--- brlcad/trunk/src/libfb/if_X24.c 2010-04-23 19:51:16 UTC (rev 38774)
+++ brlcad/trunk/src/libfb/if_X24.c 2010-04-23 20:16:44 UTC (rev 38775)
@@ -240,13 +240,14 @@
{ '\0', 0, 0, "" }
};
+
/* Flags for X24_blit's flags argument */
#define BLIT_DISP 0x1 /* Write bits to screen */
#define BLIT_PZ 0x2 /* This is a pan or zoom */
#define BLIT_RESIZE 0x4 /* We just resized (screen empty) */
-#define BS_NAME "/tmp/X24_fb"
+#define BS_NAME "/tmp/X24_fb"
/* Elements of 6x9x4 colorcube */
@@ -267,6 +268,7 @@
0.000000, 0.250980, 0.501961, 0.752941, 0.031373, 0.282353, 0.533333, 0.784314
};
+
static float dmsk883[] = {
0.784314, 0.533333, 0.282353, 0.031373, 0.752941, 0.501961, 0.250980, 0.000000,
0.345098, 0.094118, 0.815686, 0.564706, 0.313726, 0.062745, 0.847059, 0.596078,
@@ -413,21 +415,24 @@
printf("R[0..%lu] * %lu + G[0..%lu] * %lu + B[0..%lu] * %lu + %lu\n",
cmap.red_max, cmap.red_mult, cmap.green_max, cmap.green_mult,
cmap.blue_max, cmap.blue_mult, cmap.base_pixel);
- } else
+ } else {
printf("XA_RGB_BEST_MAP - No\n");
+ }
if (XGetStandardColormap(dpy, win, &cmap, XA_RGB_DEFAULT_MAP)) {
printf("XA_RGB_DEFAULT_MAP - Yes (0x%lx)\n", cmap.colormap);
printf("R[0..%lu] * %lu + G[0..%lu] * %lu + B[0..%lu] * %lu + %lu\n",
cmap.red_max, cmap.red_mult, cmap.green_max, cmap.green_mult,
cmap.blue_max, cmap.blue_mult, cmap.base_pixel);
- } else
+ } else {
printf("XA_RGB_DEFAULT_MAP - No\n");
+ }
if (XGetStandardColormap(dpy, win, &cmap, XA_RGB_GRAY_MAP)) {
printf("XA_RGB_GRAY_MAP - Yes (0x%lx)\n", cmap.colormap);
printf("R[0..%lu] * %lu + %lu\n",
cmap.red_max, cmap.red_mult, cmap.base_pixel);
- } else
+ } else {
printf("XA_RGB_GRAY_MAP - No\n");
+ }
}
@@ -467,6 +472,7 @@
XStoreColors(xi->xi_dpy, xi->xi_cmap, colors, xi->xi_ncolors);
}
+
/*
Create fast lookup tables for dithering
*/
@@ -508,23 +514,23 @@
bluval = blus[idx];
for (j = 0; j < 64; j++) {
- if (i - redval > (256 / (sizeof (reds) - 1)) *
- dmsk883[128+j])
+ if (i - redval > (256 / (sizeof (reds) - 1)) * dmsk883[128+j]) {
xi->xi_ccredtbl[(i << 6) + j] = reditbl;
- else
+ } else {
xi->xi_ccredtbl[(i << 6) + j] = redtbl;
+ }
- if (i - grnval > (256 / (sizeof (grns) - 1)) *
- dmsk883[64+j])
+ if (i - grnval > (256 / (sizeof (grns) - 1)) * dmsk883[64+j]) {
xi->xi_ccgrntbl[(i << 6) + j] = grnitbl;
- else
+ } else {
xi->xi_ccgrntbl[(i << 6) + j] = grntbl;
+ }
- if (i - bluval > (256 / (sizeof (blus) - 1)) *
- dmsk883[j])
+ if (i - bluval > (256 / (sizeof (blus) - 1)) * dmsk883[j]) {
xi->xi_ccblutbl[(i << 6) + j] = bluitbl;
- else
+ } else {
xi->xi_ccblutbl[(i << 6) + j] = blutbl;
+ }
}
}
}
@@ -556,11 +562,11 @@
/* Open the display - use the env variable DISPLAY */
xname = XDisplayName(NULL);
/* Attempt one level of fallback, esp. for fbserv daemon */
- if (!xname || *xname == '\0') xname = ":0";
+ if (!xname || *xname == '\0') xname = ":0";
if ((xi->xi_dpy = XOpenDisplay(xname)) == NULL) {
fb_log("if_X: Can't open X display \"%s\"\n", xname);
- return -1;
+ return -1;
}
#if 0
@@ -576,8 +582,7 @@
* the next.
*/
- switch ((xi->xi_mode & MODEV_MASK) >> 1)
- {
+ switch ((xi->xi_mode & MODEV_MASK) >> 1) {
default:
case FLG_VD24:
if (XMatchVisualInfo(xi->xi_dpy, xi->xi_screen, 24, DirectColor,
@@ -646,8 +651,7 @@
/* Set up colormaps, white/black pixels */
- switch (xi->xi_flags & FLG_VMASK)
- {
+ switch (xi->xi_flags & FLG_VMASK) {
case FLG_VD24:
xi->xi_cmap = XCreateColormap(xi->xi_dpy, RootWindow(xi->xi_dpy,
xi->xi_screen), xi->xi_visual, AllocAll);
@@ -787,8 +791,7 @@
if (i > (256.0 * dmsk881[didx])) {
xi->xi_andtbl[(i << 6) + j] = 0xFF;
xi->xi_ortbl[(i << 6) + j] = 1 << x;
- }
- else {
+ } else {
xi->xi_andtbl[(i << 6) + j] = ~(1 << x);
xi->xi_ortbl[(i << 6) + j] = 0;
}
@@ -840,7 +843,7 @@
if (xi->xi_win == 0) {
fb_log("if_X: Can't create window\n");
- return -1;
+ return -1;
}
/* Tell window manager about colormap */
@@ -904,8 +907,7 @@
/* Allocate image buffer, and make our X11 Image */
- switch (xi->xi_flags & FLG_VMASK)
- {
+ switch (xi->xi_flags & FLG_VMASK) {
case FLG_VD24:
case FLG_VT24:
if ((xi->xi_pix = (unsigned char *) calloc(sizeof(unsigned int),
@@ -969,8 +971,7 @@
/* Calculate luminance tables if we need them */
- switch (xi->xi_flags & FLG_VMASK)
- {
+ switch (xi->xi_flags & FLG_VMASK) {
case FLG_VG8:
case FLG_VS1:
if (!lumdone) {
@@ -987,6 +988,7 @@
return (0);
}
+
/* X 2 4 _ b l i t
*
* This routine is called when ever the framebuffer is updated OR when
@@ -1017,7 +1019,7 @@
* register. This register is then clocked out as bytes in the
* correct ordering.
*
- * x1,y1->w,h describes a Rectangle of changed bits (image space coord.)
+ * x1, y1->w, h describes a Rectangle of changed bits (image space coord.)
*/
HIDDEN void
X24_blit(FBIO *ifp, int x1, int y1, int w, int h, int flags /* BLIT_xxx flags */)
@@ -1095,7 +1097,7 @@
blue_shift = i-8;
#if BLIT_DBG
- printf("blit: enter %dx%d at (%d, %d), disp (%d, %d) to (%d, %d) flags %d\n",
+ printf("blit: enter %dx%d at (%d, %d), disp (%d, %d) to (%d, %d) flags %d\n",
w, h, x1, y1, xi->xi_ilf, xi->xi_ibt, xi->xi_irt, xi->xi_itp, flags);
#endif
@@ -1134,32 +1136,36 @@
/* Compute ox: offset from left edge of window to left pixel */
xdel = x1 - xi->xi_ilf;
- if (xdel)
+ if (xdel) {
ox = x1wd + ((xdel - 1) * ifp->if_xzoom) + xi->xi_xlf;
- else
+ } else {
ox = xi->xi_xlf;
+ }
/* Compute oy: offset from top edge of window to bottom pixel */
ydel = y1 - xi->xi_ibt;
- if (ydel)
+ if (ydel) {
oy = xi->xi_xbt - (y1ht + ((ydel - 1) * ifp->if_yzoom));
- else
+ } else {
oy = xi->xi_xbt;
+ }
/* Figure out size of changed area on screen in X pixels */
- if (x2 == x1)
+ if (x2 == x1) {
xwd = x1wd;
- else
+ } else {
xwd = x1wd + x2wd + ifp->if_xzoom * (x2 - x1 - 1);
+ }
- if (y2 == y1)
+ if (y2 == y1) {
xht = y1ht;
- else
+ } else {
xht = y1ht + y2ht + ifp->if_yzoom * (y2 - y1 - 1);
+ }
#if BLIT_DBG
printf("blit: output to (%d, %d)\n", ox, oy);
@@ -1173,8 +1179,7 @@
* quadrant IV, opix _decreases_.
*/
- switch (xi->xi_flags & FLG_VMASK)
- {
+ switch (xi->xi_flags & FLG_VMASK) {
case FLG_VD24:
case FLG_VT24:
case FLG_VD16:
@@ -1251,12 +1256,13 @@
/* Calculate # pixels needed */
/* See comment above for more info */
- if (x == x1)
+ if (x == x1) {
pxwd = x1wd;
- else if (x == x2)
+ } else if (x == x2) {
pxwd = x2wd;
- else
+ } else {
pxwd = ifp->if_xzoom;
+ }
/*
* Construct a pixel with the color components
@@ -1410,7 +1416,7 @@
/* For each line, convert/copy pixels */
- if (xi->xi_flags & (FLG_XCMAP | FLG_LINCMAP))
+ if (xi->xi_flags & (FLG_XCMAP | FLG_LINCMAP)) {
for (k = x2 - x1 + 1; k; k--) {
r = lip[RED];
g = lip[GRN];
@@ -1424,7 +1430,7 @@
dmx = (dmx + 1) & 0x7;
lip += sizeof (RGBpixel);
}
- else
+ } else {
for (k = x2 - x1 + 1; k; k--) {
r = red[lip[RED]];
g = grn[lip[GRN]];
@@ -1438,6 +1444,7 @@
dmx = (dmx + 1) & 0x7;
lip += sizeof (RGBpixel);
}
+ }
ip += xi->xi_iwidth * sizeof (RGBpixel);
op -= xi->xi_image->bytes_per_line;
@@ -1463,12 +1470,11 @@
/* For each line, convert/copy pixels */
- while (pyht--)
- {
+ while (pyht--) {
lip = ip;
lop = op;
- if (xi->xi_flags & (FLG_XCMAP | FLG_LINCMAP))
+ if (xi->xi_flags & (FLG_XCMAP | FLG_LINCMAP)) {
for (x = x1; x <= x2; x++) {
int pxwd;
@@ -1485,8 +1491,7 @@
g = lip[GRN];
b = lip[BLU];
- while (pxwd--)
- {
+ while (pxwd--) {
*lop++ = xi->xi_base +
xi->xi_ccredtbl[(r << 6) + dmx + dmy] +
xi->xi_ccgrntbl[(g << 6) + dmx + dmy] +
@@ -1497,7 +1502,7 @@
lip += sizeof (RGBpixel);
}
- else
+ } else {
for (x = x1; x <= x2; x++) {
int pxwd;
@@ -1514,8 +1519,7 @@
g = grn[lip[GRN]];
b = blu[lip[BLU]];
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|