1/* 2 * 3 * Copyright © 2000 SuSE, Inc. 4 * 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 SuSE not be used in advertising or 10 * publicity pertaining to distribution of the software without specific, 11 * written prior permission. SuSE makes no representations about the 12 * suitability of this software for any purpose. It is provided "as is" 13 * without express or implied warranty. 14 * 15 * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE 17 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 19 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 * 22 * Author: Keith Packard, SuSE, Inc. 23 */ 24 25#ifdef HAVE_CONFIG_H 26#include <config.h> 27#endif 28#include "Xrenderint.h" 29 30/* precompute the maximum size of batching request allowed */ 31 32#define size (SIZEOF(xRenderFillRectanglesReq) + FRCTSPERBATCH * SIZEOF(xRectangle)) 33 34void 35XRenderFillRectangle (Display *dpy, 36 int op, 37 Picture dst, 38 _Xconst XRenderColor *color, 39 int x, 40 int y, 41 unsigned int width, 42 unsigned int height) 43{ 44 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); 45 xRectangle *rect; 46 xRenderFillRectanglesReq *req; 47#ifdef MUSTCOPY 48 xRectangle rectdata; 49 long len = SIZEOF(xRectangle); 50 51 rect = &rectdata; 52#endif /* MUSTCOPY */ 53 54 RenderSimpleCheckExtension (dpy, info); 55 LockDisplay(dpy); 56 57 req = (xRenderFillRectanglesReq *) dpy->last_req; 58 /* if same as previous request, with same drawable, batch requests */ 59 if (req->reqType == info->codes->major_opcode && 60 req->renderReqType == X_RenderFillRectangles && 61 req->op == op && 62 req->dst == dst && 63 req->color.red == color->red && 64 req->color.green == color->green && 65 req->color.blue == color->blue && 66 req->color.alpha == color->alpha && 67 dpy->bufptr + SIZEOF(xRectangle) <= dpy->bufmax && 68 (char *)dpy->bufptr - (char *)req < size) 69 { 70 req->length = (CARD16) (req->length + (SIZEOF(xRectangle) >> 2)); 71#ifndef MUSTCOPY 72 rect = (xRectangle *) dpy->bufptr; 73 dpy->bufptr += SIZEOF(xRectangle); 74#endif /* not MUSTCOPY */ 75 } 76 else 77 { 78 GetReqExtra(RenderFillRectangles, SIZEOF(xRectangle), req); 79 80 req->reqType = (CARD8) info->codes->major_opcode; 81 req->renderReqType = X_RenderFillRectangles; 82 req->op = (CARD8) op; 83 req->dst = (CARD32) dst; 84 req->color.red = color->red; 85 req->color.green = color->green; 86 req->color.blue = color->blue; 87 req->color.alpha = color->alpha; 88 89#ifdef MUSTCOPY 90 dpy->bufptr -= SIZEOF(xRectangle); 91#else 92 rect = (xRectangle *) NEXTPTR(req,xRenderFillRectanglesReq); 93#endif /* MUSTCOPY */ 94 } 95 rect->x = (INT16) x; 96 rect->y = (INT16) y; 97 rect->width = (CARD16) width; 98 rect->height = (CARD16) height; 99 100#ifdef MUSTCOPY 101 Data (dpy, (char *) rect, len); 102#endif /* MUSTCOPY */ 103 UnlockDisplay(dpy); 104 SyncHandle(); 105} 106 107