VirtualBox

Ticket #12318: 0001-damaged-for-the-shadowfb-will-be-now-done-completely.patch

File 0001-damaged-for-the-shadowfb-will-be-now-done-completely.patch, 9.7 KB (added by gandi_gk, 11 years ago)

patch for shadowfb damage routines in xorg

  • hw/xfree86/shadowfb/shadow.c

    From 47db93d03248d464a50323d890c073125ba368f4 Mon Sep 17 00:00:00 2001
    From: Andreas Kasberger <kasberger@heidenhain.de>
    Date: Tue, 29 Oct 2013 07:44:34 +0100
    Subject: [PATCH] damaged for the shadowfb will be now done completely.
     Previously e.g glyphs were not updated correctly in all places. Needed for
     virtual box
    
    ---
     hw/xfree86/shadowfb/shadow.c   | 233 +++++++++++++++++++++++++++++++++++++++++
     hw/xfree86/shadowfb/shadowfb.h |   0
     2 files changed, 233 insertions(+)
     mode change 100644 => 100755 hw/xfree86/shadowfb/shadow.c
     mode change 100644 => 100755 hw/xfree86/shadowfb/shadowfb.h
    
    diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c
    old mode 100644
    new mode 100755
    index 6145017..7d1eb8c
    a b  
    2727#include "shadowfb.h"
    2828
    2929#include "picturestr.h"
     30#include "mipict.h"
    3031
    3132static Bool ShadowCloseScreen(ScreenPtr pScreen);
    3233static void ShadowCopyWindow(WindowPtr pWin,
    static void ShadowComposite(CARD8 op,  
    4748                            INT16 xDst,
    4849                            INT16 yDst, CARD16 width, CARD16 height);
    4950
     51static void ShadowGlyphs(CARD8 op,
     52                            PicturePtr pSrc,
     53                            PicturePtr pDst,
     54                            PictFormatPtr maskFormat,
     55                            INT16 xSrc,
     56                            INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr * glyphs);
     57
     58static void ShadowAddTraps(PicturePtr pPicture,
     59                            INT16 x_off,
     60                            INT16 y_off,
     61                            int ntrap,
     62                            xTrap * traps);
     63
     64static void ShadowTriangles(CARD8 op,
     65                            PicturePtr pSrc,
     66                            PicturePtr pDst,
     67                            PictFormatPtr maskFormat,
     68                            INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris);
     69static void ShadowTrapezoids(CARD8 op,
     70                            PicturePtr pSrc,
     71                            PicturePtr pDst,
     72                            PictFormatPtr maskFormat,
     73                            INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid * traps);
     74
     75
     76
    5077typedef struct {
    5178    ScrnInfoPtr pScrn;
    5279    RefreshAreaFuncPtr preRefresh;
    typedef struct {  
    5683    CreateGCProcPtr CreateGC;
    5784    ModifyPixmapHeaderProcPtr ModifyPixmapHeader;
    5885    CompositeProcPtr Composite;
     86    GlyphsProcPtr Glyphs;
     87    AddTrapsProcPtr AddTraps;
     88    TrapezoidsProcPtr Trapezoids;
     89    TrianglesProcPtr Triangles;
    5990    Bool (*EnterVT) (ScrnInfoPtr);
    6091    void (*LeaveVT) (ScrnInfoPtr);
    6192    Bool vtSema;
    ShadowFBInit2(ScreenPtr pScreen,  
    178209    if (ps) {
    179210        pPriv->Composite = ps->Composite;
    180211        ps->Composite = ShadowComposite;
     212        pPriv->Glyphs = ps->Glyphs;
     213        ps->Glyphs = ShadowGlyphs;
     214        pPriv->AddTraps = ps->AddTraps;
     215        ps->AddTraps = ShadowAddTraps;
     216        pPriv->Triangles = ps->Triangles;
     217        ps->Triangles = ShadowTriangles;
     218        pPriv->Trapezoids = ps->Trapezoids;
     219        ps->Trapezoids = ShadowTrapezoids;
    181220    }
    182221
    183222    return TRUE;
    ShadowCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgn)  
    284323    }
    285324}
    286325
     326
     327static void ShadowTriangles(CARD8 op,
     328                            PicturePtr pSrc,
     329                            PicturePtr pDst,
     330                            PictFormatPtr maskFormat,
     331                            INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
     332{
     333    ScreenPtr pScreen = pDst->pDrawable->pScreen;
     334    PictureScreenPtr ps = GetPictureScreen(pScreen);
     335    ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
     336    BoxRec box;
     337    Bool boxNotEmpty = FALSE;
     338    if (pPriv->vtSema && pDst->pDrawable->type == DRAWABLE_WINDOW) {
     339        miTriangleBounds(ntris, tris, &box);
     340        if (BOX_NOT_EMPTY(box)) {
     341            int dx=RegionExtents(pDst->pCompositeClip)->x1;
     342            int dy=RegionExtents(pDst->pCompositeClip)->y1;
     343            box.x1+=dx; box.x2+=dx;
     344            box.y1+=dy; box.y2+=dy;
     345            if (pPriv->preRefresh)
     346                (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
     347            boxNotEmpty = TRUE;
     348        }
     349    }
     350    ps->Triangles = pPriv->Triangles;
     351    (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntris, tris);
     352    ps->Triangles = ShadowTriangles;
     353
     354    if (pPriv->postRefresh && boxNotEmpty) {
     355        (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
     356    }
     357}
     358
     359
     360
     361static void ShadowTrapezoids(CARD8 op,
     362                            PicturePtr pSrc,
     363                            PicturePtr pDst,
     364                            PictFormatPtr maskFormat,
     365                            INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid * traps)
     366{
     367    ScreenPtr pScreen = pDst->pDrawable->pScreen;
     368    PictureScreenPtr ps = GetPictureScreen(pScreen);
     369    ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
     370    BoxRec box;
     371    Bool boxNotEmpty = FALSE;
     372    if (pPriv->vtSema && pDst->pDrawable->type == DRAWABLE_WINDOW) {
     373        miTrapezoidBounds(ntrap, traps, &box);
     374        if (BOX_NOT_EMPTY((box))) {
     375            int dx=RegionExtents(pDst->pCompositeClip)->x1;
     376            int dy=RegionExtents(pDst->pCompositeClip)->y1;
     377            box.x1+=dx; box.x2+=dx;
     378            box.y1+=dy; box.y2+=dy;
     379            if (pPriv->preRefresh)
     380                (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
     381            boxNotEmpty = TRUE;
     382        }
     383    }
     384    ps->Trapezoids = pPriv->Trapezoids;
     385    (*ps->Trapezoids) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntrap, traps);
     386    ps->Trapezoids = ShadowTrapezoids;
     387
     388    if (pPriv->postRefresh && boxNotEmpty) {
     389        (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
     390    }
     391}
     392
     393static void
     394ShadowAddTraps(PicturePtr pPicture,
     395                INT16 x_off,
     396                INT16 y_off,
     397                int ntrap,
     398                xTrap * traps)
     399{
     400    ScreenPtr pScreen = pPicture->pDrawable->pScreen;
     401    PictureScreenPtr ps = GetPictureScreen(pScreen);
     402    ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
     403    BoxRec box;
     404    Bool boxNotEmpty = FALSE;
     405    int i;
     406    int x, y;
     407    xTrap *t = traps;
     408    if (pPriv->vtSema && pPicture->pDrawable->type == DRAWABLE_WINDOW) {
     409        box.x1 = 32767;
     410        box.y1 = 32767;
     411        box.x2 = -32767;
     412        box.y2 = -32767;
     413        x = pPicture->pDrawable->x + x_off;
     414        y = pPicture->pDrawable->y + y_off;
     415        for (i = 0; i < ntrap; i++) {
     416            pixman_fixed_t l = min(t->top.l, t->bot.l);
     417            pixman_fixed_t r = max(t->top.r, t->bot.r);
     418            int x1 = x + pixman_fixed_to_int(l);
     419            int x2 = x + pixman_fixed_to_int(pixman_fixed_ceil(r));
     420            int y1 = y + pixman_fixed_to_int(t->top.y);
     421            int y2 = y + pixman_fixed_to_int(pixman_fixed_ceil(t->bot.y));
     422
     423            if (x1 < box.x1)
     424                box.x1 = x1;
     425            if (x2 > box.x2)
     426                box.x2 = x2;
     427            if (y1 < box.y1)
     428                box.y1 = y1;
     429            if (y2 > box.y2)
     430                box.y2 = y2;
     431        }
     432        if (BOX_NOT_EMPTY(box)) {
     433            if (pPriv->preRefresh)
     434                (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
     435            boxNotEmpty = TRUE;
     436        }
     437    }
     438    ps->AddTraps = pPriv->AddTraps;
     439    (*ps->AddTraps) (pPicture, x_off, y_off, ntrap, traps);
     440    ps->AddTraps = ShadowAddTraps;
     441
     442    if (pPriv->postRefresh && boxNotEmpty) {
     443        (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
     444    }
     445}
     446
     447
     448static void
     449ShadowGlyphs(CARD8 op,
     450                PicturePtr pSrc,
     451                PicturePtr pDst,
     452                PictFormatPtr maskFormat,
     453                INT16 xSrc,
     454                INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr * glyphs)
     455{
     456    ScreenPtr pScreen = pDst->pDrawable->pScreen;
     457    ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
     458    PictureScreenPtr ps = GetPictureScreen(pScreen);
     459    int x, y;
     460    int n;
     461    GlyphPtr glyph;
     462    BoxRec box;
     463    int x1, y1, x2, y2;
     464    Bool boxNotEmpty = FALSE;
     465
     466    if (pPriv->vtSema && pDst->pDrawable->type == DRAWABLE_WINDOW) {
     467        int nlistTmp = nlist;
     468        GlyphListPtr listTmp = list;
     469        GlyphPtr *glyphsTmp = glyphs;
     470
     471        box.x1 = 32767;
     472        box.y1 = 32767;
     473        box.x2 = -32767;
     474        box.y2 = -32767;
     475        x = pDst->pDrawable->x;
     476        y = pDst->pDrawable->y;
     477        while (nlistTmp--) {
     478            x += listTmp->xOff;
     479            y += listTmp->yOff;
     480            n = listTmp->len;
     481            while (n--) {
     482                glyph = *glyphsTmp++;
     483                x1 = x - glyph->info.x;
     484                y1 = y - glyph->info.y;
     485                x2 = x1 + glyph->info.width;
     486                y2 = y1 + glyph->info.height;
     487                if (x1 < box.x1)
     488                    box.x1 = x1;
     489                if (y1 < box.y1)
     490                    box.y1 = y1;
     491                if (x2 > box.x2)
     492                    box.x2 = x2;
     493                if (y2 > box.y2)
     494                    box.y2 = y2;
     495                x += glyph->info.xOff;
     496                y += glyph->info.yOff;
     497            }
     498            listTmp++;
     499        }
     500
     501
     502
     503        if (BOX_NOT_EMPTY(box)) {
     504            if (pPriv->preRefresh)
     505                (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
     506            boxNotEmpty = TRUE;
     507        }
     508    }
     509
     510    ps->Glyphs = pPriv->Glyphs;
     511    (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
     512    ps->Glyphs = ShadowGlyphs;
     513
     514    if (pPriv->postRefresh && boxNotEmpty) {
     515        (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
     516    }
     517}
     518
     519
    287520static void
    288521ShadowComposite(CARD8 op,
    289522                PicturePtr pSrc,

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy