damage.c
来自「是由intel提供的针对intel显卡915以上系列的linux驱动」· C语言 代码 · 共 1,843 行 · 第 1/3 页
C
1,843 行
if (extents.overallLeft > 0) extents.overallLeft = 0; if (extents.fontAscent > extents.overallAscent) extents.overallAscent = extents.fontAscent; if (extents.fontDescent > extents.overallDescent) extents.overallDescent = extents.fontDescent; } box.x1 = x + extents.overallLeft; box.y1 = y - extents.overallAscent; box.x2 = x + extents.overallRight; box.y2 = y + extents.overallDescent; damageDamageBox (pDrawable, &box);}/* * values for textType: */#define TT_POLY8 0#define TT_IMAGE8 1#define TT_POLY16 2#define TT_IMAGE16 3static int damageText (DrawablePtr pDrawable, GCPtr pGC, int x, int y, unsigned long count, char *chars, FontEncoding fontEncoding, Bool textType){ CharInfoPtr *charinfo; CharInfoPtr *info; unsigned long i; unsigned int n; int w; Bool imageblt; imageblt = (textType == TT_IMAGE8) || (textType == TT_IMAGE16); charinfo = (CharInfoPtr *) ALLOCATE_LOCAL(count * sizeof(CharInfoPtr)); if (!charinfo) return x; GetGlyphs(pGC->font, count, (unsigned char *)chars, fontEncoding, &i, charinfo); n = (unsigned int)i; w = 0; if (!imageblt) for (info = charinfo; i--; info++) w += (*info)->metrics.characterWidth; if (n != 0) { damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, n, charinfo, imageblt); if (imageblt) (*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font)); else (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font)); } DEALLOCATE_LOCAL(charinfo); return x + w;}static intdamagePolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char *chars){ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); if (checkGCDamage (pDrawable, pGC)) damageText (pDrawable, pGC, x, y, (unsigned long) count, chars, Linear8Bit, TT_POLY8); else x = (*pGC->ops->PolyText8)(pDrawable, pGC, x, y, count, chars); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); return x;}static intdamagePolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsigned short *chars){ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); if (checkGCDamage (pDrawable, pGC)) damageText (pDrawable, pGC, x, y, (unsigned long) count, (char *) chars, FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, TT_POLY16); else x = (*pGC->ops->PolyText16)(pDrawable, pGC, x, y, count, chars); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); return x;}static voiddamageImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char *chars){ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); if (checkGCDamage (pDrawable, pGC)) damageText (pDrawable, pGC, x, y, (unsigned long) count, chars, Linear8Bit, TT_IMAGE8); else (*pGC->ops->ImageText8)(pDrawable, pGC, x, y, count, chars); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamageImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsigned short *chars){ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); if (checkGCDamage (pDrawable, pGC)) damageText (pDrawable, pGC, x, y, (unsigned long) count, (char *) chars, FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, TT_IMAGE16); else (*pGC->ops->ImageText16)(pDrawable, pGC, x, y, count, chars); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamageImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase){ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, nglyph, ppci, TRUE); (*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamagePolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase){ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, nglyph, ppci, FALSE); (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamagePushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable, int dx, int dy, int xOrg, int yOrg){ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); if(checkGCDamage (pDrawable, pGC)) { BoxRec box; box.x1 = xOrg; box.y1 = yOrg; if(!pGC->miTranslate) { box.x1 += pDrawable->x; box.y1 += pDrawable->y; } box.x2 = box.x1 + dx; box.y2 = box.y1 + dy; TRIM_BOX(box, pGC); if(BOX_NOT_EMPTY(box)) damageDamageBox (pDrawable, &box); } (*pGC->ops->PushPixels)(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamageRemoveDamage (PixmapPtr pPixmap, DamagePtr pDamage){ pixDamageRef (pPixmap); while (*pPrev) { if (*pPrev == pDamage) { *pPrev = pDamage->pNext; break; } pPrev = &(*pPrev)->pNext; }}static voiddamageInsertDamage (PixmapPtr pPixmap, DamagePtr pDamage){ pixDamageRef (pPixmap); pDamage->pNext = *pPrev; *pPrev = pDamage;}static BooldamageDestroyPixmap (PixmapPtr pPixmap){ ScreenPtr pScreen = pPixmap->drawable.pScreen; damageScrPriv(pScreen); DamagePtr pDamage; if (pPixmap->refcnt == 1) { while ((pDamage = damageGetPixPriv(pPixmap))) { damageRemoveDamage (pPixmap, pDamage); if (!pDamage->isWindow) I830DamageDestroy (pDamage); } } unwrap (pScrPriv, pScreen, DestroyPixmap); (*pScreen->DestroyPixmap) (pPixmap); wrap (pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap); return TRUE;}static voiddamagePaintWindow(WindowPtr pWindow, RegionPtr prgn, int what){ ScreenPtr pScreen = pWindow->drawable.pScreen; damageScrPriv(pScreen); /* * Painting background none doesn't actually *do* anything, so * no damage is recorded */ if ((what != PW_BACKGROUND || pWindow->backgroundState != None) && getWindowDamage (pWindow)) damageDamageRegion (&pWindow->drawable, prgn, FALSE); if(what == PW_BACKGROUND) { unwrap (pScrPriv, pScreen, PaintWindowBackground); (*pScreen->PaintWindowBackground) (pWindow, prgn, what); wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow); } else { unwrap (pScrPriv, pScreen, PaintWindowBorder); (*pScreen->PaintWindowBorder) (pWindow, prgn, what); wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow); }}static voiddamageCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc){ ScreenPtr pScreen = pWindow->drawable.pScreen; damageScrPriv(pScreen); if (getWindowDamage (pWindow)) { int dx = pWindow->drawable.x - ptOldOrg.x; int dy = pWindow->drawable.y - ptOldOrg.y; /* * The region comes in source relative, but the damage occurs * at the destination location. Translate back and forth. */ REGION_TRANSLATE (pScreen, prgnSrc, dx, dy); damageDamageRegion (&pWindow->drawable, prgnSrc, FALSE); REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy); } unwrap (pScrPriv, pScreen, CopyWindow); (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc); wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow);}GCOps damageGCOps = { damageFillSpans, damageSetSpans, damagePutImage, damageCopyArea, damageCopyPlane, damagePolyPoint, damagePolylines, damagePolySegment, damagePolyRectangle, damagePolyArc, damageFillPolygon, damagePolyFillRect, damagePolyFillArc, damagePolyText8, damagePolyText16, damageImageText8, damageImageText16, damageImageGlyphBlt, damagePolyGlyphBlt, damagePushPixels,#ifdef NEED_LINEHELPER NULL,#endif {NULL} /* devPrivate */};static voiddamageRestoreAreas (PixmapPtr pPixmap, RegionPtr prgn, int xorg, int yorg, WindowPtr pWindow){ ScreenPtr pScreen = pWindow->drawable.pScreen; damageScrPriv(pScreen); damageDamageRegion (&pWindow->drawable, prgn, FALSE); unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas); (*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgn, xorg, yorg, pWindow); wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas, damageRestoreAreas);}static voiddamageSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap){ DamagePtr pDamage; ScreenPtr pScreen = pWindow->drawable.pScreen; damageScrPriv(pScreen); if ((pDamage = damageGetWinPriv(pWindow))) { PixmapPtr pOldPixmap = (*pScreen->GetWindowPixmap) (pWindow); while (pDamage) { damageRemoveDamage (pOldPixmap, pDamage); pDamage = pDamage->pNextWin; } } unwrap (pScrPriv, pScreen, SetWindowPixmap); (*pScreen->SetWindowPixmap) (pWindow, pPixmap); wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap); if ((pDamage = damageGetWinPriv(pWindow))) { while (pDamage) { damageInsertDamage (pPixmap, pDamage); pDamage = pDamage->pNextWin; } }}static BooldamageDestroyWindow (WindowPtr pWindow){ DamagePtr pDamage; ScreenPtr pScreen = pWindow->drawable.pScreen; Bool ret; damageScrPriv(pScreen); while ((pDamage = damageGetWinPriv(pWindow))) { I830DamageUnregister (&pWindow->drawable, pDamage); I830DamageDestroy (pDamage); } unwrap (pScrPriv, pScreen, DestroyWindow); ret = (*pScreen->DestroyWindow) (pWindow); wrap (pScrPriv, pScreen, DestroyWindow, damageDestroyWindow); return ret;}static BooldamageCloseScreen (int i, ScreenPtr pScreen){ damageScrPriv(pScreen); unwrap (pScrPriv, pScreen, DestroyPixmap); unwrap (pScrPriv, pScreen, CreateGC); unwrap (pScrPriv, pScreen, PaintWindowBackground); unwrap (pScrPriv, pScreen, PaintWindowBorder); unwrap (pScrPriv, pScreen, CopyWindow); unwrap (pScrPriv, pScreen, CloseScreen); unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas); xfree (pScrPriv); return (*pScreen->CloseScreen) (i, pScreen);}int damageScrPrivateIndex;int damagePixPrivateIndex;int damageGCPrivateIndex;int damageWinPrivateIndex;int damageGeneration;BoolI830DamageSetup (ScreenPtr pScreen){ DamageScrPrivPtr pScrPriv;#ifdef RENDER PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);#endif if (damageGeneration != serverGeneration) { damageScrPrivateIndex = AllocateScreenPrivateIndex (); if (damageScrPrivateIndex == -1) return FALSE; damageGCPrivateIndex = AllocateGCPrivateIndex (); if (damageGCPrivateIndex == -1) return FALSE; damagePixPrivateIndex = AllocatePixmapPrivateIndex (); if (damagePixPrivateIndex == -1) return FALSE; damageWinPrivateIndex = AllocateWindowPrivateIndex (); if (damageWinPrivateIndex == -1) return FALSE; damageGeneration = serverGeneration; } if (pScreen->devPrivates[damageScrPrivateIndex].ptr) return TRUE; if (!AllocateGCPrivate (pScreen, damageGCPrivateIndex, sizeof (DamageGCPrivRec))) return FALSE; if (!AllocatePixmapPrivate (pScreen, damagePixPrivateIndex, 0)) return FALSE; if (!AllocateWindowPrivate (pScreen, damageWinPrivateIndex, 0)) return FALSE; pScrPriv = (DamageScrPrivPtr) xalloc (sizeof (DamageScrPrivRec)); if (!pScrPriv) return FALSE; pScrPriv->internalLevel = 0; wrap (pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap); wrap (pScrPriv, pScreen, CreateGC, damageCreateGC); wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow); wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow); wrap (pScrPriv, pScreen, DestroyWindow, damageDestroyWindow); wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap); wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow); wrap (pScrPriv, pScreen, CloseScreen, damageCloseScreen); wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas, damageRestoreAreas);#ifdef RENDER if (ps) { wrap (pScrPriv, ps, Glyphs, damageGlyphs); wrap (pScrPriv, ps, Composite, damageComposite); }#endif pScreen->devPrivates[damageScrPrivateIndex].ptr = (pointer) pScrPriv; return TRUE;}DamagePtrI830DamageCreate (DamageReportFunc damageReport, DamageDestroyFunc damageDestroy, DamageReportLevel damageLevel, Bool isInternal, void *closure){ DamagePtr pDamage; pDamage = xalloc (sizeof (DamageRec)); if (!pDamage) return 0; pDamage->pNext = 0; pDamage->pNextWin = 0; REGION_INIT(pScreen, &pDamage->damage, NullBox, 0); pDamage->damageLevel = damageLevel; pDamage->isInternal = isInternal; pDamage->closure = closure; pDamage->isWindow = FALSE; pDamage->pDrawable = 0; pDamage->damageReport = damageReport; pDamage->damageDestroy = damageDestroy; return pDamage;}voidI830DamageRegister (DrawablePtr pDrawable, DamagePtr pDamage){ if (pDrawable->type == DRAWABLE_WINDOW) { WindowPtr pWindow = (WindowPtr) pDrawable; winDamageRef(pWindow); pDamage->pNextWin = *pPrev; *pPrev = pDamage; pDamage->isWindow = TRUE; } else pDamage->isWindow = FALSE; pDamage->pDrawable = pDrawable; damageInsertDamage (GetDrawablePixmap (pDrawable), pDamage);}voidI830DamageDrawInternal (ScreenPtr pScreen, Bool enable){ damageScrPriv (pScreen); pScrPriv->internalLevel += enable ? 1 : -1;}voidI830DamageUnregister (DrawablePtr pDrawable, DamagePtr pDamage){ if (pDrawable->type == DRAWABLE_WINDOW) { WindowPtr pWindow = (WindowPtr) pDrawable; winDamageRef (pWindow); while (*pPrev) { if (*pPrev == pDamage) { *pPrev = pDamage->pNextWin; break; } pPrev = &(*pPrev)->pNextWin; } } pDamage->pDrawable = 0; damageRemoveDamage (GetDrawablePixmap (pDrawable), pDamage);}voidI830DamageDestroy (DamagePtr pDamage){ if (pDamage->damageDestroy) (*pDamage->damageDestroy) (pDamage, pDamage->closure); REGION_UNINIT (pScreen, &pDamage->damage); xfree (pDamage);}BoolI830DamageSubtract (DamagePtr pDamage, const RegionPtr pRegion){ RegionPtr pClip; RegionRec pixmapClip; DrawablePtr pDrawable = pDamage->pDrawable; REGION_SUBTRACT (pScreen, &pDamage->damage, &pDamage->damage, pRegion); if (pDrawable) { if (pDrawable->type == DRAWABLE_WINDOW) pClip = &((WindowPtr) pDrawable)->borderClip; else { BoxRec box; box.x1 = pDrawable->x; box.y1 = pDrawable->y; box.x2 = pDrawable->x + pDrawable->width; box.y2 = pDrawable->y + pDrawable->height; REGION_INIT (pScren, &pixmapClip, &box, 1); pClip = &pixmapClip; } REGION_TRANSLATE (pScreen, &pDamage->damage, pDrawable->x, pDrawable->y); REGION_INTERSECT (pScreen, &pDamage->damage, &pDamage->damage, pClip); REGION_TRANSLATE (pScreen, &pDamage->damage, -pDrawable->x, -pDrawable->y); } return REGION_NOTEMPTY (pScreen, &pDamage->damage);}voidI830DamageEmpty (DamagePtr pDamage){ REGION_EMPTY (pScreen, &pDamage->damage);}RegionPtrI830DamageRegion (DamagePtr pDamage){ return &pDamage->damage;}voidI830DamageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion){ damageDamageRegion (pDrawable, pRegion, FALSE);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?