[PATCH xserver] Remove *Clip funcs from GCFuncs
Keith Packard
keithp at keithp.com
Tue Mar 7 23:26:46 UTC 2017
Nearly every server uses the mi versions of these; allowing them to be
replaced and wrapped is a waste of code and time.
Xnest and Xdmx required a bit of special handling as they were using
the ChangeClip function to send the updated clip lists to the
underlying X server. Moving that code up into ChangeGC is a functional
replacement, although for Xnest, it means we're always sending
rectangles and never a bitmap.
Signed-off-by: Keith Packard <keithp at keithp.com>
---
Xext/panoramiX.c | 33 +-------
dix/gc.c | 52 +++++++++++--
exa/exa.c | 47 +----------
fb/fbgc.c | 11 +--
glamor/glamor_core.c | 11 +--
hw/dmx/dmxgc.c | 110 ++++++++------------------
hw/dmx/dmxgc.h | 3 -
hw/xfree86/common/xf86VGAarbiter.c | 31 +-------
hw/xfree86/common/xf86VGAarbiterPriv.h | 4 -
hw/xfree86/drivers/modesetting/dri2.c | 2 +-
hw/xnest/GC.c | 138 ++++++---------------------------
hw/xnest/XNGC.h | 3 -
include/gc.h | 6 ++
include/gcstruct.h | 11 +--
mi/mibitblt.c | 4 +-
mi/migc.c | 40 ----------
mi/migc.h | 10 ---
miext/damage/damage.c | 33 +-------
miext/rootless/rootlessGC.c | 38 +--------
present/present.c | 4 +-
render/mirect.c | 2 +-
xfixes/region.c | 3 +-
22 files changed, 143 insertions(+), 453 deletions(-)
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 209df292c..23d9103a8 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -130,13 +130,12 @@ static void XineramaValidateGC(GCPtr, unsigned long, DrawablePtr);
static void XineramaChangeGC(GCPtr, unsigned long);
static void XineramaCopyGC(GCPtr, unsigned long, GCPtr);
static void XineramaDestroyGC(GCPtr);
-static void XineramaChangeClip(GCPtr, int, void *, int);
-static void XineramaDestroyClip(GCPtr);
-static void XineramaCopyClip(GCPtr, GCPtr);
static const GCFuncs XineramaGCFuncs = {
- XineramaValidateGC, XineramaChangeGC, XineramaCopyGC, XineramaDestroyGC,
- XineramaChangeClip, XineramaDestroyClip, XineramaCopyClip
+ .ValidateGC = XineramaValidateGC,
+ .ChangeGC = XineramaChangeGC,
+ .CopyGC = XineramaCopyGC,
+ .DestroyGC = XineramaDestroyGC,
};
#define Xinerama_GC_FUNC_PROLOGUE(pGC)\
@@ -293,30 +292,6 @@ XineramaCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
Xinerama_GC_FUNC_EPILOGUE(pGCDst);
}
-static void
-XineramaChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
-{
- Xinerama_GC_FUNC_PROLOGUE(pGC);
- (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
- Xinerama_GC_FUNC_EPILOGUE(pGC);
-}
-
-static void
-XineramaCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
-{
- Xinerama_GC_FUNC_PROLOGUE(pgcDst);
- (*pgcDst->funcs->CopyClip) (pgcDst, pgcSrc);
- Xinerama_GC_FUNC_EPILOGUE(pgcDst);
-}
-
-static void
-XineramaDestroyClip(GCPtr pGC)
-{
- Xinerama_GC_FUNC_PROLOGUE(pGC);
- (*pGC->funcs->DestroyClip) (pGC);
- Xinerama_GC_FUNC_EPILOGUE(pGC);
-}
-
int
XineramaDeleteResource(void *data, XID id)
{
diff --git a/dix/gc.c b/dix/gc.c
index cb8db8535..920620e80 100644
--- a/dix/gc.c
+++ b/dix/gc.c
@@ -340,8 +340,7 @@ ChangeGC(ClientPtr client, GC * pGC, BITS32 mask, ChangeGCValPtr pUnion)
}
pPixmap->refcnt++;
}
- (*pGC->funcs->ChangeClip) (pGC, pPixmap ? CT_PIXMAP : CT_NONE,
- (void *) pPixmap, 0);
+ ChangeClip (pGC, pPixmap ? CT_PIXMAP : CT_NONE, (void *) pPixmap, 0);
break;
case GCDashOffset:
NEXTVAL(INT16, pGC->dashOffset);
@@ -712,7 +711,7 @@ CopyGC(GC * pgcSrc, GC * pgcDst, BITS32 mask)
pgcDst->clipOrg.y = pgcSrc->clipOrg.y;
break;
case GCClipMask:
- (*pgcDst->funcs->CopyClip) (pgcDst, pgcSrc);
+ CopyClip (pgcDst, pgcSrc);
break;
case GCDashOffset:
pgcDst->dashOffset = pgcSrc->dashOffset;
@@ -770,7 +769,7 @@ FreeGC(void *value, XID gid)
GCPtr pGC = (GCPtr) value;
CloseFont(pGC->font, (Font) 0);
- (*pGC->funcs->DestroyClip) (pGC);
+ DestroyClip (pGC);
if (!pGC->tileIsPixel)
(*pGC->pScreen->DestroyPixmap) (pGC->tile.pixmap);
@@ -1022,13 +1021,54 @@ SetClipRects(GCPtr pGC, int xOrigin, int yOrigin, int nrects,
if (size)
memmove((char *) prectsNew, (char *) prects, size);
- (*pGC->funcs->ChangeClip) (pGC, newct, (void *) prectsNew, nrects);
+ ChangeClip (pGC, newct, (void *) prectsNew, nrects);
if (pGC->funcs->ChangeGC)
(*pGC->funcs->ChangeGC) (pGC,
GCClipXOrigin | GCClipYOrigin | GCClipMask);
return Success;
}
+/* Manipulate clip list */
+void
+DestroyClip(GCPtr pGC)
+{
+ if (pGC->clientClip)
+ RegionDestroy(pGC->clientClip);
+ pGC->clientClip = NULL;
+}
+
+void
+ChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
+{
+ DestroyClip (pGC);
+ if (type == CT_PIXMAP) {
+ /* convert the pixmap to a region */
+ pGC->clientClip = BitmapToRegion(pGC->pScreen, (PixmapPtr) pvalue);
+ (*pGC->pScreen->DestroyPixmap) (pvalue);
+ }
+ else if (type == CT_REGION) {
+ /* stuff the region in the GC */
+ pGC->clientClip = pvalue;
+ }
+ else if (type != CT_NONE) {
+ pGC->clientClip = RegionFromRects(nrects, (xRectangle *) pvalue, type);
+ free(pvalue);
+ }
+ pGC->stateChanges |= GCClipMask;
+}
+
+void
+CopyClip(GCPtr pgcDst, GCPtr pgcSrc)
+{
+ if (pgcSrc->clientClip) {
+ RegionPtr prgnNew = RegionCreate(NULL, 1);
+ RegionCopy(prgnNew, (RegionPtr) (pgcSrc->clientClip));
+ ChangeClip (pgcDst, CT_REGION, prgnNew, 0);
+ } else {
+ ChangeClip (pgcDst, CT_NONE, NULL, 0);
+ }
+}
+
/*
sets reasonable defaults
if we can get a pre-allocated one, use it and mark it as used.
@@ -1065,7 +1105,7 @@ GetScratchGC(unsigned depth, ScreenPtr pScreen)
pGC->clipOrg.x = 0;
pGC->clipOrg.y = 0;
if (pGC->clientClip)
- (*pGC->funcs->ChangeClip) (pGC, CT_NONE, NULL, 0);
+ ChangeClip (pGC, CT_NONE, NULL, 0);
pGC->stateChanges = GCAllBits;
return pGC;
}
diff --git a/exa/exa.c b/exa/exa.c
index 7266b71f9..e9f65c317 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -474,23 +474,11 @@ static void
static void
exaCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
-static void
- exaChangeClip(GCPtr pGC, int type, void *pvalue, int nrects);
-
-static void
- exaCopyClip(GCPtr pGCDst, GCPtr pGCSrc);
-
-static void
- exaDestroyClip(GCPtr pGC);
-
const GCFuncs exaGCFuncs = {
- exaValidateGC,
- exaChangeGC,
- exaCopyGC,
- exaDestroyGC,
- exaChangeClip,
- exaDestroyClip,
- exaCopyClip
+ .ValidateGC = exaValidateGC,
+ .ChangeGC = exaChangeGC,
+ .CopyGC =exaCopyGC,
+ .DestroyGC = exaDestroyGC,
};
static void
@@ -578,33 +566,6 @@ exaCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
swap(pExaGC, pGCDst, funcs);
}
-static void
-exaChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
-{
- ExaGCPriv(pGC);
- swap(pExaGC, pGC, funcs);
- (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
- swap(pExaGC, pGC, funcs);
-}
-
-static void
-exaCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
-{
- ExaGCPriv(pGCDst);
- swap(pExaGC, pGCDst, funcs);
- (*pGCDst->funcs->CopyClip) (pGCDst, pGCSrc);
- swap(pExaGC, pGCDst, funcs);
-}
-
-static void
-exaDestroyClip(GCPtr pGC)
-{
- ExaGCPriv(pGC);
- swap(pExaGC, pGC, funcs);
- (*pGC->funcs->DestroyClip) (pGC);
- swap(pExaGC, pGC, funcs);
-}
-
/**
* exaCreateGC makes a new GC and hooks up its funcs handler, so that
* exaValidateGC() will get called.
diff --git a/fb/fbgc.c b/fb/fbgc.c
index 19c613158..4cef28409 100644
--- a/fb/fbgc.c
+++ b/fb/fbgc.c
@@ -29,13 +29,10 @@
#include "fb.h"
const GCFuncs fbGCFuncs = {
- fbValidateGC,
- miChangeGC,
- miCopyGC,
- miDestroyGC,
- miChangeClip,
- miDestroyClip,
- miCopyClip,
+ .ValidateGC = fbValidateGC,
+ .ChangeGC = miChangeGC,
+ .CopyGC = miCopyGC,
+ .DestroyGC = miDestroyGC,
};
const GCOps fbGCOps = {
diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index 7b2b39633..54006873e 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -303,13 +303,10 @@ glamor_destroy_gc(GCPtr gc)
}
static GCFuncs glamor_gc_funcs = {
- glamor_validate_gc,
- miChangeGC,
- miCopyGC,
- glamor_destroy_gc,
- miChangeClip,
- miDestroyClip,
- miCopyClip
+ .ValidateGC = glamor_validate_gc,
+ .ChangeGC = miChangeGC,
+ .CopyGC = miCopyGC,
+ .DestroyGC = glamor_destroy_gc,
};
/**
diff --git a/hw/dmx/dmxgc.c b/hw/dmx/dmxgc.c
index c4789a607..5a592c23d 100644
--- a/hw/dmx/dmxgc.c
+++ b/hw/dmx/dmxgc.c
@@ -50,13 +50,10 @@
#include "migc.h"
static const GCFuncs dmxGCFuncs = {
- dmxValidateGC,
- dmxChangeGC,
- dmxCopyGC,
- dmxDestroyGC,
- dmxChangeClip,
- dmxDestroyClip,
- dmxCopyClip,
+ .ValidateGC = dmxValidateGC,
+ .ChangeGC = dmxChangeGC,
+ .CopyGC = dmxCopyGC,
+ .DestroyGC = dmxDestroyGC,
};
static const GCOps dmxGCOps = {
@@ -300,8 +297,34 @@ dmxChangeGC(GCPtr pGC, unsigned long mask)
v.clip_x_origin = pGC->clipOrg.x;
if (mask & GCClipYOrigin)
v.clip_y_origin = pGC->clipOrg.y;
- if (mask & GCClipMask)
- mask &= ~GCClipMask; /* See ChangeClip */
+ if (mask & GCClipMask) {
+ mask &= ~GCClipMask;
+ /* Set the client clip on the back-end server */
+ if (!pGC->clientClip) {
+ if (dmxScreen->beDisplay)
+ XSetClipMask(dmxScreen->beDisplay, pGCPriv->gc, None);
+ } else {
+ if (dmxScreen->beDisplay) {
+ int nRects = RegionNumRects((RegionPtr) pGC->clientClip);
+ XRectangle *pRects = xallocarray(nRects, sizeof(*pRects));
+ BoxPtr pBox = RegionRects((RegionPtr) pGC->clientClip);
+ int i;
+
+ for (i = 0; i < nRects; i++) {
+ pRects[i].x = pBox[i].x1;
+ pRects[i].y = pBox[i].y1;
+ pRects[i].width = pBox[i].x2 - pBox[i].x1;
+ pRects[i].height = pBox[i].y2 - pBox[i].y1;
+ }
+
+ XSetClipRectangles(dmxScreen->beDisplay, pGCPriv->gc,
+ pGC->clipOrg.x, pGC->clipOrg.y,
+ pRects, nRects, Unsorted);
+
+ free(pRects);
+ }
+ }
+ }
if (mask & GCDashOffset)
v.dash_offset = pGC->dashOffset;
if (mask & GCDashList) {
@@ -375,72 +398,3 @@ dmxDestroyGC(GCPtr pGC)
pGC->funcs->DestroyGC(pGC);
DMX_GC_FUNC_EPILOGUE(pGC);
}
-
-/** Change the clip rects for a GC. */
-void
-dmxChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
-{
- ScreenPtr pScreen = pGC->pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- XRectangle *pRects;
- BoxPtr pBox;
- int i, nRects;
-
- DMX_GC_FUNC_PROLOGUE(pGC);
- pGC->funcs->ChangeClip(pGC, type, pvalue, nrects);
-
- /* Set the client clip on the back-end server */
- if (!pGC->clientClip) {
- if (dmxScreen->beDisplay)
- XSetClipMask(dmxScreen->beDisplay, pGCPriv->gc, None);
- } else {
- if (dmxScreen->beDisplay) {
- nRects = RegionNumRects((RegionPtr) pGC->clientClip);
- pRects = xallocarray(nRects, sizeof(*pRects));
- pBox = RegionRects((RegionPtr) pGC->clientClip);
-
- for (i = 0; i < nRects; i++) {
- pRects[i].x = pBox[i].x1;
- pRects[i].y = pBox[i].y1;
- pRects[i].width = pBox[i].x2 - pBox[i].x1;
- pRects[i].height = pBox[i].y2 - pBox[i].y1;
- }
-
- XSetClipRectangles(dmxScreen->beDisplay, pGCPriv->gc,
- pGC->clipOrg.x, pGC->clipOrg.y,
- pRects, nRects, Unsorted);
-
- free(pRects);
- }
- }
-
- DMX_GC_FUNC_EPILOGUE(pGC);
-}
-
-/** Destroy a GC's clip rects. */
-void
-dmxDestroyClip(GCPtr pGC)
-{
- ScreenPtr pScreen = pGC->pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
-
- DMX_GC_FUNC_PROLOGUE(pGC);
- pGC->funcs->DestroyClip(pGC);
-
- /* Set the client clip on the back-end server to None */
- if (dmxScreen->beDisplay)
- XSetClipMask(dmxScreen->beDisplay, pGCPriv->gc, None);
-
- DMX_GC_FUNC_EPILOGUE(pGC);
-}
-
-/** Copy a GC's clip rects. */
-void
-dmxCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
-{
- DMX_GC_FUNC_PROLOGUE(pGCDst);
- pGCDst->funcs->CopyClip(pGCDst, pGCSrc);
- DMX_GC_FUNC_EPILOGUE(pGCDst);
-}
diff --git a/hw/dmx/dmxgc.h b/hw/dmx/dmxgc.h
index c5c6b7732..62a9a4dea 100644
--- a/hw/dmx/dmxgc.h
+++ b/hw/dmx/dmxgc.h
@@ -55,9 +55,6 @@ extern void dmxValidateGC(GCPtr pGC, unsigned long changes,
extern void dmxChangeGC(GCPtr pGC, unsigned long mask);
extern void dmxCopyGC(GCPtr pGCSrc, unsigned long changes, GCPtr pGCDst);
extern void dmxDestroyGC(GCPtr pGC);
-extern void dmxChangeClip(GCPtr pGC, int type, void *pvalue, int nrects);
-extern void dmxDestroyClip(GCPtr pGC);
-extern void dmxCopyClip(GCPtr pGCDst, GCPtr pGCSrc);
extern void dmxBECreateGC(ScreenPtr pScreen, GCPtr pGC);
extern Bool dmxBEFreeGC(GCPtr pGC);
diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
index 40f241aee..42264c087 100644
--- a/hw/xfree86/common/xf86VGAarbiter.c
+++ b/hw/xfree86/common/xf86VGAarbiter.c
@@ -37,9 +37,10 @@
#include "pciaccess.h"
static GCFuncs VGAarbiterGCFuncs = {
- VGAarbiterValidateGC, VGAarbiterChangeGC, VGAarbiterCopyGC,
- VGAarbiterDestroyGC, VGAarbiterChangeClip, VGAarbiterDestroyClip,
- VGAarbiterCopyClip
+ .ValidateGC = VGAarbiterValidateGC,
+ .ChangeGC = VGAarbiterChangeGC,
+ .CopyGC = VGAarbiterCopyGC,
+ .DestroyGC = VGAarbiterDestroyGC,
};
static GCOps VGAarbiterGCOps = {
@@ -583,30 +584,6 @@ VGAarbiterCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
GC_WRAP(pGCDst);
}
-static void
-VGAarbiterChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
-{
- GC_UNWRAP(pGC);
- (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
-{
- GC_UNWRAP(pgcDst);
- (*pgcDst->funcs->CopyClip) (pgcDst, pgcSrc);
- GC_WRAP(pgcDst);
-}
-
-static void
-VGAarbiterDestroyClip(GCPtr pGC)
-{
- GC_UNWRAP(pGC);
- (*pGC->funcs->DestroyClip) (pGC);
- GC_WRAP(pGC);
-}
-
/* GC Ops */
static void
VGAarbiterFillSpans(DrawablePtr pDraw,
diff --git a/hw/xfree86/common/xf86VGAarbiterPriv.h b/hw/xfree86/common/xf86VGAarbiterPriv.h
index 09be10aa3..6bd65292c 100644
--- a/hw/xfree86/common/xf86VGAarbiterPriv.h
+++ b/hw/xfree86/common/xf86VGAarbiterPriv.h
@@ -190,10 +190,6 @@ static void VGAarbiterValidateGC(GCPtr pGC, unsigned long changes,
static void VGAarbiterChangeGC(GCPtr pGC, unsigned long mask);
static void VGAarbiterCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
static void VGAarbiterDestroyGC(GCPtr pGC);
-static void VGAarbiterChangeClip(GCPtr pGC, int type, void *pvalue,
- int nrects);
-static void VGAarbiterDestroyClip(GCPtr pGC);
-static void VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
/* GC ops */
static void VGAarbiterFillSpans(DrawablePtr pDraw, GC * pGC, int nInit,
diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c
index 8944ef136..48ae6bc8e 100644
--- a/hw/xfree86/drivers/modesetting/dri2.c
+++ b/hw/xfree86/drivers/modesetting/dri2.c
@@ -303,7 +303,7 @@ ms_dri2_copy_region2(ScreenPtr screen, DrawablePtr drawable, RegionPtr pRegion,
REGION_COPY(screen, pCopyClip, pRegion);
if (translate)
REGION_TRANSLATE(screen, pCopyClip, off_x, off_y);
- (*gc->funcs->ChangeClip) (gc, CT_REGION, pCopyClip, 0);
+ ChangeClip(gc, CT_REGION, pCopyClip, 0);
ValidateGC(dst, gc);
/* It's important that this copy gets submitted before the direct
diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c
index ecfa61e39..9db9f432c 100644
--- a/hw/xnest/GC.c
+++ b/hw/xnest/GC.c
@@ -38,13 +38,10 @@ is" without express or implied warranty.
DevPrivateKeyRec xnestGCPrivateKeyRec;
static GCFuncs xnestFuncs = {
- xnestValidateGC,
- xnestChangeGC,
- xnestCopyGC,
- xnestDestroyGC,
- xnestChangeClip,
- xnestDestroyClip,
- xnestCopyClip,
+ .ValidateGC = xnestValidateGC,
+ .ChangeGC = xnestChangeGC,
+ .CopyGC = xnestCopyGC,
+ .DestroyGC = xnestDestroyGC,
};
static GCOps xnestOps = {
@@ -156,8 +153,26 @@ xnestChangeGC(GCPtr pGC, unsigned long mask)
if (mask & GCClipYOrigin)
values.clip_y_origin = pGC->clipOrg.y;
- if (mask & GCClipMask) /* this is handled in change clip */
+ if (mask & GCClipMask) {
mask &= ~GCClipMask;
+ if (pGC->clientClip == NULL) {
+ XSetClipMask(xnestDisplay, xnestGC(pGC), None);
+ } else {
+ int nRects = RegionNumRects(pGC->clientClip);
+ XRectangle *pRects = xallocarray(nRects, sizeof(*pRects));
+ BoxPtr pBox = RegionRects(pGC->clientClip);
+ int i;
+ for (i = nRects; i-- > 0;) {
+ pRects[i].x = pBox[i].x1;
+ pRects[i].y = pBox[i].y1;
+ pRects[i].width = pBox[i].x2 - pBox[i].x1;
+ pRects[i].height = pBox[i].y2 - pBox[i].y1;
+ }
+ XSetClipRectangles(xnestDisplay, xnestGC(pGC), 0, 0,
+ pRects, nRects, Unsorted);
+ free((char *) pRects);
+ }
+ }
if (mask & GCDashOffset)
values.dash_offset = pGC->dashOffset;
@@ -186,110 +201,3 @@ xnestDestroyGC(GCPtr pGC)
{
XFreeGC(xnestDisplay, xnestGC(pGC));
}
-
-void
-xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects)
-{
- int i;
- BoxPtr pBox;
- XRectangle *pRects;
-
- xnestDestroyClip(pGC);
-
- switch (type) {
- case CT_NONE:
- XSetClipMask(xnestDisplay, xnestGC(pGC), None);
- pValue = NULL;
- break;
-
- case CT_REGION:
- nRects = RegionNumRects((RegionPtr) pValue);
- pRects = xallocarray(nRects, sizeof(*pRects));
- pBox = RegionRects((RegionPtr) pValue);
- for (i = nRects; i-- > 0;) {
- pRects[i].x = pBox[i].x1;
- pRects[i].y = pBox[i].y1;
- pRects[i].width = pBox[i].x2 - pBox[i].x1;
- pRects[i].height = pBox[i].y2 - pBox[i].y1;
- }
- XSetClipRectangles(xnestDisplay, xnestGC(pGC), 0, 0,
- pRects, nRects, Unsorted);
- free((char *) pRects);
- break;
-
- case CT_PIXMAP:
- XSetClipMask(xnestDisplay, xnestGC(pGC),
- xnestPixmap((PixmapPtr) pValue));
- /*
- * Need to change into region, so subsequent uses are with
- * current pixmap contents.
- */
- pGC->clientClip = (*pGC->pScreen->BitmapToRegion) ((PixmapPtr) pValue);
- (*pGC->pScreen->DestroyPixmap) ((PixmapPtr) pValue);
- pValue = pGC->clientClip;
- break;
-
- case CT_UNSORTED:
- XSetClipRectangles(xnestDisplay, xnestGC(pGC),
- pGC->clipOrg.x, pGC->clipOrg.y,
- (XRectangle *) pValue, nRects, Unsorted);
- break;
-
- case CT_YSORTED:
- XSetClipRectangles(xnestDisplay, xnestGC(pGC),
- pGC->clipOrg.x, pGC->clipOrg.y,
- (XRectangle *) pValue, nRects, YSorted);
- break;
-
- case CT_YXSORTED:
- XSetClipRectangles(xnestDisplay, xnestGC(pGC),
- pGC->clipOrg.x, pGC->clipOrg.y,
- (XRectangle *) pValue, nRects, YXSorted);
- break;
-
- case CT_YXBANDED:
- XSetClipRectangles(xnestDisplay, xnestGC(pGC),
- pGC->clipOrg.x, pGC->clipOrg.y,
- (XRectangle *) pValue, nRects, YXBanded);
- break;
- }
-
- switch (type) {
- default:
- break;
-
- case CT_UNSORTED:
- case CT_YSORTED:
- case CT_YXSORTED:
- case CT_YXBANDED:
- /* server clip representation is a region */
- pGC->clientClip = RegionFromRects(nRects, (xRectangle *) pValue, type);
- free(pValue);
- pValue = pGC->clientClip;
- break;
- }
-
- pGC->clientClip = pValue;
-}
-
-void
-xnestDestroyClip(GCPtr pGC)
-{
- if (pGC->clientClip) {
- RegionDestroy(pGC->clientClip);
- XSetClipMask(xnestDisplay, xnestGC(pGC), None);
- pGC->clientClip = NULL;
- }
-}
-
-void
-xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
-{
- if (pGCSrc->clientClip) {
- RegionPtr pRgn = RegionCreate(NULL, 1);
- RegionCopy(pRgn, pGCSrc->clientClip);
- xnestChangeClip(pGCDst, CT_REGION, pRgn, 0);
- } else {
- xnestDestroyClip(pGCDst);
- }
-}
diff --git a/hw/xnest/XNGC.h b/hw/xnest/XNGC.h
index 974173e50..c1ec6fa92 100644
--- a/hw/xnest/XNGC.h
+++ b/hw/xnest/XNGC.h
@@ -35,8 +35,5 @@ void xnestValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
void xnestChangeGC(GCPtr pGC, unsigned long mask);
void xnestCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
void xnestDestroyGC(GCPtr pGC);
-void xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects);
-void xnestDestroyClip(GCPtr pGC);
-void xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc);
#endif /* XNESTGC_H */
diff --git a/include/gc.h b/include/gc.h
index 53f9c29e1..5f217739a 100644
--- a/include/gc.h
+++ b/include/gc.h
@@ -144,4 +144,10 @@ extern _X_EXPORT GCPtr GetScratchGC(unsigned /*depth */ ,
extern _X_EXPORT void FreeScratchGC(GCPtr /*pGC */ );
+extern _X_EXPORT void DestroyClip(GCPtr pGC);
+
+extern _X_EXPORT void ChangeClip(GCPtr pGC, int type, void *pvalue, int nrects);
+
+extern _X_EXPORT void CopyClip(GCPtr pgcDst, GCPtr pgcSrc);
+
#endif /* GC_H */
diff --git a/include/gcstruct.h b/include/gcstruct.h
index e48d61045..e756c226d 100644
--- a/include/gcstruct.h
+++ b/include/gcstruct.h
@@ -75,18 +75,9 @@ typedef struct _GCFuncs {
GCPtr /*pGCDst */ );
void (*DestroyGC) (GCPtr /*pGC */ );
-
- void (*ChangeClip) (GCPtr pGC,
- int type,
- void *pvalue,
- int nrects);
-
- void (*DestroyClip) (GCPtr /*pGC */ );
-
- void (*CopyClip) (GCPtr /*pgcDst */ ,
- GCPtr /*pgcSrc */ );
} GCFuncs;
+
/*
* graphics operations invoked through a GC
*/
diff --git a/mi/mibitblt.c b/mi/mibitblt.c
index 28296a449..e65050aeb 100644
--- a/mi/mibitblt.c
+++ b/mi/mibitblt.c
@@ -414,7 +414,7 @@ miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc,
prgnSrcClip = RegionCreate(NULL, 0);
RegionCopy(prgnSrcClip, prgnSrc);
RegionTranslate(prgnSrcClip, srcx, 0);
- (*pGCT->funcs->ChangeClip) (pGCT, CT_REGION, prgnSrcClip, 0);
+ ChangeClip(pGCT, CT_REGION, prgnSrcClip, 0);
ValidateGC((DrawablePtr) pPixmap, pGCT);
/* Since we know pDraw is always a pixmap, we never need to think
@@ -497,7 +497,7 @@ miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc,
ValidateGC(pDraw, pGC);
/* put what we hope is a smaller clip region back in the scratch gc */
- (*pGCT->funcs->ChangeClip) (pGCT, CT_NONE, NULL, 0);
+ ChangeClip(pGCT, CT_NONE, NULL, 0);
FreeScratchGC(pGCT);
(*pDraw->pScreen->DestroyPixmap) (pPixmap);
diff --git a/mi/migc.c b/mi/migc.c
index 8fdd4810c..bfb3bacbe 100644
--- a/mi/migc.c
+++ b/mi/migc.c
@@ -52,46 +52,6 @@ miDestroyGC(GCPtr pGC)
RegionDestroy(pGC->pCompositeClip);
}
-void
-miDestroyClip(GCPtr pGC)
-{
- if (pGC->clientClip)
- RegionDestroy(pGC->clientClip);
- pGC->clientClip = NULL;
-}
-
-void
-miChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
-{
- (*pGC->funcs->DestroyClip) (pGC);
- if (type == CT_PIXMAP) {
- /* convert the pixmap to a region */
- pGC->clientClip = BitmapToRegion(pGC->pScreen, (PixmapPtr) pvalue);
- (*pGC->pScreen->DestroyPixmap) (pvalue);
- }
- else if (type == CT_REGION) {
- /* stuff the region in the GC */
- pGC->clientClip = pvalue;
- }
- else if (type != CT_NONE) {
- pGC->clientClip = RegionFromRects(nrects, (xRectangle *) pvalue, type);
- free(pvalue);
- }
- pGC->stateChanges |= GCClipMask;
-}
-
-void
-miCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
-{
- if (pgcSrc->clientClip) {
- RegionPtr prgnNew = RegionCreate(NULL, 1);
- RegionCopy(prgnNew, (RegionPtr) (pgcSrc->clientClip));
- (*pgcDst->funcs->ChangeClip) (pgcDst, CT_REGION, prgnNew, 0);
- } else {
- (*pgcDst->funcs->ChangeClip) (pgcDst, CT_NONE, NULL, 0);
- }
-}
-
/* ARGSUSED */
void
miCopyGC(GCPtr pGCSrc, unsigned long changes, GCPtr pGCDst)
diff --git a/mi/migc.h b/mi/migc.h
index add601a94..59526f3e2 100644
--- a/mi/migc.h
+++ b/mi/migc.h
@@ -34,16 +34,6 @@ extern _X_EXPORT void miChangeGC(GCPtr pGC,
extern _X_EXPORT void miDestroyGC(GCPtr pGC);
-extern _X_EXPORT void miDestroyClip(GCPtr pGC);
-
-extern _X_EXPORT void miChangeClip(GCPtr pGC,
- int type,
- void *pvalue,
- int nrects);
-
-extern _X_EXPORT void miCopyClip(GCPtr pgcDst,
- GCPtr pgcSrc);
-
extern _X_EXPORT void miCopyGC(GCPtr pGCSrc,
unsigned long changes,
GCPtr pGCDst);
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 2fae03fc2..385e5fe0f 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -328,13 +328,12 @@ static void damageValidateGC(GCPtr, unsigned long, DrawablePtr);
static void damageChangeGC(GCPtr, unsigned long);
static void damageCopyGC(GCPtr, unsigned long, GCPtr);
static void damageDestroyGC(GCPtr);
-static void damageChangeClip(GCPtr, int, void *, int);
-static void damageDestroyClip(GCPtr);
-static void damageCopyClip(GCPtr, GCPtr);
static GCFuncs damageGCFuncs = {
- damageValidateGC, damageChangeGC, damageCopyGC, damageDestroyGC,
- damageChangeClip, damageDestroyClip, damageCopyClip
+ .ValidateGC = damageValidateGC,
+ .ChangeGC = damageChangeGC,
+ .CopyGC = damageCopyGC,
+ .DestroyGC = damageDestroyGC,
};
static GCOps damageGCOps;
@@ -411,30 +410,6 @@ damageCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
DAMAGE_GC_FUNC_EPILOGUE(pGCDst);
}
-static void
-damageChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
-{
- DAMAGE_GC_FUNC_PROLOGUE(pGC);
- (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
- DAMAGE_GC_FUNC_EPILOGUE(pGC);
-}
-
-static void
-damageCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
-{
- DAMAGE_GC_FUNC_PROLOGUE(pgcDst);
- (*pgcDst->funcs->CopyClip) (pgcDst, pgcSrc);
- DAMAGE_GC_FUNC_EPILOGUE(pgcDst);
-}
-
-static void
-damageDestroyClip(GCPtr pGC)
-{
- DAMAGE_GC_FUNC_PROLOGUE(pGC);
- (*pGC->funcs->DestroyClip) (pGC);
- DAMAGE_GC_FUNC_EPILOGUE(pGC);
-}
-
#define TRIM_BOX(box, pGC) if (pGC->pCompositeClip) { \
BoxPtr extents = &pGC->pCompositeClip->extents;\
if(box.x1 < extents->x1) box.x1 = extents->x1; \
diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c
index 235b3ab7c..da3697e4c 100644
--- a/miext/rootless/rootlessGC.c
+++ b/miext/rootless/rootlessGC.c
@@ -55,20 +55,14 @@ static void RootlessValidateGC(GCPtr pGC, unsigned long changes,
static void RootlessChangeGC(GCPtr pGC, unsigned long mask);
static void RootlessCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
static void RootlessDestroyGC(GCPtr pGC);
-static void RootlessChangeClip(GCPtr pGC, int type, void *pvalue, int nrects);
-static void RootlessDestroyClip(GCPtr pGC);
-static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
Bool RootlessCreateGC(GCPtr pGC);
GCFuncs rootlessGCFuncs = {
- RootlessValidateGC,
- RootlessChangeGC,
- RootlessCopyGC,
- RootlessDestroyGC,
- RootlessChangeClip,
- RootlessDestroyClip,
- RootlessCopyClip,
+ .ValidateGC = RootlessValidateGC,
+ .ChangeGC = RootlessChangeGC,
+ .CopyGC = RootlessCopyGC,
+ .DestroyGC = RootlessDestroyGC,
};
// GC operations
@@ -367,30 +361,6 @@ RootlessDestroyGC(GCPtr pGC)
GCFUNC_WRAP(pGC);
}
-static void
-RootlessChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
-{
- GCFUNC_UNWRAP(pGC);
- pGC->funcs->ChangeClip(pGC, type, pvalue, nrects);
- GCFUNC_WRAP(pGC);
-}
-
-static void
-RootlessDestroyClip(GCPtr pGC)
-{
- GCFUNC_UNWRAP(pGC);
- pGC->funcs->DestroyClip(pGC);
- GCFUNC_WRAP(pGC);
-}
-
-static void
-RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
-{
- GCFUNC_UNWRAP(pgcDst);
- pgcDst->funcs->CopyClip(pgcDst, pgcSrc);
- GCFUNC_WRAP(pgcDst);
-}
-
/*
* GC ops
*
diff --git a/present/present.c b/present/present.c
index aa9c041df..16091f613 100644
--- a/present/present.c
+++ b/present/present.c
@@ -89,7 +89,7 @@ present_copy_region(DrawablePtr drawable,
ChangeGC(serverClient, gc,
GCClipXOrigin|GCClipYOrigin,
changes);
- (*gc->funcs->ChangeClip)(gc, CT_REGION, update, 0);
+ ChangeClip(gc, CT_REGION, update, 0);
}
ValidateGC(drawable, gc);
(*gc->ops->CopyArea)(&pixmap->drawable,
@@ -99,7 +99,7 @@ present_copy_region(DrawablePtr drawable,
pixmap->drawable.width, pixmap->drawable.height,
x_off, y_off);
if (update)
- (*gc->funcs->ChangeClip)(gc, CT_NONE, NULL, 0);
+ ChangeClip(gc, CT_NONE, NULL, 0);
FreeScratchGC(gc);
}
diff --git a/render/mirect.c b/render/mirect.c
index a36d1d6e3..0ef23872d 100644
--- a/render/mirect.c
+++ b/render/mirect.c
@@ -61,7 +61,7 @@ miColorRects(PicturePtr pDst,
pClip = RegionCreate(NULL, 1);
RegionCopy(pClip, (RegionPtr) pClipPict->clientClip);
- (*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0);
+ ChangeClip(pGC, CT_REGION, pClip, 0);
}
ChangeGC(NullClient, pGC, mask, tmpval);
diff --git a/xfixes/region.c b/xfixes/region.c
index e7737011e..f1fed6cb9 100644
--- a/xfixes/region.c
+++ b/xfixes/region.c
@@ -616,8 +616,7 @@ ProcXFixesSetGCClipRegion(ClientPtr client)
vals[0].val = stuff->xOrigin;
vals[1].val = stuff->yOrigin;
ChangeGC(NullClient, pGC, GCClipXOrigin | GCClipYOrigin, vals);
- (*pGC->funcs->ChangeClip) (pGC, pRegion ? CT_REGION : CT_NONE,
- (void *) pRegion, 0);
+ ChangeClip(pGC, pRegion ? CT_REGION : CT_NONE, (void *) pRegion, 0);
return Success;
}
--
2.11.0
More information about the xorg-devel
mailing list