Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various backports for Xserver/mi/miexpose (esp. miPaintWindow rewrite) #424

Open
wants to merge 5 commits into
base: 3.6.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions nx-X11/programs/Xserver/Xext/panoramiXprocs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,7 @@ int PanoramiXCopyArea(ClientPtr client)
}
}
RegionValidate(&totalReg, &overlap);
(*pScreen->SendGraphicsExpose)(
client, &totalReg, stuff->dstDrawable, X_CopyArea, 0);
SendGraphicsExpose(client, &totalReg, stuff->dstDrawable, X_CopyArea, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why you haven't formatted this as upstream did here and below?

RegionUninit(&totalReg);
}

Expand Down Expand Up @@ -1224,8 +1223,7 @@ int PanoramiXCopyPlane(ClientPtr client)
}
}
RegionValidate(&totalReg, &overlap);
(*pScreen->SendGraphicsExpose)(
client, &totalReg, stuff->dstDrawable, X_CopyPlane, 0);
SendGraphicsExpose(client, &totalReg, stuff->dstDrawable, X_CopyPlane, 0);
RegionUninit(&totalReg);
}

Expand Down
3 changes: 3 additions & 0 deletions nx-X11/programs/Xserver/dix/Imakefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ VENDORRELEASE = XVendorRelease

SITE_DEFINES = $(SITE_FONT_PATH) $(SITE_DISPLAY_CLASS)

XSERVER_ABI_DEFINES = -DXSERVER_OLD_TRYCLIENTEVENTS_ABI

VENDOR_DEFINES = $(VENDOR_STRING) $(VENDOR_RELEASE) $(QUARTZ_DEFINES)

NormalLibraryObjectRule()
Expand All @@ -137,6 +139,7 @@ SpecialCObjectRule(main,$(ICONFIGFILES),$(VENDOR_DEFINES))
SpecialCObjectRule(pixmap,$(ICONFIGFILES),$(_NOOP_))
SpecialCObjectRule(privates,$(ICONFIGFILES),$(_NOOP_))
SpecialCObjectRule(window,$(ICONFIGFILES),$(QUARTZ_DEFINES))
SpecialCObjectRule(dispatch,$(ICONFIGFILES),$(XSERVER_ABI_DEFINES))

NormalLibraryTarget(xpstubs,$(XPOBJ))

Expand Down
57 changes: 53 additions & 4 deletions nx-X11/programs/Xserver/dix/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,57 @@ ProcClearToBackground(register ClientPtr client)
return(client->noClientException);
}

/* send GraphicsExpose events, or a NoExpose event, based on the region */
void
SendGraphicsExpose(ClientPtr client, RegionPtr pRgn, XID drawable,
int major, int minor)
{
if (pRgn && !RegionNil(pRgn)) {
xEvent *pEvent;
xEvent *pe;
BoxPtr pBox;
int i;
int numRects;

numRects = RegionNumRects(pRgn);
pBox = RegionRects(pRgn);
if (!(pEvent = calloc(numRects, sizeof(xEvent))))
return;
pe = pEvent;

for (i = 1; i <= numRects; i++, pe++, pBox++) {
pe->u.u.type = GraphicsExpose;
pe->u.graphicsExposure.drawable = drawable;
pe->u.graphicsExposure.x = pBox->x1;
pe->u.graphicsExposure.y = pBox->y1;
pe->u.graphicsExposure.width = pBox->x2 - pBox->x1;
pe->u.graphicsExposure.height = pBox->y2 - pBox->y1;
pe->u.graphicsExposure.count = numRects - i;
pe->u.graphicsExposure.majorEvent = major;
pe->u.graphicsExposure.minorEvent = minor;
}
/* GraphicsExpose is a "critical event", which TryClientEvents
* handles specially. */
#ifndef XSERVER_OLD_TRYCLIENTEVENTS_ABI
TryClientEvents(client, NULL, pEvent, numRects,
(Mask) 0, NoEventMask, NullGrab);
#else
TryClientEvents(client, pEvent, numRects,
(Mask) 0, NoEventMask, NullGrab);
#endif /* XSERVER_OLD_TRYCLIENTEVENTS_ABI */
free(pEvent);
}
else {
xEvent event = {
.u.noExposure.drawable = drawable,
.u.noExposure.majorEvent = major,
.u.noExposure.minorEvent = minor
};
event.u.u.type = NoExpose;
WriteEventsToClient(client, 1, &event);
}
}

