diff options
author | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
commit | 0f834b91a4768673833ab4917e87d86c237bb1a6 (patch) | |
tree | 363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/damageext | |
parent | fc72edebf875378459368c5383d9023730cbca54 (diff) | |
download | vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2 vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip |
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/damageext')
-rw-r--r-- | xorg-server/damageext/damageext.c | 424 |
1 files changed, 204 insertions, 220 deletions
diff --git a/xorg-server/damageext/damageext.c b/xorg-server/damageext/damageext.c index 86f880c1e..f21f71ca8 100644 --- a/xorg-server/damageext/damageext.c +++ b/xorg-server/damageext/damageext.c @@ -27,24 +27,25 @@ #include "damageextint.h" #include "protocol-versions.h" -static unsigned char DamageReqCode; -static int DamageEventBase; -static RESTYPE DamageExtType; -static RESTYPE DamageExtWinType; +static unsigned char DamageReqCode; +static int DamageEventBase; +static RESTYPE DamageExtType; +static RESTYPE DamageExtWinType; static DevPrivateKeyRec DamageClientPrivateKeyRec; + #define DamageClientPrivateKey (&DamageClientPrivateKeyRec) static void -DamageExtNotify (DamageExtPtr pDamageExt, BoxPtr pBoxes, int nBoxes) +DamageExtNotify(DamageExtPtr pDamageExt, BoxPtr pBoxes, int nBoxes) { - ClientPtr pClient = pDamageExt->pClient; - DamageClientPtr pDamageClient = GetDamageClient (pClient); - DrawablePtr pDrawable = pDamageExt->pDrawable; - xDamageNotifyEvent ev; - int i; + ClientPtr pClient = pDamageExt->pClient; + DamageClientPtr pDamageClient = GetDamageClient(pClient); + DrawablePtr pDrawable = pDamageExt->pDrawable; + xDamageNotifyEvent ev; + int i; - UpdateCurrentTimeIf (); + UpdateCurrentTimeIf(); ev.type = DamageEventBase + XDamageNotify; ev.level = pDamageExt->level; ev.drawable = pDamageExt->drawable; @@ -54,81 +55,79 @@ DamageExtNotify (DamageExtPtr pDamageExt, BoxPtr pBoxes, int nBoxes) ev.geometry.y = pDrawable->y; ev.geometry.width = pDrawable->width; ev.geometry.height = pDrawable->height; - if (pBoxes) - { - for (i = 0; i < nBoxes; i++) - { - ev.level = pDamageExt->level; - if (i < nBoxes - 1) - ev.level |= DamageNotifyMore; - ev.area.x = pBoxes[i].x1; - ev.area.y = pBoxes[i].y1; - ev.area.width = pBoxes[i].x2 - pBoxes[i].x1; - ev.area.height = pBoxes[i].y2 - pBoxes[i].y1; - WriteEventsToClient (pClient, 1, (xEvent *) &ev); - } + if (pBoxes) { + for (i = 0; i < nBoxes; i++) { + ev.level = pDamageExt->level; + if (i < nBoxes - 1) + ev.level |= DamageNotifyMore; + ev.area.x = pBoxes[i].x1; + ev.area.y = pBoxes[i].y1; + ev.area.width = pBoxes[i].x2 - pBoxes[i].x1; + ev.area.height = pBoxes[i].y2 - pBoxes[i].y1; + WriteEventsToClient(pClient, 1, (xEvent *) &ev); + } } - else - { - ev.area.x = 0; - ev.area.y = 0; - ev.area.width = pDrawable->width; - ev.area.height = pDrawable->height; - WriteEventsToClient (pClient, 1, (xEvent *) &ev); + else { + ev.area.x = 0; + ev.area.y = 0; + ev.area.width = pDrawable->width; + ev.area.height = pDrawable->height; + WriteEventsToClient(pClient, 1, (xEvent *) &ev); } /* Composite extension marks clients with manual Subwindows as critical */ - if (pDamageClient->critical > 0) - { - SetCriticalOutputPending (); - pClient->smart_priority = SMART_MAX_PRIORITY; + if (pDamageClient->critical > 0) { + SetCriticalOutputPending(); + pClient->smart_priority = SMART_MAX_PRIORITY; } } static void -DamageExtReport (DamagePtr pDamage, RegionPtr pRegion, void *closure) +DamageExtReport(DamagePtr pDamage, RegionPtr pRegion, void *closure) { - DamageExtPtr pDamageExt = closure; + DamageExtPtr pDamageExt = closure; switch (pDamageExt->level) { case DamageReportRawRegion: case DamageReportDeltaRegion: - DamageExtNotify (pDamageExt, RegionRects(pRegion), RegionNumRects(pRegion)); - break; + DamageExtNotify(pDamageExt, RegionRects(pRegion), + RegionNumRects(pRegion)); + break; case DamageReportBoundingBox: - DamageExtNotify (pDamageExt, RegionExtents(pRegion), 1); - break; + DamageExtNotify(pDamageExt, RegionExtents(pRegion), 1); + break; case DamageReportNonEmpty: - DamageExtNotify (pDamageExt, NullBox, 0); - break; + DamageExtNotify(pDamageExt, NullBox, 0); + break; case DamageReportNone: - break; + break; } } static void -DamageExtDestroy (DamagePtr pDamage, void *closure) +DamageExtDestroy(DamagePtr pDamage, void *closure) { - DamageExtPtr pDamageExt = closure; - + DamageExtPtr pDamageExt = closure; + pDamageExt->pDamage = 0; if (pDamageExt->id) - FreeResource (pDamageExt->id, RT_NONE); + FreeResource(pDamageExt->id, RT_NONE); } void -DamageExtSetCritical (ClientPtr pClient, Bool critical) +DamageExtSetCritical(ClientPtr pClient, Bool critical) { - DamageClientPtr pDamageClient = GetDamageClient (pClient); + DamageClientPtr pDamageClient = GetDamageClient(pClient); if (pDamageClient) - pDamageClient->critical += critical ? 1 : -1; + pDamageClient->critical += critical ? 1 : -1; } static int ProcDamageQueryVersion(ClientPtr client) { - DamageClientPtr pDamageClient = GetDamageClient (client); + DamageClientPtr pDamageClient = GetDamageClient(client); xDamageQueryVersionReply rep; + REQUEST(xDamageQueryVersionReq); REQUEST_SIZE_MATCH(xDamageQueryVersionReq); @@ -136,157 +135,153 @@ ProcDamageQueryVersion(ClientPtr client) rep.length = 0; rep.sequenceNumber = client->sequence; if (stuff->majorVersion < SERVER_DAMAGE_MAJOR_VERSION) { - rep.majorVersion = stuff->majorVersion; - rep.minorVersion = stuff->minorVersion; - } else { - rep.majorVersion = SERVER_DAMAGE_MAJOR_VERSION; - if (stuff->majorVersion == SERVER_DAMAGE_MAJOR_VERSION && - stuff->minorVersion < SERVER_DAMAGE_MINOR_VERSION) - rep.minorVersion = stuff->minorVersion; - else - rep.minorVersion = SERVER_DAMAGE_MINOR_VERSION; + rep.majorVersion = stuff->majorVersion; + rep.minorVersion = stuff->minorVersion; + } + else { + rep.majorVersion = SERVER_DAMAGE_MAJOR_VERSION; + if (stuff->majorVersion == SERVER_DAMAGE_MAJOR_VERSION && + stuff->minorVersion < SERVER_DAMAGE_MINOR_VERSION) + rep.minorVersion = stuff->minorVersion; + else + rep.minorVersion = SERVER_DAMAGE_MINOR_VERSION; } pDamageClient->major_version = rep.majorVersion; pDamageClient->minor_version = rep.minorVersion; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.majorVersion); - swapl(&rep.minorVersion); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.majorVersion); + swapl(&rep.minorVersion); } - WriteToClient(client, sizeof(xDamageQueryVersionReply), (char *)&rep); + WriteToClient(client, sizeof(xDamageQueryVersionReply), (char *) &rep); return Success; } static int -ProcDamageCreate (ClientPtr client) +ProcDamageCreate(ClientPtr client) { - DrawablePtr pDrawable; - DamageExtPtr pDamageExt; - DamageReportLevel level; - RegionPtr pRegion; - int rc; - + DrawablePtr pDrawable; + DamageExtPtr pDamageExt; + DamageReportLevel level; + RegionPtr pRegion; + int rc; + REQUEST(xDamageCreateReq); REQUEST_SIZE_MATCH(xDamageCreateReq); LEGAL_NEW_RESOURCE(stuff->damage, client); rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, - DixGetAttrAccess|DixReadAccess); + DixGetAttrAccess | DixReadAccess); if (rc != Success) - return rc; + return rc; switch (stuff->level) { case XDamageReportRawRectangles: - level = DamageReportRawRegion; - break; + level = DamageReportRawRegion; + break; case XDamageReportDeltaRectangles: - level = DamageReportDeltaRegion; - break; + level = DamageReportDeltaRegion; + break; case XDamageReportBoundingBox: - level = DamageReportBoundingBox; - break; + level = DamageReportBoundingBox; + break; case XDamageReportNonEmpty: - level = DamageReportNonEmpty; - break; + level = DamageReportNonEmpty; + break; default: - client->errorValue = stuff->level; - return BadValue; + client->errorValue = stuff->level; + return BadValue; } - - pDamageExt = malloc(sizeof (DamageExtRec)); + + pDamageExt = malloc(sizeof(DamageExtRec)); if (!pDamageExt) - return BadAlloc; + return BadAlloc; pDamageExt->id = stuff->damage; pDamageExt->drawable = stuff->drawable; pDamageExt->pDrawable = pDrawable; pDamageExt->level = level; pDamageExt->pClient = client; - pDamageExt->pDamage = DamageCreate (DamageExtReport, - DamageExtDestroy, - level, - FALSE, - pDrawable->pScreen, - pDamageExt); - if (!pDamageExt->pDamage) - { - free(pDamageExt); - return BadAlloc; + pDamageExt->pDamage = DamageCreate(DamageExtReport, + DamageExtDestroy, + level, + FALSE, pDrawable->pScreen, pDamageExt); + if (!pDamageExt->pDamage) { + free(pDamageExt); + return BadAlloc; } - if (!AddResource (stuff->damage, DamageExtType, (pointer) pDamageExt)) - return BadAlloc; + if (!AddResource(stuff->damage, DamageExtType, (pointer) pDamageExt)) + return BadAlloc; - DamageSetReportAfterOp (pDamageExt->pDamage, TRUE); - DamageRegister (pDamageExt->pDrawable, pDamageExt->pDamage); + DamageSetReportAfterOp(pDamageExt->pDamage, TRUE); + DamageRegister(pDamageExt->pDrawable, pDamageExt->pDamage); - if (pDrawable->type == DRAWABLE_WINDOW) - { - pRegion = &((WindowPtr) pDrawable)->borderClip; - DamageReportDamage(pDamageExt->pDamage, pRegion); + if (pDrawable->type == DRAWABLE_WINDOW) { + pRegion = &((WindowPtr) pDrawable)->borderClip; + DamageReportDamage(pDamageExt->pDamage, pRegion); } return Success; } static int -ProcDamageDestroy (ClientPtr client) +ProcDamageDestroy(ClientPtr client) { REQUEST(xDamageDestroyReq); - DamageExtPtr pDamageExt; + DamageExtPtr pDamageExt; REQUEST_SIZE_MATCH(xDamageDestroyReq); VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, DixWriteAccess); - FreeResource (stuff->damage, RT_NONE); + FreeResource(stuff->damage, RT_NONE); return Success; } static int -ProcDamageSubtract (ClientPtr client) +ProcDamageSubtract(ClientPtr client) { REQUEST(xDamageSubtractReq); - DamageExtPtr pDamageExt; - RegionPtr pRepair; - RegionPtr pParts; + DamageExtPtr pDamageExt; + RegionPtr pRepair; + RegionPtr pParts; REQUEST_SIZE_MATCH(xDamageSubtractReq); VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, DixWriteAccess); VERIFY_REGION_OR_NONE(pRepair, stuff->repair, client, DixWriteAccess); VERIFY_REGION_OR_NONE(pParts, stuff->parts, client, DixWriteAccess); - if (pDamageExt->level != DamageReportRawRegion) - { - DamagePtr pDamage = pDamageExt->pDamage; - if (pRepair) - { - if (pParts) - RegionIntersect(pParts, DamageRegion (pDamage), pRepair); - if (DamageSubtract (pDamage, pRepair)) - DamageExtReport (pDamage, DamageRegion (pDamage), (void *) pDamageExt); - } - else - { - if (pParts) - RegionCopy(pParts, DamageRegion (pDamage)); - DamageEmpty (pDamage); - } + if (pDamageExt->level != DamageReportRawRegion) { + DamagePtr pDamage = pDamageExt->pDamage; + + if (pRepair) { + if (pParts) + RegionIntersect(pParts, DamageRegion(pDamage), pRepair); + if (DamageSubtract(pDamage, pRepair)) + DamageExtReport(pDamage, DamageRegion(pDamage), + (void *) pDamageExt); + } + else { + if (pParts) + RegionCopy(pParts, DamageRegion(pDamage)); + DamageEmpty(pDamage); + } } return Success; } static int -ProcDamageAdd (ClientPtr client) +ProcDamageAdd(ClientPtr client) { REQUEST(xDamageAddReq); - DrawablePtr pDrawable; - RegionPtr pRegion; - int rc; + DrawablePtr pDrawable; + RegionPtr pRegion; + int rc; REQUEST_SIZE_MATCH(xDamageAddReq); VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess); rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, - DixWriteAccess); + DixWriteAccess); if (rc != Success) - return rc; + return rc; /* The region is relative to the drawable origin, so translate it out to * screen coordinates like damage expects. @@ -300,33 +295,29 @@ ProcDamageAdd (ClientPtr client) /* Major version controls available requests */ static const int version_requests[] = { - X_DamageQueryVersion, /* before client sends QueryVersion */ - X_DamageAdd, /* Version 1 */ + X_DamageQueryVersion, /* before client sends QueryVersion */ + X_DamageAdd, /* Version 1 */ }; #define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0])) - -static int (*ProcDamageVector[XDamageNumberRequests])(ClientPtr) = { + +static int (*ProcDamageVector[XDamageNumberRequests]) (ClientPtr) = { /*************** Version 1 ******************/ ProcDamageQueryVersion, - ProcDamageCreate, - ProcDamageDestroy, - ProcDamageSubtract, + ProcDamageCreate, ProcDamageDestroy, ProcDamageSubtract, /*************** Version 1.1 ****************/ - ProcDamageAdd, -}; - +ProcDamageAdd,}; static int -ProcDamageDispatch (ClientPtr client) +ProcDamageDispatch(ClientPtr client) { REQUEST(xDamageReq); - DamageClientPtr pDamageClient = GetDamageClient (client); + DamageClientPtr pDamageClient = GetDamageClient(client); if (pDamageClient->major_version >= NUM_VERSION_REQUESTS) - return BadRequest; + return BadRequest; if (stuff->damageReqType > version_requests[pDamageClient->major_version]) - return BadRequest; + return BadRequest; return (*ProcDamageVector[stuff->damageReqType]) (client); } @@ -343,10 +334,10 @@ SProcDamageQueryVersion(ClientPtr client) } static int -SProcDamageCreate (ClientPtr client) +SProcDamageCreate(ClientPtr client) { REQUEST(xDamageCreateReq); - + swaps(&stuff->length); REQUEST_SIZE_MATCH(xDamageCreateReq); swapl(&stuff->damage); @@ -355,10 +346,10 @@ SProcDamageCreate (ClientPtr client) } static int -SProcDamageDestroy (ClientPtr client) +SProcDamageDestroy(ClientPtr client) { REQUEST(xDamageDestroyReq); - + swaps(&stuff->length); REQUEST_SIZE_MATCH(xDamageDestroyReq); swapl(&stuff->damage); @@ -366,10 +357,10 @@ SProcDamageDestroy (ClientPtr client) } static int -SProcDamageSubtract (ClientPtr client) +SProcDamageSubtract(ClientPtr client) { REQUEST(xDamageSubtractReq); - + swaps(&stuff->length); REQUEST_SIZE_MATCH(xDamageSubtractReq); swapl(&stuff->damage); @@ -379,7 +370,7 @@ SProcDamageSubtract (ClientPtr client) } static int -SProcDamageAdd (ClientPtr client) +SProcDamageAdd(ClientPtr client) { REQUEST(xDamageAddReq); @@ -390,126 +381,119 @@ SProcDamageAdd (ClientPtr client) return (*ProcDamageVector[stuff->damageReqType]) (client); } -static int (*SProcDamageVector[XDamageNumberRequests])(ClientPtr) = { +static int (*SProcDamageVector[XDamageNumberRequests]) (ClientPtr) = { /*************** Version 1 ******************/ SProcDamageQueryVersion, - SProcDamageCreate, - SProcDamageDestroy, - SProcDamageSubtract, + SProcDamageCreate, SProcDamageDestroy, SProcDamageSubtract, /*************** Version 1.1 ****************/ - SProcDamageAdd, -}; +SProcDamageAdd,}; static int -SProcDamageDispatch (ClientPtr client) +SProcDamageDispatch(ClientPtr client) { REQUEST(xDamageReq); if (stuff->damageReqType >= XDamageNumberRequests) - return BadRequest; + return BadRequest; return (*SProcDamageVector[stuff->damageReqType]) (client); } static void -DamageClientCallback (CallbackListPtr *list, - pointer closure, - pointer data) +DamageClientCallback(CallbackListPtr *list, pointer closure, pointer data) { - NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; - ClientPtr pClient = clientinfo->client; - DamageClientPtr pDamageClient = GetDamageClient (pClient); + NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; + ClientPtr pClient = clientinfo->client; + DamageClientPtr pDamageClient = GetDamageClient(pClient); pDamageClient->critical = 0; pDamageClient->major_version = 0; pDamageClient->minor_version = 0; } -/*ARGSUSED*/ -static void -DamageResetProc (ExtensionEntry *extEntry) + /*ARGSUSED*/ static void +DamageResetProc(ExtensionEntry * extEntry) { - DeleteCallback (&ClientStateCallback, DamageClientCallback, 0); + DeleteCallback(&ClientStateCallback, DamageClientCallback, 0); } static int -FreeDamageExt (pointer value, XID did) +FreeDamageExt(pointer value, XID did) { - DamageExtPtr pDamageExt = (DamageExtPtr) value; + DamageExtPtr pDamageExt = (DamageExtPtr) value; /* * Get rid of the resource table entry hanging from the window id */ pDamageExt->id = 0; if (WindowDrawable(pDamageExt->pDrawable->type)) - FreeResourceByType (pDamageExt->pDrawable->id, DamageExtWinType, TRUE); - if (pDamageExt->pDamage) - { - DamageUnregister (pDamageExt->pDrawable, pDamageExt->pDamage); - DamageDestroy (pDamageExt->pDamage); + FreeResourceByType(pDamageExt->pDrawable->id, DamageExtWinType, TRUE); + if (pDamageExt->pDamage) { + DamageUnregister(pDamageExt->pDrawable, pDamageExt->pDamage); + DamageDestroy(pDamageExt->pDamage); } free(pDamageExt); return Success; } static int -FreeDamageExtWin (pointer value, XID wid) +FreeDamageExtWin(pointer value, XID wid) { - DamageExtPtr pDamageExt = (DamageExtPtr) value; + DamageExtPtr pDamageExt = (DamageExtPtr) value; if (pDamageExt->id) - FreeResource (pDamageExt->id, RT_NONE); + FreeResource(pDamageExt->id, RT_NONE); return Success; } static void -SDamageNotifyEvent (xDamageNotifyEvent *from, - xDamageNotifyEvent *to) +SDamageNotifyEvent(xDamageNotifyEvent * from, xDamageNotifyEvent * to) { to->type = from->type; - cpswaps (from->sequenceNumber, to->sequenceNumber); - cpswapl (from->drawable, to->drawable); - cpswapl (from->damage, to->damage); - cpswaps (from->area.x, to->area.x); - cpswaps (from->area.y, to->area.y); - cpswaps (from->area.width, to->area.width); - cpswaps (from->area.height, to->area.height); - cpswaps (from->geometry.x, to->geometry.x); - cpswaps (from->geometry.y, to->geometry.y); - cpswaps (from->geometry.width, to->geometry.width); - cpswaps (from->geometry.height, to->geometry.height); + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->drawable, to->drawable); + cpswapl(from->damage, to->damage); + cpswaps(from->area.x, to->area.x); + cpswaps(from->area.y, to->area.y); + cpswaps(from->area.width, to->area.width); + cpswaps(from->area.height, to->area.height); + cpswaps(from->geometry.x, to->geometry.x); + cpswaps(from->geometry.y, to->geometry.y); + cpswaps(from->geometry.width, to->geometry.width); + cpswaps(from->geometry.height, to->geometry.height); } void DamageExtensionInit(void) { ExtensionEntry *extEntry; - int s; + int s; for (s = 0; s < screenInfo.numScreens; s++) - DamageSetup (screenInfo.screens[s]); + DamageSetup(screenInfo.screens[s]); - DamageExtType = CreateNewResourceType (FreeDamageExt, "DamageExt"); + DamageExtType = CreateNewResourceType(FreeDamageExt, "DamageExt"); if (!DamageExtType) - return; + return; - DamageExtWinType = CreateNewResourceType (FreeDamageExtWin, "DamageExtWin"); + DamageExtWinType = CreateNewResourceType(FreeDamageExtWin, "DamageExtWin"); if (!DamageExtWinType) - return; - - if (!dixRegisterPrivateKey(&DamageClientPrivateKeyRec, PRIVATE_CLIENT, sizeof (DamageClientRec))) - return; - - if (!AddCallback (&ClientStateCallback, DamageClientCallback, 0)) - return; - - if ((extEntry = AddExtension(DAMAGE_NAME, XDamageNumberEvents, - XDamageNumberErrors, - ProcDamageDispatch, SProcDamageDispatch, - DamageResetProc, StandardMinorOpcode)) != 0) - { - DamageReqCode = (unsigned char)extEntry->base; - DamageEventBase = extEntry->eventBase; - EventSwapVector[DamageEventBase + XDamageNotify] = - (EventSwapPtr) SDamageNotifyEvent; - SetResourceTypeErrorValue(DamageExtType, extEntry->errorBase + BadDamage); + return; + + if (!dixRegisterPrivateKey + (&DamageClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(DamageClientRec))) + return; + + if (!AddCallback(&ClientStateCallback, DamageClientCallback, 0)) + return; + + if ((extEntry = AddExtension(DAMAGE_NAME, XDamageNumberEvents, + XDamageNumberErrors, + ProcDamageDispatch, SProcDamageDispatch, + DamageResetProc, StandardMinorOpcode)) != 0) { + DamageReqCode = (unsigned char) extEntry->base; + DamageEventBase = extEntry->eventBase; + EventSwapVector[DamageEventBase + XDamageNotify] = + (EventSwapPtr) SDamageNotifyEvent; + SetResourceTypeErrorValue(DamageExtType, + extEntry->errorBase + BadDamage); } } |