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
29 #ifdef HAVE_DIX_CONFIG_H
30 #include <dix-config.h>
37 #include <X11/Xproto.h>
38 #include "scrnintstr.h"
39 #include "pixmapstr.h"
40 #include "windowstr.h"
43 #include "colormapst.h"
46 #include "mipointer.h"
50 #include "fboverlay.h"
56 #define DEBUG_TRACE_FALL 0
57 #define DEBUG_MIGRATE 0
58 #define DEBUG_PIXMAP 0
59 #define DEBUG_OFFSCREEN 0
62 #define EXA_FALLBACK(x) \
64 ErrorF("EXA fallback at %s: ", __FUNCTION__); \
69 exaDrawableLocation(DrawablePtr pDrawable
);
71 #define EXA_FALLBACK(x)
75 #define DBG_PIXMAP(a) ErrorF a
81 #define EXA_MAX_FB FB_OVERLAY_MAX
85 * This is the list of migration heuristics supported by EXA. See
86 * exaDoMigration() for what their implementations do.
88 enum ExaMigrationHeuristic
{
94 typedef void (*EnableDisableFBAccessProcPtr
)(int, Bool
);
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
;
107 CompositeProcPtr SavedComposite
;
108 RasterizeTrapezoidProcPtr SavedRasterizeTrapezoid
;
109 AddTrianglesProcPtr SavedAddTriangles
;
110 GlyphsProcPtr SavedGlyphs
;
111 TrapezoidsProcPtr SavedTrapezoids
;
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
125 #define BitsPerPixel(d) (\
126 PixmapWidthPaddingInfo[d].notPower2 ? \
127 (PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \
128 ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
129 (PixmapWidthPaddingInfo[d].padRoundUp+1)))
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)
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
172 * The valid region marks the valid bits of a drawable (at least, as it's
173 * derived from damage, which may be overreported).
176 } ExaPixmapPrivRec
, *ExaPixmapPrivPtr
;
178 typedef struct _ExaMigrationRec
{
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
);
192 exaPrepareAccessGC(GCPtr pGC
);
195 exaFinishAccessGC(GCPtr pGC
);
198 ExaCheckFillSpans (DrawablePtr pDrawable
, GCPtr pGC
, int nspans
,
199 DDXPointPtr ppt
, int *pwidth
, int fSorted
);
202 ExaCheckSetSpans (DrawablePtr pDrawable
, GCPtr pGC
, char *psrc
,
203 DDXPointPtr ppt
, int *pwidth
, int nspans
, int fSorted
);
206 ExaCheckPutImage (DrawablePtr pDrawable
, GCPtr pGC
, int depth
,
207 int x
, int y
, int w
, int h
, int leftPad
, int format
,
211 ExaCheckCopyArea (DrawablePtr pSrc
, DrawablePtr pDst
, GCPtr pGC
,
212 int srcx
, int srcy
, int w
, int h
, int dstx
, int dsty
);
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
);
220 ExaCheckPolyPoint (DrawablePtr pDrawable
, GCPtr pGC
, int mode
, int npt
,
221 DDXPointPtr pptInit
);
224 ExaCheckPolylines (DrawablePtr pDrawable
, GCPtr pGC
,
225 int mode
, int npt
, DDXPointPtr ppt
);
228 ExaCheckPolySegment (DrawablePtr pDrawable
, GCPtr pGC
,
229 int nsegInit
, xSegment
*pSegInit
);
232 ExaCheckPolyArc (DrawablePtr pDrawable
, GCPtr pGC
,
233 int narcs
, xArc
*pArcs
);
236 ExaCheckPolyFillRect (DrawablePtr pDrawable
, GCPtr pGC
,
237 int nrect
, xRectangle
*prect
);
240 ExaCheckImageGlyphBlt (DrawablePtr pDrawable
, GCPtr pGC
,
241 int x
, int y
, unsigned int nglyph
,
242 CharInfoPtr
*ppci
, pointer pglyphBase
);
245 ExaCheckPolyGlyphBlt (DrawablePtr pDrawable
, GCPtr pGC
,
246 int x
, int y
, unsigned int nglyph
,
247 CharInfoPtr
*ppci
, pointer pglyphBase
);
250 ExaCheckPushPixels (GCPtr pGC
, PixmapPtr pBitmap
,
251 DrawablePtr pDrawable
,
252 int w
, int h
, int x
, int y
);
255 ExaCheckGetImage (DrawablePtr pDrawable
,
256 int x
, int y
, int w
, int h
,
257 unsigned int format
, unsigned long planeMask
,
261 ExaCheckGetSpans (DrawablePtr pDrawable
,
269 ExaCheckSaveAreas (PixmapPtr pPixmap
,
276 ExaCheckRestoreAreas (PixmapPtr pPixmap
,
283 ExaCheckPaintWindow (WindowPtr pWin
, RegionPtr pRegion
, int what
);
286 exaGetPixmapFirstPixel (PixmapPtr pPixmap
);
290 exaCopyWindow(WindowPtr pWin
, DDXPointRec ptOldOrg
, RegionPtr prgnSrc
);
293 exaFillRegionTiled (DrawablePtr pDrawable
, RegionPtr pRegion
, PixmapPtr pTile
,
294 DDXPointPtr pPatOrg
, CARD32 planemask
, CARD32 alu
);
297 exaPaintWindow(WindowPtr pWin
, RegionPtr pRegion
, int what
);
300 exaGetImage (DrawablePtr pDrawable
, int x
, int y
, int w
, int h
,
301 unsigned int format
, unsigned long planeMask
, char *d
);
304 exaGetSpans (DrawablePtr pDrawable
, int wMax
, DDXPointPtr ppt
, int *pwidth
,
305 int nspans
, char *pdstStart
);
307 extern const GCOps exaOps
;
311 ExaCheckComposite (CARD8 op
,
325 /* exa_offscreen.c */
327 ExaOffscreenSwapOut (ScreenPtr pScreen
);
330 ExaOffscreenSwapIn (ScreenPtr pScreen
);
333 exaOffscreenInit(ScreenPtr pScreen
);
336 ExaOffscreenFini (ScreenPtr pScreen
);
340 exaPrepareAccess(DrawablePtr pDrawable
, int index
);
343 exaFinishAccess(DrawablePtr pDrawable
, int index
);
346 exaPixmapDirty(PixmapPtr pPix
, int x1
, int y1
, int x2
, int y2
);
349 exaGetDrawableDeltas (DrawablePtr pDrawable
, PixmapPtr pPixmap
,
353 exaDrawableIsOffscreen (DrawablePtr pDrawable
);
356 exaPixmapIsOffscreen(PixmapPtr p
);
359 exaGetOffscreenPixmap (DrawablePtr pDrawable
, int *xp
, int *yp
);
362 exaGetDrawablePixmap(DrawablePtr pDrawable
);
365 exaCopyArea(DrawablePtr pSrcDrawable
, DrawablePtr pDstDrawable
, GCPtr pGC
,
366 int srcx
, int srcy
, int width
, int height
, int dstx
, int dsty
);
369 exaCopyNtoN (DrawablePtr pSrcDrawable
,
370 DrawablePtr pDstDrawable
,
383 exaComposite(CARD8 op
,
397 exaTrapezoids (CARD8 op
, PicturePtr pSrc
, PicturePtr pDst
,
398 PictFormatPtr maskFormat
, INT16 xSrc
, INT16 ySrc
,
399 int ntrap
, xTrapezoid
*traps
);
402 exaRasterizeTrapezoid (PicturePtr pPicture
, xTrapezoid
*trap
,
403 int x_off
, int y_off
);
406 exaAddTriangles (PicturePtr pPicture
, INT16 x_off
, INT16 y_off
, int ntri
,
413 PictFormatPtr maskFormat
,
420 /* exa_migration.c */
422 exaDoMigration (ExaMigrationPtr pixmaps
, int npixmaps
, Bool can_accel
);
425 exaPixmapSave (ScreenPtr pScreen
, ExaOffscreenArea
*area
);
427 #endif /* EXAPRIV_H */