First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xgl / xglget.c
blob87bcb0508c38f4b4d3b2033bd48edaf9a39c02b2
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"
28 void
29 xglGetImage (DrawablePtr pDrawable,
30 int x,
31 int y,
32 int w,
33 int h,
34 unsigned int format,
35 unsigned long planeMask,
36 char *d)
38 ScreenPtr pScreen = pDrawable->pScreen;
39 glitz_surface_t *surface;
40 int xOff, yOff;
41 BoxRec box;
43 XGL_SCREEN_PRIV (pScreen);
45 /* Many apps use GetImage to sync with the visible frame buffer */
46 if (pDrawable->type == DRAWABLE_WINDOW)
48 if (!xglSyncSurface (&pScreenPriv->pScreenPixmap->drawable))
49 FatalError (XGL_SW_FAILURE_STRING);
51 glitz_surface_flush (pScreenPriv->surface);
52 glitz_drawable_finish (pScreenPriv->drawable);
55 XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
57 box.x1 = pDrawable->x + xOff + x;
58 box.y1 = pDrawable->y + yOff + y;
59 box.x2 = box.x1 + w;
60 box.y2 = box.y1 + h;
62 if (!xglSyncBits (pDrawable, &box))
63 FatalError (XGL_SW_FAILURE_STRING);
65 XGL_SCREEN_UNWRAP (GetImage);
66 (*pScreen->GetImage) (pDrawable, x, y, w, h, format, planeMask, d);
67 XGL_SCREEN_WRAP (GetImage, xglGetImage);
70 void
71 xglGetSpans (DrawablePtr pDrawable,
72 int wMax,
73 DDXPointPtr ppt,
74 int *pwidth,
75 int nspans,
76 char *pchardstStart)
78 ScreenPtr pScreen = pDrawable->pScreen;
80 XGL_SCREEN_PRIV (pScreen);
82 if (!xglSyncBits (pDrawable, NullBox))
83 FatalError (XGL_SW_FAILURE_STRING);
85 XGL_SCREEN_UNWRAP (GetSpans);
86 (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
87 XGL_SCREEN_WRAP (GetSpans, xglGetSpans);