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 |
|
---|
27 | /** @file
|
---|
28 | * This is the header containing the public API of EXA for exa drivers.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #ifndef EXA_H
|
---|
32 | #define EXA_H
|
---|
33 |
|
---|
34 | #include "scrnintstr.h"
|
---|
35 | #include "pixmapstr.h"
|
---|
36 | #include "windowstr.h"
|
---|
37 | #include "gcstruct.h"
|
---|
38 | #include "picturestr.h"
|
---|
39 | #include "fb.h"
|
---|
40 |
|
---|
41 | #define EXA_VERSION_MAJOR 2
|
---|
42 | #define EXA_VERSION_MINOR 2
|
---|
43 | #define EXA_VERSION_RELEASE 0
|
---|
44 |
|
---|
45 | typedef struct _ExaOffscreenArea ExaOffscreenArea;
|
---|
46 |
|
---|
47 | typedef void (*ExaOffscreenSaveProc) (ScreenPtr pScreen, ExaOffscreenArea *area);
|
---|
48 |
|
---|
49 | typedef enum _ExaOffscreenState {
|
---|
50 | ExaOffscreenAvail,
|
---|
51 | ExaOffscreenRemovable,
|
---|
52 | ExaOffscreenLocked
|
---|
53 | } ExaOffscreenState;
|
---|
54 |
|
---|
55 | struct _ExaOffscreenArea {
|
---|
56 | int base_offset; /* allocation base */
|
---|
57 | int offset; /* aligned offset */
|
---|
58 | int size; /* total allocation size */
|
---|
59 | int score;
|
---|
60 | pointer privData;
|
---|
61 |
|
---|
62 | ExaOffscreenSaveProc save;
|
---|
63 |
|
---|
64 | ExaOffscreenState state;
|
---|
65 |
|
---|
66 | ExaOffscreenArea *next;
|
---|
67 | };
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * The ExaDriver structure is allocated through exaDriverAlloc(), and then
|
---|
71 | * fllled in by drivers.
|
---|
72 | */
|
---|
73 | typedef struct _ExaDriver {
|
---|
74 | /**
|
---|
75 | * exa_major and exa_minor should be set by the driver to the version of
|
---|
76 | * EXA which the driver was compiled for (or configures itself at runtime
|
---|
77 | * to support). This allows EXA to extend the structure for new features
|
---|
78 | * without breaking ABI for drivers compiled against older versions.
|
---|
79 | */
|
---|
80 | int exa_major, exa_minor;
|
---|
81 |
|
---|
82 | /**
|
---|
83 | * memoryBase is the address of the beginning of framebuffer memory.
|
---|
84 | * The visible screen should be within memoryBase to memoryBase +
|
---|
85 | * memorySize.
|
---|
86 | */
|
---|
87 | CARD8 *memoryBase;
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * offScreenBase is the offset from memoryBase of the beginning of the area
|
---|
91 | * to be managed by EXA's linear offscreen memory manager.
|
---|
92 | *
|
---|
93 | * In XFree86 DDX drivers, this is probably:
|
---|
94 | * (pScrn->displayWidth * cpp * pScrn->virtualY)
|
---|
95 | */
|
---|
96 | unsigned long offScreenBase;
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * memorySize is the length (in bytes) of framebuffer memory beginning
|
---|
100 | * from memoryBase.
|
---|
101 | *
|
---|
102 | * The offscreen memory manager will manage the area beginning at
|
---|
103 | * (memoryBase + offScreenBase), with a length of (memorySize -
|
---|
104 | * offScreenBase)
|
---|
105 | *
|
---|
106 | * In XFree86 DDX drivers, this is probably (pScrn->videoRam * 1024)
|
---|
107 | */
|
---|
108 | unsigned long memorySize;
|
---|
109 |
|
---|
110 | /**
|
---|
111 | * pixmapOffsetAlign is the byte alignment necessary for pixmap offsets
|
---|
112 | * within framebuffer.
|
---|
113 | *
|
---|
114 | * Hardware typically has a required alignment of offsets, which may or may
|
---|
115 | * not be a power of two. EXA will ensure that pixmaps managed by the
|
---|
116 | * offscreen memory manager meet this alignment requirement.
|
---|
117 | */
|
---|
118 | int pixmapOffsetAlign;
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * pixmapPitchAlign is the byte alignment necessary for pixmap pitches
|
---|
122 | * within the framebuffer.
|
---|
123 | *
|
---|
124 | * Hardware typically has a required alignment of pitches for acceleration.
|
---|
125 | * For 3D hardware, Composite acceleration often requires that source and
|
---|
126 | * mask pixmaps (textures) have a power-of-two pitch, which can be demanded
|
---|
127 | * using EXA_OFFSCREEN_ALIGN_POT. These pitch requirements only apply to
|
---|
128 | * pixmaps managed by the offscreen memory manager. Thus, it is up to the
|
---|
129 | * driver to ensure that the visible screen has an appropriate pitch for
|
---|
130 | * acceleration.
|
---|
131 | */
|
---|
132 | int pixmapPitchAlign;
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * The flags field is bitfield of boolean values controlling EXA's behavior.
|
---|
136 | *
|
---|
137 | * The flags in clude EXA_OFFSCREEN_PIXMAPS, EXA_OFFSCREEN_ALIGN_POT, and
|
---|
138 | * EXA_TWO_BITBLT_DIRECTIONS.
|
---|
139 | */
|
---|
140 | int flags;
|
---|
141 |
|
---|
142 | /** @{ */
|
---|
143 | /**
|
---|
144 | * maxX controls the X coordinate limitation for rendering from the card.
|
---|
145 | * The driver should never receive a request for rendering beyond maxX
|
---|
146 | * in the X direction from the origin of a pixmap.
|
---|
147 | */
|
---|
148 | int maxX;
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * maxY controls the Y coordinate limitation for rendering from the card.
|
---|
152 | * The driver should never receive a request for rendering beyond maxY
|
---|
153 | * in the Y direction from the origin of a pixmap.
|
---|
154 | */
|
---|
155 | int maxY;
|
---|
156 | /** @} */
|
---|
157 |
|
---|
158 | /* private */
|
---|
159 | ExaOffscreenArea *offScreenAreas;
|
---|
160 | Bool needsSync;
|
---|
161 | int lastMarker;
|
---|
162 |
|
---|
163 | /** @name Solid
|
---|
164 | * @{
|
---|
165 | */
|
---|
166 | /**
|
---|
167 | * PrepareSolid() sets up the driver for doing a solid fill.
|
---|
168 | * @param pPixmap Destination pixmap
|
---|
169 | * @param alu raster operation
|
---|
170 | * @param planemask write mask for the fill
|
---|
171 | * @param fg "foreground" color for the fill
|
---|
172 | *
|
---|
173 | * This call should set up the driver for doing a series of solid fills
|
---|
174 | * through the Solid() call. The alu raster op is one of the GX*
|
---|
175 | * graphics functions listed in X.h, and typically maps to a similar
|
---|
176 | * single-byte "ROP" setting in all hardware. The planemask controls
|
---|
177 | * which bits of the destination should be affected, and will only represent
|
---|
178 | * the bits up to the depth of pPixmap. The fg is the pixel value of the
|
---|
179 | * foreground color referred to in ROP descriptions.
|
---|
180 | *
|
---|
181 | * Note that many drivers will need to store some of the data in the driver
|
---|
182 | * private record, for sending to the hardware with each drawing command.
|
---|
183 | *
|
---|
184 | * The PrepareSolid() call is required of all drivers, but it may fail for any
|
---|
185 | * reason. Failure results in a fallback to software rendering.
|
---|
186 | */
|
---|
187 | Bool (*PrepareSolid) (PixmapPtr pPixmap,
|
---|
188 | int alu,
|
---|
189 | Pixel planemask,
|
---|
190 | Pixel fg);
|
---|
191 |
|
---|
192 | /**
|
---|
193 | * Solid() performs a solid fill set up in the last PrepareSolid() call.
|
---|
194 | *
|
---|
195 | * @param pPixmap destination pixmap
|
---|
196 | * @param x1 left coordinate
|
---|
197 | * @param y1 top coordinate
|
---|
198 | * @param x2 right coordinate
|
---|
199 | * @param y2 bottom coordinate
|
---|
200 | *
|
---|
201 | * Performs the fill set up by the last PrepareSolid() call, covering the
|
---|
202 | * area from (x1,y1) to (x2,y2) in pPixmap. Note that the coordinates are
|
---|
203 | * in the coordinate space of the destination pixmap, so the driver will
|
---|
204 | * need to set up the hardware's offset and pitch for the destination
|
---|
205 | * coordinates according to the pixmap's offset and pitch within
|
---|
206 | * framebuffer. This likely means using exaGetPixmapOffset() and
|
---|
207 | * exaGetPixmapPitch().
|
---|
208 | *
|
---|
209 | * This call is required if PrepareSolid() ever succeeds.
|
---|
210 | */
|
---|
211 | void (*Solid) (PixmapPtr pPixmap, int x1, int y1, int x2, int y2);
|
---|
212 |
|
---|
213 | /**
|
---|
214 | * DoneSolid() finishes a set of solid fills.
|
---|
215 | *
|
---|
216 | * @param pPixmap destination pixmap.
|
---|
217 | *
|
---|
218 | * The DoneSolid() call is called at the end of a series of consecutive
|
---|
219 | * Solid() calls following a successful PrepareSolid(). This allows drivers
|
---|
220 | * to finish up emitting drawing commands that were buffered, or clean up
|
---|
221 | * state from PrepareSolid().
|
---|
222 | *
|
---|
223 | * This call is required if PrepareSolid() ever succeeds.
|
---|
224 | */
|
---|
225 | void (*DoneSolid) (PixmapPtr pPixmap);
|
---|
226 | /** @} */
|
---|
227 |
|
---|
228 | /** @name Copy
|
---|
229 | * @{
|
---|
230 | */
|
---|
231 | /**
|
---|
232 | * PrepareCopy() sets up the driver for doing a copy within video
|
---|
233 | * memory.
|
---|
234 | *
|
---|
235 | * @param pSrcPixmap source pixmap
|
---|
236 | * @param pDstPixmap destination pixmap
|
---|
237 | * @param dx X copy direction
|
---|
238 | * @param dy Y copy direction
|
---|
239 | * @param alu raster operation
|
---|
240 | * @param planemask write mask for the fill
|
---|
241 | *
|
---|
242 | * This call should set up the driver for doing a series of copies from the
|
---|
243 | * the pSrcPixmap to the pDstPixmap. The dx flag will be positive if the
|
---|
244 | * hardware should do the copy from the left to the right, and dy will be
|
---|
245 | * positive if the copy should be done from the top to the bottom. This
|
---|
246 | * is to deal with self-overlapping copies when pSrcPixmap == pDstPixmap.
|
---|
247 | * If your hardware can only support blits that are (left to right, top to
|
---|
248 | * bottom) or (right to left, bottom to top), then you should set
|
---|
249 | * #EXA_TWO_BITBLT_DIRECTIONS, and EXA will break down Copy operations to
|
---|
250 | * ones that meet those requirements. The alu raster op is one of the GX*
|
---|
251 | * graphics functions listed in X.h, and typically maps to a similar
|
---|
252 | * single-byte "ROP" setting in all hardware. The planemask controls which
|
---|
253 | * bits of the destination should be affected, and will only represent the
|
---|
254 | * bits up to the depth of pPixmap.
|
---|
255 | *
|
---|
256 | * Note that many drivers will need to store some of the data in the driver
|
---|
257 | * private record, for sending to the hardware with each drawing command.
|
---|
258 | *
|
---|
259 | * The PrepareCopy() call is required of all drivers, but it may fail for any
|
---|
260 | * reason. Failure results in a fallback to software rendering.
|
---|
261 | */
|
---|
262 | Bool (*PrepareCopy) (PixmapPtr pSrcPixmap,
|
---|
263 | PixmapPtr pDstPixmap,
|
---|
264 | int dx,
|
---|
265 | int dy,
|
---|
266 | int alu,
|
---|
267 | Pixel planemask);
|
---|
268 |
|
---|
269 | /**
|
---|
270 | * Copy() performs a copy set up in the last PrepareCopy call.
|
---|
271 | *
|
---|
272 | * @param pDstPixmap destination pixmap
|
---|
273 | * @param srcX source X coordinate
|
---|
274 | * @param srcY source Y coordinate
|
---|
275 | * @param dstX destination X coordinate
|
---|
276 | * @param dstY destination Y coordinate
|
---|
277 | * @param width width of the rectangle to be copied
|
---|
278 | * @param height height of the rectangle to be copied.
|
---|
279 | *
|
---|
280 | * Performs the copy set up by the last PrepareCopy() call, copying the
|
---|
281 | * rectangle from (srcX, srcY) to (srcX + width, srcY + width) in the source
|
---|
282 | * pixmap to the same-sized rectangle at (dstX, dstY) in the destination
|
---|
283 | * pixmap. Those rectangles may overlap in memory, if
|
---|
284 | * pSrcPixmap == pDstPixmap. Note that this call does not receive the
|
---|
285 | * pSrcPixmap as an argument -- if it's needed in this function, it should
|
---|
286 | * be stored in the driver private during PrepareCopy(). As with Solid(),
|
---|
287 | * the coordinates are in the coordinate space of each pixmap, so the driver
|
---|
288 | * will need to set up source and destination pitches and offsets from those
|
---|
289 | * pixmaps, probably using exaGetPixmapOffset() and exaGetPixmapPitch().
|
---|
290 | *
|
---|
291 | * This call is required if PrepareCopy ever succeeds.
|
---|
292 | */
|
---|
293 | void (*Copy) (PixmapPtr pDstPixmap,
|
---|
294 | int srcX,
|
---|
295 | int srcY,
|
---|
296 | int dstX,
|
---|
297 | int dstY,
|
---|
298 | int width,
|
---|
299 | int height);
|
---|
300 |
|
---|
301 | /**
|
---|
302 | * DoneCopy() finishes a set of copies.
|
---|
303 | *
|
---|
304 | * @param pPixmap destination pixmap.
|
---|
305 | *
|
---|
306 | * The DoneCopy() call is called at the end of a series of consecutive
|
---|
307 | * Copy() calls following a successful PrepareCopy(). This allows drivers
|
---|
308 | * to finish up emitting drawing commands that were buffered, or clean up
|
---|
309 | * state from PrepareCopy().
|
---|
310 | *
|
---|
311 | * This call is required if PrepareCopy() ever succeeds.
|
---|
312 | */
|
---|
313 | void (*DoneCopy) (PixmapPtr pDstPixmap);
|
---|
314 | /** @} */
|
---|
315 |
|
---|
316 | /** @name Composite
|
---|
317 | * @{
|
---|
318 | */
|
---|
319 | /**
|
---|
320 | * CheckComposite() checks to see if a composite operation could be
|
---|
321 | * accelerated.
|
---|
322 | *
|
---|
323 | * @param op Render operation
|
---|
324 | * @param pSrcPicture source Picture
|
---|
325 | * @param pMaskPicture mask picture
|
---|
326 | * @param pDstPicture destination Picture
|
---|
327 | *
|
---|
328 | * The CheckComposite() call checks if the driver could handle acceleration
|
---|
329 | * of op with the given source, mask, and destination pictures. This allows
|
---|
330 | * drivers to check source and destination formats, supported operations,
|
---|
331 | * transformations, and component alpha state, and send operations it can't
|
---|
332 | * support to software rendering early on. This avoids costly pixmap
|
---|
333 | * migration to the wrong places when the driver can't accelerate
|
---|
334 | * operations. Note that because migration hasn't happened, the driver
|
---|
335 | * can't know during CheckComposite() what the offsets and pitches of the
|
---|
336 | * pixmaps are going to be.
|
---|
337 | *
|
---|
338 | * See PrepareComposite() for more details on likely issues that drivers
|
---|
339 | * will have in accelerating Composite operations.
|
---|
340 | *
|
---|
341 | * The CheckComposite() call is recommended if PrepareComposite() is
|
---|
342 | * implemented, but is not required.
|
---|
343 | */
|
---|
344 | Bool (*CheckComposite) (int op,
|
---|
345 | PicturePtr pSrcPicture,
|
---|
346 | PicturePtr pMaskPicture,
|
---|
347 | PicturePtr pDstPicture);
|
---|
348 |
|
---|
349 | /**
|
---|
350 | * PrepareComposite() sets up the driver for doing a Composite operation
|
---|
351 | * described in the Render extension protocol spec.
|
---|
352 | *
|
---|
353 | * @param op Render operation
|
---|
354 | * @param pSrcPicture source Picture
|
---|
355 | * @param pMaskPicture mask picture
|
---|
356 | * @param pDstPicture destination Picture
|
---|
357 | * @param pSrc source pixmap
|
---|
358 | * @param pMask mask pixmap
|
---|
359 | * @param pDst destination pixmap
|
---|
360 | *
|
---|
361 | * This call should set up the driver for doing a series of Composite
|
---|
362 | * operations, as described in the Render protocol spec, with the given
|
---|
363 | * pSrcPicture, pMaskPicture, and pDstPicture. The pSrc, pMask, and
|
---|
364 | * pDst are the pixmaps containing the pixel data, and should be used for
|
---|
365 | * setting the offset and pitch used for the coordinate spaces for each of
|
---|
366 | * the Pictures.
|
---|
367 | *
|
---|
368 | * Notes on interpreting Picture structures:
|
---|
369 | * - The Picture structures will always have a valid pDrawable.
|
---|
370 | * - The Picture structures will never have alphaMap set.
|
---|
371 | * - The mask Picture (and therefore pMask) may be NULL, in which case the
|
---|
372 | * operation is simply src OP dst instead of src IN mask OP dst, and
|
---|
373 | * mask coordinates should be ignored.
|
---|
374 | * - pMarkPicture may have componentAlpha set, which greatly changes
|
---|
375 | * the behavior of the Composite operation. componentAlpha has no effect
|
---|
376 | * when set on pSrcPicture or pDstPicture.
|
---|
377 | * - The source and mask Pictures may have a transformation set
|
---|
378 | * (Picture->transform != NULL), which means that the source coordinates
|
---|
379 | * should be transformed by that transformation, resulting in scaling,
|
---|
380 | * rotation, etc. The PictureTransformPoint() call can transform
|
---|
381 | * coordinates for you. Transforms have no effect on Pictures when used
|
---|
382 | * as a destination.
|
---|
383 | * - The source and mask pictures may have a filter set. PictFilterNearest
|
---|
384 | * and PictFilterBilinear are defined in the Render protocol, but others
|
---|
385 | * may be encountered, and must be handled correctly (usually by
|
---|
386 | * PrepareComposite failing, and falling back to software). Filters have
|
---|
387 | * no effect on Pictures when used as a destination.
|
---|
388 | * - The source and mask Pictures may have repeating set, which must be
|
---|
389 | * respected. Many chipsets will be unable to support repeating on
|
---|
390 | * pixmaps that have a width or height that is not a power of two.
|
---|
391 | *
|
---|
392 | * If your hardware can't support source pictures (textures) with
|
---|
393 | * non-power-of-two pitches, you should set #EXA_OFFSCREEN_ALIGN_POT.
|
---|
394 | *
|
---|
395 | * Note that many drivers will need to store some of the data in the driver
|
---|
396 | * private record, for sending to the hardware with each drawing command.
|
---|
397 | *
|
---|
398 | * The PrepareComposite() call is not required. However, it is highly
|
---|
399 | * recommended for performance of antialiased font rendering and performance
|
---|
400 | * of cairo applications. Failure results in a fallback to software
|
---|
401 | * rendering.
|
---|
402 | */
|
---|
403 | Bool (*PrepareComposite) (int op,
|
---|
404 | PicturePtr pSrcPicture,
|
---|
405 | PicturePtr pMaskPicture,
|
---|
406 | PicturePtr pDstPicture,
|
---|
407 | PixmapPtr pSrc,
|
---|
408 | PixmapPtr pMask,
|
---|
409 | PixmapPtr pDst);
|
---|
410 |
|
---|
411 | /**
|
---|
412 | * Composite() performs a Composite operation set up in the last
|
---|
413 | * PrepareComposite() call.
|
---|
414 | *
|
---|
415 | * @param pDstPixmap destination pixmap
|
---|
416 | * @param srcX source X coordinate
|
---|
417 | * @param srcY source Y coordinate
|
---|
418 | * @param maskX source X coordinate
|
---|
419 | * @param maskY source Y coordinate
|
---|
420 | * @param dstX destination X coordinate
|
---|
421 | * @param dstY destination Y coordinate
|
---|
422 | * @param width destination rectangle width
|
---|
423 | * @param height destination rectangle height
|
---|
424 | *
|
---|
425 | * Performs the Composite operation set up by the last PrepareComposite()
|
---|
426 | * call, to the rectangle from (dstX, dstY) to (dstX + width, dstY + height)
|
---|
427 | * in the destination Pixmap. Note that if a transformation was set on
|
---|
428 | * the source or mask Pictures, the source rectangles may not be the same
|
---|
429 | * size as the destination rectangles and filtering. Getting the coordinate
|
---|
430 | * transformation right at the subpixel level can be tricky, and rendercheck
|
---|
431 | * can test this for you.
|
---|
432 | *
|
---|
433 | * This call is required if PrepareComposite() ever succeeds.
|
---|
434 | */
|
---|
435 | void (*Composite) (PixmapPtr pDst,
|
---|
436 | int srcX,
|
---|
437 | int srcY,
|
---|
438 | int maskX,
|
---|
439 | int maskY,
|
---|
440 | int dstX,
|
---|
441 | int dstY,
|
---|
442 | int width,
|
---|
443 | int height);
|
---|
444 |
|
---|
445 | /**
|
---|
446 | * DoneComposite() finishes a set of Composite operations.
|
---|
447 | *
|
---|
448 | * @param pPixmap destination pixmap.
|
---|
449 | *
|
---|
450 | * The DoneComposite() call is called at the end of a series of consecutive
|
---|
451 | * Composite() calls following a successful PrepareComposite(). This allows
|
---|
452 | * drivers to finish up emitting drawing commands that were buffered, or
|
---|
453 | * clean up state from PrepareComposite().
|
---|
454 | *
|
---|
455 | * This call is required if PrepareComposite() ever succeeds.
|
---|
456 | */
|
---|
457 | void (*DoneComposite) (PixmapPtr pDst);
|
---|
458 | /** @} */
|
---|
459 |
|
---|
460 | /**
|
---|
461 | * UploadToScreen() loads a rectangle of data from src into pDst.
|
---|
462 | *
|
---|
463 | * @param pDst destination pixmap
|
---|
464 | * @param x destination X coordinate.
|
---|
465 | * @param y destination Y coordinate
|
---|
466 | * @param width width of the rectangle to be copied
|
---|
467 | * @param height height of the rectangle to be copied
|
---|
468 | * @param src pointer to the beginning of the source data
|
---|
469 | * @param src_pitch pitch (in bytes) of the lines of source data.
|
---|
470 | *
|
---|
471 | * UploadToScreen() copies data in system memory beginning at src (with
|
---|
472 | * pitch src_pitch) into the destination pixmap from (x, y) to
|
---|
473 | * (x + width, y + height). This is typically done with hostdata uploads,
|
---|
474 | * where the CPU sets up a blit command on the hardware with instructions
|
---|
475 | * that the blit data will be fed through some sort of aperture on the card.
|
---|
476 | *
|
---|
477 | * If UploadToScreen() is performed asynchronously, it is up to the driver
|
---|
478 | * to call exaMarkSync(). This is in contrast to most other acceleration
|
---|
479 | * calls in EXA.
|
---|
480 | *
|
---|
481 | * UploadToScreen() can aid in pixmap migration, but is most important for
|
---|
482 | * the performance of exaGlyphs() (antialiased font drawing) by allowing
|
---|
483 | * pipelining of data uploads, avoiding a sync of the card after each glyph.
|
---|
484 | *
|
---|
485 | * @return TRUE if the driver successfully uploaded the data. FALSE
|
---|
486 | * indicates that EXA should fall back to doing the upload in software.
|
---|
487 | *
|
---|
488 | * UploadToScreen() is not required, but is recommended if Composite
|
---|
489 | * acceleration is supported.
|
---|
490 | */
|
---|
491 | Bool (*UploadToScreen) (PixmapPtr pDst,
|
---|
492 | int x,
|
---|
493 | int y,
|
---|
494 | int w,
|
---|
495 | int h,
|
---|
496 | char *src,
|
---|
497 | int src_pitch);
|
---|
498 |
|
---|
499 | /**
|
---|
500 | * UploadToScratch() is used to upload a pixmap to a scratch area for
|
---|
501 | * acceleration.
|
---|
502 | *
|
---|
503 | * @param pSrc source pixmap in host memory
|
---|
504 | * @param pDst fake, scratch pixmap to be set up in offscreen memory.
|
---|
505 | *
|
---|
506 | * The UploadToScratch() call was added to support Xati before Xati had
|
---|
507 | * support for hostdata uploads and before exaGlyphs() was written. It
|
---|
508 | * behaves incorrectly (uses an invalid pixmap as pDst),
|
---|
509 | * and UploadToScreen() should be implemented instead.
|
---|
510 | *
|
---|
511 | * Drivers implementing UploadToScratch() had to set up space (likely in a
|
---|
512 | * statically allocated area) in offscreen memory, copy pSrc to that
|
---|
513 | * scratch area, and adust pDst->devKind for the pitch and
|
---|
514 | * pDst->devPrivate.ptr for the pointer to that scratch area. The driver
|
---|
515 | * was responsible for syncing (as it was implemented using memcpy() in
|
---|
516 | * Xati), and only the data from the last UploadToScratch() was guaranteed
|
---|
517 | * to be valid at any given time.
|
---|
518 | *
|
---|
519 | * UploadToScratch() should not be implemented by drivers, and will likely
|
---|
520 | * be removed in a future version of EXA.
|
---|
521 | */
|
---|
522 | Bool (*UploadToScratch) (PixmapPtr pSrc,
|
---|
523 | PixmapPtr pDst);
|
---|
524 |
|
---|
525 | /**
|
---|
526 | * DownloadFromScreen() loads a rectangle of data from pSrc into dst
|
---|
527 | *
|
---|
528 | * @param pSrc source pixmap
|
---|
529 | * @param x source X coordinate.
|
---|
530 | * @param y source Y coordinate
|
---|
531 | * @param width width of the rectangle to be copied
|
---|
532 | * @param height height of the rectangle to be copied
|
---|
533 | * @param dst pointer to the beginning of the destination data
|
---|
534 | * @param dst_pitch pitch (in bytes) of the lines of destination data.
|
---|
535 | *
|
---|
536 | * DownloadFromScreen() copies data from offscreen memory in pSrc from
|
---|
537 | * (x, y) to (x + width, y + height), to system memory starting at
|
---|
538 | * dst (with pitch dst_pitch). This would usually be done
|
---|
539 | * using scatter-gather DMA, supported by a DRM call, or by blitting to AGP
|
---|
540 | * and then synchronously reading from AGP. Because the implementation
|
---|
541 | * might be synchronous, EXA leaves it up to the driver to call
|
---|
542 | * exaMarkSync() if DownloadFromScreen() was asynchronous. This is in
|
---|
543 | * contrast to most other acceleration calls in EXA.
|
---|
544 | *
|
---|
545 | * DownloadFromScreen() can aid in the largest bottleneck in pixmap
|
---|
546 | * migration, which is the read from framebuffer when evicting pixmaps from
|
---|
547 | * framebuffer memory. Thus, it is highly recommended, even though
|
---|
548 | * implementations are typically complicated.
|
---|
549 | *
|
---|
550 | * @return TRUE if the driver successfully downloaded the data. FALSE
|
---|
551 | * indicates that EXA should fall back to doing the download in software.
|
---|
552 | *
|
---|
553 | * DownloadFromScreen() is not required, but is highly recommended.
|
---|
554 | */
|
---|
555 | Bool (*DownloadFromScreen)(PixmapPtr pSrc,
|
---|
556 | int x, int y,
|
---|
557 | int w, int h,
|
---|
558 | char *dst, int dst_pitch);
|
---|
559 |
|
---|
560 | /**
|
---|
561 | * MarkSync() requests that the driver mark a synchronization point,
|
---|
562 | * returning an driver-defined integer marker which could be requested for
|
---|
563 | * synchronization to later in WaitMarker(). This might be used in the
|
---|
564 | * future to avoid waiting for full hardware stalls before accessing pixmap
|
---|
565 | * data with the CPU, but is not important in the current incarnation of
|
---|
566 | * EXA.
|
---|
567 | *
|
---|
568 | * Note that drivers should call exaMarkSync() when they have done some
|
---|
569 | * acceleration, rather than their own MarkSync() handler, as otherwise EXA
|
---|
570 | * will be unaware of the driver's acceleration and not sync to it during
|
---|
571 | * fallbacks.
|
---|
572 | *
|
---|
573 | * MarkSync() is optional.
|
---|
574 | */
|
---|
575 | int (*MarkSync) (ScreenPtr pScreen);
|
---|
576 |
|
---|
577 | /**
|
---|
578 | * WaitMarker() waits for all rendering before the given marker to have
|
---|
579 | * completed. If the driver does not implement MarkSync(), marker is
|
---|
580 | * meaningless, and all rendering by the hardware should be completed before
|
---|
581 | * WaitMarker() returns.
|
---|
582 | *
|
---|
583 | * Note that drivers should call exaWaitSync() to wait for all acceleration
|
---|
584 | * to finish, as otherwise EXA will be unaware of the driver having
|
---|
585 | * synchronized, resulting in excessive WaitMarker() calls.
|
---|
586 | *
|
---|
587 | * WaitMarker() is required of all drivers.
|
---|
588 | */
|
---|
589 | void (*WaitMarker) (ScreenPtr pScreen, int marker);
|
---|
590 |
|
---|
591 | /** @{ */
|
---|
592 | /**
|
---|
593 | * PrepareAccess() is called before CPU access to an offscreen pixmap.
|
---|
594 | *
|
---|
595 | * @param pPix the pixmap being accessed
|
---|
596 | * @param index the index of the pixmap being accessed.
|
---|
597 | *
|
---|
598 | * PrepareAccess() will be called before CPU access to an offscreen pixmap.
|
---|
599 | * This can be used to set up hardware surfaces for byteswapping or
|
---|
600 | * untiling, or to adjust the pixmap's devPrivate.ptr for the purpose of
|
---|
601 | * making CPU access use a different aperture.
|
---|
602 | *
|
---|
603 | * The index is one of #EXA_PREPARE_DEST, #EXA_PREPARE_SRC, or
|
---|
604 | * #EXA_PREPARE_MASK, indicating which pixmap is in question. Since only up
|
---|
605 | * to three pixmaps will have PrepareAccess() called on them per operation,
|
---|
606 | * drivers can have a small, statically-allocated space to maintain state
|
---|
607 | * for PrepareAccess() and FinishAccess() in. Note that the same pixmap may
|
---|
608 | * have PrepareAccess() called on it more than once, for example when doing
|
---|
609 | * a copy within the same pixmap (so it gets PrepareAccess as()
|
---|
610 | * #EXA_PREPARE_DEST and then as #EXA_PREPARE_SRC).
|
---|
611 | *
|
---|
612 | * PrepareAccess() may fail. An example might be the case of hardware that
|
---|
613 | * can set up 1 or 2 surfaces for CPU access, but not 3. If PrepareAccess()
|
---|
614 | * fails, EXA will migrate the pixmap to system memory.
|
---|
615 | * DownloadFromScreen() must be implemented and must not fail if a driver
|
---|
616 | * wishes to fail in PrepareAccess(). PrepareAccess() must not fail when
|
---|
617 | * pPix is the visible screen, because the visible screen can not be
|
---|
618 | * migrated.
|
---|
619 | *
|
---|
620 | * @return TRUE if PrepareAccess() successfully prepared the pixmap for CPU
|
---|
621 | * drawing.
|
---|
622 | * @return FALSE if PrepareAccess() is unsuccessful and EXA should use
|
---|
623 | * DownloadFromScreen() to migate the pixmap out.
|
---|
624 | */
|
---|
625 | Bool (*PrepareAccess)(PixmapPtr pPix, int index);
|
---|
626 |
|
---|
627 | /**
|
---|
628 | * FinishAccess() is called after CPU access to an offscreen pixmap.
|
---|
629 | *
|
---|
630 | * @param pPix the pixmap being accessed
|
---|
631 | * @param index the index of the pixmap being accessed.
|
---|
632 | *
|
---|
633 | * FinishAccess() will be called after finishing CPU access of an offscreen
|
---|
634 | * pixmap set up by PrepareAccess(). Note that the FinishAccess() will not be
|
---|
635 | * called if PrepareAccess() failed and the pixmap was migrated out.
|
---|
636 | */
|
---|
637 | void (*FinishAccess)(PixmapPtr pPix, int index);
|
---|
638 |
|
---|
639 | /**
|
---|
640 | * PixmapIsOffscreen() is an optional driver replacement to
|
---|
641 | * exaPixmapIsOffscreen(). Set to NULL if you want the standard behaviour
|
---|
642 | * of exaPixmapIsOffscreen().
|
---|
643 | *
|
---|
644 | * @param pPix the pixmap
|
---|
645 | * @return TRUE if the given drawable is in framebuffer memory.
|
---|
646 | *
|
---|
647 | * exaPixmapIsOffscreen() is used to determine if a pixmap is in offscreen
|
---|
648 | * memory, meaning that acceleration could probably be done to it, and that it
|
---|
649 | * will need to be wrapped by PrepareAccess()/FinishAccess() when accessing it
|
---|
650 | * with the CPU.
|
---|
651 | *
|
---|
652 | *
|
---|
653 | */
|
---|
654 | Bool (*PixmapIsOffscreen)(PixmapPtr pPix);
|
---|
655 |
|
---|
656 | /** @name PrepareAccess() and FinishAccess() indices
|
---|
657 | * @{
|
---|
658 | */
|
---|
659 | /**
|
---|
660 | * EXA_PREPARE_DEST is the index for a pixmap that may be drawn to or
|
---|
661 | * read from.
|
---|
662 | */
|
---|
663 | #define EXA_PREPARE_DEST 0
|
---|
664 | /**
|
---|
665 | * EXA_PREPARE_SRC is the index for a pixmap that may be read from
|
---|
666 | */
|
---|
667 | #define EXA_PREPARE_SRC 1
|
---|
668 | /**
|
---|
669 | * EXA_PREPARE_SRC is the index for a second pixmap that may be read
|
---|
670 | * from.
|
---|
671 | */
|
---|
672 | #define EXA_PREPARE_MASK 2
|
---|
673 | /** @} */
|
---|
674 | /** @} */
|
---|
675 | } ExaDriverRec, *ExaDriverPtr;
|
---|
676 |
|
---|
677 | /** @name EXA driver flags
|
---|
678 | * @{
|
---|
679 | */
|
---|
680 | /**
|
---|
681 | * EXA_OFFSCREEN_PIXMAPS indicates to EXA that the driver can support
|
---|
682 | * offscreen pixmaps.
|
---|
683 | */
|
---|
684 | #define EXA_OFFSCREEN_PIXMAPS (1 << 0)
|
---|
685 |
|
---|
686 | /**
|
---|
687 | * EXA_OFFSCREEN_ALIGN_POT indicates to EXA that the driver needs pixmaps
|
---|
688 | * to have a power-of-two pitch.
|
---|
689 | */
|
---|
690 | #define EXA_OFFSCREEN_ALIGN_POT (1 << 1)
|
---|
691 |
|
---|
692 | /**
|
---|
693 | * EXA_TWO_BITBLT_DIRECTIONS indicates to EXA that the driver can only
|
---|
694 | * support copies that are (left-to-right, top-to-bottom) or
|
---|
695 | * (right-to-left, bottom-to-top).
|
---|
696 | */
|
---|
697 | #define EXA_TWO_BITBLT_DIRECTIONS (1 << 2)
|
---|
698 | /** @} */
|
---|
699 |
|
---|
700 | ExaDriverPtr
|
---|
701 | exaDriverAlloc(void);
|
---|
702 |
|
---|
703 | Bool
|
---|
704 | exaDriverInit(ScreenPtr pScreen,
|
---|
705 | ExaDriverPtr pScreenInfo);
|
---|
706 |
|
---|
707 | void
|
---|
708 | exaDriverFini(ScreenPtr pScreen);
|
---|
709 |
|
---|
710 | void
|
---|
711 | exaMarkSync(ScreenPtr pScreen);
|
---|
712 | void
|
---|
713 | exaWaitSync(ScreenPtr pScreen);
|
---|
714 |
|
---|
715 | ExaOffscreenArea *
|
---|
716 | exaOffscreenAlloc(ScreenPtr pScreen, int size, int align,
|
---|
717 | Bool locked,
|
---|
718 | ExaOffscreenSaveProc save,
|
---|
719 | pointer privData);
|
---|
720 |
|
---|
721 | ExaOffscreenArea *
|
---|
722 | exaOffscreenFree(ScreenPtr pScreen, ExaOffscreenArea *area);
|
---|
723 |
|
---|
724 | void
|
---|
725 | ExaOffscreenMarkUsed (PixmapPtr pPixmap);
|
---|
726 |
|
---|
727 | unsigned long
|
---|
728 | exaGetPixmapOffset(PixmapPtr pPix);
|
---|
729 |
|
---|
730 | unsigned long
|
---|
731 | exaGetPixmapPitch(PixmapPtr pPix);
|
---|
732 |
|
---|
733 | unsigned long
|
---|
734 | exaGetPixmapSize(PixmapPtr pPix);
|
---|
735 |
|
---|
736 | void
|
---|
737 | exaEnableDisableFBAccess (int index, Bool enable);
|
---|
738 |
|
---|
739 | void
|
---|
740 | exaMoveInPixmap (PixmapPtr pPixmap);
|
---|
741 |
|
---|
742 | void
|
---|
743 | exaMoveOutPixmap (PixmapPtr pPixmap);
|
---|
744 |
|
---|
745 | /**
|
---|
746 | * Returns TRUE if the given planemask covers all the significant bits in the
|
---|
747 | * pixel values for pDrawable.
|
---|
748 | */
|
---|
749 | #define EXA_PM_IS_SOLID(_pDrawable, _pm) \
|
---|
750 | (((_pm) & FbFullMask((_pDrawable)->depth)) == \
|
---|
751 | FbFullMask((_pDrawable)->depth))
|
---|
752 |
|
---|
753 | #endif /* EXA_H */
|
---|