From 6a870992d81a6bacfa9d313c15784fdb281d474f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 25 May 2007 20:33:08 -0700 Subject: [PATCH] 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. --- hw/xfree86/common/xf86xv.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 02fcde68c..6abe31c2f 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -1875,42 +1875,35 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes) _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 -