First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xgl / xglcopy.c
blobd612b332ad5c84ce846b8be13b9f9e74d096ba5a
1 /*
2 * Copyright © 2004 David Reveman
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * David Reveman not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * David Reveman makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
15 * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: David Reveman <davidr@novell.com>
26 #include "xgl.h"
27 #include "fb.h"
29 Bool
30 xglCopy (DrawablePtr pSrc,
31 DrawablePtr pDst,
32 int dx,
33 int dy,
34 BoxPtr pBox,
35 int nBox)
37 glitz_surface_t *src, *dst;
38 int srcXoff, srcYoff;
39 int dstXoff, dstYoff;
41 XGL_DRAWABLE_PIXMAP (pDst);
43 if (!nBox)
44 return TRUE;
46 if (xglPrepareTarget (pDst))
48 if (!xglSyncSurface (pSrc))
49 return FALSE;
51 else
53 if (!xglPrepareTarget (pSrc))
54 return FALSE;
56 if (!xglSyncSurface (pDst))
57 return FALSE;
60 XGL_GET_DRAWABLE (pSrc, src, srcXoff, srcYoff);
61 XGL_GET_DRAWABLE (pDst, dst, dstXoff, dstYoff);
63 glitz_surface_set_clip_region (dst,
64 dstXoff, dstYoff,
65 (glitz_box_t *) pBox, nBox);
67 glitz_copy_area (src,
68 dst,
69 srcXoff + dx,
70 srcYoff + dy,
71 pPixmap->drawable.width - dstXoff,
72 pPixmap->drawable.height - dstYoff,
73 dstXoff,
74 dstYoff);
76 glitz_surface_set_clip_region (dst, 0, 0, NULL, 0);
78 if (glitz_surface_get_status (dst))
79 return FALSE;
81 return TRUE;
84 void
85 xglCopyProc (DrawablePtr pSrc,
86 DrawablePtr pDst,
87 GCPtr pGC,
88 BoxPtr pBox,
89 int nBox,
90 int dx,
91 int dy,
92 Bool reverse,
93 Bool upsidedown,
94 Pixel bitplane,
95 void *closure)
97 BoxPtr pSrcBox = (BoxPtr) closure;
99 if (!xglCopy (pSrc, pDst, dx, dy, pBox, nBox))
101 RegionRec region;
103 XGL_DRAWABLE_PIXMAP (pDst);
104 XGL_PIXMAP_PRIV (pPixmap);
106 if (!xglSyncBits (pSrc, pSrcBox))
107 FatalError (XGL_SW_FAILURE_STRING);
109 if (!xglMapPixmapBits (pPixmap))
110 FatalError (XGL_SW_FAILURE_STRING);
112 fbCopyNtoN (pSrc, pDst, pGC,
113 pBox, nBox,
114 dx, dy,
115 reverse, upsidedown, bitplane,
116 (void *) 0);
118 pPixmapPriv->damageBox = miEmptyBox;
120 while (nBox--)
122 REGION_INIT (pDst->pScreen, &region, pBox, 1);
123 xglAddSurfaceDamage (pDst, &region);
124 REGION_UNINIT (pDst->pScreen, &region);
126 pBox++;
128 } else
129 xglAddCurrentBitDamage (pDst);