xserver: Branch 'master'

Keith Packard keithp at kemper.freedesktop.org
Fri May 25 20:33:18 PDT 2007


 hw/xfree86/common/xf86xv.c |   35 ++++++++++++++---------------------
 1 files changed, 14 insertions(+), 21 deletions(-)

New commits:
diff-tree 6a870992d81a6bacfa9d313c15784fdb281d474f (from 3c982bc1a49509dda7bc469b0eced44df02755b3)
Author: Keith Packard <keithp at dulcimer.keithp.com>
Date:   Fri May 25 20:33:08 2007 -0700

    xf86XVFillKeyHelper assumed root clip never changed.
    
    When the root window changed size, xf86XVFillKeyHelper would not revalidate
    the GC, leaving the clip at the old size causing lossage (and possibly
    memory corruption if the screen and frame buffer shrank).
    
    Fixed by just using a scratch GC; saving memory, eliminating bugs and
    shrinking the code.

diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 02fcde6..6abe31c 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -1875,42 +1875,35 @@ xf86XVFillKeyHelperDrawable (DrawablePtr
 _X_EXPORT void
 xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
 {
-   XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
    DrawablePtr root = &WindowTable[pScreen->myNum]->drawable;
    XID pval[2];
    BoxPtr pbox = REGION_RECTS(clipboxes);
    int i, nbox = REGION_NUM_RECTS(clipboxes);
    xRectangle *rects;
+   GCPtr gc;
 
    if(!xf86Screens[pScreen->myNum]->vtSema) return;
 
-   if(!ScreenPriv->videoGC) {
-       int status;
-       pval[0] = key;
-       pval[1] = IncludeInferiors;
-       ScreenPriv->videoGC = CreateGC(root, GCForeground | GCSubwindowMode,
-				      pval, &status);
-       if(!ScreenPriv->videoGC) return;
-       ValidateGC(root, ScreenPriv->videoGC);
-   } else if (key != ScreenPriv->videoGC->fgPixel){
-       pval[0] = key;
-       ChangeGC(ScreenPriv->videoGC, GCForeground, pval);
-       ValidateGC(root, ScreenPriv->videoGC);
-   }
+   gc = GetScratchGC(root->depth, pScreen);
+   pval[0] = key;
+   pval[1] = IncludeInferiors;
+   (void) ChangeGC(gc, GCForeground|GCSubwindowMode, pval);
+   ValidateGC(root, gc);
 
-   rects = ALLOCATE_LOCAL(nbox * sizeof(xRectangle));
+   rects = xalloc (nbox * sizeof(xRectangle));
 
-   for(i = 0; i < nbox; i++, pbox++) {
+   for(i = 0; i < nbox; i++, pbox++) 
+   {
       rects[i].x = pbox->x1;
       rects[i].y = pbox->y1;
       rects[i].width = pbox->x2 - pbox->x1;
       rects[i].height = pbox->y2 - pbox->y1;
    }
-
-   (*ScreenPriv->videoGC->ops->PolyFillRect)(
-			     root, ScreenPriv->videoGC, nbox, rects);
-
-   DEALLOCATE_LOCAL(rects);
+   
+   (*gc->ops->PolyFillRect)(root, gc, nbox, rects);
+   
+   xfree (rects);
+   FreeScratchGC (gc);
 }
 
 /* xf86XVClipVideoHelper -


More information about the xorg-commit mailing list