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