1706f2543Smrg/*
2706f2543Smrg *
3706f2543Smrg * Copyright (C) 2000 Keith Packard, member of The XFree86 Project, Inc.
4706f2543Smrg *               2005 Zack Rusin, Trolltech
5706f2543Smrg *
6706f2543Smrg * Permission to use, copy, modify, distribute, and sell this software and its
7706f2543Smrg * documentation for any purpose is hereby granted without fee, provided that
8706f2543Smrg * the above copyright notice appear in all copies and that both that
9706f2543Smrg * copyright notice and this permission notice appear in supporting
10706f2543Smrg * documentation, and that the name of Keith Packard not be used in
11706f2543Smrg * advertising or publicity pertaining to distribution of the software without
12706f2543Smrg * specific, written prior permission.  Keith Packard makes no
13706f2543Smrg * representations about the suitability of this software for any purpose.  It
14706f2543Smrg * is provided "as is" without express or implied warranty.
15706f2543Smrg *
16706f2543Smrg * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17706f2543Smrg * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18706f2543Smrg * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19706f2543Smrg * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20706f2543Smrg * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
21706f2543Smrg * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
22706f2543Smrg * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
23706f2543Smrg * SOFTWARE.
24706f2543Smrg */
25706f2543Smrg
26706f2543Smrg#ifndef EXAPRIV_H
27706f2543Smrg#define EXAPRIV_H
28706f2543Smrg
29706f2543Smrg#ifdef HAVE_DIX_CONFIG_H
30706f2543Smrg#include <dix-config.h>
31706f2543Smrg#endif
32706f2543Smrg
33706f2543Smrg#include "exa.h"
34706f2543Smrg
35706f2543Smrg#include <X11/X.h>
36706f2543Smrg#include <X11/Xproto.h>
37706f2543Smrg#ifdef MITSHM
38706f2543Smrg#include "shmint.h"
39706f2543Smrg#endif
40706f2543Smrg#include "scrnintstr.h"
41706f2543Smrg#include "pixmapstr.h"
42706f2543Smrg#include "windowstr.h"
43706f2543Smrg#include "servermd.h"
44706f2543Smrg#include "mibstore.h"
45706f2543Smrg#include "colormapst.h"
46706f2543Smrg#include "gcstruct.h"
47706f2543Smrg#include "input.h"
48706f2543Smrg#include "mipointer.h"
49706f2543Smrg#include "mi.h"
50706f2543Smrg#include "dix.h"
51706f2543Smrg#include "fb.h"
52706f2543Smrg#include "fboverlay.h"
53706f2543Smrg#include "fbpict.h"
54706f2543Smrg#include "glyphstr.h"
55706f2543Smrg#include "damage.h"
56706f2543Smrg
57706f2543Smrg#define DEBUG_TRACE_FALL	0
58706f2543Smrg#define DEBUG_MIGRATE		0
59706f2543Smrg#define DEBUG_PIXMAP		0
60706f2543Smrg#define DEBUG_OFFSCREEN		0
61706f2543Smrg#define DEBUG_GLYPH_CACHE	0
62706f2543Smrg
63706f2543Smrg#if DEBUG_TRACE_FALL
64706f2543Smrg#define EXA_FALLBACK(x)     					\
65706f2543Smrgdo {								\
66706f2543Smrg	ErrorF("EXA fallback at %s: ", __FUNCTION__);		\
67706f2543Smrg	ErrorF x;						\
68706f2543Smrg} while (0)
69706f2543Smrg
70706f2543Smrgchar
71706f2543SmrgexaDrawableLocation(DrawablePtr pDrawable);
72706f2543Smrg#else
73706f2543Smrg#define EXA_FALLBACK(x)
74706f2543Smrg#endif
75706f2543Smrg
76706f2543Smrg#if DEBUG_PIXMAP
77706f2543Smrg#define DBG_PIXMAP(a) ErrorF a
78706f2543Smrg#else
79706f2543Smrg#define DBG_PIXMAP(a)
80706f2543Smrg#endif
81706f2543Smrg
82706f2543Smrg#ifndef EXA_MAX_FB
83706f2543Smrg#define EXA_MAX_FB   FB_OVERLAY_MAX
84706f2543Smrg#endif
85706f2543Smrg
86706f2543Smrg#ifdef DEBUG
87706f2543Smrg#define EXA_FatalErrorDebug(x) FatalError x
88706f2543Smrg#define EXA_FatalErrorDebugWithRet(x, ret) FatalError x
89706f2543Smrg#else
90706f2543Smrg#define EXA_FatalErrorDebug(x) ErrorF x
91706f2543Smrg#define EXA_FatalErrorDebugWithRet(x, ret) \
92706f2543Smrgdo { \
93706f2543Smrg    ErrorF x; \
94706f2543Smrg    return ret; \
95706f2543Smrg} while (0)
96706f2543Smrg#endif
97706f2543Smrg
98706f2543Smrg/**
99706f2543Smrg * This is the list of migration heuristics supported by EXA.  See
100706f2543Smrg * exaDoMigration() for what their implementations do.
101706f2543Smrg */
102706f2543Smrgenum ExaMigrationHeuristic {
103706f2543Smrg    ExaMigrationGreedy,
104706f2543Smrg    ExaMigrationAlways,
105706f2543Smrg    ExaMigrationSmart
106706f2543Smrg};
107706f2543Smrg
108706f2543Smrgtypedef struct {
109706f2543Smrg    unsigned char sha1[20];
110706f2543Smrg} ExaCachedGlyphRec, *ExaCachedGlyphPtr;
111706f2543Smrg
112706f2543Smrgtypedef struct {
113706f2543Smrg    /* The identity of the cache, statically configured at initialization */
114706f2543Smrg    unsigned int format;
115706f2543Smrg    int glyphWidth;
116706f2543Smrg    int glyphHeight;
117706f2543Smrg
118706f2543Smrg    int size; /* Size of cache; eventually this should be dynamically determined */
119706f2543Smrg
120706f2543Smrg    /* Hash table mapping from glyph sha1 to position in the glyph; we use
121706f2543Smrg     * open addressing with a hash table size determined based on size and large
122706f2543Smrg     * enough so that we always have a good amount of free space, so we can
123706f2543Smrg     * use linear probing. (Linear probing is preferrable to double hashing
124706f2543Smrg     * here because it allows us to easily remove entries.)
125706f2543Smrg     */
126706f2543Smrg    int *hashEntries;
127706f2543Smrg    int hashSize;
128706f2543Smrg
129706f2543Smrg    ExaCachedGlyphPtr glyphs;
130706f2543Smrg    int glyphCount; /* Current number of glyphs */
131706f2543Smrg
132706f2543Smrg    PicturePtr picture;   /* Where the glyphs of the cache are stored */
133706f2543Smrg    int yOffset;          /* y location within the picture where the cache starts */
134706f2543Smrg    int columns;          /* Number of columns the glyphs are layed out in */
135706f2543Smrg    int evictionPosition; /* Next random position to evict a glyph */
136706f2543Smrg} ExaGlyphCacheRec, *ExaGlyphCachePtr;
137706f2543Smrg
138706f2543Smrg#define EXA_NUM_GLYPH_CACHES 4
139706f2543Smrg
140706f2543Smrg#define EXA_FALLBACK_COPYWINDOW (1 << 0)
141706f2543Smrg#define EXA_ACCEL_COPYWINDOW (1 << 1)
142706f2543Smrg
143706f2543Smrgtypedef struct _ExaMigrationRec {
144706f2543Smrg    Bool as_dst;
145706f2543Smrg    Bool as_src;
146706f2543Smrg    PixmapPtr pPix;
147706f2543Smrg    RegionPtr pReg;
148706f2543Smrg} ExaMigrationRec, *ExaMigrationPtr;
149706f2543Smrg
150706f2543Smrgtypedef void (*EnableDisableFBAccessProcPtr)(int, Bool);
151706f2543Smrgtypedef struct {
152706f2543Smrg    ExaDriverPtr info;
153706f2543Smrg    ScreenBlockHandlerProcPtr	 SavedBlockHandler;
154706f2543Smrg    ScreenWakeupHandlerProcPtr	 SavedWakeupHandler;
155706f2543Smrg    CreateGCProcPtr 		 SavedCreateGC;
156706f2543Smrg    CloseScreenProcPtr 		 SavedCloseScreen;
157706f2543Smrg    GetImageProcPtr 		 SavedGetImage;
158706f2543Smrg    GetSpansProcPtr 		 SavedGetSpans;
159706f2543Smrg    CreatePixmapProcPtr 	 SavedCreatePixmap;
160706f2543Smrg    DestroyPixmapProcPtr 	 SavedDestroyPixmap;
161706f2543Smrg    CopyWindowProcPtr 		 SavedCopyWindow;
162706f2543Smrg    ChangeWindowAttributesProcPtr SavedChangeWindowAttributes;
163706f2543Smrg    BitmapToRegionProcPtr        SavedBitmapToRegion;
164706f2543Smrg    CreateScreenResourcesProcPtr SavedCreateScreenResources;
165706f2543Smrg    ModifyPixmapHeaderProcPtr    SavedModifyPixmapHeader;
166706f2543Smrg    SourceValidateProcPtr        SavedSourceValidate;
167706f2543Smrg    CompositeProcPtr             SavedComposite;
168706f2543Smrg    TrianglesProcPtr		 SavedTriangles;
169706f2543Smrg    GlyphsProcPtr                SavedGlyphs;
170706f2543Smrg    TrapezoidsProcPtr            SavedTrapezoids;
171706f2543Smrg    AddTrapsProcPtr		 SavedAddTraps;
172706f2543Smrg    void (*do_migration) (ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel);
173706f2543Smrg    Bool (*pixmap_has_gpu_copy) (PixmapPtr pPixmap);
174706f2543Smrg    void (*do_move_in_pixmap) (PixmapPtr pPixmap);
175706f2543Smrg    void (*do_move_out_pixmap) (PixmapPtr pPixmap);
176706f2543Smrg    void (*prepare_access_reg)(PixmapPtr pPixmap, int index, RegionPtr pReg);
177706f2543Smrg
178706f2543Smrg    Bool			 swappedOut;
179706f2543Smrg    enum ExaMigrationHeuristic	 migration;
180706f2543Smrg    Bool			 checkDirtyCorrectness;
181706f2543Smrg    unsigned			 disableFbCount;
182706f2543Smrg    Bool			 optimize_migration;
183706f2543Smrg    unsigned			 offScreenCounter;
184706f2543Smrg    unsigned			 numOffscreenAvailable;
185706f2543Smrg    CARD32			 lastDefragment;
186706f2543Smrg    CARD32			 nextDefragment;
187706f2543Smrg    PixmapPtr			 deferred_mixed_pixmap;
188706f2543Smrg
189706f2543Smrg    /* Reference counting for accessed pixmaps */
190706f2543Smrg    struct {
191706f2543Smrg	PixmapPtr pixmap;
192706f2543Smrg	int count;
193706f2543Smrg	Bool retval;
194706f2543Smrg    } access[EXA_NUM_PREPARE_INDICES];
195706f2543Smrg
196706f2543Smrg    /* Holds information on fallbacks that cannot be relayed otherwise. */
197706f2543Smrg    unsigned int fallback_flags;
198706f2543Smrg    unsigned int fallback_counter;
199706f2543Smrg
200706f2543Smrg    ExaGlyphCacheRec             glyphCaches[EXA_NUM_GLYPH_CACHES];
201706f2543Smrg
202706f2543Smrg    /**
203706f2543Smrg     * Regions affected by fallback composite source / mask operations.
204706f2543Smrg     */
205706f2543Smrg
206706f2543Smrg    RegionRec srcReg;
207706f2543Smrg    RegionRec maskReg;
208706f2543Smrg    PixmapPtr srcPix;
209706f2543Smrg    PixmapPtr maskPix;
210706f2543Smrg
211706f2543Smrg} ExaScreenPrivRec, *ExaScreenPrivPtr;
212706f2543Smrg
213706f2543Smrg/*
214706f2543Smrg * This is the only completely portable way to
215706f2543Smrg * compute this info.
216706f2543Smrg */
217706f2543Smrg#ifndef BitsPerPixel
218706f2543Smrg#define BitsPerPixel(d) (\
219706f2543Smrg    PixmapWidthPaddingInfo[d].notPower2 ? \
220706f2543Smrg    (PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \
221706f2543Smrg    ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
222706f2543Smrg    (PixmapWidthPaddingInfo[d].padRoundUp+1)))
223706f2543Smrg#endif
224706f2543Smrg
225706f2543Smrgextern DevPrivateKeyRec exaScreenPrivateKeyRec;
226706f2543Smrg#define exaScreenPrivateKey (&exaScreenPrivateKeyRec)
227706f2543Smrgextern DevPrivateKeyRec exaPixmapPrivateKeyRec;
228706f2543Smrg#define exaPixmapPrivateKey (&exaPixmapPrivateKeyRec)
229706f2543Smrgextern DevPrivateKeyRec exaGCPrivateKeyRec;
230706f2543Smrg#define exaGCPrivateKey (&exaGCPrivateKeyRec)
231706f2543Smrg
232706f2543Smrg#define ExaGetScreenPriv(s) ((ExaScreenPrivPtr)dixLookupPrivate(&(s)->devPrivates, exaScreenPrivateKey))
233706f2543Smrg#define ExaScreenPriv(s)	ExaScreenPrivPtr    pExaScr = ExaGetScreenPriv(s)
234706f2543Smrg
235706f2543Smrg#define ExaGetGCPriv(gc) ((ExaGCPrivPtr)dixLookupPrivate(&(gc)->devPrivates, exaGCPrivateKey))
236706f2543Smrg#define ExaGCPriv(gc) ExaGCPrivPtr pExaGC = ExaGetGCPriv(gc)
237706f2543Smrg
238706f2543Smrg/*
239706f2543Smrg * Some macros to deal with function wrapping.
240706f2543Smrg */
241706f2543Smrg#define wrap(priv, real, mem, func) {\
242706f2543Smrg    priv->Saved##mem = real->mem; \
243706f2543Smrg    real->mem = func; \
244706f2543Smrg}
245706f2543Smrg
246706f2543Smrg#define unwrap(priv, real, mem) {\
247706f2543Smrg    real->mem = priv->Saved##mem; \
248706f2543Smrg}
249706f2543Smrg
250706f2543Smrg#define swap(priv, real, mem) {\
251706f2543Smrg    void *tmp = priv->Saved##mem; \
252706f2543Smrg    priv->Saved##mem = real->mem; \
253706f2543Smrg    real->mem = tmp; \
254706f2543Smrg}
255706f2543Smrg
256706f2543Smrg#define EXA_PRE_FALLBACK(_screen_) \
257706f2543Smrg    ExaScreenPriv(_screen_); \
258706f2543Smrg    pExaScr->fallback_counter++;
259706f2543Smrg
260706f2543Smrg#define EXA_POST_FALLBACK(_screen_) \
261706f2543Smrg    pExaScr->fallback_counter--;
262706f2543Smrg
263706f2543Smrg#define EXA_PRE_FALLBACK_GC(_gc_) \
264706f2543Smrg    ExaScreenPriv(_gc_->pScreen); \
265706f2543Smrg    ExaGCPriv(_gc_); \
266706f2543Smrg    pExaScr->fallback_counter++; \
267706f2543Smrg    swap(pExaGC, _gc_, ops);
268706f2543Smrg
269706f2543Smrg#define EXA_POST_FALLBACK_GC(_gc_) \
270706f2543Smrg    pExaScr->fallback_counter--; \
271706f2543Smrg    swap(pExaGC, _gc_, ops);
272706f2543Smrg
273706f2543Smrg/** Align an offset to an arbitrary alignment */
274706f2543Smrg#define EXA_ALIGN(offset, align) (((offset) + (align) - 1) - \
275706f2543Smrg	(((offset) + (align) - 1) % (align)))
276706f2543Smrg/** Align an offset to a power-of-two alignment */
277706f2543Smrg#define EXA_ALIGN2(offset, align) (((offset) + (align) - 1) & ~((align) - 1))
278706f2543Smrg
279706f2543Smrg#define EXA_PIXMAP_SCORE_MOVE_IN    10
280706f2543Smrg#define EXA_PIXMAP_SCORE_MAX	    20
281706f2543Smrg#define EXA_PIXMAP_SCORE_MOVE_OUT   -10
282706f2543Smrg#define EXA_PIXMAP_SCORE_MIN	    -20
283706f2543Smrg#define EXA_PIXMAP_SCORE_PINNED	    1000
284706f2543Smrg#define EXA_PIXMAP_SCORE_INIT	    1001
285706f2543Smrg
286706f2543Smrg#define ExaGetPixmapPriv(p) ((ExaPixmapPrivPtr)dixLookupPrivate(&(p)->devPrivates, exaPixmapPrivateKey))
287706f2543Smrg#define ExaSetPixmapPriv(p,a) dixSetPrivate(&(p)->devPrivates, exaPixmapPrivateKey, a)
288706f2543Smrg#define ExaPixmapPriv(p)	ExaPixmapPrivPtr pExaPixmap = ExaGetPixmapPriv(p)
289706f2543Smrg
290706f2543Smrg#define EXA_RANGE_PITCH (1 << 0)
291706f2543Smrg#define EXA_RANGE_WIDTH (1 << 1)
292706f2543Smrg#define EXA_RANGE_HEIGHT (1 << 2)
293706f2543Smrg
294706f2543Smrgtypedef struct {
295706f2543Smrg    ExaOffscreenArea *area;
296706f2543Smrg    int		    score;	/**< score for the move-in vs move-out heuristic */
297706f2543Smrg    Bool	    use_gpu_copy;
298706f2543Smrg
299706f2543Smrg    CARD8	    *sys_ptr;	/**< pointer to pixmap data in system memory */
300706f2543Smrg    int		    sys_pitch;	/**< pitch of pixmap in system memory */
301706f2543Smrg
302706f2543Smrg    CARD8	    *fb_ptr;	/**< pointer to pixmap data in framebuffer memory */
303706f2543Smrg    int		    fb_pitch;	/**< pitch of pixmap in framebuffer memory */
304706f2543Smrg    unsigned int    fb_size;	/**< size of pixmap in framebuffer memory */
305706f2543Smrg
306706f2543Smrg    /**
307706f2543Smrg     * Holds information about whether this pixmap can be used for
308706f2543Smrg     * acceleration (== 0) or not (> 0).
309706f2543Smrg     *
310706f2543Smrg     * Contains a OR'ed combination of the following values:
311706f2543Smrg     * EXA_RANGE_PITCH - set if the pixmap's pitch is out of range
312706f2543Smrg     * EXA_RANGE_WIDTH - set if the pixmap's width is out of range
313706f2543Smrg     * EXA_RANGE_HEIGHT - set if the pixmap's height is out of range
314706f2543Smrg     */
315706f2543Smrg    unsigned int    accel_blocked;
316706f2543Smrg
317706f2543Smrg    /**
318706f2543Smrg     * The damage record contains the areas of the pixmap's current location
319706f2543Smrg     * (framebuffer or system) that have been damaged compared to the other
320706f2543Smrg     * location.
321706f2543Smrg     */
322706f2543Smrg    DamagePtr	    pDamage;
323706f2543Smrg    /**
324706f2543Smrg     * The valid regions mark the valid bits (at least, as they're derived from
325706f2543Smrg     * damage, which may be overreported) of a pixmap's system and FB copies.
326706f2543Smrg     */
327706f2543Smrg    RegionRec	    validSys, validFB;
328706f2543Smrg    /**
329706f2543Smrg     * Driver private storage per EXA pixmap
330706f2543Smrg     */
331706f2543Smrg    void *driverPriv;
332706f2543Smrg} ExaPixmapPrivRec, *ExaPixmapPrivPtr;
333706f2543Smrg
334706f2543Smrgtypedef struct {
335706f2543Smrg    /* GC values from the layer below. */
336706f2543Smrg    GCOps *Savedops;
337706f2543Smrg    GCFuncs *Savedfuncs;
338706f2543Smrg} ExaGCPrivRec, *ExaGCPrivPtr;
339706f2543Smrg
340706f2543Smrgtypedef struct {
341706f2543Smrg    PicturePtr pDst;
342706f2543Smrg    INT16 xSrc;
343706f2543Smrg    INT16 ySrc;
344706f2543Smrg    INT16 xMask;
345706f2543Smrg    INT16 yMask;
346706f2543Smrg    INT16 xDst;
347706f2543Smrg    INT16 yDst;
348706f2543Smrg    INT16 width;
349706f2543Smrg    INT16 height;
350706f2543Smrg} ExaCompositeRectRec, *ExaCompositeRectPtr;
351706f2543Smrg
352706f2543Smrg/**
353706f2543Smrg * exaDDXDriverInit must be implemented by the DDX using EXA, and is the place
354706f2543Smrg * to set EXA options or hook in screen functions to handle using EXA as the AA.
355706f2543Smrg  */
356706f2543Smrgvoid exaDDXDriverInit (ScreenPtr pScreen);
357706f2543Smrg
358706f2543Smrg/* exa_unaccel.c */
359706f2543Smrgvoid
360706f2543SmrgexaPrepareAccessGC(GCPtr pGC);
361706f2543Smrg
362706f2543Smrgvoid
363706f2543SmrgexaFinishAccessGC(GCPtr pGC);
364706f2543Smrg
365706f2543Smrgvoid
366706f2543SmrgExaCheckFillSpans  (DrawablePtr pDrawable, GCPtr pGC, int nspans,
367706f2543Smrg		   DDXPointPtr ppt, int *pwidth, int fSorted);
368706f2543Smrg
369706f2543Smrgvoid
370706f2543SmrgExaCheckSetSpans (DrawablePtr pDrawable, GCPtr pGC, char *psrc,
371706f2543Smrg		 DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
372706f2543Smrg
373706f2543Smrgvoid
374706f2543SmrgExaCheckPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth,
375706f2543Smrg		 int x, int y, int w, int h, int leftPad, int format,
376706f2543Smrg		 char *bits);
377706f2543Smrg
378706f2543Smrgvoid
379706f2543SmrgExaCheckCopyNtoN (DrawablePtr pSrc, DrawablePtr pDst,  GCPtr pGC,
380706f2543Smrg	     BoxPtr	pbox, int nbox, int dx, int dy, Bool	reverse,
381706f2543Smrg	     Bool upsidedown, Pixel bitplane, void *closure);
382706f2543Smrg
383706f2543SmrgRegionPtr
384706f2543SmrgExaCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
385706f2543Smrg		 int srcx, int srcy, int w, int h, int dstx, int dsty);
386706f2543Smrg
387706f2543SmrgRegionPtr
388706f2543SmrgExaCheckCopyPlane (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
389706f2543Smrg		  int srcx, int srcy, int w, int h, int dstx, int dsty,
390706f2543Smrg		  unsigned long bitPlane);
391706f2543Smrg
392706f2543Smrgvoid
393706f2543SmrgExaCheckPolyPoint (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
394706f2543Smrg		  DDXPointPtr pptInit);
395706f2543Smrg
396706f2543Smrgvoid
397706f2543SmrgExaCheckPolylines (DrawablePtr pDrawable, GCPtr pGC,
398706f2543Smrg		  int mode, int npt, DDXPointPtr ppt);
399706f2543Smrg
400706f2543Smrgvoid
401706f2543SmrgExaCheckPolySegment (DrawablePtr pDrawable, GCPtr pGC,
402706f2543Smrg		    int nsegInit, xSegment *pSegInit);
403706f2543Smrg
404706f2543Smrgvoid
405706f2543SmrgExaCheckPolyArc (DrawablePtr pDrawable, GCPtr pGC,
406706f2543Smrg		int narcs, xArc *pArcs);
407706f2543Smrg
408706f2543Smrgvoid
409706f2543SmrgExaCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
410706f2543Smrg		     int nrect, xRectangle *prect);
411706f2543Smrg
412706f2543Smrgvoid
413706f2543SmrgExaCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
414706f2543Smrg		      int x, int y, unsigned int nglyph,
415706f2543Smrg		      CharInfoPtr *ppci, pointer pglyphBase);
416706f2543Smrg
417706f2543Smrgvoid
418706f2543SmrgExaCheckPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
419706f2543Smrg		     int x, int y, unsigned int nglyph,
420706f2543Smrg		     CharInfoPtr *ppci, pointer pglyphBase);
421706f2543Smrg
422706f2543Smrgvoid
423706f2543SmrgExaCheckPushPixels (GCPtr pGC, PixmapPtr pBitmap,
424706f2543Smrg		   DrawablePtr pDrawable,
425706f2543Smrg		   int w, int h, int x, int y);
426706f2543Smrg
427706f2543Smrgvoid
428706f2543SmrgExaCheckCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
429706f2543Smrg
430706f2543Smrgvoid
431706f2543SmrgExaCheckGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
432706f2543Smrg		unsigned int format, unsigned long planeMask, char *d);
433706f2543Smrg
434706f2543Smrgvoid
435706f2543SmrgExaCheckGetSpans (DrawablePtr pDrawable,
436706f2543Smrg		 int wMax,
437706f2543Smrg		 DDXPointPtr ppt,
438706f2543Smrg		 int *pwidth,
439706f2543Smrg		 int nspans,
440706f2543Smrg		 char *pdstStart);
441706f2543Smrg
442706f2543Smrgvoid
443706f2543SmrgExaCheckAddTraps (PicturePtr	pPicture,
444706f2543Smrg		  INT16		x_off,
445706f2543Smrg		  INT16		y_off,
446706f2543Smrg		  int		ntrap,
447706f2543Smrg		  xTrap		*traps);
448706f2543Smrg
449706f2543Smrg/* exa_accel.c */
450706f2543Smrg
451706f2543Smrgstatic _X_INLINE Bool
452706f2543SmrgexaGCReadsDestination(DrawablePtr pDrawable, unsigned long planemask,
453706f2543Smrg		      unsigned int fillStyle, unsigned char alu,
454706f2543Smrg		      unsigned int clientClipType)
455706f2543Smrg{
456706f2543Smrg    return ((alu != GXcopy && alu != GXclear && alu != GXset &&
457706f2543Smrg	     alu != GXcopyInverted) || fillStyle == FillStippled ||
458706f2543Smrg	    clientClipType != CT_NONE || !EXA_PM_IS_SOLID(pDrawable, planemask));
459706f2543Smrg}
460706f2543Smrg
461706f2543Smrgvoid
462706f2543SmrgexaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
463706f2543Smrg
464706f2543SmrgBool
465706f2543SmrgexaFillRegionTiled (DrawablePtr	pDrawable, RegionPtr pRegion, PixmapPtr pTile,
466706f2543Smrg		    DDXPointPtr pPatOrg, CARD32 planemask, CARD32 alu,
467706f2543Smrg		    unsigned int clientClipType);
468706f2543Smrg
469706f2543Smrgvoid
470706f2543SmrgexaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h,
471706f2543Smrg	     unsigned int format, unsigned long planeMask, char *d);
472706f2543Smrg
473706f2543SmrgRegionPtr
474706f2543SmrgexaCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
475706f2543Smrg	    int srcx, int srcy, int width, int height, int dstx, int dsty);
476706f2543Smrg
477706f2543SmrgBool
478706f2543SmrgexaHWCopyNtoN (DrawablePtr    pSrcDrawable,
479706f2543Smrg	     DrawablePtr    pDstDrawable,
480706f2543Smrg	     GCPtr	    pGC,
481706f2543Smrg	     BoxPtr	    pbox,
482706f2543Smrg	     int	    nbox,
483706f2543Smrg	     int	    dx,
484706f2543Smrg	     int	    dy,
485706f2543Smrg	     Bool	    reverse,
486706f2543Smrg	     Bool	    upsidedown);
487706f2543Smrg
488706f2543Smrgvoid
489706f2543SmrgexaCopyNtoN (DrawablePtr    pSrcDrawable,
490706f2543Smrg	     DrawablePtr    pDstDrawable,
491706f2543Smrg	     GCPtr	    pGC,
492706f2543Smrg	     BoxPtr	    pbox,
493706f2543Smrg	     int	    nbox,
494706f2543Smrg	     int	    dx,
495706f2543Smrg	     int	    dy,
496706f2543Smrg	     Bool	    reverse,
497706f2543Smrg	     Bool	    upsidedown,
498706f2543Smrg	     Pixel	    bitplane,
499706f2543Smrg	     void	    *closure);
500706f2543Smrg
501706f2543Smrgextern const GCOps exaOps;
502706f2543Smrg
503706f2543Smrgvoid
504706f2543SmrgExaCheckComposite (CARD8      op,
505706f2543Smrg		  PicturePtr pSrc,
506706f2543Smrg		  PicturePtr pMask,
507706f2543Smrg		  PicturePtr pDst,
508706f2543Smrg		  INT16      xSrc,
509706f2543Smrg		  INT16      ySrc,
510706f2543Smrg		  INT16      xMask,
511706f2543Smrg		  INT16      yMask,
512706f2543Smrg		  INT16      xDst,
513706f2543Smrg		  INT16      yDst,
514706f2543Smrg		  CARD16     width,
515706f2543Smrg		  CARD16     height);
516706f2543Smrg
517706f2543Smrgvoid
518706f2543SmrgExaCheckGlyphs (CARD8	      op,
519706f2543Smrg		PicturePtr    pSrc,
520706f2543Smrg		PicturePtr    pDst,
521706f2543Smrg		PictFormatPtr maskFormat,
522706f2543Smrg		INT16	      xSrc,
523706f2543Smrg		INT16	      ySrc,
524706f2543Smrg		int	      nlist,
525706f2543Smrg		GlyphListPtr  list,
526706f2543Smrg		GlyphPtr      *glyphs);
527706f2543Smrg
528706f2543Smrg/* exa_offscreen.c */
529706f2543Smrgvoid
530706f2543SmrgExaOffscreenSwapOut (ScreenPtr pScreen);
531706f2543Smrg
532706f2543Smrgvoid
533706f2543SmrgExaOffscreenSwapIn (ScreenPtr pScreen);
534706f2543Smrg
535706f2543SmrgExaOffscreenArea*
536706f2543SmrgExaOffscreenDefragment (ScreenPtr pScreen);
537706f2543Smrg
538706f2543SmrgBool
539706f2543SmrgexaOffscreenInit(ScreenPtr pScreen);
540706f2543Smrg
541706f2543Smrgvoid
542706f2543SmrgExaOffscreenFini (ScreenPtr pScreen);
543706f2543Smrg
544706f2543Smrg/* exa.c */
545706f2543SmrgBool
546706f2543SmrgExaDoPrepareAccess(PixmapPtr pPixmap, int index);
547706f2543Smrg
548706f2543Smrgvoid
549706f2543SmrgexaPrepareAccess(DrawablePtr pDrawable, int index);
550706f2543Smrg
551706f2543Smrgvoid
552706f2543SmrgexaFinishAccess(DrawablePtr pDrawable, int index);
553706f2543Smrg
554706f2543Smrgvoid
555706f2543SmrgexaDestroyPixmap(PixmapPtr pPixmap);
556706f2543Smrg
557706f2543Smrgvoid
558706f2543SmrgexaPixmapDirty(PixmapPtr pPix, int x1, int y1, int x2, int y2);
559706f2543Smrg
560706f2543Smrgvoid
561706f2543SmrgexaGetDrawableDeltas (DrawablePtr pDrawable, PixmapPtr pPixmap,
562706f2543Smrg		      int *xp, int *yp);
563706f2543Smrg
564706f2543SmrgBool
565706f2543SmrgexaPixmapHasGpuCopy(PixmapPtr p);
566706f2543Smrg
567706f2543SmrgPixmapPtr
568706f2543SmrgexaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp);
569706f2543Smrg
570706f2543SmrgPixmapPtr
571706f2543SmrgexaGetDrawablePixmap(DrawablePtr pDrawable);
572706f2543Smrg
573706f2543Smrgvoid
574706f2543SmrgexaSetFbPitch(ExaScreenPrivPtr pExaScr, ExaPixmapPrivPtr pExaPixmap,
575706f2543Smrg              int w, int h, int bpp);
576706f2543Smrg
577706f2543Smrgvoid
578706f2543SmrgexaSetAccelBlock(ExaScreenPrivPtr pExaScr, ExaPixmapPrivPtr pExaPixmap,
579706f2543Smrg                 int w, int h, int bpp);
580706f2543Smrg
581706f2543Smrgvoid
582706f2543SmrgexaDoMigration (ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel);
583706f2543Smrg
584706f2543SmrgBool
585706f2543SmrgexaPixmapIsPinned (PixmapPtr pPix);
586706f2543Smrg
587706f2543Smrgextern const GCFuncs exaGCFuncs;
588706f2543Smrg
589706f2543Smrg/* exa_classic.c */
590706f2543SmrgPixmapPtr
591706f2543SmrgexaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth,
592706f2543Smrg		unsigned usage_hint);
593706f2543Smrg
594706f2543SmrgBool
595706f2543SmrgexaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, int depth,
596706f2543Smrg		      int bitsPerPixel, int devKind, pointer pPixData);
597706f2543Smrg
598706f2543SmrgBool
599706f2543SmrgexaDestroyPixmap_classic (PixmapPtr pPixmap);
600706f2543Smrg
601706f2543SmrgBool
602706f2543SmrgexaPixmapHasGpuCopy_classic(PixmapPtr pPixmap);
603706f2543Smrg
604706f2543Smrg/* exa_driver.c */
605706f2543SmrgPixmapPtr
606706f2543SmrgexaCreatePixmap_driver(ScreenPtr pScreen, int w, int h, int depth,
607706f2543Smrg		unsigned usage_hint);
608706f2543Smrg
609706f2543SmrgBool
610706f2543SmrgexaModifyPixmapHeader_driver(PixmapPtr pPixmap, int width, int height, int depth,
611706f2543Smrg		      int bitsPerPixel, int devKind, pointer pPixData);
612706f2543Smrg
613706f2543SmrgBool
614706f2543SmrgexaDestroyPixmap_driver (PixmapPtr pPixmap);
615706f2543Smrg
616706f2543SmrgBool
617706f2543SmrgexaPixmapHasGpuCopy_driver(PixmapPtr pPixmap);
618706f2543Smrg
619706f2543Smrg/* exa_mixed.c */
620706f2543SmrgPixmapPtr
621706f2543SmrgexaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth,
622706f2543Smrg		unsigned usage_hint);
623706f2543Smrg
624706f2543SmrgBool
625706f2543SmrgexaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth,
626706f2543Smrg		      int bitsPerPixel, int devKind, pointer pPixData);
627706f2543Smrg
628706f2543SmrgBool
629706f2543SmrgexaDestroyPixmap_mixed(PixmapPtr pPixmap);
630706f2543Smrg
631706f2543SmrgBool
632706f2543SmrgexaPixmapHasGpuCopy_mixed(PixmapPtr pPixmap);
633706f2543Smrg
634706f2543Smrg/* exa_migration_mixed.c */
635706f2543Smrgvoid
636706f2543SmrgexaCreateDriverPixmap_mixed(PixmapPtr pPixmap);
637706f2543Smrg
638706f2543Smrgvoid
639706f2543SmrgexaDoMigration_mixed(ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel);
640706f2543Smrg
641706f2543Smrgvoid
642706f2543SmrgexaMoveInPixmap_mixed(PixmapPtr pPixmap);
643706f2543Smrg
644706f2543Smrgvoid
645706f2543SmrgexaDamageReport_mixed(DamagePtr pDamage, RegionPtr pRegion, void *closure);
646706f2543Smrg
647706f2543Smrgvoid
648706f2543SmrgexaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg);
649706f2543Smrg
650706f2543Smrg/* exa_render.c */
651706f2543SmrgBool
652706f2543SmrgexaOpReadsDestination (CARD8 op);
653706f2543Smrg
654706f2543Smrgvoid
655706f2543SmrgexaComposite(CARD8	op,
656706f2543Smrg	     PicturePtr pSrc,
657706f2543Smrg	     PicturePtr pMask,
658706f2543Smrg	     PicturePtr pDst,
659706f2543Smrg	     INT16	xSrc,
660706f2543Smrg	     INT16	ySrc,
661706f2543Smrg	     INT16	xMask,
662706f2543Smrg	     INT16	yMask,
663706f2543Smrg	     INT16	xDst,
664706f2543Smrg	     INT16	yDst,
665706f2543Smrg	     CARD16	width,
666706f2543Smrg	     CARD16	height);
667706f2543Smrg
668706f2543Smrgvoid
669706f2543SmrgexaCompositeRects(CARD8	              op,
670706f2543Smrg		  PicturePtr	      Src,
671706f2543Smrg		  PicturePtr	      pMask,
672706f2543Smrg		  PicturePtr	      pDst,
673706f2543Smrg		  int                 nrect,
674706f2543Smrg		  ExaCompositeRectPtr rects);
675706f2543Smrg
676706f2543Smrgvoid
677706f2543SmrgexaTrapezoids (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
678706f2543Smrg               PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
679706f2543Smrg               int ntrap, xTrapezoid *traps);
680706f2543Smrg
681706f2543Smrgvoid
682706f2543SmrgexaTriangles (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
683706f2543Smrg	      PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
684706f2543Smrg	      int ntri, xTriangle *tris);
685706f2543Smrg
686706f2543Smrg/* exa_glyph.c */
687706f2543Smrgvoid
688706f2543SmrgexaGlyphsInit(ScreenPtr pScreen);
689706f2543Smrg
690706f2543Smrgvoid
691706f2543SmrgexaGlyphsFini (ScreenPtr pScreen);
692706f2543Smrg
693706f2543Smrgvoid
694706f2543SmrgexaGlyphs (CARD8	op,
695706f2543Smrg	  PicturePtr	pSrc,
696706f2543Smrg	  PicturePtr	pDst,
697706f2543Smrg	  PictFormatPtr	maskFormat,
698706f2543Smrg	  INT16		xSrc,
699706f2543Smrg	  INT16		ySrc,
700706f2543Smrg	  int		nlist,
701706f2543Smrg	  GlyphListPtr	list,
702706f2543Smrg	  GlyphPtr	*glyphs);
703706f2543Smrg
704706f2543Smrg/* exa_migration_classic.c */
705706f2543Smrgvoid
706706f2543SmrgexaCopyDirtyToSys (ExaMigrationPtr migrate);
707706f2543Smrg
708706f2543Smrgvoid
709706f2543SmrgexaCopyDirtyToFb (ExaMigrationPtr migrate);
710706f2543Smrg
711706f2543Smrgvoid
712706f2543SmrgexaDoMigration_classic (ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel);
713706f2543Smrg
714706f2543Smrgvoid
715706f2543SmrgexaPixmapSave (ScreenPtr pScreen, ExaOffscreenArea *area);
716706f2543Smrg
717706f2543Smrgvoid
718706f2543SmrgexaMoveOutPixmap_classic (PixmapPtr pPixmap);
719706f2543Smrg
720706f2543Smrgvoid
721706f2543SmrgexaMoveInPixmap_classic (PixmapPtr pPixmap);
722706f2543Smrg
723706f2543Smrgvoid
724706f2543SmrgexaPrepareAccessReg_classic(PixmapPtr pPixmap, int index, RegionPtr pReg);
725706f2543Smrg
726706f2543Smrg#endif /* EXAPRIV_H */
727