int
ProcCopyArea(register ClientPtr client)
{
Expand Down Expand Up @@ -1743,8 +1794,7 @@ ProcCopyArea(register ClientPtr client)
stuff->dstX, stuff->dstY);
if (pGC->graphicsExposures)
{
(*pDst->pScreen->SendGraphicsExpose)
(client, pRgn, stuff->dstDrawable, X_CopyArea, 0);
SendGraphicsExpose(client, pRgn, stuff->dstDrawable, X_CopyArea, 0);
if (pRgn)
RegionDestroy(pRgn);
}
Expand Down Expand Up @@ -1791,8 +1841,7 @@ ProcCopyPlane(register ClientPtr client)
stuff->dstX, stuff->dstY, stuff->bitPlane);
if (pGC->graphicsExposures)
{
(*pdstDraw->pScreen->SendGraphicsExpose)
(client, pRgn, stuff->dstDrawable, X_CopyPlane, 0);
SendGraphicsExpose(client, pRgn, stuff->dstDrawable, X_CopyPlane, 0);
if (pRgn)
RegionDestroy(pRgn);
}
Expand Down
1 change: 1 addition & 0 deletions nx-X11/programs/Xserver/hw/nxagent/Imakefile
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ DEFINES = \
-DRANDR_15_INTERFACE=1 \
-DPANORAMIX \
-UDEBUG_TREE \
-DXSERVER_OLD_TRYCLIENTEVENTS_ABI \
$(NULL)

all:: $(OBJS)
Expand Down
265 changes: 0 additions & 265 deletions nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,268 +476,3 @@ miWindowExposures(pWin, prgn, other_exposed)
else if (exposures && exposures != prgn)
RegionDestroy(exposures);
}

