summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2004-08-15 21:13:11 +0000
committerKeith Packard <keithp@keithp.com>2004-08-15 21:13:11 +0000
commit9da0c214ab5f4ee9c1610b4888f5c7c0dd2bcacc (patch)
tree9c59f6aaab49c42e28ec871f0aed16b279abd506
parenta68f350195c1c54034f98e2b78c2c3da70044884 (diff)
Clip destination instead of source. Should be the same, but it looks nicer
to me. Clean up transition between cheap and expensive GC wrappers by using the prologue and epilogue macros. Before, the GC would be left unvalidated sometimes which would cause all kinds of entertaining bugs against a DDX which cares (XAA).
-rw-r--r--composite/compwindow.c11
-rw-r--r--miext/cw/cw.c111
2 files changed, 64 insertions, 58 deletions
diff --git a/composite/compwindow.c b/composite/compwindow.c
index f8945bdc4..c7ea98c13 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -702,15 +702,15 @@ compWindowUpdateAutomatic (WindowPtr pWin)
REGION_INTERSECT (pScreen, pRegion, pRegion, &cw->borderClip);
/*
- * Now translate from screen to pixmap coordinates
+ * Now translate from screen to dest coordinates
*/
REGION_TRANSLATE (pScreen, pRegion,
- -pSrcPixmap->screen_x, -pSrcPixmap->screen_y);
+ -pParent->drawable.x, -pParent->drawable.y);
/*
* Clip the picture
*/
- SetPictureClipRegion (pSrcPicture, 0, 0, pRegion);
+ SetPictureClipRegion (pDstPicture, 0, 0, pRegion);
/*
* And paint
@@ -719,9 +719,8 @@ compWindowUpdateAutomatic (WindowPtr pWin)
pSrcPicture,
0,
pDstPicture,
- 0,
- 0,
- 0, 0,
+ 0, 0, /* src_x, src_y */
+ 0, 0, /* msk_x, msk_y */
pSrcPixmap->screen_x - pParent->drawable.x,
pSrcPixmap->screen_y - pParent->drawable.y,
pSrcPixmap->drawable.width,
diff --git a/miext/cw/cw.c b/miext/cw/cw.c
index c72db3809..0c9edee83 100644
--- a/miext/cw/cw.c
+++ b/miext/cw/cw.c
@@ -120,8 +120,39 @@ cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off)
}
}
+/* GCFuncs wrappers. These only get used when the drawable is a window with a
+ * backing pixmap, to avoid the overhead in the non-window-backing-pixmap case.
+ */
+
+#define FUNC_PROLOGUE(pGC, pPriv) do { \
+ (pGC)->funcs = (pPriv)->wrapFuncs; \
+ (pGC)->ops = (pPriv)->wrapOps; \
+} while (0)
+
+#define FUNC_EPILOGUE(pGC, pPriv) do { \
+ (pPriv)->wrapFuncs = (pGC)->funcs; \
+ (pPriv)->wrapOps = (pGC)->ops; \
+ (pGC)->funcs = &cwGCFuncs; \
+ (pGC)->ops = &cwGCOps; \
+} while (0)
+
+/*
+ * Cheap GC func wrappers. Pass everything through unless we find a window with
+ * a backing pixmap, then turn on the real wrappers.
+ */
+
+#define CHEAP_FUNC_PROLOGUE(pGC) \
+ ((pGC)->funcs = (GCFuncs *)getCwGC(pGC))
+
+#define CHEAP_FUNC_EPILOGUE(pGC) do { \
+ setCwGC(pGC,(pGC)->funcs); \
+ (pGC)->funcs = &cwCheapGCFuncs; \
+} while (0)
+
/*
- * create the full func/op wrappers for a GC
+ * create the full func/op wrappers for a GC.
+ * This enters with the GC unwrapped. If successful, it must leave
+ * with the GC wrapped. If unsuccessful, it leaves the GC alone
*/
static Bool
@@ -144,43 +175,35 @@ cwCreateGCPrivate(GCPtr pGC, DrawablePtr pDrawable)
}
pPriv->serialNumber = 0;
pPriv->stateChanges = (1 << (GCLastBit + 1)) - 1;
- pPriv->wrapOps = pGC->ops;
- pPriv->wrapFuncs = pGC->funcs;
- pGC->funcs = &cwGCFuncs;
- pGC->ops = &cwGCOps;
- setCwGC (pGC, pPriv);
+
+ setCwGC(pGC,pPriv);
+
+ FUNC_EPILOGUE(pGC,pPriv);
+
return TRUE;
}
+/*
+ * Destroy the full func/op wrappers for a GC and
+ * switch backto the cheap ones
+ * This enters with the GC unwrapped and must leave
+ * with the GC cheap wrapped
+ */
+
static void
cwDestroyGCPrivate(GCPtr pGC)
{
cwGCPtr pPriv;
pPriv = (cwGCPtr) getCwGC (pGC);
- pGC->funcs = &cwCheapGCFuncs;
- pGC->ops = pPriv->wrapOps;
+
if (pPriv->pBackingGC)
FreeGC(pPriv->pBackingGC, (XID)0);
- setCwGC (pGC, pPriv->wrapFuncs);
+
xfree((pointer)pPriv);
-}
-/* GCFuncs wrappers. These only get used when the drawable is a window with a
- * backing pixmap, to avoid the overhead in the non-window-backing-pixmap case.
- */
-
-#define FUNC_PROLOGUE(pGC, pPriv) do { \
- (pGC)->funcs = (pPriv)->wrapFuncs; \
- (pGC)->ops = (pPriv)->wrapOps; \
-} while (0)
-
-#define FUNC_EPILOGUE(pGC, pPriv) do { \
- (pPriv)->wrapFuncs = (pGC)->funcs; \
- (pPriv)->wrapOps = (pGC)->ops; \
- (pGC)->funcs = &cwGCFuncs; \
- (pGC)->ops = &cwGCOps; \
-} while (0)
+ CHEAP_FUNC_EPILOGUE (pGC);
+}
static void
cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable)
@@ -343,42 +366,26 @@ cwDestroyClip(GCPtr pGC)
FUNC_EPILOGUE(pGC, pPriv);
}
-/*
- * Cheap GC func wrappers. Pass everything through unless we find a window with
- * a backing pixmap, then turn on the real wrappers.
- */
-
-#define CHEAP_FUNC_PROLOGUE(pGC) \
- ((pGC)->funcs = (GCFuncs *)(pGC)->devPrivates[cwGCIndex].ptr)
-
-#define CHEAP_FUNC_EPILOGUE(pGC) do { \
- (pGC)->devPrivates[cwGCIndex].ptr = (pointer)(pGC)->funcs; \
- (pGC)->funcs = &cwCheapGCFuncs; \
-} while (0)
static void
cwCheapValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable)
{
CHEAP_FUNC_PROLOGUE(pGC);
- /* Check if the drawable is a window with backing pixmap. If so,
- * cwCreateGCPrivate will wrap with the backing-pixmap GC funcs and we won't
- * re-wrap on return.
+ /*
+ * If the drawable is a redirected window, switch the GC
+ * around and revalidate with cwValidateGC.
*/
- if (cwDrawableIsRedirWindow(pDrawable) &&
- cwCreateGCPrivate(pGC, pDrawable))
+ if (cwDrawableIsRedirWindow(pDrawable) &&
+ cwCreateGCPrivate (pGC, pDrawable))
{
- (*pGC->funcs->ValidateGC)(pGC, stateChanges, pDrawable);
- }
- else
- {
- (*pGC->funcs->ValidateGC)(pGC, stateChanges, pDrawable);
-
- /* rewrap funcs as Validate may have changed them */
- pGC->devPrivates[cwGCIndex].ptr = (pointer) pGC->funcs;
-
- CHEAP_FUNC_EPILOGUE(pGC);
+ cwValidateGC (pGC, stateChanges, pDrawable);
+ return;
}
+
+ (*pGC->funcs->ValidateGC)(pGC, stateChanges, pDrawable);
+
+ CHEAP_FUNC_EPILOGUE(pGC);
}
static void