2006-11-26 11:13:41 -07:00
|
|
|
/***********************************************************
|
|
|
|
|
|
|
|
Copyright 1987, 1998 The Open Group
|
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
the above copyright notice appear in all copies and that both that
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of The Open Group shall not be
|
|
|
|
used in advertising or otherwise to promote the sale, use or other dealings
|
|
|
|
in this Software without prior written authorization from The Open Group.
|
|
|
|
|
|
|
|
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
2006-11-26 11:13:41 -07:00
|
|
|
provided that the above copyright notice appear in all copies and that
|
2015-09-16 13:10:19 -06:00
|
|
|
both that copyright notice and this permission notice appear in
|
2006-11-26 11:13:41 -07:00
|
|
|
supporting documentation, and that the name of Digital not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
2015-09-16 13:10:19 -06:00
|
|
|
software without specific, written prior permission.
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
/*****************************************************************
|
|
|
|
|
|
|
|
Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
|
|
|
|
BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
|
|
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of Digital Equipment Corporation
|
|
|
|
shall not be used in advertising or otherwise to promote the sale, use or other
|
|
|
|
dealings in this Software without prior written authorization from Digital
|
|
|
|
Equipment Corporation.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include <X11/Xprotostr.h>
|
|
|
|
|
|
|
|
#include "misc.h"
|
|
|
|
#include "regionstr.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "gcstruct.h"
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include "pixmap.h"
|
|
|
|
#include "input.h"
|
|
|
|
|
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "mi.h"
|
|
|
|
#include <X11/Xmd.h>
|
|
|
|
|
|
|
|
#include "globals.h"
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
#include "panoramiX.h"
|
|
|
|
#include "panoramiXsrv.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
machine-independent graphics exposure code. any device that uses
|
|
|
|
the region package can call this.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RECTLIMIT
|
2012-06-10 07:21:05 -06:00
|
|
|
#define RECTLIMIT 25 /* pick a number, any number > 8 */
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
/* miHandleExposures
|
2006-11-26 11:13:41 -07:00
|
|
|
generate a region for exposures for areas that were copied from obscured or
|
|
|
|
non-existent areas to non-obscured areas of the destination. Paint the
|
|
|
|
background for the region, if the destination is a window.
|
|
|
|
|
|
|
|
NOTE:
|
|
|
|
this should generally be called, even if graphicsExposures is false,
|
|
|
|
because this is where bits get recovered from backing store.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
RegionPtr
|
2009-09-06 13:44:18 -06:00
|
|
|
miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
|
2012-06-10 07:21:05 -06:00
|
|
|
GCPtr pGC, int srcx, int srcy, int width, int height,
|
2015-09-16 13:10:19 -06:00
|
|
|
int dstx, int dsty)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionPtr prgnSrcClip; /* drawable-relative source clip */
|
2006-11-26 11:13:41 -07:00
|
|
|
RegionRec rgnSrcRec;
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionPtr prgnDstClip; /* drawable-relative dest clip */
|
2006-11-26 11:13:41 -07:00
|
|
|
RegionRec rgnDstRec;
|
2012-06-10 07:21:05 -06:00
|
|
|
BoxRec srcBox; /* unclipped source */
|
|
|
|
RegionRec rgnExposed; /* exposed region, calculated source-
|
|
|
|
relative, made dst relative to
|
|
|
|
intersect with visible parts of
|
2015-09-16 13:10:19 -06:00
|
|
|
dest and send events to client,
|
|
|
|
and then screen relative to paint
|
2012-06-10 07:21:05 -06:00
|
|
|
the window background
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
WindowPtr pSrcWin;
|
2019-07-27 01:57:06 -06:00
|
|
|
BoxRec expBox = { 0, };
|
2006-11-26 11:13:41 -07:00
|
|
|
Bool extents;
|
|
|
|
|
|
|
|
/* avoid work if we can */
|
|
|
|
if (!pGC->graphicsExposures &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(pDstDrawable->type == DRAWABLE_PIXMAP) &&
|
|
|
|
((pSrcDrawable->type == DRAWABLE_PIXMAP) ||
|
2015-09-16 13:10:19 -06:00
|
|
|
(((WindowPtr) pSrcDrawable)->backStorage == 0)))
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
srcBox.x1 = srcx;
|
|
|
|
srcBox.y1 = srcy;
|
2012-06-10 07:21:05 -06:00
|
|
|
srcBox.x2 = srcx + width;
|
|
|
|
srcBox.y2 = srcy + height;
|
|
|
|
|
|
|
|
if (pSrcDrawable->type != DRAWABLE_PIXMAP) {
|
|
|
|
BoxRec TsrcBox;
|
|
|
|
|
|
|
|
TsrcBox.x1 = srcx + pSrcDrawable->x;
|
|
|
|
TsrcBox.y1 = srcy + pSrcDrawable->y;
|
|
|
|
TsrcBox.x2 = TsrcBox.x1 + width;
|
|
|
|
TsrcBox.y2 = TsrcBox.y1 + height;
|
|
|
|
pSrcWin = (WindowPtr) pSrcDrawable;
|
|
|
|
if (pGC->subWindowMode == IncludeInferiors) {
|
|
|
|
prgnSrcClip = NotClippedByChildren(pSrcWin);
|
|
|
|
if ((RegionContainsRect(prgnSrcClip, &TsrcBox)) == rgnIN) {
|
|
|
|
RegionDestroy(prgnSrcClip);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ((RegionContainsRect(&pSrcWin->clipList, &TsrcBox)) == rgnIN)
|
|
|
|
return NULL;
|
|
|
|
prgnSrcClip = &rgnSrcRec;
|
|
|
|
RegionNull(prgnSrcClip);
|
|
|
|
RegionCopy(prgnSrcClip, &pSrcWin->clipList);
|
|
|
|
}
|
|
|
|
RegionTranslate(prgnSrcClip, -pSrcDrawable->x, -pSrcDrawable->y);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
BoxRec box;
|
|
|
|
|
|
|
|
if ((srcBox.x1 >= 0) && (srcBox.y1 >= 0) &&
|
|
|
|
(srcBox.x2 <= pSrcDrawable->width) &&
|
|
|
|
(srcBox.y2 <= pSrcDrawable->height))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
box.x1 = 0;
|
|
|
|
box.y1 = 0;
|
|
|
|
box.x2 = pSrcDrawable->width;
|
|
|
|
box.y2 = pSrcDrawable->height;
|
|
|
|
prgnSrcClip = &rgnSrcRec;
|
|
|
|
RegionInit(prgnSrcClip, &box, 1);
|
|
|
|
pSrcWin = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pDstDrawable == pSrcDrawable) {
|
|
|
|
prgnDstClip = prgnSrcClip;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else if (pDstDrawable->type != DRAWABLE_PIXMAP) {
|
|
|
|
if (pGC->subWindowMode == IncludeInferiors) {
|
|
|
|
prgnDstClip = NotClippedByChildren((WindowPtr) pDstDrawable);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
prgnDstClip = &rgnDstRec;
|
|
|
|
RegionNull(prgnDstClip);
|
|
|
|
RegionCopy(prgnDstClip, &((WindowPtr) pDstDrawable)->clipList);
|
|
|
|
}
|
|
|
|
RegionTranslate(prgnDstClip, -pDstDrawable->x, -pDstDrawable->y);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
BoxRec box;
|
|
|
|
|
|
|
|
box.x1 = 0;
|
|
|
|
box.y1 = 0;
|
|
|
|
box.x2 = pDstDrawable->width;
|
|
|
|
box.y2 = pDstDrawable->height;
|
|
|
|
prgnDstClip = &rgnDstRec;
|
|
|
|
RegionInit(prgnDstClip, &box, 1);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* drawable-relative source region */
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionInit(&rgnExposed, &srcBox, 1);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* now get the hidden parts of the source box */
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionSubtract(&rgnExposed, &rgnExposed, prgnSrcClip);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* move them over the destination */
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionTranslate(&rgnExposed, dstx - srcx, dsty - srcy);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* intersect with visible areas of dest */
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionIntersect(&rgnExposed, &rgnExposed, prgnDstClip);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/* intersect with client clip region. */
|
2015-09-16 13:10:19 -06:00
|
|
|
if (pGC->clientClip)
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionIntersect(&rgnExposed, &rgnExposed, pGC->clientClip);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* If we have LOTS of rectangles, we decide to take the extents
|
|
|
|
* and force an exposure on that. This should require much less
|
|
|
|
* work overall, on both client and server. This is cheating, but
|
|
|
|
* isn't prohibited by the protocol ("spontaneous combustion" :-)
|
|
|
|
* for windows.
|
|
|
|
*/
|
|
|
|
extents = pGC->graphicsExposures &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(RegionNumRects(&rgnExposed) > RECTLIMIT) &&
|
|
|
|
(pDstDrawable->type != DRAWABLE_PIXMAP);
|
|
|
|
if (pSrcWin) {
|
|
|
|
RegionPtr region;
|
|
|
|
|
|
|
|
if (!(region = wClipShape(pSrcWin)))
|
|
|
|
region = wBoundingShape(pSrcWin);
|
|
|
|
/*
|
|
|
|
* If you try to CopyArea the extents of a shaped window, compacting the
|
|
|
|
* exposed region will undo all our work!
|
|
|
|
*/
|
|
|
|
if (extents && pSrcWin && region &&
|
|
|
|
(RegionContainsRect(region, &srcBox) != rgnIN))
|
|
|
|
extents = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (extents) {
|
|
|
|
expBox = *RegionExtents(&rgnExposed);
|
|
|
|
RegionReset(&rgnExposed, &expBox);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if ((pDstDrawable->type != DRAWABLE_PIXMAP) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(((WindowPtr) pDstDrawable)->backgroundState != None)) {
|
|
|
|
WindowPtr pWin = (WindowPtr) pDstDrawable;
|
|
|
|
|
|
|
|
/* make the exposed area screen-relative */
|
|
|
|
RegionTranslate(&rgnExposed, pDstDrawable->x, pDstDrawable->y);
|
|
|
|
|
|
|
|
if (extents) {
|
2016-05-29 06:02:34 -06:00
|
|
|
/* PaintWindow doesn't clip, so we have to */
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionIntersect(&rgnExposed, &rgnExposed, &pWin->clipList);
|
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
pDstDrawable->pScreen->PaintWindow((WindowPtr) pDstDrawable,
|
|
|
|
&rgnExposed, PW_BACKGROUND);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (extents) {
|
|
|
|
RegionReset(&rgnExposed, &expBox);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
RegionTranslate(&rgnExposed, -pDstDrawable->x, -pDstDrawable->y);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (prgnDstClip == &rgnDstRec) {
|
|
|
|
RegionUninit(prgnDstClip);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else if (prgnDstClip != prgnSrcClip) {
|
|
|
|
RegionDestroy(prgnDstClip);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (prgnSrcClip == &rgnSrcRec) {
|
|
|
|
RegionUninit(prgnSrcClip);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
RegionDestroy(prgnSrcClip);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pGC->graphicsExposures) {
|
|
|
|
/* don't look */
|
|
|
|
RegionPtr exposed = RegionCreate(NullBox, 0);
|
|
|
|
|
|
|
|
*exposed = rgnExposed;
|
|
|
|
return exposed;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
RegionUninit(&rgnExposed);
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
miSendExposures(WindowPtr pWin, RegionPtr pRgn, int dx, int dy)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
BoxPtr pBox;
|
2006-11-26 11:13:41 -07:00
|
|
|
int numRects;
|
2007-11-24 10:55:21 -07:00
|
|
|
xEvent *pEvent, *pe;
|
|
|
|
int i;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
pBox = RegionRects(pRgn);
|
|
|
|
numRects = RegionNumRects(pRgn);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pEvent = calloc(1, numRects * sizeof(xEvent))))
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = numRects, pe = pEvent; --i >= 0; pe++, pBox++) {
|
|
|
|
pe->u.u.type = Expose;
|
|
|
|
pe->u.expose.window = pWin->drawable.id;
|
|
|
|
pe->u.expose.x = pBox->x1 - dx;
|
|
|
|
pe->u.expose.y = pBox->y1 - dy;
|
|
|
|
pe->u.expose.width = pBox->x2 - pBox->x1;
|
|
|
|
pe->u.expose.height = pBox->y2 - pBox->y1;
|
|
|
|
pe->u.expose.count = i;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!noPanoramiXExtension) {
|
|
|
|
int scrnum = pWin->drawable.pScreen->myNum;
|
|
|
|
int x = 0, y = 0;
|
|
|
|
XID realWin = 0;
|
|
|
|
|
|
|
|
if (!pWin->parent) {
|
|
|
|
x = screenInfo.screens[scrnum]->x;
|
|
|
|
y = screenInfo.screens[scrnum]->y;
|
|
|
|
pWin = screenInfo.screens[0]->root;
|
|
|
|
realWin = pWin->drawable.id;
|
|
|
|
}
|
|
|
|
else if (scrnum) {
|
|
|
|
PanoramiXRes *win;
|
|
|
|
|
|
|
|
win = PanoramiXFindIDByScrnum(XRT_WINDOW,
|
|
|
|
pWin->drawable.id, scrnum);
|
|
|
|
if (!win) {
|
|
|
|
free(pEvent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
realWin = win->info[0].id;
|
|
|
|
dixLookupWindow(&pWin, realWin, serverClient, DixSendAccess);
|
|
|
|
}
|
|
|
|
if (x || y || scrnum)
|
|
|
|
for (i = 0; i < numRects; i++) {
|
|
|
|
pEvent[i].u.expose.window = realWin;
|
|
|
|
pEvent[i].u.expose.x += x;
|
|
|
|
pEvent[i].u.expose.y += y;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DeliverEvents(pWin, pEvent, numRects, NullWindow);
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pEvent);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2015-09-16 13:10:19 -06:00
|
|
|
miWindowExposures(WindowPtr pWin, RegionPtr prgn)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionPtr exposures = prgn;
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
if (prgn && !RegionNil(prgn)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionRec expRec;
|
2015-09-16 13:10:19 -06:00
|
|
|
int clientInterested =
|
2012-06-10 07:21:05 -06:00
|
|
|
(pWin->eventMask | wOtherEventMasks(pWin)) & ExposureMask;
|
2015-09-16 13:10:19 -06:00
|
|
|
if (clientInterested && (RegionNumRects(prgn) > RECTLIMIT)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
* If we have LOTS of rectangles, we decide to take the extents
|
|
|
|
* and force an exposure on that. This should require much less
|
|
|
|
* work overall, on both client and server. This is cheating, but
|
|
|
|
* isn't prohibited by the protocol ("spontaneous combustion" :-).
|
|
|
|
*/
|
2016-05-29 06:02:34 -06:00
|
|
|
BoxRec box = *RegionExtents(prgn);
|
2015-09-16 13:10:19 -06:00
|
|
|
exposures = &expRec;
|
|
|
|
RegionInit(exposures, &box, 1);
|
|
|
|
RegionReset(prgn, &box);
|
2012-06-10 07:21:05 -06:00
|
|
|
/* miPaintWindow doesn't clip, so we have to */
|
|
|
|
RegionIntersect(prgn, prgn, &pWin->clipList);
|
|
|
|
}
|
2016-05-29 06:02:34 -06:00
|
|
|
pWin->drawable.pScreen->PaintWindow(pWin, prgn, PW_BACKGROUND);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (clientInterested)
|
2012-06-10 07:21:05 -06:00
|
|
|
miSendExposures(pWin, exposures,
|
|
|
|
pWin->drawable.x, pWin->drawable.y);
|
2015-09-16 13:10:19 -06:00
|
|
|
if (exposures == &expRec)
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionUninit(exposures);
|
2015-09-16 13:10:19 -06:00
|
|
|
RegionEmpty(prgn);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
void
|
2008-11-02 08:26:08 -07:00
|
|
|
miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
2010-07-27 13:02:24 -06:00
|
|
|
ChangeGCVal gcval[6];
|
2012-06-10 07:21:05 -06:00
|
|
|
BITS32 gcmask;
|
|
|
|
GCPtr pGC;
|
|
|
|
int i;
|
|
|
|
BoxPtr pbox;
|
|
|
|
xRectangle *prect;
|
|
|
|
int numRects;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
/*
|
|
|
|
* Distance from screen to destination drawable, use this
|
|
|
|
* to adjust rendering coordinates which come in in screen space
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
int draw_x_off, draw_y_off;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
/*
|
|
|
|
* Tile offset for drawing; these need to align the tile
|
|
|
|
* to the appropriate window origin
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
int tile_x_off, tile_y_off;
|
|
|
|
PixUnion fill;
|
|
|
|
Bool solid = TRUE;
|
|
|
|
DrawablePtr drawable = &pWin->drawable;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (what == PW_BACKGROUND) {
|
|
|
|
while (pWin->backgroundState == ParentRelative)
|
|
|
|
pWin = pWin->parent;
|
|
|
|
|
|
|
|
draw_x_off = drawable->x;
|
|
|
|
draw_y_off = drawable->y;
|
|
|
|
|
|
|
|
tile_x_off = pWin->drawable.x - draw_x_off;
|
|
|
|
tile_y_off = pWin->drawable.y - draw_y_off;
|
|
|
|
fill = pWin->background;
|
2011-11-05 07:32:40 -06:00
|
|
|
#ifdef COMPOSITE
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWin->inhibitBGPaint)
|
|
|
|
return;
|
2011-11-05 07:32:40 -06:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (pWin->backgroundState) {
|
|
|
|
case None:
|
|
|
|
return;
|
|
|
|
case BackgroundPixmap:
|
|
|
|
solid = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
PixmapPtr pixmap;
|
|
|
|
|
2015-11-07 09:48:51 -07:00
|
|
|
fill = pWin->border;
|
|
|
|
solid = pWin->borderIsPixel;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
/* servers without pixmaps draw their own borders */
|
|
|
|
if (!pScreen->GetWindowPixmap)
|
|
|
|
return;
|
|
|
|
pixmap = (*pScreen->GetWindowPixmap) ((WindowPtr) drawable);
|
|
|
|
drawable = &pixmap->drawable;
|
2015-11-07 09:48:51 -07:00
|
|
|
|
|
|
|
while (pWin->backgroundState == ParentRelative)
|
|
|
|
pWin = pWin->parent;
|
|
|
|
|
|
|
|
tile_x_off = pWin->drawable.x;
|
|
|
|
tile_y_off = pWin->drawable.y;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
#ifdef COMPOSITE
|
2012-06-10 07:21:05 -06:00
|
|
|
draw_x_off = pixmap->screen_x;
|
|
|
|
draw_y_off = pixmap->screen_y;
|
|
|
|
tile_x_off -= draw_x_off;
|
|
|
|
tile_y_off -= draw_y_off;
|
2008-11-02 08:26:08 -07:00
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
draw_x_off = 0;
|
|
|
|
draw_y_off = 0;
|
2008-11-02 08:26:08 -07:00
|
|
|
#endif
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
gcval[0].val = GXcopy;
|
|
|
|
gcmask = GCFunction;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
#ifdef ROOTLESS_SAFEALPHA
|
|
|
|
/* Bit mask for alpha channel with a particular number of bits per
|
|
|
|
* pixel. Note that we only care for 32bpp data. Mac OS X uses planar
|
|
|
|
* alpha for 16bpp.
|
|
|
|
*/
|
|
|
|
#define RootlessAlphaMask(bpp) ((bpp) == 32 ? 0xFF000000 : 0)
|
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (solid) {
|
2010-07-27 13:02:24 -06:00
|
|
|
#ifdef ROOTLESS_SAFEALPHA
|
2012-06-10 07:21:05 -06:00
|
|
|
gcval[1].val =
|
|
|
|
fill.pixel | RootlessAlphaMask(pWin->drawable.bitsPerPixel);
|
2010-07-27 13:02:24 -06:00
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
gcval[1].val = fill.pixel;
|
2010-07-27 13:02:24 -06:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
gcval[2].val = FillSolid;
|
|
|
|
gcmask |= GCForeground | GCFillStyle;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
int c = 1;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
#ifdef ROOTLESS_SAFEALPHA
|
2012-06-10 07:21:05 -06:00
|
|
|
gcval[c++].val =
|
|
|
|
((CARD32) -1) & ~RootlessAlphaMask(pWin->drawable.bitsPerPixel);
|
|
|
|
gcmask |= GCPlaneMask;
|
2010-07-27 13:02:24 -06:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
gcval[c++].val = FillTiled;
|
2014-09-27 11:52:59 -06:00
|
|
|
gcval[c++].ptr = (void *) fill.pixmap;
|
2012-06-10 07:21:05 -06:00
|
|
|
gcval[c++].val = tile_x_off;
|
|
|
|
gcval[c++].val = tile_y_off;
|
|
|
|
gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
prect = xallocarray(RegionNumRects(prgn), sizeof(xRectangle));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!prect)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pGC = GetScratchGC(drawable->depth, drawable->pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pGC) {
|
|
|
|
free(prect);
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
ChangeGC(NullClient, pGC, gcmask, gcval);
|
|
|
|
ValidateGC(drawable, pGC);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
numRects = RegionNumRects(prgn);
|
|
|
|
pbox = RegionRects(prgn);
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = numRects; --i >= 0; pbox++, prect++) {
|
|
|
|
prect->x = pbox->x1 - draw_x_off;
|
|
|
|
prect->y = pbox->y1 - draw_y_off;
|
|
|
|
prect->width = pbox->x2 - pbox->x1;
|
|
|
|
prect->height = pbox->y2 - pbox->y1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
prect -= numRects;
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pGC->ops->PolyFillRect) (drawable, pGC, numRects, prect);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(prect);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
FreeScratchGC(pGC);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* MICLEARDRAWABLE -- sets the entire drawable to the background color of
|
2015-09-16 13:10:19 -06:00
|
|
|
* the GC. Useful when we have a scratch drawable and need to initialize
|
2006-11-26 11:13:41 -07:00
|
|
|
* it. */
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2009-09-06 13:44:18 -06:00
|
|
|
miClearDrawable(DrawablePtr pDraw, GCPtr pGC)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
ChangeGCVal fg, bg;
|
2006-11-26 11:13:41 -07:00
|
|
|
xRectangle rect;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
fg.val = pGC->fgPixel;
|
|
|
|
bg.val = pGC->bgPixel;
|
2006-11-26 11:13:41 -07:00
|
|
|
rect.x = 0;
|
|
|
|
rect.y = 0;
|
|
|
|
rect.width = pDraw->width;
|
|
|
|
rect.height = pDraw->height;
|
2010-12-05 08:36:02 -07:00
|
|
|
ChangeGC(NullClient, pGC, GCForeground, &bg);
|
2006-11-26 11:13:41 -07:00
|
|
|
ValidateGC(pDraw, pGC);
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pGC->ops->PolyFillRect) (pDraw, pGC, 1, &rect);
|
2010-12-05 08:36:02 -07:00
|
|
|
ChangeGC(NullClient, pGC, GCForeground, &fg);
|
2006-11-26 11:13:41 -07:00
|
|
|
ValidateGC(pDraw, pGC);
|
|
|
|
}
|