11f0ac6a5Smrg/*
21f0ac6a5Smrg *
31f0ac6a5Smrg * Copyright © 2000 SuSE, Inc.
41f0ac6a5Smrg *
51f0ac6a5Smrg * Permission to use, copy, modify, distribute, and sell this software and its
61f0ac6a5Smrg * documentation for any purpose is hereby granted without fee, provided that
71f0ac6a5Smrg * the above copyright notice appear in all copies and that both that
81f0ac6a5Smrg * copyright notice and this permission notice appear in supporting
91f0ac6a5Smrg * documentation, and that the name of SuSE not be used in advertising or
101f0ac6a5Smrg * publicity pertaining to distribution of the software without specific,
111f0ac6a5Smrg * written prior permission.  SuSE makes no representations about the
121f0ac6a5Smrg * suitability of this software for any purpose.  It is provided "as is"
131f0ac6a5Smrg * without express or implied warranty.
141f0ac6a5Smrg *
151f0ac6a5Smrg * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
161f0ac6a5Smrg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
171f0ac6a5Smrg * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
181f0ac6a5Smrg * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
196fae4e5dSmrg * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
201f0ac6a5Smrg * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
211f0ac6a5Smrg *
221f0ac6a5Smrg * Author:  Keith Packard, SuSE, Inc.
231f0ac6a5Smrg */
241f0ac6a5Smrg
251f0ac6a5Smrg#ifdef HAVE_CONFIG_H
261f0ac6a5Smrg#include <config.h>
271f0ac6a5Smrg#endif
281f0ac6a5Smrg#include "Xrenderint.h"
291f0ac6a5Smrg
301f0ac6a5Smrg/* precompute the maximum size of batching request allowed */
311f0ac6a5Smrg
321f0ac6a5Smrg#define size (SIZEOF(xRenderFillRectanglesReq) + FRCTSPERBATCH * SIZEOF(xRectangle))
331f0ac6a5Smrg
341f0ac6a5Smrgvoid
351f0ac6a5SmrgXRenderFillRectangle (Display	    *dpy,
361f0ac6a5Smrg		      int	    op,
371f0ac6a5Smrg		      Picture	    dst,
381f0ac6a5Smrg		      _Xconst XRenderColor  *color,
391f0ac6a5Smrg		      int	    x,
401f0ac6a5Smrg		      int	    y,
411f0ac6a5Smrg		      unsigned int  width,
421f0ac6a5Smrg		      unsigned int  height)
431f0ac6a5Smrg{
44d21ab8bcSmrg    XRenderExtDisplayInfo	*info = XRenderFindDisplay (dpy);
451f0ac6a5Smrg    xRectangle			*rect;
461f0ac6a5Smrg    xRenderFillRectanglesReq	*req;
471f0ac6a5Smrg#ifdef MUSTCOPY
481f0ac6a5Smrg    xRectangle			rectdata;
491f0ac6a5Smrg    long			len = SIZEOF(xRectangle);
501f0ac6a5Smrg
511f0ac6a5Smrg    rect = &rectdata;
521f0ac6a5Smrg#endif /* MUSTCOPY */
531f0ac6a5Smrg
541f0ac6a5Smrg    RenderSimpleCheckExtension (dpy, info);
551f0ac6a5Smrg    LockDisplay(dpy);
561f0ac6a5Smrg
571f0ac6a5Smrg    req = (xRenderFillRectanglesReq *) dpy->last_req;
581f0ac6a5Smrg    /* if same as previous request, with same drawable, batch requests */
591f0ac6a5Smrg    if (req->reqType == info->codes->major_opcode &&
601f0ac6a5Smrg	req->renderReqType == X_RenderFillRectangles &&
611f0ac6a5Smrg	req->op == op &&
621f0ac6a5Smrg	req->dst == dst &&
631f0ac6a5Smrg	req->color.red == color->red &&
641f0ac6a5Smrg	req->color.green == color->green &&
651f0ac6a5Smrg	req->color.blue == color->blue &&
661f0ac6a5Smrg	req->color.alpha == color->alpha &&
671f0ac6a5Smrg	dpy->bufptr + SIZEOF(xRectangle) <= dpy->bufmax &&
681f0ac6a5Smrg	(char *)dpy->bufptr - (char *)req < size)
691f0ac6a5Smrg    {
70d21ab8bcSmrg	req->length = (CARD16) (req->length + (SIZEOF(xRectangle) >> 2));
711f0ac6a5Smrg#ifndef MUSTCOPY
721f0ac6a5Smrg	rect = (xRectangle *) dpy->bufptr;
731f0ac6a5Smrg	dpy->bufptr += SIZEOF(xRectangle);
741f0ac6a5Smrg#endif /* not MUSTCOPY */
751f0ac6a5Smrg    }
766fae4e5dSmrg    else
771f0ac6a5Smrg    {
781f0ac6a5Smrg	GetReqExtra(RenderFillRectangles, SIZEOF(xRectangle), req);
796fae4e5dSmrg
80d21ab8bcSmrg	req->reqType = (CARD8) info->codes->major_opcode;
811f0ac6a5Smrg	req->renderReqType = X_RenderFillRectangles;
82d21ab8bcSmrg	req->op = (CARD8) op;
83d21ab8bcSmrg	req->dst = (CARD32) dst;
841f0ac6a5Smrg	req->color.red = color->red;
851f0ac6a5Smrg	req->color.green = color->green;
861f0ac6a5Smrg	req->color.blue = color->blue;
871f0ac6a5Smrg	req->color.alpha = color->alpha;
886fae4e5dSmrg
891f0ac6a5Smrg#ifdef MUSTCOPY
901f0ac6a5Smrg	dpy->bufptr -= SIZEOF(xRectangle);
911f0ac6a5Smrg#else
921f0ac6a5Smrg	rect = (xRectangle *) NEXTPTR(req,xRenderFillRectanglesReq);
931f0ac6a5Smrg#endif /* MUSTCOPY */
941f0ac6a5Smrg    }
95d21ab8bcSmrg    rect->x = (INT16) x;
96d21ab8bcSmrg    rect->y = (INT16) y;
97d21ab8bcSmrg    rect->width = (CARD16) width;
98d21ab8bcSmrg    rect->height = (CARD16) height;
991f0ac6a5Smrg
1001f0ac6a5Smrg#ifdef MUSTCOPY
1011f0ac6a5Smrg    Data (dpy, (char *) rect, len);
1021f0ac6a5Smrg#endif /* MUSTCOPY */
1031f0ac6a5Smrg    UnlockDisplay(dpy);
1041f0ac6a5Smrg    SyncHandle();
1051f0ac6a5Smrg}
1061f0ac6a5Smrg
107