3 * Copyright © 2002 Keith Packard
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of Keith Packard not be used in
10 * advertising or publicity pertaining to distribution of the software without
11 * specific, written prior permission. Keith Packard makes no
12 * representations about the suitability of this software for any purpose. It
13 * is provided "as is" without express or implied warranty.
15 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21 * PERFORMANCE OF THIS SOFTWARE.
27 #include "Xrenderint.h"
30 XRenderQueryFilters (Display *dpy, Drawable drawable)
32 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
34 xRenderQueryFiltersReq *req;
35 xRenderQueryFiltersReply rep;
40 long nbytes, nbytesAlias, nbytesName;
42 if (!RenderHasExtension (info))
45 if (!XRenderQueryFormats (dpy))
49 if (xri->minor_version < 6)
53 GetReq (RenderQueryFilters, req);
54 req->reqType = info->codes->major_opcode;
55 req->renderReqType = X_RenderQueryFilters;
56 req->drawable = drawable;
57 if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))
64 * Compute total number of bytes for filter names
66 nbytes = (long)rep.length << 2;
67 nbytesAlias = rep.numAliases * 2;
68 if (rep.numAliases & 1)
70 nbytesName = nbytes - nbytesAlias;
73 * Allocate one giant block for the whole data structure
75 filters = Xmalloc (sizeof (XFilters) +
76 rep.numFilters * sizeof (char *) +
77 rep.numAliases * sizeof (short) +
82 _XEatData (dpy, (unsigned long) rep.length << 2);
91 * numFilters char * pointers to filter names
92 * numAliases short alias values
93 * nbytesName char strings
96 filters->nfilter = rep.numFilters;
97 filters->nalias = rep.numAliases;
98 filters->filter = (char **) (filters + 1);
99 filters->alias = (short *) (filters->filter + rep.numFilters);
100 name = (char *) (filters->alias + rep.numAliases);
103 * Read the filter aliases
105 _XRead16Pad (dpy, filters->alias, 2 * rep.numAliases);
108 * Read the filter names
110 for (i = 0; i < rep.numFilters; i++)
113 _XRead (dpy, &len, 1);
115 filters->filter[i] = name;
116 _XRead (dpy, name, l);
120 i = name - (char *) (filters->alias + rep.numAliases);
123 _XEatData (dpy, 4 - (i & 3));
131 XRenderSetPictureFilter (Display *dpy,
137 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
138 xRenderSetPictureFilterReq *req;
139 int nbytes = strlen (filter);
141 RenderSimpleCheckExtension (dpy, info);
143 GetReq(RenderSetPictureFilter, req);
144 req->reqType = info->codes->major_opcode;
145 req->renderReqType = X_RenderSetPictureFilter;
146 req->picture = picture;
147 req->nbytes = nbytes;
148 req->length += ((nbytes + 3) >> 2) + nparams;
149 Data (dpy, filter, nbytes);
150 Data (dpy, (_Xconst char *)params, nparams << 2);