1 | /*
|
---|
2 | *
|
---|
3 | * Copyright (C) 2000 Keith Packard, member of The XFree86 Project, Inc.
|
---|
4 | * 2005 Zack Rusin, Trolltech
|
---|
5 | *
|
---|
6 | * Permission to use, copy, modify, distribute, and sell this software and its
|
---|
7 | * documentation for any purpose is hereby granted without fee, provided that
|
---|
8 | * the above copyright notice appear in all copies and that both that
|
---|
9 | * copyright notice and this permission notice appear in supporting
|
---|
10 | * documentation, and that the name of Keith Packard not be used in
|
---|
11 | * advertising or publicity pertaining to distribution of the software without
|
---|
12 | * specific, written prior permission. Keith Packard makes no
|
---|
13 | * representations about the suitability of this software for any purpose. It
|
---|
14 | * is provided "as is" without express or implied warranty.
|
---|
15 | *
|
---|
16 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
---|
17 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
---|
18 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
---|
19 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
---|
20 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
---|
21 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
---|
22 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
23 | * SOFTWARE.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef EXAPRIV_H
|
---|
27 | #define EXAPRIV_H
|
---|
28 |
|
---|
29 | #ifdef HAVE_DIX_CONFIG_H
|
---|
30 | #include <dix-config.h>
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | #include "exa.h"
|
---|
34 |
|
---|
35 | #include <X11/X.h>
|
---|
36 | #define NEED_EVENTS
|
---|
37 | #include <X11/Xproto.h>
|
---|
38 | #include "scrnintstr.h"
|
---|
39 | #include "pixmapstr.h"
|
---|
40 | #include "windowstr.h"
|
---|
41 | #include "servermd.h"
|
---|
42 | #include "mibstore.h"
|
---|
43 | #include "colormapst.h"
|
---|
44 | #include "gcstruct.h"
|
---|
45 | #include "input.h"
|
---|
46 | #include "mipointer.h"
|
---|
47 | #include "mi.h"
|
---|
48 | #include "dix.h"
|
---|
49 | #include "fb.h"
|
---|
50 | #include "fboverlay.h"
|
---|
51 | #ifdef RENDER
|
---|
52 | #include "fbpict.h"
|
---|
53 | #endif
|
---|
54 |
|
---|
55 | #define DEBUG_TRACE_FALL 0
|
---|
56 | #define DEBUG_MIGRATE 0
|
---|
57 | #define DEBUG_PIXMAP 0
|
---|
58 | #define DEBUG_OFFSCREEN 0
|
---|
59 |
|
---|
60 | #if DEBUG_TRACE_FALL
|
---|
61 | #define EXA_FALLBACK(x) \
|
---|
62 | do { \
|
---|
63 | ErrorF("EXA fallback at %s: ", __FUNCTION__); \
|
---|
64 | ErrorF x; \
|
---|
65 | } while (0)
|
---|
66 | #else
|
---|
67 | #define EXA_FALLBACK(x)
|
---|
68 | #endif
|
---|
69 |
|
---|
70 | #if DEBUG_PIXMAP
|
---|
71 | #define DBG_PIXMAP(a) ErrorF a
|
---|
72 | #else
|
---|
73 | #define DBG_PIXMAP(a)
|
---|
74 | #endif
|
---|
75 |
|
---|
76 | #ifndef EXA_MAX_FB
|
---|
77 | #define EXA_MAX_FB FB_OVERLAY_MAX
|
---|
78 | #endif
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * This is the list of migration heuristics supported by EXA. See
|
---|
82 | * exaDoMigration() for what their implementations do.
|
---|
83 | */
|
---|
84 | enum ExaMigrationHeuristic {
|
---|
85 | ExaMigrationGreedy,
|
---|
86 | ExaMigrationAlways
|
---|
87 | };
|
---|
88 |
|
---|
89 | typedef void (*EnableDisableFBAccessProcPtr)(int, Bool);
|
---|
90 | typedef struct {
|
---|
91 | ExaDriverPtr info;
|
---|
92 | CreateGCProcPtr SavedCreateGC;
|
---|
93 | CloseScreenProcPtr SavedCloseScreen;
|
---|
94 | GetImageProcPtr SavedGetImage;
|
---|
95 | GetSpansProcPtr SavedGetSpans;
|
---|
96 | PaintWindowBackgroundProcPtr SavedPaintWindowBackground;
|
---|
97 | CreatePixmapProcPtr SavedCreatePixmap;
|
---|
98 | DestroyPixmapProcPtr SavedDestroyPixmap;
|
---|
99 | PaintWindowBorderProcPtr SavedPaintWindowBorder;
|
---|
100 | CopyWindowProcPtr SavedCopyWindow;
|
---|
101 | #ifdef RENDER
|
---|
102 | CompositeProcPtr SavedComposite;
|
---|
103 | RasterizeTrapezoidProcPtr SavedRasterizeTrapezoid;
|
---|
104 | AddTrianglesProcPtr SavedAddTriangles;
|
---|
105 | GlyphsProcPtr SavedGlyphs;
|
---|
106 | #endif
|
---|
107 | Bool swappedOut;
|
---|
108 | enum ExaMigrationHeuristic migration;
|
---|
109 | Bool hideOffscreenPixmapData;
|
---|
110 | } ExaScreenPrivRec, *ExaScreenPrivPtr;
|
---|
111 |
|
---|
112 | /*
|
---|
113 | * This is the only completely portable way to
|
---|
114 | * compute this info.
|
---|
115 | */
|
---|
116 | #ifndef BitsPerPixel
|
---|
117 | #define BitsPerPixel(d) (\
|
---|
118 | PixmapWidthPaddingInfo[d].notPower2 ? \
|
---|
119 | (PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \
|
---|
120 | ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
|
---|
121 | (PixmapWidthPaddingInfo[d].padRoundUp+1)))
|
---|
122 | #endif
|
---|
123 |
|
---|
124 | extern int exaScreenPrivateIndex;
|
---|
125 | extern int exaPixmapPrivateIndex;
|
---|
126 | #define ExaGetScreenPriv(s) ((ExaScreenPrivPtr)(s)->devPrivates[exaScreenPrivateIndex].ptr)
|
---|
127 | #define ExaScreenPriv(s) ExaScreenPrivPtr pExaScr = ExaGetScreenPriv(s)
|
---|
128 |
|
---|
129 | /** Align an offset to an arbitrary alignment */
|
---|
130 | #define EXA_ALIGN(offset, align) (((offset) + (align) - 1) - \
|
---|
131 | (((offset) + (align) - 1) % (align)))
|
---|
132 | /** Align an offset to a power-of-two alignment */
|
---|
133 | #define EXA_ALIGN2(offset, align) (((offset) + (align) - 1) & ~((align) - 1))
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Returns TRUE if the given planemask covers all the significant bits in the
|
---|
137 | * pixel values for pDrawable.
|
---|
138 | */
|
---|
139 | #define EXA_PM_IS_SOLID(_pDrawable, _pm) \
|
---|
140 | (((_pm) & FbFullMask((_pDrawable)->depth)) == \
|
---|
141 | FbFullMask((_pDrawable)->depth))
|
---|
142 |
|
---|
143 | #define EXA_PIXMAP_SCORE_MOVE_IN 10
|
---|
144 | #define EXA_PIXMAP_SCORE_MAX 20
|
---|
145 | #define EXA_PIXMAP_SCORE_MOVE_OUT -10
|
---|
146 | #define EXA_PIXMAP_SCORE_MIN -20
|
---|
147 | #define EXA_PIXMAP_SCORE_PINNED 1000
|
---|
148 | #define EXA_PIXMAP_SCORE_INIT 1001
|
---|
149 |
|
---|
150 | #define ExaGetPixmapPriv(p) ((ExaPixmapPrivPtr)(p)->devPrivates[exaPixmapPrivateIndex].ptr)
|
---|
151 | #define ExaSetPixmapPriv(p,a) ((p)->devPrivates[exaPixmapPrivateIndex].ptr = (pointer) (a))
|
---|
152 | #define ExaPixmapPriv(p) ExaPixmapPrivPtr pExaPixmap = ExaGetPixmapPriv(p)
|
---|
153 |
|
---|
154 | typedef struct {
|
---|
155 | ExaOffscreenArea *area;
|
---|
156 | int score; /**< score for the move-in vs move-out heuristic */
|
---|
157 |
|
---|
158 | CARD8 *sys_ptr; /**< pointer to pixmap data in system memory */
|
---|
159 | int sys_pitch; /**< pitch of pixmap in system memory */
|
---|
160 |
|
---|
161 | CARD8 *fb_ptr; /**< pointer to pixmap data in framebuffer memory */
|
---|
162 | int fb_pitch; /**< pitch of pixmap in framebuffer memory */
|
---|
163 | unsigned int fb_size; /**< size of pixmap in framebuffer memory */
|
---|
164 |
|
---|
165 | /**
|
---|
166 | * If area is NULL, then dirty == TRUE means that the pixmap has been
|
---|
167 | * modified, so the contents are defined. Used to avoid uploads of
|
---|
168 | * undefined data.
|
---|
169 | *
|
---|
170 | * If area is non-NULL, then dirty == TRUE means that the pixmap data at
|
---|
171 | * pPixmap->devPrivate.ptr (either fb_ptr or sys_ptr) has been changed
|
---|
172 | * compared to the copy in the other location. This is used to avoid
|
---|
173 | * uploads/downloads of unmodified data.
|
---|
174 | */
|
---|
175 | Bool dirty;
|
---|
176 | } ExaPixmapPrivRec, *ExaPixmapPrivPtr;
|
---|
177 |
|
---|
178 | typedef struct _ExaMigrationRec {
|
---|
179 | Bool as_dst;
|
---|
180 | Bool as_src;
|
---|
181 | PixmapPtr pPix;
|
---|
182 | } ExaMigrationRec, *ExaMigrationPtr;
|
---|
183 |
|
---|
184 | /**
|
---|
185 | * exaDDXDriverInit must be implemented by the DDX using EXA, and is the place
|
---|
186 | * to set EXA options or hook in screen functions to handle using EXA as the AA.
|
---|
187 | */
|
---|
188 | void exaDDXDriverInit (ScreenPtr pScreen);
|
---|
189 |
|
---|
190 | /* exa_unaccel.c */
|
---|
191 | void
|
---|
192 | exaPrepareAccessGC(GCPtr pGC);
|
---|
193 |
|
---|
194 | void
|
---|
195 | exaFinishAccessGC(GCPtr pGC);
|
---|
196 |
|
---|
197 | void
|
---|
198 | ExaCheckFillSpans (DrawablePtr pDrawable, GCPtr pGC, int nspans,
|
---|
199 | DDXPointPtr ppt, int *pwidth, int fSorted);
|
---|
200 |
|
---|
201 | void
|
---|
202 | ExaCheckSetSpans (DrawablePtr pDrawable, GCPtr pGC, char *psrc,
|
---|
203 | DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
|
---|
204 |
|
---|
205 | void
|
---|
206 | ExaCheckPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth,
|
---|
207 | int x, int y, int w, int h, int leftPad, int format,
|
---|
208 | char *bits);
|
---|
209 |
|
---|
210 | RegionPtr
|
---|
211 | ExaCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
---|
212 | int srcx, int srcy, int w, int h, int dstx, int dsty);
|
---|
213 |
|
---|
214 | RegionPtr
|
---|
215 | ExaCheckCopyPlane (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
---|
216 | int srcx, int srcy, int w, int h, int dstx, int dsty,
|
---|
217 | unsigned long bitPlane);
|
---|
218 |
|
---|
219 | void
|
---|
220 | ExaCheckPolyPoint (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
---|
221 | DDXPointPtr pptInit);
|
---|
222 |
|
---|
223 | void
|
---|
224 | ExaCheckPolylines (DrawablePtr pDrawable, GCPtr pGC,
|
---|
225 | int mode, int npt, DDXPointPtr ppt);
|
---|
226 |
|
---|
227 | void
|
---|
228 | ExaCheckPolySegment (DrawablePtr pDrawable, GCPtr pGC,
|
---|
229 | int nsegInit, xSegment *pSegInit);
|
---|
230 |
|
---|
231 | void
|
---|
232 | ExaCheckPolyArc (DrawablePtr pDrawable, GCPtr pGC,
|
---|
233 | int narcs, xArc *pArcs);
|
---|
234 |
|
---|
235 | void
|
---|
236 | ExaCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
|
---|
237 | int nrect, xRectangle *prect);
|
---|
238 |
|
---|
239 | void
|
---|
240 | ExaCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
|
---|
241 | int x, int y, unsigned int nglyph,
|
---|
242 | CharInfoPtr *ppci, pointer pglyphBase);
|
---|
243 |
|
---|
244 | void
|
---|
245 | ExaCheckPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
|
---|
246 | int x, int y, unsigned int nglyph,
|
---|
247 | CharInfoPtr *ppci, pointer pglyphBase);
|
---|
248 |
|
---|
249 | void
|
---|
250 | ExaCheckPushPixels (GCPtr pGC, PixmapPtr pBitmap,
|
---|
251 | DrawablePtr pDrawable,
|
---|
252 | int w, int h, int x, int y);
|
---|
253 |
|
---|
254 | void
|
---|
255 | ExaCheckGetImage (DrawablePtr pDrawable,
|
---|
256 | int x, int y, int w, int h,
|
---|
257 | unsigned int format, unsigned long planeMask,
|
---|
258 | char *d);
|
---|
259 |
|
---|
260 | void
|
---|
261 | ExaCheckGetSpans (DrawablePtr pDrawable,
|
---|
262 | int wMax,
|
---|
263 | DDXPointPtr ppt,
|
---|
264 | int *pwidth,
|
---|
265 | int nspans,
|
---|
266 | char *pdstStart);
|
---|
267 |
|
---|
268 | void
|
---|
269 | ExaCheckSaveAreas (PixmapPtr pPixmap,
|
---|
270 | RegionPtr prgnSave,
|
---|
271 | int xorg,
|
---|
272 | int yorg,
|
---|
273 | WindowPtr pWin);
|
---|
274 |
|
---|
275 | void
|
---|
276 | ExaCheckRestoreAreas (PixmapPtr pPixmap,
|
---|
277 | RegionPtr prgnSave,
|
---|
278 | int xorg,
|
---|
279 | int yorg,
|
---|
280 | WindowPtr pWin);
|
---|
281 |
|
---|
282 | void
|
---|
283 | ExaCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
|
---|
284 |
|
---|
285 | CARD32
|
---|
286 | exaGetPixmapFirstPixel (PixmapPtr pPixmap);
|
---|
287 |
|
---|
288 | /* exa_accel.c */
|
---|
289 | void
|
---|
290 | exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
|
---|
291 |
|
---|
292 | void
|
---|
293 | exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
|
---|
294 |
|
---|
295 | void
|
---|
296 | exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h,
|
---|
297 | unsigned int format, unsigned long planeMask, char *d);
|
---|
298 |
|
---|
299 | void
|
---|
300 | exaGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, int *pwidth,
|
---|
301 | int nspans, char *pdstStart);
|
---|
302 |
|
---|
303 | extern const GCOps exaOps;
|
---|
304 |
|
---|
305 | #ifdef RENDER
|
---|
306 | void
|
---|
307 | ExaCheckComposite (CARD8 op,
|
---|
308 | PicturePtr pSrc,
|
---|
309 | PicturePtr pMask,
|
---|
310 | PicturePtr pDst,
|
---|
311 | INT16 xSrc,
|
---|
312 | INT16 ySrc,
|
---|
313 | INT16 xMask,
|
---|
314 | INT16 yMask,
|
---|
315 | INT16 xDst,
|
---|
316 | INT16 yDst,
|
---|
317 | CARD16 width,
|
---|
318 | CARD16 height);
|
---|
319 | #endif
|
---|
320 |
|
---|
321 | /* exaoffscreen.c */
|
---|
322 | void
|
---|
323 | ExaOffscreenMarkUsed (PixmapPtr pPixmap);
|
---|
324 |
|
---|
325 | void
|
---|
326 | ExaOffscreenSwapOut (ScreenPtr pScreen);
|
---|
327 |
|
---|
328 | void
|
---|
329 | ExaOffscreenSwapIn (ScreenPtr pScreen);
|
---|
330 |
|
---|
331 | Bool
|
---|
332 | exaOffscreenInit(ScreenPtr pScreen);
|
---|
333 |
|
---|
334 | void
|
---|
335 | ExaOffscreenFini (ScreenPtr pScreen);
|
---|
336 |
|
---|
337 | /* exa.c */
|
---|
338 | void
|
---|
339 | exaPrepareAccess(DrawablePtr pDrawable, int index);
|
---|
340 |
|
---|
341 | void
|
---|
342 | exaFinishAccess(DrawablePtr pDrawable, int index);
|
---|
343 |
|
---|
344 | void
|
---|
345 | exaDrawableDirty(DrawablePtr pDrawable);
|
---|
346 |
|
---|
347 | Bool
|
---|
348 | exaDrawableIsOffscreen (DrawablePtr pDrawable);
|
---|
349 |
|
---|
350 | Bool
|
---|
351 | exaPixmapIsOffscreen(PixmapPtr p);
|
---|
352 |
|
---|
353 | PixmapPtr
|
---|
354 | exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp);
|
---|
355 |
|
---|
356 | PixmapPtr
|
---|
357 | exaGetDrawablePixmap(DrawablePtr pDrawable);
|
---|
358 |
|
---|
359 | RegionPtr
|
---|
360 | exaCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
|
---|
361 | int srcx, int srcy, int width, int height, int dstx, int dsty);
|
---|
362 |
|
---|
363 | void
|
---|
364 | exaCopyNtoN (DrawablePtr pSrcDrawable,
|
---|
365 | DrawablePtr pDstDrawable,
|
---|
366 | GCPtr pGC,
|
---|
367 | BoxPtr pbox,
|
---|
368 | int nbox,
|
---|
369 | int dx,
|
---|
370 | int dy,
|
---|
371 | Bool reverse,
|
---|
372 | Bool upsidedown,
|
---|
373 | Pixel bitplane,
|
---|
374 | void *closure);
|
---|
375 |
|
---|
376 | /* exa_render.c */
|
---|
377 | void
|
---|
378 | exaComposite(CARD8 op,
|
---|
379 | PicturePtr pSrc,
|
---|
380 | PicturePtr pMask,
|
---|
381 | PicturePtr pDst,
|
---|
382 | INT16 xSrc,
|
---|
383 | INT16 ySrc,
|
---|
384 | INT16 xMask,
|
---|
385 | INT16 yMask,
|
---|
386 | INT16 xDst,
|
---|
387 | INT16 yDst,
|
---|
388 | CARD16 width,
|
---|
389 | CARD16 height);
|
---|
390 |
|
---|
391 | void
|
---|
392 | exaRasterizeTrapezoid (PicturePtr pPicture, xTrapezoid *trap,
|
---|
393 | int x_off, int y_off);
|
---|
394 |
|
---|
395 | void
|
---|
396 | exaAddTriangles (PicturePtr pPicture, INT16 x_off, INT16 y_off, int ntri,
|
---|
397 | xTriangle *tris);
|
---|
398 |
|
---|
399 | void
|
---|
400 | exaGlyphs (CARD8 op,
|
---|
401 | PicturePtr pSrc,
|
---|
402 | PicturePtr pDst,
|
---|
403 | PictFormatPtr maskFormat,
|
---|
404 | INT16 xSrc,
|
---|
405 | INT16 ySrc,
|
---|
406 | int nlist,
|
---|
407 | GlyphListPtr list,
|
---|
408 | GlyphPtr *glyphs);
|
---|
409 |
|
---|
410 | /* exa_migration.c */
|
---|
411 | void
|
---|
412 | exaDoMigration (ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel);
|
---|
413 |
|
---|
414 | void
|
---|
415 | exaMoveInPixmap (PixmapPtr pPixmap);
|
---|
416 |
|
---|
417 | void
|
---|
418 | exaMoveOutPixmap (PixmapPtr pPixmap);
|
---|
419 |
|
---|
420 | #endif /* EXAPRIV_H */
|
---|