home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / SVGALIB / SVGALIB1.TAR / svgalib / src / accel.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-12  |  6.7 KB  |  177 lines

  1.  
  2. #ifndef ACCEL_H
  3. #define ACCEL_H
  4.  
  5. /*
  6.  * New accelerator interface sketch.
  7.  * As of svgalib 1.23, this isn't used yet.
  8.  *
  9.  * The main goal is to define functions that can be used as part of
  10.  * certain kinds of interesting graphical operations (not necessarily
  11.  * interesting primitives on their own). Obvious useful primitives
  12.  * in their own are FillBox, ScreenCopy, DrawHLineList (solid polygon),
  13.  * DrawLine.
  14.  *
  15.  * An interesting purpose is the fast drawing of color bitmaps, both
  16.  * straight and transparent (masked, certain color not written). For
  17.  * masked bitmaps ("sprites"), there is a number of possible methods,
  18.  * the availability of which depends on the chips. Caching in
  19.  * non-visible video memory is often useful. One way is to use a
  20.  * transparency color compare feature of a BITBLT chip, either
  21.  * transferring the image from system memory or cached in video memory.
  22.  * If transparency compare is not available, it may be possible to first
  23.  * clear (zeroes) the mask in the destination area, and then use BITBLT
  24.  * raster-operation to OR the image into the destination (this requires
  25.  * the mask color to be 0). A higher level (library) interface should
  26.  * control this kind of operation.
  27.  */
  28.  
  29.  
  30. typedef struct {
  31. /* Graphics mode-independent fields. */
  32.     int flags;
  33.     /*
  34.      * The following fields define lists of linewidths in pixel
  35.      * units that the accelerator supports for each depth. Each
  36.      * list is terminated by 0. These fields are only relevant
  37.      * if the ACCELERATE_ANY_LINEWIDTH flag is not set.
  38.      */
  39.     int *supportedLineWidths8bpp;
  40.     int *supportedLineWidths16bpp;
  41.     int *supportedLineWidths24bpp;
  42.     int *supportedLineWidths32bpp;
  43.     /*
  44.      * The following function sets up the accelerator interface for
  45.      * pixels of size bpp and scanline width of width_in_pixels.
  46.      */
  47.     void (*initAccelerator)(int bpp, int width_in_pixels);
  48. /* Fields that are initialized after setting a graphics mode. */
  49.     /*
  50.      * The following field defines which accelerated primitives are
  51.      * available in the selected graphics mode.
  52.      */
  53.     int operations;
  54.     /*
  55.      * The following field defines which accelerated primitives are
  56.      * available with special raster-ops in the selected graphics mode.
  57.      */
  58.     int ropOperations;
  59.     /*
  60.      * The following field defines which accelerated primitives are
  61.      * available with transparency in the selected graphics mode.
  62.      */
  63.     int transparencyOperations;
  64. /* Acceleration primitive functions. */
  65.     void (*FillBox)(int x, int y, int width, int height);
  66.     void (*ScreenCopy)(int x1, int y1, int x2, int y2, int width,
  67.         int height);
  68.     void (*PutImage)(int x, int y, int width, int height, void *image);
  69.     void (*DrawLine)(int x1, int y1, int x2, int y2);
  70.     void (*SetFGColor)(int c);
  71.     void (*SetBGColor)(int c);
  72.     void (*SetRasterOp)(int rop);
  73.     void (*SetTransparency)(int mode, int color);
  74.     void (*PutBitmap)(int x, int y, int w, int h, void *bitmap);
  75.     void (*ScreenCopyBitmap)(int x1, int y1, int x2, int y2, int width,
  76.         int height);
  77.     void (*DrawHLineList)(int ymin, int n, int *xmin, int *xmax);
  78.     void (*SetMode)();
  79.     void (*Sync)();
  80. } AccelSpecs;
  81.  
  82. /* Flags: */
  83. /* Every programmable scanline width is supported by the accelerator. */
  84. #define ACCELERATE_ANY_LINEWIDTH    0x1
  85. /* Bitmap (1-bit-per-pixel) operations support transparency (bit = 0). */
  86. #define BITMAP_TRANSPARENCY        0x2
  87. /* For bitmaps (1 bpp) stored in video memory, the most-significant bit */
  88. /* within a byte is the leftmost pixel. */
  89. #define BITMAP_ORDER_MSB_FIRST        0x4
  90.  
  91. /* Operation flags: see vga.h. */
  92.  
  93. /*
  94.  * Acceleration primitive description:
  95.  *
  96.  * FillBox    Simple solid fill of rectangle with a single color.
  97.  * ScreenCopy    Screen-to-screen BLT (BitBlt), handles overlapping areas.
  98.  * PutImage    Straight image transfer (PutImage). Advantage over
  99.  *        framebuffer writes is mainly in alignment handling.
  100.  * DrawLine    Draw general line ("zero-pixel wide").
  101.  * SetFGColor    Set foreground color for some operations (FillBox, DrawLine,
  102.  *        PutBitmap).
  103.  * SetBGColor    Set background color for some operations (PutBitmap).
  104.  * SetRasterOp    Set the raster operation for drawing operations that support
  105.  *        raster ops as defined in ropOperations.
  106.  * SetTransparency
  107.  *        Set the transparency mode for some operations (enable/disable,
  108.  *        and the transparency pixel value). Source pixels equal to
  109.  *        the transparency color are not written. Operations supported
  110.  *        are ScreenCopy and PutImage, subject to their flags being set
  111.  *         in the transparencyOperations field.
  112.  * PutBitmap    Color-expand a bit-wise (bit-per-pixel, each byte is 8 pixels)
  113.  *        image to the screen with the foreground and background color.
  114.  *        The lowest order bit of each byte is leftmost on the screen
  115.  *        (contrary to the VGA tradition), irrespective of the bitmap
  116.  *        bit order flag. Each scanline is aligned to a multiple of
  117.  *        32-bits.
  118.  *        If the transparency mode is enabled (irrespective of the
  119.  *        transparency color), then bits that are zero in the bitmap
  120.  *        are not written (the background color is not used).
  121.  * ScreenCopyBitmap
  122.  *        Color-expand bit-wise bitmap stored in video memory
  123.  *        (may also support transparency).
  124.  * DrawHLineList
  125.  *        Draw a set of horizontal line segments from top to bottom
  126.  *        in the foreground color.
  127.  * SetMode    Set the acceleration mode, e.g. let blits go
  128.  *        on in the background (program must not access video memory
  129.  *        when blits can be running).
  130.  * Sync        Wait for any background blits to finish.
  131.  *
  132.  * It is not the intention to have alternative non-accelerated routines
  133.  * available for each possible operation (library functions should
  134.  * take advantage of accelerator functions, rather than the accelerator
  135.  * functions being primitives on their own right). If something like
  136.  * bit-order reversal is required to implement an accelerated primitive,
  137.  * it's still worthwhile if it's still much quicker than similar
  138.  * unaccelerated functionality would be.
  139.  *
  140.  * Strategy for accelerator registers in accelerated functions:
  141.  *    Foreground color, background color, raster operation and transparency
  142.  *     compare setting are preserved, source and destination pitch is always
  143.  *    set to screen pitch (may be temporarily changed and then restored).
  144.  */
  145.  
  146.  
  147. /* Macros. */
  148.  
  149. #define BLTBYTEADDRESS(x, y) \
  150.     (y * accel_screenpitchinbytes + x * accel_bytesperpixel)
  151.  
  152.  
  153. /* Variables defined in accel.c */
  154.  
  155. extern int accel_screenpitch;
  156. extern int accel_bytesperpixel;
  157. extern int accel_screenpitchinbytes;
  158. extern int accel_mode;
  159. extern int accel_bitmaptransparency;
  160.  
  161. /*
  162.  * The following function should be called when the mode is set.
  163.  * This is currently done in the setmode driver functions.
  164.  */
  165.  
  166. void InitializeAcceleratorInterface( ModeInfo *modeinfo );
  167.  
  168. /*
  169.  * The following driver function fills in available accelerator
  170.  * primitives for a graphics mode (operations etc.). It could be part
  171.  * of the setmode driver function.
  172.  *
  173.  * void initOperations( AccelSpecs *accelspecs, int bpp, int width_in_pixels );
  174.  */
  175.  
  176. #endif
  177.