void
miPaintWindow(pWin, prgn, what)
register WindowPtr pWin;
RegionPtr prgn;
int what;
{
int status;

Bool usingScratchGC = FALSE;
WindowPtr pRoot;

#define FUNCTION 0
#define FOREGROUND 1
#define TILE 2
#define FILLSTYLE 3
#define ABSX 4
#define ABSY 5
#define CLIPMASK 6
#define SUBWINDOW 7
#define COUNT_BITS 8

ChangeGCVal gcval[7];
ChangeGCVal newValues [COUNT_BITS] = {{ 0 }};

BITS32 gcmask, index, mask;
RegionRec prgnWin;
DDXPointRec oldCorner;
BoxRec box;
WindowPtr pBgWin;
GCPtr pGC;
register int i;
register BoxPtr pbox;
register ScreenPtr pScreen = pWin->drawable.pScreen;
register xRectangle *prect;
int numRects;

/*
* Set the elements reported by the compiler
* as uninitialized.
*/

prgnWin.extents.x1 = 0;
prgnWin.extents.y1 = 0;
prgnWin.extents.x2 = 0;
prgnWin.extents.y2 = 0;

prgnWin.data = NULL;

oldCorner.x = 0;
oldCorner.y = 0;

gcmask = 0;

if (what == PW_BACKGROUND)
{
switch (pWin->backgroundState) {
case None:
return;
case ParentRelative:
(*pWin->parent->drawable.pScreen->PaintWindowBackground)(pWin->parent, prgn, what);
return;
case BackgroundPixel:
newValues[FOREGROUND].val = pWin->background.pixel;
newValues[FILLSTYLE].val = FillSolid;
gcmask |= GCForeground | GCFillStyle;
break;
case BackgroundPixmap:
newValues[TILE].ptr = (void *)pWin->background.pixmap;
newValues[FILLSTYLE].val = FillTiled;
gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
break;
}
}
else
{
if (pWin->borderIsPixel)
{
newValues[FOREGROUND].val = pWin->border.pixel;
newValues[FILLSTYLE].val = FillSolid;
gcmask |= GCForeground | GCFillStyle;
}
else
{
newValues[TILE].ptr = (void *)pWin->border.pixmap;
newValues[FILLSTYLE].val = FillTiled;
gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
}
}

prect = (xRectangle *)malloc(RegionNumRects(prgn) *
sizeof(xRectangle));
if (!prect)
return;

newValues[FUNCTION].val = GXcopy;
gcmask |= GCFunction | GCClipMask;

i = pScreen->myNum;
pRoot = screenInfo.screens[i]->root;

pBgWin = pWin;
if (what == PW_BORDER)
{
while (pBgWin->backgroundState == ParentRelative)
pBgWin = pBgWin->parent;
}

if ((pWin->drawable.depth != pRoot->drawable.depth) ||
(pWin->drawable.bitsPerPixel != pRoot->drawable.bitsPerPixel))
{
usingScratchGC = TRUE;
pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
if (!pGC)
{
free(prect);
return;
}
/*
* mash the clip list so we can paint the border by
* mangling the window in place, pretending it
* spans the entire screen
*/
if (what == PW_BORDER)
{
prgnWin = pWin->clipList;
oldCorner.x = pWin->drawable.x;
oldCorner.y = pWin->drawable.y;
pWin->drawable.x = pWin->drawable.y = 0;
box.x1 = 0;
box.y1 = 0;
box.x2 = pScreen->width;
box.y2 = pScreen->height;
RegionInit(&pWin->clipList, &box, 1);
pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
newValues[ABSX].val = pBgWin->drawable.x;
newValues[ABSY].val = pBgWin->drawable.y;
}
else
{
newValues[ABSX].val = 0;
newValues[ABSY].val = 0;
}
} else {
/*
* draw the background to the root window
*/
if (screenContext[i] == (GCPtr)NULL)
{
if (!ResType && !(ResType = CreateNewResourceType(tossGC)))
return;
screenContext[i] = CreateGC((DrawablePtr)pWin, (BITS32) 0,
(XID *)NULL, &status);
if (!screenContext[i])
return;
numGCs++;
if (!AddResource(FakeClientID(0), ResType,
(void *)screenContext[i]))
return;
}
pGC = screenContext[i];
newValues[SUBWINDOW].val = IncludeInferiors;
newValues[ABSX].val = pBgWin->drawable.x;
newValues[ABSY].val = pBgWin->drawable.y;
gcmask |= GCSubwindowMode;
pWin = pRoot;
}

if (pWin->backStorage)
(*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack);

mask = gcmask;
gcmask = 0;
i = 0;
while (mask) {
index = lowbit (mask);
mask &= ~index;
switch (index) {
case GCFunction:
if (pGC->alu != newValues[FUNCTION].val) {
gcmask |= index;
gcval[i++].val = newValues[FUNCTION].val;
}
break;
case GCTileStipXOrigin:
if ( pGC->patOrg.x != newValues[ABSX].val) {
gcmask |= index;
gcval[i++].val = newValues[ABSX].val;
}
break;
case GCTileStipYOrigin:
if ( pGC->patOrg.y != newValues[ABSY].val) {
gcmask |= index;
gcval[i++].val = newValues[ABSY].val;
}
break;
case GCClipMask:
if ( pGC->clientClipType != CT_NONE) {
gcmask |= index;
gcval[i++].val = CT_NONE;
}
break;
case GCSubwindowMode:
if ( pGC->subWindowMode != newValues[SUBWINDOW].val) {
gcmask |= index;
gcval[i++].val = newValues[SUBWINDOW].val;
}
break;
case GCTile:
if (pGC->tileIsPixel || pGC->tile.pixmap != newValues[TILE].ptr)
{
gcmask |= index;
gcval[i++].ptr = newValues[TILE].ptr;
}
break;
case GCFillStyle:
if ( pGC->fillStyle != newValues[FILLSTYLE].val) {
gcmask |= index;
gcval[i++].val = newValues[FILLSTYLE].val;
}
break;
case GCForeground:
if ( pGC->fgPixel != newValues[FOREGROUND].val) {
gcmask |= index;
gcval[i++].val = newValues[FOREGROUND].val;
}
break;
}
}

if (gcmask)
dixChangeGC(NullClient, pGC, gcmask, NULL, gcval);

if (pWin->drawable.serialNumber != pGC->serialNumber)
ValidateGC((DrawablePtr)pWin, pGC);

numRects = RegionNumRects(prgn);
pbox = RegionRects(prgn);
for (i= numRects; --i >= 0; pbox++, prect++)
{
prect->x = pbox->x1 - pWin->drawable.x;
prect->y = pbox->y1 - pWin->drawable.y;
prect->width = pbox->x2 - pbox->x1;
prect->height = pbox->y2 - pbox->y1;
}
prect -= numRects;
(*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
free(prect);

if (pWin->backStorage)
(*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing);

if (usingScratchGC)
{
if (what == PW_BORDER)
{
RegionUninit(&pWin->clipList);
pWin->clipList = prgnWin;
pWin->drawable.x = oldCorner.x;
pWin->drawable.y = oldCorner.y;
pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
}
FreeScratchGC(pGC);
}
}
Loading