First import
[xorg_rtime.git] / xorg-server-1.4 / exa / exa_priv.h
blobbab8aa23b341dcf61909221a44e0c717a5f77628
1 /*
3 * Copyright (C) 2000 Keith Packard, member of The XFree86 Project, Inc.
4 * 2005 Zack Rusin, Trolltech
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.
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.
26 #ifndef EXAPRIV_H
27 #define EXAPRIV_H
29 #ifdef HAVE_DIX_CONFIG_H
30 #include <dix-config.h>
31 #endif
33 #include "exa.h"
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"
56 #define DEBUG_TRACE_FALL 0
57 #define DEBUG_MIGRATE 0
58 #define DEBUG_PIXMAP 0
59 #define DEBUG_OFFSCREEN 0
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)
68 char
69 exaDrawableLocation(DrawablePtr pDrawable);
70 #else
71 #define EXA_FALLBACK(x)
72 #endif
74 #if DEBUG_PIXMAP
75 #define DBG_PIXMAP(a) ErrorF a
76 #else
77 #define DBG_PIXMAP(a)
78 #endif
80 #ifndef EXA_MAX_FB
81 #define EXA_MAX_FB FB_OVERLAY_MAX
82 #endif
84 /**
85 * This is the list of migration heuristics supported by EXA. See
86 * exaDoMigration() for what their implementations do.
88 enum ExaMigrationHeuristic {
89 ExaMigrationGreedy,
90 ExaMigrationAlways,
91 ExaMigrationSmart
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 TrapezoidsProcPtr SavedTrapezoids;
112 #endif
113 Bool swappedOut;
114 enum ExaMigrationHeuristic migration;
115 Bool hideOffscreenPixmapData;
116 Bool checkDirtyCorrectness;
117 unsigned disableFbCount;
118 } ExaScreenPrivRec, *ExaScreenPrivPtr;
121 * This is the only completely portable way to
122 * compute this info.
124 #ifndef BitsPerPixel
125 #define BitsPerPixel(d) (\
126 PixmapWidthPaddingInfo[d].notPower2 ? \
127 (PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \
128 ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
129 (PixmapWidthPaddingInfo[d].padRoundUp+1)))
130 #endif
132 extern int exaScreenPrivateIndex;
133 extern int exaPixmapPrivateIndex;
134 #define ExaGetScreenPriv(s) ((ExaScreenPrivPtr)(s)->devPrivates[exaScreenPrivateIndex].ptr)
135 #define ExaScreenPriv(s) ExaScreenPrivPtr pExaScr = ExaGetScreenPriv(s)
137 /** Align an offset to an arbitrary alignment */
138 #define EXA_ALIGN(offset, align) (((offset) + (align) - 1) - \
139 (((offset) + (align) - 1) % (align)))
140 /** Align an offset to a power-of-two alignment */
141 #define EXA_ALIGN2(offset, align) (((offset) + (align) - 1) & ~((align) - 1))
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
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)
154 typedef struct {
155 ExaOffscreenArea *area;
156 int score; /**< score for the move-in vs move-out heuristic */
158 CARD8 *sys_ptr; /**< pointer to pixmap data in system memory */
159 int sys_pitch; /**< pitch of pixmap in system memory */
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 */
166 * The damage record contains the areas of the pixmap's current location
167 * (framebuffer or system) that have been damaged compared to the other
168 * location.
170 DamagePtr pDamage;
172 * The valid region marks the valid bits of a drawable (at least, as it's
173 * derived from damage, which may be overreported).
175 RegionRec validReg;
176 } ExaPixmapPrivRec, *ExaPixmapPrivPtr;
178 typedef struct _ExaMigrationRec {
179 Bool as_dst;
180 Bool as_src;
181 PixmapPtr pPix;
182 } ExaMigrationRec, *ExaMigrationPtr;
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.
188 void exaDDXDriverInit (ScreenPtr pScreen);
190 /* exa_unaccel.c */
191 void
192 exaPrepareAccessGC(GCPtr pGC);
194 void
195 exaFinishAccessGC(GCPtr pGC);
197 void
198 ExaCheckFillSpans (DrawablePtr pDrawable, GCPtr pGC, int nspans,
199 DDXPointPtr ppt, int *pwidth, int fSorted);
201 void
202 ExaCheckSetSpans (DrawablePtr pDrawable, GCPtr pGC, char *psrc,
203 DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
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);
210 RegionPtr
211 ExaCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
212 int srcx, int srcy, int w, int h, int dstx, int dsty);
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);
219 void
220 ExaCheckPolyPoint (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
221 DDXPointPtr pptInit);
223 void
224 ExaCheckPolylines (DrawablePtr pDrawable, GCPtr pGC,
225 int mode, int npt, DDXPointPtr ppt);
227 void
228 ExaCheckPolySegment (DrawablePtr pDrawable, GCPtr pGC,
229 int nsegInit, xSegment *pSegInit);
231 void
232 ExaCheckPolyArc (DrawablePtr pDrawable, GCPtr pGC,
233 int narcs, xArc *pArcs);
235 void
236 ExaCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
237 int nrect, xRectangle *prect);
239 void
240 ExaCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
241 int x, int y, unsigned int nglyph,
242 CharInfoPtr *ppci, pointer pglyphBase);
244 void
245 ExaCheckPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
246 int x, int y, unsigned int nglyph,
247 CharInfoPtr *ppci, pointer pglyphBase);
249 void
250 ExaCheckPushPixels (GCPtr pGC, PixmapPtr pBitmap,
251 DrawablePtr pDrawable,
252 int w, int h, int x, int y);
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);
260 void
261 ExaCheckGetSpans (DrawablePtr pDrawable,
262 int wMax,
263 DDXPointPtr ppt,
264 int *pwidth,
265 int nspans,
266 char *pdstStart);
268 void
269 ExaCheckSaveAreas (PixmapPtr pPixmap,
270 RegionPtr prgnSave,
271 int xorg,
272 int yorg,
273 WindowPtr pWin);
275 void
276 ExaCheckRestoreAreas (PixmapPtr pPixmap,
277 RegionPtr prgnSave,
278 int xorg,
279 int yorg,
280 WindowPtr pWin);
282 void
283 ExaCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
285 CARD32
286 exaGetPixmapFirstPixel (PixmapPtr pPixmap);
288 /* exa_accel.c */
289 void
290 exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
292 Bool
293 exaFillRegionTiled (DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
294 DDXPointPtr pPatOrg, CARD32 planemask, CARD32 alu);
296 void
297 exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
299 void
300 exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h,
301 unsigned int format, unsigned long planeMask, char *d);
303 void
304 exaGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, int *pwidth,
305 int nspans, char *pdstStart);
307 extern const GCOps exaOps;
309 #ifdef RENDER
310 void
311 ExaCheckComposite (CARD8 op,
312 PicturePtr pSrc,
313 PicturePtr pMask,
314 PicturePtr pDst,
315 INT16 xSrc,
316 INT16 ySrc,
317 INT16 xMask,
318 INT16 yMask,
319 INT16 xDst,
320 INT16 yDst,
321 CARD16 width,
322 CARD16 height);
323 #endif
325 /* exa_offscreen.c */
326 void
327 ExaOffscreenSwapOut (ScreenPtr pScreen);
329 void
330 ExaOffscreenSwapIn (ScreenPtr pScreen);
332 Bool
333 exaOffscreenInit(ScreenPtr pScreen);
335 void
336 ExaOffscreenFini (ScreenPtr pScreen);
338 /* exa.c */
339 void
340 exaPrepareAccess(DrawablePtr pDrawable, int index);
342 void
343 exaFinishAccess(DrawablePtr pDrawable, int index);
345 void
346 exaPixmapDirty(PixmapPtr pPix, int x1, int y1, int x2, int y2);
348 void
349 exaGetDrawableDeltas (DrawablePtr pDrawable, PixmapPtr pPixmap,
350 int *xp, int *yp);
352 Bool
353 exaDrawableIsOffscreen (DrawablePtr pDrawable);
355 Bool
356 exaPixmapIsOffscreen(PixmapPtr p);
358 PixmapPtr
359 exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp);
361 PixmapPtr
362 exaGetDrawablePixmap(DrawablePtr pDrawable);
364 RegionPtr
365 exaCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
366 int srcx, int srcy, int width, int height, int dstx, int dsty);
368 void
369 exaCopyNtoN (DrawablePtr pSrcDrawable,
370 DrawablePtr pDstDrawable,
371 GCPtr pGC,
372 BoxPtr pbox,
373 int nbox,
374 int dx,
375 int dy,
376 Bool reverse,
377 Bool upsidedown,
378 Pixel bitplane,
379 void *closure);
381 /* exa_render.c */
382 void
383 exaComposite(CARD8 op,
384 PicturePtr pSrc,
385 PicturePtr pMask,
386 PicturePtr pDst,
387 INT16 xSrc,
388 INT16 ySrc,
389 INT16 xMask,
390 INT16 yMask,
391 INT16 xDst,
392 INT16 yDst,
393 CARD16 width,
394 CARD16 height);
396 void
397 exaTrapezoids (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
398 PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
399 int ntrap, xTrapezoid *traps);
401 void
402 exaRasterizeTrapezoid (PicturePtr pPicture, xTrapezoid *trap,
403 int x_off, int y_off);
405 void
406 exaAddTriangles (PicturePtr pPicture, INT16 x_off, INT16 y_off, int ntri,
407 xTriangle *tris);
409 void
410 exaGlyphs (CARD8 op,
411 PicturePtr pSrc,
412 PicturePtr pDst,
413 PictFormatPtr maskFormat,
414 INT16 xSrc,
415 INT16 ySrc,
416 int nlist,
417 GlyphListPtr list,
418 GlyphPtr *glyphs);
420 /* exa_migration.c */
421 void
422 exaDoMigration (ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel);
424 void
425 exaPixmapSave (ScreenPtr pScreen, ExaOffscreenArea *area);
427 #endif /* EXAPRIV_H */