135c4bbdfSmrg/*
235c4bbdfSmrg * Copyright © 2014 Keith Packard
335c4bbdfSmrg *
435c4bbdfSmrg * Permission to use, copy, modify, distribute, and sell this software and its
535c4bbdfSmrg * documentation for any purpose is hereby granted without fee, provided that
635c4bbdfSmrg * the above copyright notice appear in all copies and that both that copyright
735c4bbdfSmrg * notice and this permission notice appear in supporting documentation, and
835c4bbdfSmrg * that the name of the copyright holders not be used in advertising or
935c4bbdfSmrg * publicity pertaining to distribution of the software without specific,
1035c4bbdfSmrg * written prior permission.  The copyright holders make no representations
1135c4bbdfSmrg * about the suitability of this software for any purpose.  It is provided "as
1235c4bbdfSmrg * is" without express or implied warranty.
1335c4bbdfSmrg *
1435c4bbdfSmrg * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1535c4bbdfSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
1635c4bbdfSmrg * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1735c4bbdfSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
1835c4bbdfSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
1935c4bbdfSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
2035c4bbdfSmrg * OF THIS SOFTWARE.
2135c4bbdfSmrg */
2235c4bbdfSmrg
2335c4bbdfSmrg#include "glamor_priv.h"
2435c4bbdfSmrg
2535c4bbdfSmrgvoid
2635c4bbdfSmrgglamor_solid_boxes(PixmapPtr pixmap,
2735c4bbdfSmrg                   BoxPtr box, int nbox, unsigned long fg_pixel)
2835c4bbdfSmrg{
2935c4bbdfSmrg    DrawablePtr drawable = &pixmap->drawable;
3035c4bbdfSmrg    GCPtr gc;
3135c4bbdfSmrg    xRectangle *rect;
3235c4bbdfSmrg    int n;
3335c4bbdfSmrg
3435c4bbdfSmrg    rect = xallocarray(nbox, sizeof(xRectangle));
3535c4bbdfSmrg    if (!rect)
3635c4bbdfSmrg        return;
3735c4bbdfSmrg    for (n = 0; n < nbox; n++) {
3835c4bbdfSmrg        rect[n].x = box[n].x1;
3935c4bbdfSmrg        rect[n].y = box[n].y1;
4035c4bbdfSmrg        rect[n].width = box[n].x2 - box[n].x1;
4135c4bbdfSmrg        rect[n].height = box[n].y2 - box[n].y1;
4235c4bbdfSmrg    }
4335c4bbdfSmrg
4435c4bbdfSmrg    gc = GetScratchGC(drawable->depth, drawable->pScreen);
4535c4bbdfSmrg    if (gc) {
4635c4bbdfSmrg        ChangeGCVal vals[1];
4735c4bbdfSmrg
4835c4bbdfSmrg        vals[0].val = fg_pixel;
4935c4bbdfSmrg        ChangeGC(NullClient, gc, GCForeground, vals);
5035c4bbdfSmrg        ValidateGC(drawable, gc);
5135c4bbdfSmrg        gc->ops->PolyFillRect(drawable, gc, nbox, rect);
5235c4bbdfSmrg        FreeScratchGC(gc);
5335c4bbdfSmrg    }
5435c4bbdfSmrg    free(rect);
5535c4bbdfSmrg}
5635c4bbdfSmrg
5735c4bbdfSmrgvoid
5835c4bbdfSmrgglamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
5935c4bbdfSmrg             unsigned long fg_pixel)
6035c4bbdfSmrg{
6135c4bbdfSmrg    DrawablePtr drawable = &pixmap->drawable;
6235c4bbdfSmrg    GCPtr gc;
6335c4bbdfSmrg    ChangeGCVal vals[1];
6435c4bbdfSmrg    xRectangle rect;
6535c4bbdfSmrg
6635c4bbdfSmrg    vals[0].val = fg_pixel;
6735c4bbdfSmrg    gc = GetScratchGC(drawable->depth, drawable->pScreen);
6835c4bbdfSmrg    if (!gc)
6935c4bbdfSmrg        return;
7035c4bbdfSmrg    ChangeGC(NullClient, gc, GCForeground, vals);
7135c4bbdfSmrg    ValidateGC(drawable, gc);
7235c4bbdfSmrg    rect.x = x;
7335c4bbdfSmrg    rect.y = y;
7435c4bbdfSmrg    rect.width = width;
7535c4bbdfSmrg    rect.height = height;
7635c4bbdfSmrg    gc->ops->PolyFillRect(drawable, gc, 1, &rect);
7735c4bbdfSmrg    FreeScratchGC(gc);
7835c4bbdfSmrg}
7935c4bbdfSmrg
80