1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright © 2014 Keith Packard
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * Permission to use, copy, modify, distribute, and sell this software and its
5*4882a593Smuzhiyun * documentation for any purpose is hereby granted without fee, provided that
6*4882a593Smuzhiyun * the above copyright notice appear in all copies and that both that copyright
7*4882a593Smuzhiyun * notice and this permission notice appear in supporting documentation, and
8*4882a593Smuzhiyun * that the name of the copyright holders not be used in advertising or
9*4882a593Smuzhiyun * publicity pertaining to distribution of the software without specific,
10*4882a593Smuzhiyun * written prior permission. The copyright holders make no representations
11*4882a593Smuzhiyun * about the suitability of this software for any purpose. It is provided "as
12*4882a593Smuzhiyun * is" without express or implied warranty.
13*4882a593Smuzhiyun *
14*4882a593Smuzhiyun * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15*4882a593Smuzhiyun * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16*4882a593Smuzhiyun * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17*4882a593Smuzhiyun * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18*4882a593Smuzhiyun * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19*4882a593Smuzhiyun * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20*4882a593Smuzhiyun * OF THIS SOFTWARE.
21*4882a593Smuzhiyun */
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun #include "glamor_priv.h"
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun void
glamor_solid_boxes(PixmapPtr pixmap,BoxPtr box,int nbox,unsigned long fg_pixel)26*4882a593Smuzhiyun glamor_solid_boxes(PixmapPtr pixmap,
27*4882a593Smuzhiyun BoxPtr box, int nbox, unsigned long fg_pixel)
28*4882a593Smuzhiyun {
29*4882a593Smuzhiyun DrawablePtr drawable = &pixmap->drawable;
30*4882a593Smuzhiyun GCPtr gc;
31*4882a593Smuzhiyun xRectangle *rect;
32*4882a593Smuzhiyun int n;
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun rect = xallocarray(nbox, sizeof(xRectangle));
35*4882a593Smuzhiyun if (!rect)
36*4882a593Smuzhiyun return;
37*4882a593Smuzhiyun for (n = 0; n < nbox; n++) {
38*4882a593Smuzhiyun rect[n].x = box[n].x1;
39*4882a593Smuzhiyun rect[n].y = box[n].y1;
40*4882a593Smuzhiyun rect[n].width = box[n].x2 - box[n].x1;
41*4882a593Smuzhiyun rect[n].height = box[n].y2 - box[n].y1;
42*4882a593Smuzhiyun }
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun gc = GetScratchGC(drawable->depth, drawable->pScreen);
45*4882a593Smuzhiyun if (gc) {
46*4882a593Smuzhiyun ChangeGCVal vals[1];
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun vals[0].val = fg_pixel;
49*4882a593Smuzhiyun ChangeGC(NullClient, gc, GCForeground, vals);
50*4882a593Smuzhiyun ValidateGC(drawable, gc);
51*4882a593Smuzhiyun gc->ops->PolyFillRect(drawable, gc, nbox, rect);
52*4882a593Smuzhiyun FreeScratchGC(gc);
53*4882a593Smuzhiyun }
54*4882a593Smuzhiyun free(rect);
55*4882a593Smuzhiyun }
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun void
glamor_solid(PixmapPtr pixmap,int x,int y,int width,int height,unsigned long fg_pixel)58*4882a593Smuzhiyun glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
59*4882a593Smuzhiyun unsigned long fg_pixel)
60*4882a593Smuzhiyun {
61*4882a593Smuzhiyun DrawablePtr drawable = &pixmap->drawable;
62*4882a593Smuzhiyun GCPtr gc;
63*4882a593Smuzhiyun ChangeGCVal vals[1];
64*4882a593Smuzhiyun xRectangle rect;
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun vals[0].val = fg_pixel;
67*4882a593Smuzhiyun gc = GetScratchGC(drawable->depth, drawable->pScreen);
68*4882a593Smuzhiyun if (!gc)
69*4882a593Smuzhiyun return;
70*4882a593Smuzhiyun ChangeGC(NullClient, gc, GCForeground, vals);
71*4882a593Smuzhiyun ValidateGC(drawable, gc);
72*4882a593Smuzhiyun rect.x = x;
73*4882a593Smuzhiyun rect.y = y;
74*4882a593Smuzhiyun rect.width = width;
75*4882a593Smuzhiyun rect.height = height;
76*4882a593Smuzhiyun gc->ops->PolyFillRect(drawable, gc, 1, &rect);
77*4882a593Smuzhiyun FreeScratchGC(gc);
78*4882a593Smuzhiyun }
79*4882a593Smuzhiyun
80