asvisual.h

Go to the documentation of this file.
00001 #ifndef _ASVISUAL_H_HEADER_INCLUDED
00002 #define _ASVISUAL_H_HEADER_INCLUDED
00003 
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007 
00008 /****h* libAfterImage/asvisual.h
00009  * NAME
00010  * asvisual - Defines abstraction layer on top of X Visuals, as well as 
00011  * several fundamental color datatypes.
00012  * SEE ALSO
00013  * Structures:
00014  *          ColorPair
00015  *          ASVisual
00016  *
00017  * Functions :
00018  *   ASVisual initialization :
00019  *          query_screen_visual(), setup_truecolor_visual(),
00020  *          setup_pseudo_visual(), setup_as_colormap(),create_asvisual(),
00021  *          destroy_asvisual()
00022  *
00023  *   ASVisual encoding/decoding :
00024  *          visual2visual_prop(), visual_prop2visual()
00025  *
00026  *   ASVisual convenience functions :
00027  *          create_visual_window(), create_visual_pixmap(),
00028  *          create_visual_ximage()
00029  *
00030  * Other libAfterImage modules :
00031  *          ascmap.h asfont.h asimage.h asvisual.h blender.h export.h
00032  *          import.h transform.h ximage.h
00033  * AUTHOR
00034  * Sasha Vasko <sasha at aftercode dot net>
00035  ******************/
00036 
00037 /****d* libAfterImage/alpha
00038  * FUNCTION
00039  * Alpha channel adds visibility parameter to color value.
00040  * Alpha channel's value of 0xFF signifies complete visibility, while 0
00041  * makes pixel completely transparent.
00042  * SOURCE
00043  */
00044 #define ALPHA_TRANSPARENT       0x00
00045 #define ALPHA_SEMI_TRANSPARENT  0x7F
00046 #define ALPHA_SOLID             0xFF
00047 /*******************/
00048 /****d* libAfterImage/ARGB32
00049  * NAME
00050  * ARGB32 - main color datatype
00051  * FUNCTION
00052  * ARGB32 is fundamental datatype that hold 32bit value corresponding to
00053  * pixels color and transparency value (alpha channel) in ARGB
00054  * colorspace. It is encoded as follows :
00055  * Lowermost 8 bits - Blue channel
00056  * bits 8 to 15     - Green channel
00057  * bits 16 to 23    - Red channel
00058  * bits 24 to 31    - Alpha channel
00059  * EXAMPLE
00060  * ASTile.1
00061  * SOURCE
00062  */
00063 typedef CARD32 ARGB32;
00064 #define ARGB32_White                    0xFFFFFFFF
00065 #define ARGB32_Black                    0xFF000000
00066 /* default background color is #FF000000 : */
00067 #define ARGB32_DEFAULT_BACK_COLOR       ARGB32_Black
00068 
00069 #define ARGB32_ALPHA_CHAN               3
00070 #define ARGB32_RED_CHAN                 2
00071 #define ARGB32_GREEN_CHAN               1
00072 #define ARGB32_BLUE_CHAN                0
00073 #define ARGB32_CHANNELS                 4
00074 
00075 #define MAKE_ARGB32(a,r,g,b)    ((( (CARD32)a)        <<24)| \
00076                                                                  ((((CARD32)r)&0x00FF)<<16)| \
00077                                  ((((CARD32)g)&0x00FF)<<8 )| \
00078                                                                  (( (CARD32)b)&0x00FF))
00079 
00080 #define MAKE_ARGB32_GREY8(a,l)  (((a)<<24)|(((l)&0x00FF)<<16)| \
00081                                  (((l)&0x00FF)<<8)|((l)&0x00FF))
00082 #define ARGB32_ALPHA8(c)                (((c)>>24)&0x00FF)
00083 #define ARGB32_RED8(c)                  (((c)>>16)&0x00FF)
00084 #define ARGB32_GREEN8(c)                (((c)>>8 )&0x00FF)
00085 #define ARGB32_BLUE8(c)                 ( (c)     &0x00FF)
00086 #define ARGB32_CHAN8(c,i)               (((c)>>((i)<<3))&0x00FF)
00087 #define MAKE_ARGB32_CHAN8(v,i)  (((v)&0x0000FF)<<((i)<<3))
00088 
00089 #ifdef __GNUC__
00090 #define ARGB32_ALPHA16(c)               ({ CARD32 __c = ARGB32_ALPHA8(c); __c | (__c<<8);})
00091 #define ARGB32_RED16(c)                 ({ CARD32 __c = ARGB32_RED8(c); __c | (__c<<8);})
00092 #define ARGB32_GREEN16(c)               ({ CARD32 __c = ARGB32_GREEN8(c); __c | (__c<<8);})
00093 #define ARGB32_BLUE16(c)                ({ CARD32 __c = ARGB32_BLUE8(c); __c | (__c<<8);})
00094 #define ARGB32_CHAN16(c,i)              ({ CARD32 __c = ARGB32_CHAN8(c,i); __c | (__c<<8);})
00095 #else
00096 #define ARGB32_ALPHA16(c)               ((((c)>>16)&0x00FF00)|(((c)>>24)&0x0000FF))
00097 #define ARGB32_RED16(c)                 ((((c)>>8 )&0x00FF00)|(((c)>>16)&0x0000FF))
00098 #define ARGB32_GREEN16(c)               (( (c)     &0x00FF00)|(((c)>>8 )&0x0000FF))
00099 #define ARGB32_BLUE16(c)                ((((c)<<8) &0x00FF00)|(((c)    )&0x0000FF))
00100 #define ARGB32_CHAN16(c,i)              ((ARGB32_CHAN8(c,i)<<8)|ARGB32_CHAN8(c,i))
00101 #endif
00102 
00103 #define MAKE_ARGB32_CHAN16(v,i) ((((v)&0x00FF00)>>8)<<((i)<<3))
00104 /*******************/
00105 
00106 
00107 struct ASScanline;
00108 
00109 /****d* libAfterImage/ColorPart
00110  * NAME
00111  * IC_RED - red channel
00112  * NAME
00113  * IC_GREEN - green channel
00114  * NAME 
00115  * IC_BLUE - blue channel
00116  * NAME
00117  * IC_ALPHA - alpha channel
00118  * NAME
00119  * IC_NUM_CHANNELS - number of supported channels
00120  * FUNCTION
00121  * Ids of the channels. These are basically synonyms to related ARGB32
00122  * channel numbers
00123  * SOURCE
00124  */
00125 typedef enum
00126 {
00127   IC_BLUE       = ARGB32_BLUE_CHAN ,
00128   IC_GREEN      = ARGB32_GREEN_CHAN,
00129   IC_RED        = ARGB32_RED_CHAN  ,
00130   IC_ALPHA  = ARGB32_ALPHA_CHAN,
00131   IC_NUM_CHANNELS = ARGB32_CHANNELS
00132 }
00133 ColorPart;
00134 /*******************/
00135 /****s* libAfterImage/ColorPair
00136  * NAME
00137  * ColorPair - convenient structure to hold pair of colors.
00138  * SOURCE
00139  */
00140 typedef struct ColorPair
00141 {
00142   ARGB32 fore;
00143   ARGB32 back;
00144 }ColorPair;
00145 /*******************/
00146 /****f* libAfterImage/ARGB32_manhattan_distance()
00147  * NAME 
00148  * ARGB32_manhattan_distance() - This function can be used to evaluate closeness of 
00149  * two colors.
00150  * SYNOPSIS
00151  * long ARGB32_manhattan_distance (long a, long b);
00152  * INPUTS
00153  * a, b - ARGB32 color values to calculate Manhattan distance in between
00154  * RETURN VALUE
00155  * returns calculated Manhattan distance.
00156  *********/
00157 long ARGB32_manhattan_distance (long a, long b);
00158 
00159 /****s* libAfterImage/ASVisual
00160  * NAME
00161  * ASVisual - an abstraction layer on top of X Server Visual.
00162  * DESCRIPTION
00163  * This structure has been introduced in order to compensate for the
00164  * fact that X may have so many different types of Visuals. It provides
00165  * shortcuts to most Visual data, compensated for differences in Visuals.
00166  * For PseudoColor visual it also contains preallocated set of colors.
00167  * This colormap allows us to write XImages very fast and without
00168  * exhausting available X colors. This colormap consist of 8, 64, or 4096
00169  * colors and constitutes fraction of colors available in particular
00170  * colordepth. This colors are allocated to be evenly spread around RGB
00171  * spectrum. Thus when converting from internal presentation - all we
00172  * need to do is to discard unused bits, and use rest of them bits as
00173  * an index in our colormap. Opposite conversion is much trickier and we
00174  * engage into nasty business of having hash table mapping pixel values
00175  * into colors, or straight table doing same in lower colordepths.
00176  * Idea is that we do all internal processing in 32bit colordepth, and
00177  * ASVisual provides us with means to convert it to actual X display
00178  * format. Respectively ASVisual has methods to write out XImage lines
00179  * and read XImage lines.
00180  * ASVisual creation is a tricky process. Basically first we have to go
00181  * through the list of available Visuals and choose the best suitable.
00182  * Then based on the type of this Visual we have to setup our data
00183  * members and method hooks. Several functions provided for that :
00184  *  query_screen_visual()    - will lookup best suitable visual
00185  *  setup_truecolor_visual() - will setup hooks if visual is TrueColor
00186  *  setup_pseudo_visual()        - will setup hooks and data if Visual is
00187  *                             PseudoColor.
00188  *  setup_as_colormap()      - will preallocate colors for PseudoColor.
00189  * Alternative to the above is :
00190  *  create_asvisual()        - it encapsulates all of the above
00191  *                             functionality, and returns completely set
00192  *                             up ASVisual object.
00193  * Since Visual selected for ASVisual may differ from default
00194  * ( we choose the best suitable ), all the window creation function
00195  * must provide colormap and some other parameters, like border color
00196  * for example. Thus we created some convenience functions.
00197  * These should be used instead of standard Xlib calls :
00198  *  create_visual_window() - to create window
00199  *  create_visual_pixmap() - to create pixmap
00200  *  create_visual_ximage() - to create XImage
00201  * ASVisual could be dealolocated and its resources freed with :
00202  *  destroy_asvisual()
00203  * EXAMPLE
00204  * asview.c: ASView
00205  * SOURCE
00206  */
00207 typedef struct ASVisual
00208 {
00209         Display      *dpy;
00210 
00211         /* This envvar will be used to determine what X Visual 
00212          * (in hex) to use. If unset then best possible will 
00213          * be selected automagically : */
00214 #define ASVISUAL_ID_ENVVAR "AFTERIMAGE_VISUAL_ID"
00215 
00216         XVisualInfo       visual_info;
00217         /* this things are calculated based on Visual : */
00218         unsigned long rshift, gshift, bshift;
00219         unsigned long rbits,  gbits,  bbits;
00220         unsigned long true_depth;       /* could be 15 when X reports 16 */
00221         Bool          BGR_mode;
00222         Bool              msb_first;
00223         /* we must have colormap so that we can safely create windows
00224          * with different visuals even if we are in TrueColor mode : */
00225         Colormap          colormap;
00226         Bool          own_colormap; /* tells us to free colormap when we
00227                                                                  * done */
00228         unsigned long black_pixel, white_pixel;
00229         /* for PseudoColor mode we need some more stuff : */
00230         enum {
00231                 ACM_None = 0,
00232                 ACM_3BPP,
00233                 ACM_6BPP,
00234                 ACM_12BPP
00235         } as_colormap_type ;    /* there can only be 64 or 4096 entries
00236                                                          * so far ( 6 or 12 bpp) */
00237         unsigned long *as_colormap; /* array of preallocated colors for
00238                                                                  * PseudoColor mode */
00239         union                       /* reverse color lookup tables : */
00240         {
00241                 ARGB32                          *xref;
00242                 struct ASHashTable  *hash;
00243         }as_colormap_reverse ;
00244 
00245         /* different useful callbacks : */
00246         CARD32 (*color2pixel_func)        ( struct ASVisual *asv,
00247                                             CARD32 encoded_color,
00248                                                                         unsigned long *pixel);
00249         void   (*pixel2color_func)    ( struct ASVisual *asv,
00250                                             unsigned long pixel,
00251                                                                         CARD32 *red, CARD32 *green,
00252                                                                         CARD32 *blue);
00253         void   (*ximage2scanline_func)( struct ASVisual *asv, 
00254                                                                         XImage *xim,
00255                                             struct ASScanline *sl, int y,
00256                                                                     unsigned char *xim_data );
00257         void   (*scanline2ximage_func)( struct ASVisual *asv, 
00258                                                                         XImage *xim,
00259                                                                         struct ASScanline *sl, int y,
00260                                                                         unsigned char *xim_data );
00261 
00262 #define ASGLX_Unavailable                       0
00263 #define ASGLX_Available                         (0x01<<0)
00264 #define ASGLX_DoubleBuffer                      (0x01<<1)
00265 #define ASGLX_RGBA                                      (0x01<<2)
00266 #define ASGLX_UseForImageTx                     (0x01<<3)       
00267         ASFlagType glx_support ;    /* one of the above flags */
00268 
00269         void *glx_scratch_gc_indirect ; /* (GLXContext) */
00270         void *glx_scratch_gc_direct ;   /* (GLXContext) */
00271 
00272         Window scratch_window;
00273 
00274 #ifndef X_DISPLAY_MISSING
00275 #define ARGB2PIXEL(asv,argb,pixel)                 \
00276         (asv)->color2pixel_func((asv),(argb),(pixel))
00277 #define GET_SCANLINE(asv,xim,sl,y,xim_data) \
00278         (asv)->ximage2scanline_func((asv),(xim),(sl),(y),(xim_data))
00279 #define PUT_SCANLINE(asv,xim,sl,y,xim_data) \
00280         (asv)->scanline2ximage_func((asv),(xim),(sl),(y),(xim_data))
00281 #else
00282 #define ARGB2PIXEL(asv,argb,pixel)                 \
00283         do{ break; }while(0)
00284 #define GET_SCANLINE(asv,xim,sl,y,xim_data) \
00285         do{ break; }while(0)
00286 #define PUT_SCANLINE(asv,xim,sl,y,xim_data) \
00287         do{ break; }while(0)
00288 #endif
00289 }ASVisual;
00290 /*******************/
00291 CARD32 color2pixel32bgr(ASVisual *asv, CARD32 encoded_color, unsigned long *pixel);
00292 CARD32 color2pixel32rgb(ASVisual *asv, CARD32 encoded_color, unsigned long *pixel);
00293 CARD32 color2pixel24bgr(ASVisual *asv, CARD32 encoded_color, unsigned long *pixel);
00294 CARD32 color2pixel24rgb(ASVisual *asv, CARD32 encoded_color, unsigned long *pixel);
00295 CARD32 color2pixel16bgr(ASVisual *asv, CARD32 encoded_color, unsigned long *pixel);
00296 CARD32 color2pixel16rgb(ASVisual *asv, CARD32 encoded_color, unsigned long *pixel);
00297 CARD32 color2pixel15bgr(ASVisual *asv, CARD32 encoded_color, unsigned long *pixel);
00298 CARD32 color2pixel15rgb(ASVisual *asv, CARD32 encoded_color, unsigned long *pixel);
00299 CARD32 color2pixel_pseudo3bpp( ASVisual *asv, CARD32 encoded_color, unsigned long *pixel );
00300 CARD32 color2pixel_pseudo6bpp( ASVisual *asv, CARD32 encoded_color, unsigned long *pixel );
00301 CARD32 color2pixel_pseudo12bpp( ASVisual *asv, CARD32 encoded_color, unsigned long *pixel );
00302 
00303 void pixel2color32rgb(ASVisual *asv, unsigned long pixel, CARD32 *red, CARD32 *green, CARD32 *blue);
00304 void pixel2color32bgr(ASVisual *asv, unsigned long pixel, CARD32 *red, CARD32 *green, CARD32 *blue);
00305 void pixel2color24rgb(ASVisual *asv, unsigned long pixel, CARD32 *red, CARD32 *green, CARD32 *blue);
00306 void pixel2color24bgr(ASVisual *asv, unsigned long pixel, CARD32 *red, CARD32 *green, CARD32 *blue);
00307 void pixel2color16rgb(ASVisual *asv, unsigned long pixel, CARD32 *red, CARD32 *green, CARD32 *blue);
00308 void pixel2color16bgr(ASVisual *asv, unsigned long pixel, CARD32 *red, CARD32 *green, CARD32 *blue);
00309 void pixel2color15rgb(ASVisual *asv, unsigned long pixel, CARD32 *red, CARD32 *green, CARD32 *blue);
00310 void pixel2color15bgr(ASVisual *asv, unsigned long pixel, CARD32 *red, CARD32 *green, CARD32 *blue);
00311 
00312 void ximage2scanline32( ASVisual *asv, XImage *xim, struct ASScanline *sl, int y,  register unsigned char *xim_data );
00313 void ximage2scanline16( ASVisual *asv, XImage *xim, struct ASScanline *sl, int y,  register unsigned char *xim_data );
00314 void ximage2scanline15( ASVisual *asv, XImage *xim, struct ASScanline *sl, int y,  register unsigned char *xim_data );
00315 void ximage2scanline_pseudo3bpp( ASVisual *asv, XImage *xim, struct ASScanline *sl, int y,  register unsigned char *xim_data );
00316 void ximage2scanline_pseudo6bpp( ASVisual *asv, XImage *xim, struct ASScanline *sl, int y,  register unsigned char *xim_data );
00317 void ximage2scanline_pseudo12bpp( ASVisual *asv, XImage *xim, struct ASScanline *sl, int y,  register unsigned char *xim_data );
00318 
00319 void scanline2ximage32( ASVisual *asv, XImage *xim, struct ASScanline *sl, int y,  register unsigned char *xim_data );
00320 void scanline2ximage16( ASVisual *asv, XImage *xim, struct ASScanline *sl, int y,  register unsigned char *xim_data );
00321 void scanline2ximage15( ASVisual *asv, XImage *xim, struct ASScanline *sl, int y,  register unsigned char *xim_data );
00322 void scanline2ximage_pseudo3bpp( ASVisual *asv, XImage *xim, struct ASScanline *sl, int y,  register unsigned char *xim_data );
00323 void scanline2ximage_pseudo6bpp( ASVisual *asv, XImage *xim, struct ASScanline *sl, int y,  register unsigned char *xim_data );
00324 void scanline2ximage_pseudo12bpp( ASVisual *asv, XImage *xim, struct ASScanline *sl, int y,  register unsigned char *xim_data );
00325 
00326 /****f* libAfterImage/query_screen_visual()
00327  * NAME
00328  * query_screen_visual_id()
00329  * NAME
00330  * query_screen_visual()
00331  * SYNOPSIS
00332  * Bool query_screen_visual_id( ASVisual *asv, Display *dpy, int screen,
00333  *                           Window root, int default_depth,
00334  *                                                       VisualID visual_id, Colormap cmap );
00335  * Bool query_screen_visual( ASVisual *asv, Display *dpy, int screen,
00336  *                           Window root, int default_depth );
00337  * INPUTS
00338  * asv                  - preallocated ASVisual structure.
00339  * dpy                  - valid pointer to opened X display.
00340  * screen       - screen number on which to query visuals.
00341  * root         - root window on that screen.
00342  * default_depth- default colordepth of the screen.
00343  * visual_id    - optional ID of prefered Visual.
00344  * cmap         - optional colormap to be used.
00345  * RETURN VALUE
00346  * True on success, False on failure
00347  * ASVisual structure pointed by asv will have the following data
00348  * members set on success :
00349  * dpy, visual_info, colormap, own_colormap, black_pixel, white_pixel.
00350  * DESCRIPTION
00351  * query_screen_visual_id() will go though prioritized list of possible
00352  * Visuals and attempt to match those to what is available on the
00353  * specified screen. If all items from list fail, then it goes about
00354  * querying default visual.
00355  * query_screen_visual is identical to query_screen_visual_id with
00356  * visual_id and cmap set to 0.
00357  * Once X Visual has been identified, we create X colormap and allocate
00358  * white and black pixels from it.
00359  *********/
00360 /****f* libAfterImage/setup_truecolor_visual()
00361  * NAME
00362  * setup_truecolor_visual()
00363  * SYNOPSIS
00364  * Bool setup_truecolor_visual( ASVisual *asv );
00365  * INPUTS
00366  * asv                  - preallocated ASVisual structure.
00367  * RETURN VALUE
00368  * True on success, False if visual is not TrueColor.
00369  * DESCRIPTION
00370  * setup_truecolor_visual() checks if Visual is indeed TrueColor and if
00371  * so it goes about querying color masks, deducing real XImage
00372  * colordepth, and whether we work in BGR mode. It then goes about
00373  * setting up correct hooks to X IO functions.
00374  *********/
00375 /****f* libAfterImage/setup_pseudo_visual()
00376  * NAME
00377  * setup_pseudo_visual()
00378  * SYNOPSIS
00379  * void setup_pseudo_visual( ASVisual *asv  );
00380  * INPUTS
00381  * asv                  - preallocated ASVisual structure.
00382  * DESCRIPTION
00383  * setup_pseudo_visual() assumes that Visual is PseudoColor. It then
00384  * tries to decide as to how many colors preallocate, and goes about
00385  * setting up correct X IO hooks and possibly initialization of reverse
00386  * colormap in case ASVisual already has colormap preallocated.
00387  *********/
00388 /****f* libAfterImage/setup_as_colormap()
00389  * NAME
00390  * setup_as_colormap()
00391  * SYNOPSIS
00392  * void setup_as_colormap( ASVisual *asv );
00393  * INPUTS
00394  * asv                  - preallocated ASVisual structure.
00395  * DESCRIPTION
00396  * That has to be called in order to pre-allocate sufficient number of
00397  * colors. It uses colormap size identification supplied in ASVisual
00398  * structure. If colors where preallocated successfully - it will also
00399  * create reverse lookup colormap.
00400  *********/
00401 
00402 Bool query_screen_visual_id( ASVisual *asv, Display *dpy, int screen,
00403                                  Window root, int default_depth,
00404                                                          VisualID visual_id, Colormap cmap );
00405 #define query_screen_visual(a,d,s,r,dd) query_screen_visual_id((a),(d),(s),(r),(dd),0,0)
00406 
00407 Bool setup_truecolor_visual( ASVisual *asv );
00408 void setup_pseudo_visual( ASVisual *asv  );
00409 void setup_as_colormap( ASVisual *asv );
00410 /****f* libAfterImage/create_asvisual_for_id()
00411  * NAME
00412  * create_asvisual_for_id()
00413  * SYNOPSIS
00414  * ASVisual *create_asvisual_for_id( Display *dpy, int screen,
00415  *                                   int default_depth,
00416  *                                   VisualID visual_id, Colormap cmap,
00417  *                                   ASVisual *reusable_memory );
00418  * INPUTS
00419  * dpy                  - valid pointer to opened X display.
00420  * screen       - screen number on which to query visuals.
00421  * root         - root window on that screen.
00422  * default_depth- default colordepth of the screen.
00423  * visual_id    - ID of X visual to use.
00424  * cmap         - optional ID of the colormap to be used.
00425  * reusable_memory - pointer to preallocated ASVisual structure.
00426  * RETURN VALUE
00427  * Pointer to ASVisual structure initialized with enough information
00428  * to be able to deal with current X Visual.
00429  * DESCRIPTION
00430  * This function calls all the needed functions in order to setup new
00431  * ASVisual structure for the specified screen and visual. If
00432  * reusable_memory is not null - it will not allocate new ASVisual
00433  * structure, but instead will use supplied one. Useful for allocating
00434  * ASVisual on stack.
00435  * This particular function will not do any autodetection and will use
00436  * Visual ID supplied. That is usefull when libAfterImage is used with
00437  * an app that has its own approach to Visual handling, and since Visuals
00438  * on all Windows, Pixmaps and colormaps must match, there is a need to
00439  * synchronise visuals used by an app and libAfterImage.
00440  *********/
00441 /****f* libAfterImage/create_asvisual()
00442  * NAME
00443  * create_asvisual()
00444  * SYNOPSIS
00445  * ASVisual *create_asvisual( Display *dpy, int screen,
00446  *                            int default_depth,
00447  *                            ASVisual *reusable_memory );
00448  * INPUTS
00449  * dpy                  - valid pointer to opened X display.
00450  * screen       - screen number on which to query visuals.
00451  * root         - root window on that screen.
00452  * default_depth- default colordepth of the screen.
00453  * reusable_memory - pointer to preallocated ASVisual structure.
00454  * RETURN VALUE
00455  * Pointer to ASVisual structure initialized with enough information
00456  * to be able to deal with current X Visual.
00457  * DESCRIPTION
00458  * This function calls all the needed functions in order to setup new
00459  * ASVisual structure for the specified screen. If reusable_memory is
00460  * not null - it will not allocate new ASVisual structure, but instead
00461  * will use supplied one. Useful for allocating ASVisual on stack.
00462  * It is different from create_asvisualfor_id() in that it will attempt
00463  * to autodetect best possible visual for the screen. For example on some
00464  * SUN Solaris X servers there will be both 8bpp pseudocolor and 24bpp
00465  * truecolor, and default will be 8bpp. In this scenario libAfterImage
00466  * will detect and use 24bpp true color visual, thus producing much better
00467  * results.
00468  *********/
00469 
00470 /****f* libAfterImage/destroy_asvisual()
00471  * NAME
00472  * destroy_asvisual()
00473  * SYNOPSIS
00474  * void destroy_asvisual( ASVisual *asv, Bool reusable );
00475  * INPUTS
00476  * asv      - valid ASVisual structure.
00477  * reusable - if True it will cause function to not free object
00478  *            itself.
00479  * DESCRIPTION
00480  * Cleanup function. Frees all the memory and deallocates all the
00481  * resources. If reusable is False it will also free the object, pointed
00482  * to by asv.
00483  * EXAMPLE
00484  * asview.c: ASView.2
00485  *********/
00486 ASVisual *create_asvisual_for_id( Display *dpy, int screen, int default_depth,
00487                                       VisualID visual_id, Colormap cmap,
00488                                                                   ASVisual *reusable_memory );
00489 ASVisual *create_asvisual( Display *dpy, int screen, int default_depth,
00490                                ASVisual *reusable_memory );
00491 ASVisual *get_default_asvisual();
00492 void destroy_asvisual( ASVisual *asv, Bool reusable );
00493 /****f* libAfterImage/visual2visual_prop()
00494  * NAME
00495  * visual2visual_prop()
00496  * SYNOPSIS
00497  * Bool visual2visual_prop( ASVisual *asv, size_t *size,
00498  *                          unsigned long *version, unsigned long **data );
00499  * INPUTS
00500  * asv          - valid ASVisual structure.
00501  * RETURN VALUE
00502  * size         - size of the encoded memory block.
00503  * version      - version of the encoding
00504  * data         - actual encoded memory block
00505  * True on success, False on failure
00506  * DESCRIPTION
00507  * This function will encode ASVisual structure into memory block of
00508  * 32 bit values, suitable for storing in X property.
00509  *********/
00510 /****f* libAfterImage/visual_prop2visual()
00511  * NAME
00512  * visual_prop2visual()
00513  * SYNOPSIS
00514  * Bool visual_prop2visual( ASVisual *asv, Display *dpy, int screen,
00515  *                          size_t size,
00516  *                          unsigned long version, unsigned long *data );
00517  * INPUTS
00518  * asv       - valid ASVisual structure.
00519  * dpy       - valid pointer to open X display.
00520  * screen    - screen number.
00521  * size      - encoded memory block's size.
00522  * version   - version of encoding.
00523  * data      - actual encoded memory block.
00524  * RETURN VALUE
00525  * True on success, False on failure
00526  * DESCRIPTION
00527  * visual_prop2visual() will read ASVisual data from the memory block
00528  * encoded by visual2visual_prop(). It could be used to read data from
00529  * X property and convert it into usable information - such as colormap,
00530  * visual info, etc.
00531  * Note: setup_truecolor_visual() or setup_pseudo_visual() has to be
00532  * invoked in order to complete ASVisual setup.
00533  *********/
00534 Bool visual2visual_prop( ASVisual *asv, size_t *size,
00535                              unsigned long *version, unsigned long **data );
00536 Bool visual_prop2visual( ASVisual *asv, Display *dpy, int screen,
00537                                                  size_t size,
00538                                                  unsigned long version, unsigned long *data );
00539 /* handy utility functions for creation of windows/pixmaps/XImages : */
00540 /* this is from xc/programs/xserver/dix/window.h */
00541 #define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \
00542                                                       CWDontPropagate | CWOverrideRedirect | \
00543                                                           CWCursor )
00544 /****f* libAfterImage/create_visual_window()
00545  * NAME
00546  * create_visual_window()
00547  * SYNOPSIS
00548  * Window  create_visual_window( ASVisual *asv, Window parent,
00549  *                               int x, int y,
00550  *                               unsigned int width, unsigned int height,
00551  *                               unsigned int border_width,
00552  *                               unsigned int wclass,
00553  *                               unsigned long mask,
00554  *                               XSetWindowAttributes *attributes );
00555  * INPUTS
00556  * asv           - pointer to the valid ASVisual structure.
00557  * parent        - Window ID of the parent the window.
00558  * x, y          - initial position of the new window.
00559  * width, height - initial size of the new window.
00560  * border_width  - initial border width of the new window.
00561  * wclass         - Window class  - InputOnly or InputOutput.
00562  * mask          - defines what attributes are set.
00563  * attributes    - different window attributes.
00564  * RETURN VALUE
00565  * ID of the newly created window on success. None on failure.
00566  * DESCRIPTION
00567  * create_visual_window() will do sanity checks on passed parameters,
00568  * it will then add mandatory attributes if needed, and attempt to
00569  * create window for the specified ASVisual.
00570  *********/
00571 /****f* libAfterImage/create_visual_gc()
00572  * NAME
00573  * create_visual_gc()
00574  * SYNOPSIS
00575  * GC      create_visual_gc( ASVisual *asv, Window root,
00576  *                           unsigned long mask, XGCValues *gcvalues );
00577  * INPUTS
00578  * asv            - pointer to the valid ASVisual structure.
00579  * root           - Window ID of the root window of destination screen
00580  * mask, gcvalues - values for creation of new GC - see XCreateGC() for
00581  *                  details.
00582  * RETURN VALUE
00583  * New GC created for regular window on success. NULL on failure.
00584  * DESCRIPTION
00585  * create_visual_gc() will create temporary window for the ASVisual
00586  * specific depth and Visual and it will then create GC for such window.
00587  * Obtained GC should be good to be used for manipulation of windows and
00588  * Pixmaps created for the same ASVisual.
00589  *********/
00590 /****f* libAfterImage/create_visual_pixmap()
00591  * NAME
00592  * create_visual_pixmap()
00593  * SYNOPSIS
00594  * Pixmap  create_visual_pixmap( ASVisual *asv, Window root,
00595  *                               unsigned int width, unsigned int height,
00596  *                               unsigned int depth );
00597  * INPUTS
00598  * asv            - pointer to the valid ASVisual structure.
00599  * root           - Window ID of the root window of destination screen
00600  * width, height  - size of the pixmap to create.
00601  * depth          - depth of the pixmap to create. If 0 asv->true_depth
00602  *                  will be used.
00603  * RETURN VALUE
00604  * ID of the newly created pixmap on success. None on failure.
00605  * DESCRIPTION
00606  * create_visual_pixmap() will perform sanity checks on passed
00607  * parameters, and attempt to create pixmap for the specified ASVisual,
00608  * root and depth.
00609  *********/
00610 /****f* libAfterImage/create_visual_ximage()
00611  * NAME
00612  * create_visual_ximage()
00613  * SYNOPSIS
00614  * XImage* create_visual_ximage( ASVisual *asv,
00615  *                               unsigned int width, unsigned int height,
00616  *                               unsigned int depth );
00617  * INPUTS
00618  * asv            - pointer to the valid ASVisual structure.
00619  * width, height  - size of the XImage to create.
00620  * depth          - depth of the XImage to create. If 0 asv->true_depth
00621  *                  will be used.
00622  * RETURN VALUE
00623  * pointer to newly created XImage on success. NULL on failure.
00624  * DESCRIPTION
00625  * create_visual_ximage() will perform sanity checks on passed
00626  * parameters, and it will attempt to create XImage of sufficient size,
00627  * and specified colordepth. It will also setup hooks for XImage
00628  * deallocation to be handled by custom function.
00629  *********/
00630 Window  create_visual_window( ASVisual *asv, Window parent,
00631                                                           int x, int y,
00632                                                           unsigned int width, unsigned int height,
00633                                                           unsigned int border_width,
00634                                                           unsigned int wclass,
00635                                                           unsigned long mask,
00636                                                           XSetWindowAttributes *attributes );
00637 GC      create_visual_gc( ASVisual *asv, Window root,
00638                                   unsigned long mask, XGCValues *gcvalues );
00639 Pixmap  create_visual_pixmap( ASVisual *asv, Window root,
00640                                   unsigned int width, unsigned int height,
00641                                                           unsigned int depth );
00642 void destroy_visual_pixmap( ASVisual *asv, Pixmap *ppmap );
00643 
00644 int get_dpy_drawable_size (Display *drawable_dpy, Drawable d, unsigned int *ret_w, unsigned int *ret_h);
00645 Bool get_dpy_window_position (Display *window_dpy, Window root, Window w, int *px, int *py, int *transparency_x, int *transparency_y);
00646 
00647 
00648 XImage* create_visual_ximage( ASVisual *asv,
00649                                   unsigned int width, unsigned int height,
00650                                                           unsigned int depth );
00651 XImage* create_visual_scratch_ximage( ASVisual *asv,
00652                                   unsigned int width, unsigned int height,
00653                                                           unsigned int depth );
00654 
00655 #define ASSHM_SAVED_MAX (256*1024)
00656 
00657 #ifdef XSHMIMAGE
00658 Bool destroy_xshm_segment( unsigned long );
00659 unsigned long ximage2shmseg( XImage *xim );
00660 void flush_shm_cache();
00661 #endif
00662 Bool enable_shmem_images ();
00663 void disable_shmem_images();
00664 Bool check_shmem_images_enabled();
00665 
00666 void* check_XImage_shared( XImage *xim );
00667 Bool ASPutXImage( ASVisual *asv, Drawable d, GC gc, XImage *xim,
00668                   int src_x, int src_y, int dest_x, int dest_y,
00669                                   unsigned int width, unsigned int height );
00670 XImage * ASGetXImage( ASVisual *asv, Drawable d,
00671                   int x, int y, unsigned int width, unsigned int height,
00672                                   unsigned long plane_mask );
00673 
00674 
00675 #ifdef __cplusplus
00676 }
00677 #endif
00678 
00679 #endif /* _SCREEN_ */

Generated on Tue Jul 5 14:13:27 2011 for ROOT_528-00b_version by  doxygen 1.5.1