3 * Copyright © 2000,2008 Keith Packard
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
32 #ifdef HAVE_DIX_CONFIG_H
33 #include <dix-config.h>
35 #include <xorg-server.h>
42 #include <X11/Xproto.h>
43 #include "scrnintstr.h"
44 #include "pixmapstr.h"
45 #include "windowstr.h"
48 #include "colormapst.h"
51 #include "mipointer.h"
55 #include "fboverlay.h"
62 /* Provide substitutes for gcc's __FUNCTION__ on other compilers */
63 #if !defined(__GNUC__) && !defined(__FUNCTION__)
64 # if defined(__STDC__) && (__STDC_VERSION__>=199901L) /* C99 */
65 # define __FUNCTION__ __func__
67 # define __FUNCTION__ ""
71 /* 1.6 and earlier server compat */
72 #ifndef miGetCompositeClip
73 #define miCopyRegion fbCopyRegion
74 #define miDoCopy fbDoCopy
77 #define DEBUG_MIGRATE 0
78 #define DEBUG_PIXMAP 0
79 #define DEBUG_OFFSCREEN 0
80 #define DEBUG_GLYPH_CACHE 0
82 #define UXA_FALLBACK(x) \
83 if (uxa_get_screen(screen)->fallback_debug) { \
84 ErrorF("UXA fallback at %s: ", __FUNCTION__); \
88 char uxa_drawable_location(DrawablePtr pDrawable);
91 #define DBG_PIXMAP(a) ErrorF a
97 PicturePtr picture; /* Where the glyphs of the cache are stored */
103 #define UXA_NUM_GLYPH_CACHE_FORMATS 2
110 #define UXA_NUM_SOLID_CACHE 16
112 typedef void (*EnableDisableFBAccessProcPtr) (int, Bool);
115 CreateGCProcPtr SavedCreateGC;
116 CloseScreenProcPtr SavedCloseScreen;
117 GetImageProcPtr SavedGetImage;
118 GetSpansProcPtr SavedGetSpans;
119 CreatePixmapProcPtr SavedCreatePixmap;
120 DestroyPixmapProcPtr SavedDestroyPixmap;
121 CopyWindowProcPtr SavedCopyWindow;
122 ChangeWindowAttributesProcPtr SavedChangeWindowAttributes;
123 BitmapToRegionProcPtr SavedBitmapToRegion;
125 CompositeProcPtr SavedComposite;
126 CompositeRectsProcPtr SavedCompositeRects;
127 TrianglesProcPtr SavedTriangles;
128 GlyphsProcPtr SavedGlyphs;
129 TrapezoidsProcPtr SavedTrapezoids;
130 AddTrapsProcPtr SavedAddTraps;
131 UnrealizeGlyphProcPtr SavedUnrealizeGlyph;
133 EnableDisableFBAccessProcPtr SavedEnableDisableFBAccess;
138 unsigned disableFbCount;
139 unsigned offScreenCounter;
141 uxa_glyph_cache_t glyphCaches[UXA_NUM_GLYPH_CACHE_FORMATS];
142 Bool glyph_cache_initialized;
144 PicturePtr solid_clear, solid_black, solid_white;
145 uxa_solid_cache_t solid_cache[UXA_NUM_SOLID_CACHE];
146 int solid_cache_size;
150 * This is the only completely portable way to
154 #define BitsPerPixel(d) (\
155 PixmapWidthPaddingInfo[d].notPower2 ? \
156 (PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \
157 ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
158 (PixmapWidthPaddingInfo[d].padRoundUp+1)))
161 #if HAS_DEVPRIVATEKEYREC
162 extern DevPrivateKeyRec uxa_screen_index;
164 extern int uxa_screen_index;
167 static inline uxa_screen_t *uxa_get_screen(ScreenPtr screen)
169 #if HAS_DEVPRIVATEKEYREC
170 return dixGetPrivate(&screen->devPrivates, &uxa_screen_index);
172 return dixLookupPrivate(&screen->devPrivates, &uxa_screen_index);
176 /** Align an offset to an arbitrary alignment */
177 #define UXA_ALIGN(offset, align) (((offset) + (align) - 1) - \
178 (((offset) + (align) - 1) % (align)))
179 /** Align an offset to a power-of-two alignment */
180 #define UXA_ALIGN2(offset, align) (((offset) + (align) - 1) & ~((align) - 1))
189 } uxa_composite_rect_t;
192 * exaDDXDriverInit must be implemented by the DDX using EXA, and is the place
193 * to set EXA options or hook in screen functions to handle using EXA as the AA.
195 void exaDDXDriverInit(ScreenPtr pScreen);
197 Bool uxa_prepare_access_window(WindowPtr pWin);
199 void uxa_finish_access_window(WindowPtr pWin);
202 Bool uxa_prepare_access_gc(GCPtr pGC);
204 void uxa_finish_access_gc(GCPtr pGC);
207 uxa_check_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int nspans,
208 DDXPointPtr ppt, int *pwidth, int fSorted);
211 uxa_check_set_spans(DrawablePtr pDrawable, GCPtr pGC, char *psrc,
212 DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
215 uxa_check_put_image(DrawablePtr pDrawable, GCPtr pGC, int depth,
216 int x, int y, int w, int h, int leftPad, int format,
220 uxa_check_copy_area(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
221 int srcx, int srcy, int w, int h, int dstx, int dsty);
224 uxa_check_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
225 int srcx, int srcy, int w, int h, int dstx, int dsty,
226 unsigned long bitPlane);
229 uxa_check_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
230 DDXPointPtr pptInit);
233 uxa_check_poly_lines(DrawablePtr pDrawable, GCPtr pGC,
234 int mode, int npt, DDXPointPtr ppt);
237 uxa_check_poly_segment(DrawablePtr pDrawable, GCPtr pGC,
238 int nsegInit, xSegment * pSegInit);
241 uxa_check_poly_arc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc * pArcs);
244 uxa_check_poly_fill_rect(DrawablePtr pDrawable, GCPtr pGC,
245 int nrect, xRectangle * prect);
248 uxa_check_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
249 int x, int y, unsigned int nglyph,
250 CharInfoPtr * ppci, pointer pglyphBase);
253 uxa_check_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
254 int x, int y, unsigned int nglyph,
255 CharInfoPtr * ppci, pointer pglyphBase);
258 uxa_check_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
259 DrawablePtr pDrawable, int w, int h, int x, int y);
262 uxa_check_get_spans(DrawablePtr pDrawable,
264 DDXPointPtr ppt, int *pwidth, int nspans, char *pdstStart);
266 void uxa_check_paint_window(WindowPtr pWin, RegionPtr pRegion, int what);
269 uxa_check_add_traps(PicturePtr pPicture,
270 INT16 x_off, INT16 y_off, int ntrap, xTrap * traps);
274 static _X_INLINE Bool
275 uxa_gc_reads_destination(DrawablePtr pDrawable, unsigned long planemask,
276 unsigned int fillStyle, unsigned char alu)
278 return ((alu != GXcopy && alu != GXclear && alu != GXset &&
279 alu != GXcopyInverted) || fillStyle == FillStippled ||
280 !UXA_PM_IS_SOLID(pDrawable, planemask));
283 void uxa_copy_window(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
286 uxa_fill_region_tiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
287 DDXPointPtr pPatOrg, CARD32 planemask, CARD32 alu);
289 void uxa_paint_window(WindowPtr pWin, RegionPtr pRegion, int what);
292 uxa_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
293 unsigned int format, unsigned long planeMask, char *d);
295 extern const GCOps uxa_ops;
299 /* XXX these are in fbpict.h, which is not installed */
301 fbComposite(CARD8 op,
308 INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
311 fbAddTraps(PicturePtr pPicture,
312 INT16 xOff, INT16 yOff, int ntrap, xTrap * traps);
315 uxa_check_composite(CARD8 op,
323 INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
327 Bool uxa_prepare_access(DrawablePtr pDrawable, uxa_access_t access);
329 void uxa_finish_access(DrawablePtr pDrawable);
332 uxa_get_drawable_deltas(DrawablePtr pDrawable, PixmapPtr pPixmap,
335 Bool uxa_drawable_is_offscreen(DrawablePtr pDrawable);
337 Bool uxa_pixmap_is_offscreen(PixmapPtr p);
339 PixmapPtr uxa_get_offscreen_pixmap(DrawablePtr pDrawable, int *xp, int *yp);
341 PixmapPtr uxa_get_drawable_pixmap(DrawablePtr pDrawable);
344 uxa_copy_area(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
345 int srcx, int srcy, int width, int height, int dstx, int dsty);
348 uxa_copy_n_to_n(DrawablePtr pSrcDrawable,
349 DrawablePtr pDstDrawable,
355 Bool reverse, Bool upsidedown, Pixel bitplane, void *closure);
358 Bool uxa_op_reads_destination(CARD8 op);
361 uxa_composite(CARD8 op,
368 INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
371 uxa_composite_rects(CARD8 op,
373 PicturePtr pDst, int nrect, uxa_composite_rect_t * rects);
376 uxa_solid_rects (CARD8 op,
383 uxa_trapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
384 PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
385 int ntrap, xTrapezoid * traps);
388 uxa_triangles(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
389 PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
390 int ntri, xTriangle * tris);
393 uxa_acquire_solid(ScreenPtr screen, SourcePict *source);
396 uxa_acquire_drawable(ScreenPtr pScreen,
399 CARD16 width, CARD16 height,
400 INT16 * out_x, INT16 * out_y);
403 uxa_acquire_pattern(ScreenPtr pScreen,
405 pixman_format_code_t format,
407 CARD16 width, CARD16 height);
410 uxa_get_rgba_from_pixel(CARD32 pixel,
418 Bool uxa_glyphs_init(ScreenPtr pScreen);
420 void uxa_glyphs_fini(ScreenPtr pScreen);
426 PictFormatPtr maskFormat,
428 INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr * glyphs);
431 uxa_glyph_unrealize(ScreenPtr pScreen,
434 #endif /* UXAPRIV_H */