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 | #include "damage.h"
|
---|
55 |
|
---|
56 | #define DEBUG_TRACE_FALL 0
|
---|
57 | #define DEBUG_MIGRATE 0
|
---|
58 | #define DEBUG_PIXMAP 0
|
---|
59 | #define DEBUG_OFFSCREEN 0
|
---|
60 |
|
---|
61 | #if DEBUG_TRACE_FALL
|
---|
62 | #define EXA_FALLBACK(x) \
|
---|
63 | do { \
|
---|
64 | ErrorF("EXA fallback at %s: ", __FUNCTION__); \
|
---|
65 | ErrorF x; \
|
---|
66 | } while (0)
|
---|
67 |
|
---|
68 | char
|
---|
69 | exaDrawableLocation(DrawablePtr pDrawable);
|
---|
70 | #else
|
---|
71 | #define EXA_FALLBACK(x)
|
---|
72 | #endif
|
---|
73 |
|
---|
74 | #if DEBUG_PIXMAP
|
---|
75 | #define DBG_PIXMAP(a) ErrorF a
|
---|
76 | #else
|
---|
77 | #define DBG_PIXMAP(a)
|
---|
78 | #endif
|
---|
79 |
|
---|
80 | #ifndef EXA_MAX_FB
|
---|
81 | #define EXA_MAX_FB FB_OVERLAY_MAX
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * This is the list of migration heuristics supported by EXA. See
|
---|
86 | * exaDoMigration() for what their implementations do.
|
---|
87 | */
|
---|
88 | enum ExaMigrationHeuristic {
|
---|
89 | ExaMigrationGreedy,
|
---|
90 | ExaMigrationAlways,
|
---|
91 | ExaMigrationSmart
|
---|
92 | };
|
---|
93 |
|
---|
94 | typedef void (*EnableDisableFBAccessProcPtr)(int, Bool);
|
---|
95 | typedef struct {
|
---|
96 | ExaDriverPtr info;
|
---|
97 | CreateGCProcPtr SavedCreateGC;
|
---|
98 | CloseScreenProcPtr SavedCloseScreen;
|
---|
99 | GetImageProcPtr SavedGetImage;
|
---|
100 | GetSpansProcPtr SavedGetSpans;
|
---|
101 | PaintWindowBackgroundProcPtr SavedPaintWindowBackground;
|
---|
102 | CreatePixmapProcPtr SavedCreatePixmap;
|
---|
103 | DestroyPixmapProcPtr SavedDestroyPixmap;
|
---|
104 | PaintWindowBorderProcPtr SavedPaintWindowBorder;
|
---|
105 | CopyWindowProcPtr SavedCopyWindow;
|
---|
106 | #ifdef RENDER
|
---|
107 | CompositeProcPtr SavedComposite;
|
---|
108 | RasterizeTrapezoidProcPtr SavedRasterizeTrapezoid;
|
---|
109 | AddTrianglesProcPtr SavedAddTriangles;
|
---|
110 | GlyphsProcPtr SavedGlyphs;
|
---|
111 | #endif
|
---|
112 | Bool swappedOut;
|
---|
113 | enum ExaMigrationHeuristic migration;
|
---|
114 | Bool hideOffscreenPixmapData;
|
---|
115 | Bool checkDirtyCorrectness;
|
---|
116 | } ExaScreenPrivRec, *ExaScreenPrivPtr;
|
---|
117 |
|
---|
118 | /*
|
---|
119 | * This is the only completely portable way to
|
---|
120 | * compute this info.
|
---|
121 | */
|
---|
122 | #ifndef BitsPerPixel
|
---|
123 | #define BitsPerPixel(d) (\
|
---|
124 | PixmapWidthPaddingInfo[d].notPower2 ? \
|
---|
125 | (PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \
|
---|
126 | ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
|
---|
127 | (PixmapWidthPaddingInfo[d].padRoundUp+1)))
|
---|
128 | #endif
|
---|
129 |
|
---|
130 | extern int exaScreenPrivateIndex;
|
---|
131 | extern int exaPixmapPrivateIndex;
|
---|
132 | #define ExaGetScreenPriv(s) ((ExaScreenPrivPtr)(s)->devPrivates[exaScreenPrivateIndex].ptr)
|
---|
133 | #define ExaScreenPriv(s) ExaScreenPrivPtr pExaScr = ExaGetScreenPriv(s)
|
---|
134 |
|
---|
135 | /** Align an offset to an arbitrary alignment */
|
---|
136 | #define EXA_ALIGN(offset, align) (((offset) + (align) - 1) - \
|
---|
137 | (((offset) + (align) - 1) % (align)))
|
---|
138 | /** Align an offset to a power-of-two alignment */
|
---|
139 | #define EXA_ALIGN2(offset, align) (((offset) + (align) - 1) & ~((align) - 1))
|
---|
140 |
|
---|
141 | #define EXA_PIXMAP_SCORE_MOVE_IN 10
|
---|
142 | #define EXA_PIXMAP_SCORE_MAX 20
|
---|
143 | #define EXA_PIXMAP_SCORE_MOVE_OUT -10
|
---|
144 | #define EXA_PIXMAP_SCORE_MIN -20
|
---|
145 | #define EXA_PIXMAP_SCORE_PINNED 1000
|
---|
146 | #define EXA_PIXMAP_SCORE_INIT 1001
|
---|
147 |
|
---|
148 | #define ExaGetPixmapPriv(p) ((ExaPixmapPrivPtr)(p)->devPrivates[exaPixmapPrivateIndex].ptr)
|
---|
149 | #define ExaSetPixmapPriv(p,a) ((p)->devPrivates[exaPixmapPrivateIndex].ptr = (pointer) (a))
|
---|
150 | #define ExaPixmapPriv(p) ExaPixmapPrivPtr pExaPixmap = ExaGetPixmapPriv(p)
|
---|
151 |
|
---|
152 | typedef struct {
|
---|
153 | ExaOffscreenArea *area;
|
---|
154 | int score; /**< score for the move-in vs move-out heuristic */
|
---|
155 |
|
---|
156 | CARD8 *sys_ptr; /**< pointer to pixmap data in system memory */
|
---|
157 | int sys_pitch; /**< pitch of pixmap in system memory */
|
---|
158 |
|
---|
159 | CARD8 *fb_ptr; /**< pointer to pixmap data in framebuffer memory */
|
---|
160 | int fb_pitch; /**< pitch of pixmap in framebuffer memory */
|
---|
161 | unsigned int fb_size; /**< size of pixmap in framebuffer memory */
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * The damage record contains the areas of the pixmap's current location
|
---|
165 | * (framebuffer or system) that have been damaged compared to the other
|
---|
166 | * location.
|
---|
167 | */
|
---|
168 | DamagePtr pDamage;
|
---|
169 | /**
|
---|
170 | * The valid region marks the valid bits of a drawable (at least, as it's
|
---|
171 | * derived from damage, which may be overreported).
|
---|
172 | */
|
---|
173 | RegionRec validReg;
|
---|
174 | } ExaPixmapPrivRec, *ExaPixmapPrivPtr;
|
---|
175 |
|
---|
176 | typedef struct _ExaMigrationRec {
|
---|
177 | Bool as_dst;
|
---|
178 | Bool as_src;
|
---|
179 | PixmapPtr pPix;
|
---|
180 | } ExaMigrationRec, *ExaMigrationPtr;
|
---|
181 |
|
---|
182 | /**
|
---|
183 | * exaDDXDriverInit must be implemented by the DDX using EXA, and is the place
|
---|
184 | * to set EXA options or hook in screen functions to handle using EXA as the AA.
|
---|
185 | */
|
---|
186 | void exaDDXDriverInit (ScreenPtr pScreen);
|
---|
187 |
|
---|
188 | /* exa_unaccel.c */
|
---|
189 | void
|
---|
190 | exaPrepareAccessGC(GCPtr pGC);
|
---|
191 |
|
---|
192 | void
|
---|
193 | exaFinishAccessGC(GCPtr pGC);
|
---|
194 |
|
---|
195 | void
|
---|
196 | ExaCheckFillSpans (DrawablePtr pDrawable, GCPtr pGC, int nspans,
|
---|
197 | DDXPointPtr ppt, int *pwidth, int fSorted);
|
---|
198 |
|
---|
199 | void
|
---|
200 | ExaCheckSetSpans (DrawablePtr pDrawable, GCPtr pGC, char *psrc,
|
---|
201 | DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
|
---|
202 |
|
---|
203 | void
|
---|
204 | ExaCheckPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth,
|
---|
205 | int x, int y, int w, int h, int leftPad, int format,
|
---|
206 | char *bits);
|
---|
207 |
|
---|
208 | RegionPtr
|
---|
209 | ExaCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
---|
210 | int srcx, int srcy, int w, int h, int dstx, int dsty);
|
---|
211 |
|
---|
212 | RegionPtr
|
---|
213 | ExaCheckCopyPlane (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
---|
214 | int srcx, int srcy, int w, int h, int dstx, int dsty,
|
---|
215 | unsigned long bitPlane);
|
---|
216 |
|
---|
217 | void
|
---|
218 | ExaCheckPolyPoint (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
---|
219 | DDXPointPtr pptInit);
|
---|
220 |
|
---|
221 | void
|
---|
222 | ExaCheckPolylines (DrawablePtr pDrawable, GCPtr pGC,
|
---|
223 | int mode, int npt, DDXPointPtr ppt);
|
---|
224 |
|
---|
225 | void
|
---|
226 | ExaCheckPolySegment (DrawablePtr pDrawable, GCPtr pGC,
|
---|
227 | int nsegInit, xSegment *pSegInit);
|
---|
228 |
|
---|
229 | void
|
---|
230 | ExaCheckPolyArc (DrawablePtr pDrawable, GCPtr pGC,
|
---|
231 | int narcs, xArc *pArcs);
|
---|
232 |
|
---|
233 | void
|
---|
234 | ExaCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
|
---|
235 | int nrect, xRectangle *prect);
|
---|
236 |
|
---|
237 | void
|
---|
238 | ExaCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
|
---|
239 | int x, int y, unsigned int nglyph,
|
---|
240 | CharInfoPtr *ppci, pointer pglyphBase);
|
---|
241 |
|
---|
242 | void
|
---|
243 | ExaCheckPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
|
---|
244 | int x, int y, unsigned int nglyph,
|
---|
245 | CharInfoPtr *ppci, pointer pglyphBase);
|
---|
246 |
|
---|
247 | void
|
---|
248 | ExaCheckPushPixels (GCPtr pGC, PixmapPtr pBitmap,
|
---|
249 | DrawablePtr pDrawable,
|
---|
250 | int w, int h, int x, int y);
|
---|
251 |
|
---|
252 | void
|
---|
253 | ExaCheckGetImage (DrawablePtr pDrawable,
|
---|
254 | int x, int y, int w, int h,
|
---|
255 | unsigned int format, unsigned long planeMask,
|
---|
256 | char *d);
|
---|
257 |
|
---|
258 | void
|
---|
259 | ExaCheckGetSpans (DrawablePtr pDrawable,
|
---|
260 | int wMax,
|
---|
261 | DDXPointPtr ppt,
|
---|
262 | int *pwidth,
|
---|
263 | int nspans,
|
---|
264 | char *pdstStart);
|
---|
265 |
|
---|
266 | void
|
---|
267 | ExaCheckSaveAreas (PixmapPtr pPixmap,
|
---|
268 | RegionPtr prgnSave,
|
---|
269 | int xorg,
|
---|
270 | int yorg,
|
---|
271 | WindowPtr pWin);
|
---|
272 |
|
---|
273 | void
|
---|
274 | ExaCheckRestoreAreas (PixmapPtr pPixmap,
|
---|
275 | RegionPtr prgnSave,
|
---|
276 | int xorg,
|
---|
277 | int yorg,
|
---|
278 | WindowPtr pWin);
|
---|
279 |
|
---|
280 | void
|
---|
281 | ExaCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
|
---|
282 |
|
---|
283 | CARD32
|
---|
284 | exaGetPixmapFirstPixel (PixmapPtr pPixmap);
|
---|
285 |
|
---|
286 | /* exa_accel.c */
|
---|
287 | void
|
---|
288 | exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
|
---|
289 |
|
---|
290 | void
|
---|
291 | exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
|
---|
292 |
|
---|
293 | void
|
---|
294 | exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h,
|
---|
295 | unsigned int format, unsigned long planeMask, char *d);
|
---|
296 |
|
---|
297 | void
|
---|
298 | exaGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, int *pwidth,
|
---|
299 | int nspans, char *pdstStart);
|
---|
300 |
|
---|
301 | extern const GCOps exaOps;
|
---|
302 |
|
---|
303 | #ifdef RENDER
|
---|
304 | void
|
---|
305 | ExaCheckComposite (CARD8 op,
|
---|
306 | PicturePtr pSrc,
|
---|
307 | PicturePtr pMask,
|
---|
308 | PicturePtr pDst,
|
---|
309 | INT16 xSrc,
|
---|
310 | INT16 ySrc,
|
---|
311 | INT16 xMask,
|
---|
312 | INT16 yMask,
|
---|
313 | INT16 xDst,
|
---|
314 | INT16 yDst,
|
---|
315 | CARD16 width,
|
---|
316 | CARD16 height);
|
---|
317 | #endif
|
---|
318 |
|
---|
319 | /* exa_offscreen.c */
|
---|
320 | void
|
---|
321 | ExaOffscreenMarkUsed (PixmapPtr pPixmap);
|
---|
322 |
|
---|
323 | void
|
---|
324 | ExaOffscreenSwapOut (ScreenPtr pScreen);
|
---|
325 |
|
---|
326 | void
|
---|
327 | ExaOffscreenSwapIn (ScreenPtr pScreen);
|
---|
328 |
|
---|
329 | Bool
|
---|
330 | exaOffscreenInit(ScreenPtr pScreen);
|
---|
331 |
|
---|
332 | void
|
---|
333 | ExaOffscreenFini (ScreenPtr pScreen);
|
---|
334 |
|
---|
335 | /* exa.c */
|
---|
336 | void
|
---|
337 | exaPrepareAccess(DrawablePtr pDrawable, int index);
|
---|
338 |
|
---|
339 | void
|
---|
340 | exaFinishAccess(DrawablePtr pDrawable, int index);
|
---|
341 |
|
---|
342 | void
|
---|
343 | exaPixmapDirty(PixmapPtr pPix, int x1, int y1, int x2, int y2);
|
---|
344 |
|
---|
345 | void
|
---|
346 | exaDrawableDirty(DrawablePtr pDrawable, int x1, int y1, int x2, int y2);
|
---|
347 |
|
---|
348 | Bool
|
---|
349 | exaDrawableIsOffscreen (DrawablePtr pDrawable);
|
---|
350 |
|
---|
351 | Bool
|
---|
352 | exaPixmapIsOffscreen(PixmapPtr p);
|
---|
353 |
|
---|
354 | PixmapPtr
|
---|
355 | exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp);
|
---|
356 |
|
---|
357 | PixmapPtr
|
---|
358 | exaGetDrawablePixmap(DrawablePtr pDrawable);
|
---|
359 |
|
---|
360 | RegionPtr
|
---|
361 | exaCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
|
---|
362 | int srcx, int srcy, int width, int height, int dstx, int dsty);
|
---|
363 |
|
---|
364 | void
|
---|
365 | exaCopyNtoN (DrawablePtr pSrcDrawable,
|
---|
366 | DrawablePtr pDstDrawable,
|
---|
367 | GCPtr pGC,
|
---|
368 | BoxPtr pbox,
|
---|
369 | int nbox,
|
---|
370 | int dx,
|
---|
371 | int dy,
|
---|
372 | Bool reverse,
|
---|
373 | Bool upsidedown,
|
---|
374 | Pixel bitplane,
|
---|
375 | void *closure);
|
---|
376 |
|
---|
377 | /* exa_render.c */
|
---|
378 | void
|
---|
379 | exaComposite(CARD8 op,
|
---|
380 | PicturePtr pSrc,
|
---|
381 | PicturePtr pMask,
|
---|
382 | PicturePtr pDst,
|
---|
383 | INT16 xSrc,
|
---|
384 | INT16 ySrc,
|
---|
385 | INT16 xMask,
|
---|
386 | INT16 yMask,
|
---|
387 | INT16 xDst,
|
---|
388 | INT16 yDst,
|
---|
389 | CARD16 width,
|
---|
390 | CARD16 height);
|
---|
391 |
|
---|
392 | void
|
---|
393 | exaRasterizeTrapezoid (PicturePtr pPicture, xTrapezoid *trap,
|
---|
394 | int x_off, int y_off);
|
---|
395 |
|
---|
396 | void
|
---|
397 | exaAddTriangles (PicturePtr pPicture, INT16 x_off, INT16 y_off, int ntri,
|
---|
398 | xTriangle *tris);
|
---|
399 |
|
---|
400 | void
|
---|
401 | exaGlyphs (CARD8 op,
|
---|
402 | PicturePtr pSrc,
|
---|
403 | PicturePtr pDst,
|
---|
404 | PictFormatPtr maskFormat,
|
---|
405 | INT16 xSrc,
|
---|
406 | INT16 ySrc,
|
---|
407 | int nlist,
|
---|
408 | GlyphListPtr list,
|
---|
409 | GlyphPtr *glyphs);
|
---|
410 |
|
---|
411 | /* exa_migration.c */
|
---|
412 | void
|
---|
413 | exaDoMigration (ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel);
|
---|
414 |
|
---|
415 | void
|
---|
416 | exaPixmapSave (ScreenPtr pScreen, ExaOffscreenArea *area);
|
---|
417 |
|
---|
418 | #endif /* EXAPRIV_H */
|
---|