summaryrefslogtreecommitdiff
path: root/xc/lib/Xxf86rush/XF86Rush.c
blob: 6281b174281a3b025e1f6c11b9c9e1c8fb9a87af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/* $XFree86: xc/lib/Xxf86rush/XF86Rush.c,v 1.3 2000/02/11 22:35:45 dawes Exp $ */
/*

Copyright (c) 1998 Daryll Strauss

*/

/* THIS IS NOT AN X CONSORTIUM STANDARD */

#define NEED_EVENTS
#define NEED_REPLIES
#include "Xlibint.h"
#include "xf86rushstr.h"
#include "Xext.h"
#include "extutil.h"

static XExtensionInfo _xf86rush_info_data;
static XExtensionInfo *xf86rush_info = &_xf86rush_info_data;
static char *xf86rush_extension_name = XF86RUSHNAME;

#define XF86RushCheckExtension(dpy,i,val) \
  XextCheckExtension (dpy, i, xf86rush_extension_name, val)

/*****************************************************************************
 *                                                                           *
 *			   private utility routines                          *
 *                                                                           *
 *****************************************************************************/

static int close_display();
static /* const */ XExtensionHooks xf86rush_extension_hooks = {
    NULL,				/* create_gc */
    NULL,				/* copy_gc */
    NULL,				/* flush_gc */
    NULL,				/* free_gc */
    NULL,				/* create_font */
    NULL,				/* free_font */
    close_display,			/* close_display */
    NULL,				/* wire_to_event */
    NULL,				/* event_to_wire */
    NULL,				/* error */
    NULL,				/* error_string */
};

static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86rush_info, 
				   xf86rush_extension_name, 
				   &xf86rush_extension_hooks, 
				   0, NULL)

static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86rush_info)


/*****************************************************************************
 *                                                                           *
 *		    public XFree86-DGA Extension routines                *
 *                                                                           *
 *****************************************************************************/

Bool XF86RushQueryExtension (Display *dpy, int *event_basep, int *error_basep)
{
    XExtDisplayInfo *info = find_display (dpy);

    if (XextHasExtension(info)) {
	*event_basep = info->codes->first_event;
	*error_basep = info->codes->first_error;
	return True;
    } else {
	return False;
    }
}

Bool XF86RushQueryVersion(Display *dpy, int *majorVersion, int *minorVersion)
{
    XExtDisplayInfo *info = find_display (dpy);
    xXF86RushQueryVersionReply rep;
    xXF86RushQueryVersionReq *req;

    XF86RushCheckExtension (dpy, info, False);

    LockDisplay(dpy);
    GetReq(XF86RushQueryVersion, req);
    req->reqType = info->codes->major_opcode;
    req->rushReqType = X_XF86RushQueryVersion;
    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
	UnlockDisplay(dpy);
	SyncHandle();
	return False;
    }
    *majorVersion = rep.majorVersion;
    *minorVersion = rep.minorVersion;
    UnlockDisplay(dpy);
    SyncHandle();
    return True;
}

Bool XF86RushLockPixmap(Display *dpy, int screen, Pixmap pixmap, void **addr)
{
  XExtDisplayInfo *info = find_display (dpy);
  xXF86RushLockPixmapReply rep;
  xXF86RushLockPixmapReq *req;

  XF86RushCheckExtension (dpy, info, False);
  LockDisplay(dpy);
  GetReq(XF86RushLockPixmap, req);
  req->reqType = info->codes->major_opcode;
  req->rushReqType = X_XF86RushLockPixmap;
  req->screen = screen;
  req->pixmap = pixmap;
  if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    UnlockDisplay(dpy);
    SyncHandle();
    return False;
  }
  if (addr)
      *addr = (void *)rep.addr;
  UnlockDisplay(dpy);
  SyncHandle();
  return True;
}

Bool XF86RushUnlockPixmap(Display *dpy, int screen, Pixmap pixmap)
{
  XExtDisplayInfo *info = find_display(dpy);
  xXF86RushUnlockPixmapReq *req;

  XF86RushCheckExtension (dpy, info, False);
  LockDisplay(dpy);
  GetReq(XF86RushUnlockPixmap, req);
  req->reqType = info->codes->major_opcode;
  req->rushReqType = X_XF86RushUnlockPixmap;
  req->screen=screen;
  req->pixmap=pixmap;
  UnlockDisplay(dpy);
  SyncHandle();
  return True;
}

Bool XF86RushUnlockAllPixmaps(Display *dpy)
{
  XExtDisplayInfo *info = find_display(dpy);
  xXF86RushUnlockAllPixmapsReq *req;

  XF86RushCheckExtension (dpy, info, False);
  LockDisplay(dpy);
  GetReq(XF86RushUnlockAllPixmaps, req);
  req->reqType = info->codes->major_opcode;
  req->rushReqType = X_XF86RushUnlockAllPixmaps;
  UnlockDisplay(dpy);
  SyncHandle();
  return True;
}

Bool XF86RushSetCopyMode(Display *dpy, int screen, int mode)
{
  XExtDisplayInfo *info = find_display(dpy);
  xXF86RushSetCopyModeReq *req;

  XF86RushCheckExtension (dpy, info, False);
  LockDisplay(dpy);
  GetReq(XF86RushSetCopyMode, req);
  req->reqType = info->codes->major_opcode;
  req->rushReqType = X_XF86RushSetCopyMode;
  req->screen = screen;
  req->CopyMode = mode;
  UnlockDisplay(dpy);
  SyncHandle();
  return True;
}

Bool XF86RushSetPixelStride(Display *dpy, int screen, int stride)
{
  XExtDisplayInfo *info = find_display(dpy);
  xXF86RushSetPixelStrideReq *req;

  XF86RushCheckExtension (dpy, info, False);
  LockDisplay(dpy);
  GetReq(XF86RushSetPixelStride, req);
  req->reqType = info->codes->major_opcode;
  req->rushReqType = X_XF86RushSetPixelStride;
  req->screen = screen;
  req->PixelStride = stride;
  UnlockDisplay(dpy);
  SyncHandle();
  return True;
}

int XF86RushOverlayPixmap (Display *dpy, XvPortID port, Drawable d,
			   GC gc, Pixmap pixmap, int src_x, int src_y,
			   unsigned int src_w, unsigned int src_h,
			   int dest_x, int dest_y,
			   unsigned int dest_w, unsigned int dest_h,
			   unsigned int id)
{
  XExtDisplayInfo *info = find_display(dpy);
  xXF86RushOverlayPixmapReq *req;

  XF86RushCheckExtension (dpy, info, False);

  FlushGC(dpy, gc);

  LockDisplay(dpy);
  GetReq(XF86RushOverlayPixmap, req);

  req->reqType = info->codes->major_opcode;
  req->rushReqType = X_XF86RushOverlayPixmap;
  req->port = port;
  req->drawable = d;
  req->gc = gc->gid;
  req->id = id;
  req->pixmap = pixmap;
  req->src_x = src_x;
  req->src_y = src_y;
  req->src_w = src_w;
  req->src_h = src_h;
  req->drw_x = dest_x;
  req->drw_y = dest_y;
  req->drw_w = dest_w;
  req->drw_h = dest_h;

  UnlockDisplay(dpy);
  SyncHandle();
  return Success;
}