103b705cfSriastradh/*
203b705cfSriastradh *
303b705cfSriastradh * Copyright � 1999 Keith Packard
403b705cfSriastradh *
503b705cfSriastradh * Permission to use, copy, modify, distribute, and sell this software and its
603b705cfSriastradh * documentation for any purpose is hereby granted without fee, provided that
703b705cfSriastradh * the above copyright notice appear in all copies and that both that
803b705cfSriastradh * copyright notice and this permission notice appear in supporting
903b705cfSriastradh * documentation, and that the name of Keith Packard not be used in
1003b705cfSriastradh * advertising or publicity pertaining to distribution of the software without
1103b705cfSriastradh * specific, written prior permission.  Keith Packard makes no
1203b705cfSriastradh * representations about the suitability of this software for any purpose.  It
1303b705cfSriastradh * is provided "as is" without express or implied warranty.
1403b705cfSriastradh *
1503b705cfSriastradh * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1603b705cfSriastradh * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
1703b705cfSriastradh * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1803b705cfSriastradh * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
1903b705cfSriastradh * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
2003b705cfSriastradh * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2103b705cfSriastradh * PERFORMANCE OF THIS SOFTWARE.
2203b705cfSriastradh */
2303b705cfSriastradh
2403b705cfSriastradh#include "uxa-priv.h"
2503b705cfSriastradh
2603b705cfSriastradh/*
2703b705cfSriastradh * These functions wrap the low-level fb rendering functions and
2803b705cfSriastradh * synchronize framebuffer/accelerated drawing by stalling until
2903b705cfSriastradh * the accelerator is idle
3003b705cfSriastradh */
3103b705cfSriastradh
3203b705cfSriastradh/**
3303b705cfSriastradh * Calls uxa_prepare_access with UXA_PREPARE_SRC for the tile, if that is the
3403b705cfSriastradh * current fill style.
3503b705cfSriastradh *
3603b705cfSriastradh * Solid doesn't use an extra pixmap source, and Stippled/OpaqueStippled are
3703b705cfSriastradh * 1bpp and never in fb, so we don't worry about them.
3803b705cfSriastradh * We should worry about them for completeness sake and going forward.
3903b705cfSriastradh */
4003b705cfSriastradhBool uxa_prepare_access_gc(GCPtr pGC)
4103b705cfSriastradh{
4203b705cfSriastradh	if (pGC->stipple)
4303b705cfSriastradh		if (!uxa_prepare_access(&pGC->stipple->drawable, UXA_ACCESS_RO))
4403b705cfSriastradh			return FALSE;
4503b705cfSriastradh	if (pGC->fillStyle == FillTiled)
4603b705cfSriastradh		if (!uxa_prepare_access
4703b705cfSriastradh		    (&pGC->tile.pixmap->drawable, UXA_ACCESS_RO)) {
4803b705cfSriastradh			if (pGC->stipple)
4903b705cfSriastradh				uxa_finish_access(&pGC->stipple->drawable, UXA_ACCESS_RO);
5003b705cfSriastradh			return FALSE;
5103b705cfSriastradh		}
5203b705cfSriastradh	return TRUE;
5303b705cfSriastradh}
5403b705cfSriastradh
5503b705cfSriastradh/**
5603b705cfSriastradh * Finishes access to the tile in the GC, if used.
5703b705cfSriastradh */
5803b705cfSriastradhvoid uxa_finish_access_gc(GCPtr pGC)
5903b705cfSriastradh{
6003b705cfSriastradh	if (pGC->fillStyle == FillTiled)
6103b705cfSriastradh		uxa_finish_access(&pGC->tile.pixmap->drawable, UXA_ACCESS_RO);
6203b705cfSriastradh	if (pGC->stipple)
6303b705cfSriastradh		uxa_finish_access(&pGC->stipple->drawable, UXA_ACCESS_RO);
6403b705cfSriastradh}
6503b705cfSriastradh
6603b705cfSriastradhBool uxa_picture_prepare_access(PicturePtr picture, int mode)
6703b705cfSriastradh{
6803b705cfSriastradh	if (picture->pDrawable == NULL)
6903b705cfSriastradh		return TRUE;
7003b705cfSriastradh
7103b705cfSriastradh	if (!uxa_prepare_access(picture->pDrawable, mode))
7203b705cfSriastradh		return FALSE;
7303b705cfSriastradh
7403b705cfSriastradh	if (picture->alphaMap &&
7503b705cfSriastradh	    !uxa_prepare_access(picture->alphaMap->pDrawable, mode)) {
7603b705cfSriastradh		uxa_finish_access(picture->pDrawable, mode);
7703b705cfSriastradh		return FALSE;
7803b705cfSriastradh	}
7903b705cfSriastradh
8003b705cfSriastradh	return TRUE;
8103b705cfSriastradh}
8203b705cfSriastradh
8303b705cfSriastradhvoid uxa_picture_finish_access(PicturePtr picture, int mode)
8403b705cfSriastradh{
8503b705cfSriastradh	if (picture->pDrawable == NULL)
8603b705cfSriastradh		return;
8703b705cfSriastradh
8803b705cfSriastradh	uxa_finish_access(picture->pDrawable, mode);
8903b705cfSriastradh	if (picture->alphaMap)
9003b705cfSriastradh		uxa_finish_access(picture->alphaMap->pDrawable, mode);
9103b705cfSriastradh}
9203b705cfSriastradh
9303b705cfSriastradh
9403b705cfSriastradhchar uxa_drawable_location(DrawablePtr pDrawable)
9503b705cfSriastradh{
9603b705cfSriastradh	return uxa_drawable_is_offscreen(pDrawable) ? 's' : 'm';
9703b705cfSriastradh}
9803b705cfSriastradh
9903b705cfSriastradhvoid
10003b705cfSriastradhuxa_check_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int nspans,
10103b705cfSriastradh		     DDXPointPtr ppt, int *pwidth, int fSorted)
10203b705cfSriastradh{
10303b705cfSriastradh	ScreenPtr screen = pDrawable->pScreen;
10403b705cfSriastradh
10503b705cfSriastradh	UXA_FALLBACK(("to %p (%c)\n", pDrawable,
10603b705cfSriastradh		      uxa_drawable_location(pDrawable)));
10703b705cfSriastradh	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
10803b705cfSriastradh		if (uxa_prepare_access_gc(pGC)) {
10903b705cfSriastradh			fbFillSpans(pDrawable, pGC, nspans, ppt, pwidth,
11003b705cfSriastradh				    fSorted);
11103b705cfSriastradh			uxa_finish_access_gc(pGC);
11203b705cfSriastradh		}
11303b705cfSriastradh		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
11403b705cfSriastradh	}
11503b705cfSriastradh}
11603b705cfSriastradh
11703b705cfSriastradhvoid
11803b705cfSriastradhuxa_check_set_spans(DrawablePtr pDrawable, GCPtr pGC, char *psrc,
11903b705cfSriastradh		    DDXPointPtr ppt, int *pwidth, int nspans, int fSorted)
12003b705cfSriastradh{
12103b705cfSriastradh	ScreenPtr screen = pDrawable->pScreen;
12203b705cfSriastradh
12303b705cfSriastradh	UXA_FALLBACK(("to %p (%c)\n", pDrawable,
12403b705cfSriastradh		      uxa_drawable_location(pDrawable)));
12503b705cfSriastradh	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
12603b705cfSriastradh		fbSetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
12703b705cfSriastradh		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
12803b705cfSriastradh	}
12903b705cfSriastradh}
13003b705cfSriastradh
13103b705cfSriastradhvoid
13203b705cfSriastradhuxa_check_put_image(DrawablePtr pDrawable, GCPtr pGC, int depth,
13303b705cfSriastradh		    int x, int y, int w, int h, int leftPad, int format,
13403b705cfSriastradh		    char *bits)
13503b705cfSriastradh{
13603b705cfSriastradh	ScreenPtr screen = pDrawable->pScreen;
13703b705cfSriastradh
13803b705cfSriastradh	UXA_FALLBACK(("to %p (%c)\n", pDrawable,
13903b705cfSriastradh		      uxa_drawable_location(pDrawable)));
14003b705cfSriastradh	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
14103b705cfSriastradh		fbPutImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format,
14203b705cfSriastradh			   bits);
14303b705cfSriastradh		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
14403b705cfSriastradh	}
14503b705cfSriastradh}
14603b705cfSriastradh
14703b705cfSriastradhRegionPtr
14803b705cfSriastradhuxa_check_copy_area(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
14903b705cfSriastradh		    int srcx, int srcy, int w, int h, int dstx, int dsty)
15003b705cfSriastradh{
15103b705cfSriastradh	ScreenPtr screen = pSrc->pScreen;
15203b705cfSriastradh	RegionPtr ret = NULL;
15303b705cfSriastradh
15403b705cfSriastradh	UXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst,
15503b705cfSriastradh		      uxa_drawable_location(pSrc),
15603b705cfSriastradh		      uxa_drawable_location(pDst)));
15703b705cfSriastradh	if (uxa_prepare_access(pDst, UXA_ACCESS_RW)) {
15803b705cfSriastradh		if (uxa_prepare_access(pSrc, UXA_ACCESS_RO)) {
15903b705cfSriastradh			ret =
16003b705cfSriastradh			    fbCopyArea(pSrc, pDst, pGC, srcx, srcy, w, h, dstx,
16103b705cfSriastradh				       dsty);
16203b705cfSriastradh			uxa_finish_access(pSrc, UXA_ACCESS_RO);
16303b705cfSriastradh		}
16403b705cfSriastradh		uxa_finish_access(pDst, UXA_ACCESS_RW);
16503b705cfSriastradh	}
16603b705cfSriastradh	return ret;
16703b705cfSriastradh}
16803b705cfSriastradh
16903b705cfSriastradhRegionPtr
17003b705cfSriastradhuxa_check_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
17103b705cfSriastradh		     int srcx, int srcy, int w, int h, int dstx, int dsty,
17203b705cfSriastradh		     unsigned long bitPlane)
17303b705cfSriastradh{
17403b705cfSriastradh	ScreenPtr screen = pSrc->pScreen;
17503b705cfSriastradh	RegionPtr ret = NULL;
17603b705cfSriastradh
17703b705cfSriastradh	UXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst,
17803b705cfSriastradh		      uxa_drawable_location(pSrc),
17903b705cfSriastradh		      uxa_drawable_location(pDst)));
18003b705cfSriastradh	if (uxa_prepare_access(pDst, UXA_ACCESS_RW)) {
18103b705cfSriastradh		if (uxa_prepare_access(pSrc, UXA_ACCESS_RO)) {
18203b705cfSriastradh			ret =
18303b705cfSriastradh			    fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h, dstx,
18403b705cfSriastradh					dsty, bitPlane);
18503b705cfSriastradh			uxa_finish_access(pSrc, UXA_ACCESS_RO);
18603b705cfSriastradh		}
18703b705cfSriastradh		uxa_finish_access(pDst, UXA_ACCESS_RW);
18803b705cfSriastradh	}
18903b705cfSriastradh	return ret;
19003b705cfSriastradh}
19103b705cfSriastradh
19203b705cfSriastradhvoid
19303b705cfSriastradhuxa_check_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
19403b705cfSriastradh		     DDXPointPtr pptInit)
19503b705cfSriastradh{
19603b705cfSriastradh	ScreenPtr screen = pDrawable->pScreen;
19703b705cfSriastradh
19803b705cfSriastradh	UXA_FALLBACK(("to %p (%c)\n", pDrawable,
19903b705cfSriastradh		      uxa_drawable_location(pDrawable)));
20003b705cfSriastradh	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
20103b705cfSriastradh		fbPolyPoint(pDrawable, pGC, mode, npt, pptInit);
20203b705cfSriastradh		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
20303b705cfSriastradh	}
20403b705cfSriastradh}
20503b705cfSriastradh
20603b705cfSriastradhvoid
20703b705cfSriastradhuxa_check_poly_lines(DrawablePtr pDrawable, GCPtr pGC,
20803b705cfSriastradh		     int mode, int npt, DDXPointPtr ppt)
20903b705cfSriastradh{
21003b705cfSriastradh	ScreenPtr screen = pDrawable->pScreen;
21103b705cfSriastradh
21203b705cfSriastradh	UXA_FALLBACK(("to %p (%c), width %d, mode %d, count %d\n",
21303b705cfSriastradh		      pDrawable, uxa_drawable_location(pDrawable),
21403b705cfSriastradh		      pGC->lineWidth, mode, npt));
21503b705cfSriastradh
21603b705cfSriastradh	if (pGC->lineWidth == 0) {
21703b705cfSriastradh		if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
21803b705cfSriastradh			if (uxa_prepare_access_gc(pGC)) {
21903b705cfSriastradh				fbPolyLine(pDrawable, pGC, mode, npt, ppt);
22003b705cfSriastradh				uxa_finish_access_gc(pGC);
22103b705cfSriastradh			}
22203b705cfSriastradh			uxa_finish_access(pDrawable, UXA_ACCESS_RW);
22303b705cfSriastradh		}
22403b705cfSriastradh		return;
22503b705cfSriastradh	}
22603b705cfSriastradh	/* fb calls mi functions in the lineWidth != 0 case. */
22703b705cfSriastradh	fbPolyLine(pDrawable, pGC, mode, npt, ppt);
22803b705cfSriastradh}
22903b705cfSriastradh
23003b705cfSriastradhvoid
23103b705cfSriastradhuxa_check_poly_segment(DrawablePtr pDrawable, GCPtr pGC,
23203b705cfSriastradh		       int nsegInit, xSegment * pSegInit)
23303b705cfSriastradh{
23403b705cfSriastradh	ScreenPtr screen = pDrawable->pScreen;
23503b705cfSriastradh
23603b705cfSriastradh	UXA_FALLBACK(("to %p (%c) width %d, count %d\n", pDrawable,
23703b705cfSriastradh		      uxa_drawable_location(pDrawable), pGC->lineWidth,
23803b705cfSriastradh		      nsegInit));
23903b705cfSriastradh	if (pGC->lineWidth == 0) {
24003b705cfSriastradh		if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
24103b705cfSriastradh			if (uxa_prepare_access_gc(pGC)) {
24203b705cfSriastradh				fbPolySegment(pDrawable, pGC, nsegInit,
24303b705cfSriastradh					      pSegInit);
24403b705cfSriastradh				uxa_finish_access_gc(pGC);
24503b705cfSriastradh			}
24603b705cfSriastradh			uxa_finish_access(pDrawable, UXA_ACCESS_RW);
24703b705cfSriastradh		}
24803b705cfSriastradh		return;
24903b705cfSriastradh	}
25003b705cfSriastradh	/* fb calls mi functions in the lineWidth != 0 case. */
25103b705cfSriastradh	fbPolySegment(pDrawable, pGC, nsegInit, pSegInit);
25203b705cfSriastradh}
25303b705cfSriastradh
25403b705cfSriastradhvoid
25503b705cfSriastradhuxa_check_poly_arc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc * pArcs)
25603b705cfSriastradh{
25703b705cfSriastradh	ScreenPtr screen = pDrawable->pScreen;
25803b705cfSriastradh
25903b705cfSriastradh	UXA_FALLBACK(("to %p (%c)\n", pDrawable,
26003b705cfSriastradh		      uxa_drawable_location(pDrawable)));
26103b705cfSriastradh
26203b705cfSriastradh	/* Disable this as fbPolyArc can call miZeroPolyArc which in turn
26303b705cfSriastradh	 * can call accelerated functions, that as yet, haven't been notified
26403b705cfSriastradh	 * with uxa_finish_access().
26503b705cfSriastradh	 */
26603b705cfSriastradh#if 0
26703b705cfSriastradh	if (pGC->lineWidth == 0) {
26803b705cfSriastradh		if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
26903b705cfSriastradh			if (uxa_prepare_access_gc(pGC)) {
27003b705cfSriastradh				fbPolyArc(pDrawable, pGC, narcs, pArcs);
27103b705cfSriastradh				uxa_finish_access_gc(pGC);
27203b705cfSriastradh			}
27303b705cfSriastradh			uxa_finish_access(pDrawable, UXA_ACCESS_RW);
27403b705cfSriastradh		}
27503b705cfSriastradh		return;
27603b705cfSriastradh	}
27703b705cfSriastradh#endif
27803b705cfSriastradh	miPolyArc(pDrawable, pGC, narcs, pArcs);
27903b705cfSriastradh}
28003b705cfSriastradh
28103b705cfSriastradhvoid
28203b705cfSriastradhuxa_check_poly_fill_rect(DrawablePtr pDrawable, GCPtr pGC,
28303b705cfSriastradh			 int nrect, xRectangle * prect)
28403b705cfSriastradh{
28503b705cfSriastradh	ScreenPtr screen = pDrawable->pScreen;
28603b705cfSriastradh
28703b705cfSriastradh	UXA_FALLBACK(("to %p (%c)\n", pDrawable,
28803b705cfSriastradh		      uxa_drawable_location(pDrawable)));
28903b705cfSriastradh
29003b705cfSriastradh	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
29103b705cfSriastradh		if (uxa_prepare_access_gc(pGC)) {
29203b705cfSriastradh			fbPolyFillRect(pDrawable, pGC, nrect, prect);
29303b705cfSriastradh			uxa_finish_access_gc(pGC);
29403b705cfSriastradh		}
29503b705cfSriastradh		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
29603b705cfSriastradh	}
29703b705cfSriastradh}
29803b705cfSriastradh
29903b705cfSriastradhvoid
30003b705cfSriastradhuxa_check_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
30103b705cfSriastradh			  int x, int y, unsigned int nglyph,
30203b705cfSriastradh			  CharInfoPtr * ppci, pointer pglyphBase)
30303b705cfSriastradh{
30403b705cfSriastradh	ScreenPtr screen = pDrawable->pScreen;
30503b705cfSriastradh
30603b705cfSriastradh	UXA_FALLBACK(("to %p (%c)\n", pDrawable,
30703b705cfSriastradh		      uxa_drawable_location(pDrawable)));
30803b705cfSriastradh	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
30903b705cfSriastradh		if (uxa_prepare_access_gc(pGC)) {
31003b705cfSriastradh			fbImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci,
31103b705cfSriastradh					pglyphBase);
31203b705cfSriastradh			uxa_finish_access_gc(pGC);
31303b705cfSriastradh		}
31403b705cfSriastradh		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
31503b705cfSriastradh	}
31603b705cfSriastradh}
31703b705cfSriastradh
31803b705cfSriastradhvoid
31903b705cfSriastradhuxa_check_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
32003b705cfSriastradh			 int x, int y, unsigned int nglyph,
32103b705cfSriastradh			 CharInfoPtr * ppci, pointer pglyphBase)
32203b705cfSriastradh{
32303b705cfSriastradh	ScreenPtr screen = pDrawable->pScreen;
32403b705cfSriastradh
32503b705cfSriastradh	UXA_FALLBACK(("to %p (%c), style %d alu %d\n", pDrawable,
32603b705cfSriastradh		      uxa_drawable_location(pDrawable), pGC->fillStyle,
32703b705cfSriastradh		      pGC->alu));
32803b705cfSriastradh	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
32903b705cfSriastradh		if (uxa_prepare_access_gc(pGC)) {
33003b705cfSriastradh			fbPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci,
33103b705cfSriastradh				       pglyphBase);
33203b705cfSriastradh			uxa_finish_access_gc(pGC);
33303b705cfSriastradh		}
33403b705cfSriastradh		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
33503b705cfSriastradh	}
33603b705cfSriastradh}
33703b705cfSriastradh
33803b705cfSriastradhvoid
33903b705cfSriastradhuxa_check_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
34003b705cfSriastradh		      DrawablePtr pDrawable, int w, int h, int x, int y)
34103b705cfSriastradh{
34203b705cfSriastradh	ScreenPtr screen = pDrawable->pScreen;
34303b705cfSriastradh
34403b705cfSriastradh	UXA_FALLBACK(("from %p to %p (%c,%c)\n", pBitmap, pDrawable,
34503b705cfSriastradh		      uxa_drawable_location(&pBitmap->drawable),
34603b705cfSriastradh		      uxa_drawable_location(pDrawable)));
34703b705cfSriastradh	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
34803b705cfSriastradh		if (uxa_prepare_access(&pBitmap->drawable, UXA_ACCESS_RO)) {
34903b705cfSriastradh			if (uxa_prepare_access_gc(pGC)) {
35003b705cfSriastradh				fbPushPixels(pGC, pBitmap, pDrawable, w, h, x,
35103b705cfSriastradh					     y);
35203b705cfSriastradh				uxa_finish_access_gc(pGC);
35303b705cfSriastradh			}
35403b705cfSriastradh			uxa_finish_access(&pBitmap->drawable, UXA_ACCESS_RO);
35503b705cfSriastradh		}
35603b705cfSriastradh		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
35703b705cfSriastradh	}
35803b705cfSriastradh}
35903b705cfSriastradh
36003b705cfSriastradhvoid
36103b705cfSriastradhuxa_check_get_spans(DrawablePtr pDrawable,
36203b705cfSriastradh		    int wMax,
36303b705cfSriastradh		    DDXPointPtr ppt, int *pwidth, int nspans, char *pdstStart)
36403b705cfSriastradh{
36503b705cfSriastradh	ScreenPtr screen = pDrawable->pScreen;
36603b705cfSriastradh
36703b705cfSriastradh	UXA_FALLBACK(("from %p (%c)\n", pDrawable,
36803b705cfSriastradh		      uxa_drawable_location(pDrawable)));
36903b705cfSriastradh	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RO)) {
37003b705cfSriastradh		fbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
37103b705cfSriastradh		uxa_finish_access(pDrawable, UXA_ACCESS_RO);
37203b705cfSriastradh	}
37303b705cfSriastradh}
37403b705cfSriastradh
37503b705cfSriastradhvoid
37603b705cfSriastradhuxa_check_composite(CARD8 op,
37703b705cfSriastradh		    PicturePtr pSrc,
37803b705cfSriastradh		    PicturePtr pMask,
37903b705cfSriastradh		    PicturePtr pDst,
38003b705cfSriastradh		    INT16 xSrc, INT16 ySrc,
38103b705cfSriastradh		    INT16 xMask, INT16 yMask,
38203b705cfSriastradh		    INT16 xDst, INT16 yDst,
38303b705cfSriastradh		    CARD16 width, CARD16 height)
38403b705cfSriastradh{
38503b705cfSriastradh	ScreenPtr screen = pDst->pDrawable->pScreen;
38603b705cfSriastradh
38703b705cfSriastradh	UXA_FALLBACK(("from picts %p/%p to pict %p\n", pSrc, pMask, pDst));
38803b705cfSriastradh
38903b705cfSriastradh	if (uxa_picture_prepare_access(pDst, UXA_ACCESS_RW)) {
39003b705cfSriastradh		if (uxa_picture_prepare_access(pSrc, UXA_ACCESS_RO)) {
39103b705cfSriastradh			if (!pMask || uxa_picture_prepare_access(pMask, UXA_ACCESS_RO)) {
39203b705cfSriastradh				fbComposite(op, pSrc, pMask, pDst,
39303b705cfSriastradh					    xSrc, ySrc,
39403b705cfSriastradh					    xMask, yMask,
39503b705cfSriastradh					    xDst, yDst,
39603b705cfSriastradh					    width, height);
39703b705cfSriastradh				if (pMask)
39803b705cfSriastradh					uxa_picture_finish_access(pMask, UXA_ACCESS_RO);
39903b705cfSriastradh			}
40003b705cfSriastradh			uxa_picture_finish_access(pSrc, UXA_ACCESS_RO);
40103b705cfSriastradh		}
40203b705cfSriastradh		uxa_picture_finish_access(pDst, UXA_ACCESS_RW);
40303b705cfSriastradh	}
40403b705cfSriastradh}
40503b705cfSriastradh
40603b705cfSriastradhvoid
40703b705cfSriastradhuxa_check_add_traps(PicturePtr pPicture,
40803b705cfSriastradh		    INT16 x_off, INT16 y_off, int ntrap, xTrap * traps)
40903b705cfSriastradh{
41003b705cfSriastradh	ScreenPtr screen = pPicture->pDrawable->pScreen;
41103b705cfSriastradh
41203b705cfSriastradh	UXA_FALLBACK(("to pict %p (%c)\n", pPicture,
41303b705cfSriastradh		      uxa_drawable_location(pPicture->pDrawable)));
41403b705cfSriastradh	if (uxa_picture_prepare_access(pPicture, UXA_ACCESS_RW)) {
41503b705cfSriastradh		fbAddTraps(pPicture, x_off, y_off, ntrap, traps);
41603b705cfSriastradh		uxa_picture_finish_access(pPicture, UXA_ACCESS_RW);
41703b705cfSriastradh	}
41803b705cfSriastradh}
41903b705cfSriastradh
42003b705cfSriastradh/**
42103b705cfSriastradh * Gets the 0,0 pixel of a pixmap.  Used for doing solid fills of tiled pixmaps
42203b705cfSriastradh * that happen to be 1x1.  Pixmap must be at least 8bpp.
42303b705cfSriastradh *
42403b705cfSriastradh * XXX This really belongs in fb, so it can be aware of tiling and etc.
42503b705cfSriastradh */
42603b705cfSriastradhCARD32 uxa_get_pixmap_first_pixel(PixmapPtr pPixmap)
42703b705cfSriastradh{
42803b705cfSriastradh	CARD32 pixel;
42903b705cfSriastradh	void *fb;
43003b705cfSriastradh
43103b705cfSriastradh	if (!uxa_prepare_access(&pPixmap->drawable, UXA_ACCESS_RO))
43203b705cfSriastradh		return 0;
43303b705cfSriastradh
43403b705cfSriastradh	fb = pPixmap->devPrivate.ptr;
43503b705cfSriastradh
43603b705cfSriastradh	switch (pPixmap->drawable.bitsPerPixel) {
43703b705cfSriastradh	case 32:
43803b705cfSriastradh		pixel = *(CARD32 *) fb;
43903b705cfSriastradh		break;
44003b705cfSriastradh	case 16:
44103b705cfSriastradh		pixel = *(CARD16 *) fb;
44203b705cfSriastradh		break;
44303b705cfSriastradh	default:
44403b705cfSriastradh		pixel = *(CARD8 *) fb;
44503b705cfSriastradh		break;
44603b705cfSriastradh	}
44703b705cfSriastradh	uxa_finish_access(&pPixmap->drawable, UXA_ACCESS_RO);
44803b705cfSriastradh
44903b705cfSriastradh	return pixel;
45003b705cfSriastradh}
451