1 | /*
|
---|
2 | *
|
---|
3 | * Copyright (C) 2000 Keith Packard
|
---|
4 | * 2004 Eric Anholt
|
---|
5 | * 2005 Zack Rusin
|
---|
6 | *
|
---|
7 | * Permission to use, copy, modify, distribute, and sell this software and its
|
---|
8 | * documentation for any purpose is hereby granted without fee, provided that
|
---|
9 | * the above copyright notice appear in all copies and that both that
|
---|
10 | * copyright notice and this permission notice appear in supporting
|
---|
11 | * documentation, and that the name of copyright holders not be used in
|
---|
12 | * advertising or publicity pertaining to distribution of the software without
|
---|
13 | * specific, written prior permission. Copyright holders make no
|
---|
14 | * representations about the suitability of this software for any purpose. It
|
---|
15 | * is provided "as is" without express or implied warranty.
|
---|
16 | *
|
---|
17 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
---|
18 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
---|
19 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
---|
20 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
---|
21 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
---|
22 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
---|
23 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
24 | * SOFTWARE.
|
---|
25 | */
|
---|
26 | #ifndef EXA_H
|
---|
27 | #define EXA_H
|
---|
28 |
|
---|
29 | #include "scrnintstr.h"
|
---|
30 | #include "pixmapstr.h"
|
---|
31 | #include "windowstr.h"
|
---|
32 | #include "gcstruct.h"
|
---|
33 | #include "picturestr.h"
|
---|
34 |
|
---|
35 | #define EXA_VERSION_MAJOR 0
|
---|
36 | #define EXA_VERSION_MINOR 2
|
---|
37 | #define EXA_VERSION_RELEASE 0
|
---|
38 |
|
---|
39 | typedef struct _ExaOffscreenArea ExaOffscreenArea;
|
---|
40 |
|
---|
41 | typedef void (*ExaOffscreenSaveProc) (ScreenPtr pScreen, ExaOffscreenArea *area);
|
---|
42 |
|
---|
43 | typedef enum _ExaOffscreenState {
|
---|
44 | ExaOffscreenAvail,
|
---|
45 | ExaOffscreenRemovable,
|
---|
46 | ExaOffscreenLocked
|
---|
47 | } ExaOffscreenState;
|
---|
48 |
|
---|
49 | struct _ExaOffscreenArea {
|
---|
50 | int base_offset; /* allocation base */
|
---|
51 | int offset; /* aligned offset */
|
---|
52 | int size; /* total allocation size */
|
---|
53 | int score;
|
---|
54 | pointer privData;
|
---|
55 |
|
---|
56 | ExaOffscreenSaveProc save;
|
---|
57 |
|
---|
58 | ExaOffscreenState state;
|
---|
59 |
|
---|
60 | ExaOffscreenArea *next;
|
---|
61 | };
|
---|
62 |
|
---|
63 | typedef struct _ExaCardInfo {
|
---|
64 | /* These are here because I don't want to be adding more to
|
---|
65 | * ScrnInfoRec */
|
---|
66 | CARD8 *memoryBase;
|
---|
67 | unsigned long offScreenBase;
|
---|
68 |
|
---|
69 | /* It's fix.smem_len.
|
---|
70 | This one could be potentially substituted by ScrnInfoRec
|
---|
71 | videoRam member, but I do not want to be doing the silly
|
---|
72 | << 10, >>10 all over the place */
|
---|
73 | unsigned long memorySize;
|
---|
74 |
|
---|
75 | int pixmapOffsetAlign;
|
---|
76 | int pixmapPitchAlign;
|
---|
77 | int flags;
|
---|
78 |
|
---|
79 | /* The coordinate limitations for rendering for this hardware.
|
---|
80 | * Exa breaks larger pixmaps into smaller pieces and calls Prepare multiple times
|
---|
81 | * to handle larger pixmaps
|
---|
82 | */
|
---|
83 | int maxX;
|
---|
84 | int maxY;
|
---|
85 |
|
---|
86 | /* private */
|
---|
87 | ExaOffscreenArea *offScreenAreas;
|
---|
88 | Bool needsSync;
|
---|
89 | int lastMarker;
|
---|
90 | } ExaCardInfoRec, *ExaCardInfoPtr;
|
---|
91 |
|
---|
92 | typedef struct _ExaAccelInfo {
|
---|
93 | /* PrepareSolid may fail if the pixmaps can't be accelerated to/from.
|
---|
94 | * This is an important feature for handling strange corner cases
|
---|
95 | * in hardware that are poorly expressed through flags.
|
---|
96 | */
|
---|
97 | Bool (*PrepareSolid) (PixmapPtr pPixmap,
|
---|
98 | int alu,
|
---|
99 | Pixel planemask,
|
---|
100 | Pixel fg);
|
---|
101 | void (*Solid) (PixmapPtr pPixmap, int x1, int y1, int x2, int y2);
|
---|
102 | void (*DoneSolid) (PixmapPtr pPixmap);
|
---|
103 |
|
---|
104 | /* PrepareSolid may fail if the pixmaps can't be accelerated to/from.
|
---|
105 | * This is an important feature for handling strange corner cases
|
---|
106 | * in hardware that are poorly expressed through flags.
|
---|
107 | */
|
---|
108 | Bool (*PrepareCopy) (PixmapPtr pSrcPixmap,
|
---|
109 | PixmapPtr pDstPixmap,
|
---|
110 | int dx,
|
---|
111 | int dy,
|
---|
112 | int alu,
|
---|
113 | Pixel planemask);
|
---|
114 | void (*Copy) (PixmapPtr pDstPixmap,
|
---|
115 | int srcX,
|
---|
116 | int srcY,
|
---|
117 | int dstX,
|
---|
118 | int dstY,
|
---|
119 | int width,
|
---|
120 | int height);
|
---|
121 | void (*DoneCopy) (PixmapPtr pDstPixmap);
|
---|
122 |
|
---|
123 | /* The Composite hooks are a wrapper around the Composite operation.
|
---|
124 | * The CheckComposite occurs before pixmap migration occurs,
|
---|
125 | * and may fail for many hardware-dependent reasons.
|
---|
126 | * PrepareComposite should not fail, and the Bool return may
|
---|
127 | * not be necessary if we can
|
---|
128 | * adequately represent pixmap location/pitch limitations..
|
---|
129 | */
|
---|
130 | Bool (*CheckComposite) (int op,
|
---|
131 | PicturePtr pSrcPicture,
|
---|
132 | PicturePtr pMaskPicture,
|
---|
133 | PicturePtr pDstPicture);
|
---|
134 | Bool (*PrepareComposite) (int op,
|
---|
135 | PicturePtr pSrcPicture,
|
---|
136 | PicturePtr pMaskPicture,
|
---|
137 | PicturePtr pDstPicture,
|
---|
138 | PixmapPtr pSrc,
|
---|
139 | PixmapPtr pMask,
|
---|
140 | PixmapPtr pDst);
|
---|
141 | void (*Composite) (PixmapPtr pDst,
|
---|
142 | int srcX,
|
---|
143 | int srcY,
|
---|
144 | int maskX,
|
---|
145 | int maskY,
|
---|
146 | int dstX,
|
---|
147 | int dstY,
|
---|
148 | int width,
|
---|
149 | int height);
|
---|
150 | void (*DoneComposite) (PixmapPtr pDst);
|
---|
151 |
|
---|
152 | /* Attempt to upload the data from src into the rectangle of the
|
---|
153 | * in-framebuffer pDst beginning at x,y and of width w,h. May fail.
|
---|
154 | */
|
---|
155 | Bool (*UploadToScreen) (PixmapPtr pDst,
|
---|
156 | int x,
|
---|
157 | int y,
|
---|
158 | int w,
|
---|
159 | int h,
|
---|
160 | char *src,
|
---|
161 | int src_pitch);
|
---|
162 | Bool (*UploadToScratch) (PixmapPtr pSrc,
|
---|
163 | PixmapPtr pDst);
|
---|
164 |
|
---|
165 | /* Attempt to download the rectangle from the in-framebuffer pSrc into
|
---|
166 | * dst, given the pitch. May fail. Since it is likely
|
---|
167 | * accelerated, a markSync will follow it as with other acceleration
|
---|
168 | * hooks.
|
---|
169 | */
|
---|
170 | Bool (*DownloadFromScreen)(PixmapPtr pSrc,
|
---|
171 | int x, int y,
|
---|
172 | int w, int h,
|
---|
173 | char *dst, int dst_pitch);
|
---|
174 |
|
---|
175 | /* Should return a hrdware-dependent marker number which can
|
---|
176 | * be waited for with WaitMarker. It can be not implemented in which
|
---|
177 | * case WaitMarker must wait for idle on any given marker
|
---|
178 | * number.
|
---|
179 | */
|
---|
180 | int (*MarkSync) (ScreenPtr pScreen);
|
---|
181 | void (*WaitMarker) (ScreenPtr pScreen, int marker);
|
---|
182 |
|
---|
183 | /* These are wrapping all fb or composite operations that will cause
|
---|
184 | * a direct access to the framebuffer. You can use them to update
|
---|
185 | * endian swappers, force migration to RAM, or whatever else you find
|
---|
186 | * useful at this point. EXA can stack up to 3 calls to Prepare/Finish
|
---|
187 | * access, though they will have a different index. If your hardware
|
---|
188 | * doesn't have enough separate configurable swapper, you can return
|
---|
189 | * FALSE from PrepareAccess() to force EXA to migrate the pixmap to RAM.
|
---|
190 | * Note that DownloadFromScreen and UploadToScreen can both be called
|
---|
191 | * between PrepareAccess() and FinishAccess(). If they need to use a
|
---|
192 | * swapper, they should save & restore its setting.
|
---|
193 | */
|
---|
194 | Bool (*PrepareAccess)(PixmapPtr pPix, int index);
|
---|
195 | void (*FinishAccess)(PixmapPtr pPix, int index);
|
---|
196 | #define EXA_PREPARE_DEST 0
|
---|
197 | #define EXA_PREPARE_SRC 1
|
---|
198 | #define EXA_PREPARE_MASK 2
|
---|
199 |
|
---|
200 | } ExaAccelInfoRec, *ExaAccelInfoPtr;
|
---|
201 |
|
---|
202 | typedef struct _ExaDriver {
|
---|
203 | ExaCardInfoRec card;
|
---|
204 | ExaAccelInfoRec accel;
|
---|
205 | } ExaDriverRec, *ExaDriverPtr;
|
---|
206 |
|
---|
207 | #define EXA_OFFSCREEN_PIXMAPS (1 << 0)
|
---|
208 | #define EXA_OFFSCREEN_ALIGN_POT (1 << 1)
|
---|
209 |
|
---|
210 |
|
---|
211 | #define EXA_MAKE_VERSION(a, b, c) (((a) << 16) | ((b) << 8) | (c))
|
---|
212 | #define EXA_VERSION \
|
---|
213 | EXA_MAKE_VERSION(EXA_VERSION_MAJOR, EXA_VERSION_MINOR, EXA_VERSION_RELEASE)
|
---|
214 | #define EXA_IS_VERSION(a,b,c) (EXA_VERSION >= EXA_MAKE_VERSION(a,b,c))
|
---|
215 |
|
---|
216 | unsigned int
|
---|
217 | exaGetVersion(void);
|
---|
218 |
|
---|
219 | Bool
|
---|
220 | exaDriverInit(ScreenPtr pScreen,
|
---|
221 | ExaDriverPtr pScreenInfo);
|
---|
222 |
|
---|
223 | void
|
---|
224 | exaDriverFini(ScreenPtr pScreen);
|
---|
225 |
|
---|
226 | void
|
---|
227 | exaMarkSync(ScreenPtr pScreen);
|
---|
228 | void
|
---|
229 | exaWaitSync(ScreenPtr pScreen);
|
---|
230 |
|
---|
231 | Bool
|
---|
232 | exaOffscreenInit(ScreenPtr pScreen);
|
---|
233 |
|
---|
234 | ExaOffscreenArea *
|
---|
235 | exaOffscreenAlloc(ScreenPtr pScreen, int size, int align,
|
---|
236 | Bool locked,
|
---|
237 | ExaOffscreenSaveProc save,
|
---|
238 | pointer privData);
|
---|
239 |
|
---|
240 | ExaOffscreenArea *
|
---|
241 | exaOffscreenFree(ScreenPtr pScreen, ExaOffscreenArea *area);
|
---|
242 |
|
---|
243 | unsigned long
|
---|
244 | exaGetPixmapOffset(PixmapPtr pPix);
|
---|
245 |
|
---|
246 | unsigned long
|
---|
247 | exaGetPixmapPitch(PixmapPtr pPix);
|
---|
248 |
|
---|
249 | unsigned long
|
---|
250 | exaGetPixmapSize(PixmapPtr pPix);
|
---|
251 |
|
---|
252 | #define exaInitCard(exa, sync, memory_base, off_screen_base, memory_size, \
|
---|
253 | offscreen_byte_align, offscreen_pitch, flags, \
|
---|
254 | max_x, max_y) \
|
---|
255 | (exa)->card.Sync = sync; \
|
---|
256 | (exa)->card.memoryBase = memory_base; \
|
---|
257 | (exa)->card.offScreenBase = off_screen_base; \
|
---|
258 | (exa)->card.memorySize = memory_size; \
|
---|
259 | (exa)->card.offscreenByteAlign = offscreen_byte_align; \
|
---|
260 | (exa)->card.offscreenPitch = offscreen_pitch; \
|
---|
261 | (exa)->card.flags = flags; \
|
---|
262 | (exa)->card.maxX = max_x; \
|
---|
263 | (exa)->card.maxY = max_y
|
---|
264 |
|
---|
265 | #endif /* EXA_H */
|
---|