VirtualBox

Changeset 45132 in vbox for trunk/src/VBox/HostServices


Ignore:
Timestamp:
Mar 21, 2013 4:11:28 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84435
Message:

crOpenGL: seamles mode support impl; bugfizes & cleanup

Location:
trunk/src/VBox/HostServices/SharedOpenGL
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserver/crservice.cpp

    r44528 r45132  
    10741074            Assert(sizeof(RTRECT)==4*sizeof(GLint));
    10751075
    1076             rc = crVBoxServerSetRootVisibleRegion(paParms[1].u.uint32, (GLint*)paParms[0].u.pointer.addr);
     1076            rc = crVBoxServerSetRootVisibleRegion(paParms[1].u.uint32, (const RTRECT*)paParms[0].u.pointer.addr);
    10771077            break;
    10781078        }
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h

    r45066 r45132  
    116116void crServerMuralTerm(CRMuralInfo *mural);
    117117void crServerMuralSize(CRMuralInfo *mural, GLint width, GLint height);
     118int crServerMuralSynchRootVr(CRMuralInfo *mural, uint32_t *pcRects, const RTRECT **ppRects);
    118119
    119120GLint crServerGenerateID(GLint *pCounter);
     
    150151                && mural->width
    151152                && mural->height
    152                 && CrVrScrCompositorEntryIsInList(&mural->CEntry);
     153                && !mural->fRootVrOn ? CrVrScrCompositorEntryIsInList(&mural->CEntry) : CrVrScrCompositorEntryIsInList(&mural->RootVrCEntry);
    153154}
    154155
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r45096 r45132  
    349349    cr_server.dummyMuralTable = crAllocHashtable();
    350350
     351    cr_server.fRootVrOn = GL_FALSE;
     352    VBoxVrListInit(&cr_server.RootVr);
     353    crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint));
     354
    351355    crServerInitDispatch();
    352356    crStateDiffAPI( &(cr_server.head_spu->dispatch_table) );
     
    433437
    434438    cr_server.dummyMuralTable = crAllocHashtable();
     439
     440    cr_server.fRootVrOn = GL_FALSE;
     441    VBoxVrListInit(&cr_server.RootVr);
     442    crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint));
    435443
    436444    crServerSetVBoxConfigurationHGCM();
     
    23282336}
    23292337
    2330 DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, GLint *pRects)
    2331 {
    2332     renderspuSetRootVisibleRegion(cRects, pRects);
     2338static int crVBoxServerUpdateMuralRootVisibleRegion(CRMuralInfo *pMI)
     2339{
     2340    GLboolean fForcePresent;
     2341    uint32_t cRects;
     2342    const RTRECT *pRects;
     2343    int rc;
     2344
     2345    fForcePresent = crServerVBoxCompositionPresentNeeded(pMI);
     2346
     2347    crServerVBoxCompositionDisable(pMI);
     2348
     2349    if (cr_server.fRootVrOn)
     2350    {
     2351        if (!pMI->fRootVrOn)
     2352        {
     2353            VBOXVR_TEXTURE Tex = {0};
     2354
     2355            rc = CrVrScrCompositorInit(&pMI->RootVrCompositor);
     2356            if (!RT_SUCCESS(rc))
     2357            {
     2358                crWarning("CrVrScrCompositorInit failed, rc %d", rc);
     2359                return rc;
     2360            }
     2361
     2362
     2363            Tex.width = pMI->width;
     2364            Tex.height = pMI->height;
     2365            Tex.target = GL_TEXTURE_2D;
     2366            Tex.hwid = 0;
     2367            CrVrScrCompositorEntryInit(&pMI->RootVrCEntry, &Tex);
     2368        }
     2369
     2370        rc = crServerMuralSynchRootVr(pMI, &cRects, &pRects);
     2371        if (!RT_SUCCESS(rc))
     2372        {
     2373            crWarning("crServerMuralSynchRootVr failed, rc %d", rc);
     2374            return rc;
     2375        }
     2376
     2377        if (!pMI->fRootVrOn)
     2378            CrVrScrCompositorEntryTexUpdate(&pMI->RootVrCEntry,  CrVrScrCompositorEntryTexGet(&pMI->CEntry));
     2379    }
     2380    else
     2381    {
     2382        CrVrScrCompositorTerm(&pMI->RootVrCompositor);
     2383        rc = CrVrScrCompositorEntryRegionsGet(&pMI->Compositor, &pMI->CEntry, &cRects, NULL, &pRects);
     2384        if (!RT_SUCCESS(rc))
     2385        {
     2386            crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
     2387            return rc;
     2388        }
     2389
     2390        /* CEntry should always be in sync */
     2391//        CrVrScrCompositorEntryTexUpdate(&pMI->CEntry,  CrVrScrCompositorEntryTexGet(&pMI->RootVrCEntry));
     2392    }
     2393
     2394    cr_server.head_spu->dispatch_table.WindowVisibleRegion(pMI->spuWindow, cRects, pRects);
     2395
     2396    if (pMI->pvOutputRedirectInstance)
     2397    {
     2398        /* @todo the code assumes that RTRECT == four GLInts. */
     2399        cr_server.outputRedirect.CRORVisibleRegion(pMI->pvOutputRedirectInstance,
     2400                                                   cRects, pRects);
     2401    }
     2402
     2403    pMI->fRootVrOn = cr_server.fRootVrOn;
     2404
     2405    crServerVBoxCompositionReenable(pMI, fForcePresent);
     2406
     2407    return rc;
     2408}
     2409
     2410static void crVBoxServerSetRootVisibleRegionCB(unsigned long key, void *data1, void *data2)
     2411{
     2412    CRMuralInfo *pMI = (CRMuralInfo*) data1;
     2413
     2414    if (!pMI->CreateInfo.externalID)
     2415        return;
     2416    (void) data2;
     2417
     2418    crVBoxServerUpdateMuralRootVisibleRegion(pMI);
     2419}
     2420
     2421DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, const RTRECT *pRects)
     2422{
     2423    int32_t rc = VINF_SUCCESS;
     2424
     2425    /* non-zero rects pointer indicate rects are present and switched on
     2426     * i.e. cRects==0 and pRects!=NULL means root visible regioning is ON and there are no visible regions,
     2427     * while pRects==NULL means root visible regioning is OFF, i.e. everything is visible */
     2428    if (pRects)
     2429    {
     2430        crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint));
     2431        rc = VBoxVrListRectsSet(&cr_server.RootVr, cRects, pRects, NULL);
     2432        if (!RT_SUCCESS(rc))
     2433        {
     2434            crWarning("VBoxVrListRectsSet failed! rc %d", rc);
     2435            return rc;
     2436        }
     2437
     2438        cr_server.fRootVrOn = GL_TRUE;
     2439    }
     2440    else
     2441    {
     2442        if (!cr_server.fRootVrOn)
     2443            return VINF_SUCCESS;
     2444
     2445        VBoxVrListClear(&cr_server.RootVr);
     2446
     2447        cr_server.fRootVrOn = GL_FALSE;
     2448    }
     2449
     2450    crHashtableWalk(cr_server.muralTable, crVBoxServerSetRootVisibleRegionCB, NULL);
    23332451
    23342452    return VINF_SUCCESS;
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_muralfbo.c

    r45066 r45132  
    325325    SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
    326326    CRContextInfo *pMuralContextInfo;
     327    VBOXVR_TEXTURE Tex;
    327328
    328329    CRASSERT(mural->aidFBOs[0]==0);
     
    429430
    430431    CRASSERT(mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
    431     CrVrScrCompositorEntryTexNameUpdate(&mural->CEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
     432
     433    Tex.width = mural->width;
     434    Tex.height = mural->height;
     435    Tex.target = GL_TEXTURE_2D;
     436    Tex.hwid = mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)];
     437
     438    CrVrScrCompositorEntryTexUpdate(&mural->CEntry, &Tex);
     439
     440    if (mural->fRootVrOn)
     441        CrVrScrCompositorEntryTexUpdate(&mural->RootVrCEntry, &Tex);
    432442}
    433443
     
    538548    crStateSwitchPrepare(NULL, curCtx, idDrawFBO, idReadFBO);
    539549
    540     cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, &mural->Compositor, &mural->CEntry);
     550    if (!mural->fRootVrOn)
     551        cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, &mural->Compositor, &mural->CEntry);
     552    else
     553        cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, &mural->RootVrCompositor, &mural->RootVrCEntry);
    541554
    542555    crStateSwitchPostprocess(curCtx, NULL, idDrawFBO, idReadFBO);
     
    677690GLboolean crServerIsRedirectedToFBO()
    678691{
     692#ifdef DEBUG_misha
     693    Assert(cr_server.curClient);
     694    if (cr_server.curClient)
     695    {
     696        Assert(cr_server.curClient->currentMural == cr_server.currentMural);
     697        Assert(cr_server.curClient->currentCtxInfo == cr_server.currentCtxInfo);
     698    }
     699#endif
    679700    return cr_server.curClient
    680701           && cr_server.curClient->currentMural
     
    711732    Assert(mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
    712733    CrVrScrCompositorEntryTexNameUpdate(&mural->CEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
    713 }
     734    if (mural->fRootVrOn)
     735        CrVrScrCompositorEntryTexNameUpdate(&mural->RootVrCEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
     736}
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp

    r44766 r45132  
    107107{
    108108    CrVrScrCompositorLock(&pDisplay->Compositor);
    109     int rc = CrVrScrCompositorEntryRegionsSet(&pDisplay->Compositor, &pEntry->CEntry, pPos, cRegions, paRegions);
     109    int rc = CrVrScrCompositorEntryRegionsSet(&pDisplay->Compositor, &pEntry->CEntry, pPos, cRegions, paRegions, NULL);
    110110    CrVrScrCompositorUnlock(&pDisplay->Compositor);
    111111    return rc;
     
    115115{
    116116    CrVrScrCompositorLock(&pDisplay->Compositor);
    117     int rc = CrVrScrCompositorEntryRegionsAdd(&pDisplay->Compositor, &pEntry->CEntry, pPos, cRegions, paRegions);
     117    int rc = CrVrScrCompositorEntryRegionsAdd(&pDisplay->Compositor, &pEntry->CEntry, pPos, cRegions, paRegions, NULL);
    118118    CrVrScrCompositorUnlock(&pDisplay->Compositor);
    119119    return rc;
     
    141141}
    142142
    143 void CrDpEntryInit(PCR_DISPLAY_ENTRY pEntry, const PVBOXVR_TEXTURE pTextureData)
     143void CrDpEntryInit(PCR_DISPLAY_ENTRY pEntry, const VBOXVR_TEXTURE *pTextureData)
    144144{
    145145    CrVrScrCompositorEntryInit(&pEntry->CEntry, pTextureData);
     
    317317
    318318        GLuint uid = pTObj->hwid;
     319        CRASSERT(uid);
    319320        cr_server.head_spu->dispatch_table.BindTexture(pTexture->target, uid);
    320321    }
     
    363364
    364365        GLuint uid = pTObj->hwid;
     366        CRASSERT(uid);
    365367        cr_server.head_spu->dispatch_table.BindTexture(pTexture->target, uid);
    366368    }
     
    385387
    386388void SERVER_DISPATCH_APIENTRY
    387 crServerDispatchVBoxTexPresent(GLuint texture, GLuint cfg, GLint xPos, GLint yPos, GLint cRects, GLint *pRects)
     389crServerDispatchVBoxTexPresent(GLuint texture, GLuint cfg, GLint xPos, GLint yPos, GLint cRects, const GLint *pRects)
    388390{
    389391    uint32_t idScreen = CR_PRESENT_GET_SCREEN(cfg);
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c

    r45066 r45132  
    2424    GLint spuWindow;
    2525    VBOXVR_TEXTURE Tex = {0};
    26 
    27     int rc = CrVrScrCompositorInit(&mural->Compositor);
     26    RTRECT Rect;
     27    int rc;
     28
     29    crMemset(mural, 0, sizeof (*mural));
     30
     31    rc = CrVrScrCompositorInit(&mural->Compositor);
    2832    if (!RT_SUCCESS(rc))
    2933    {
    3034        crWarning("CrVrScrCompositorInit failed, rc %d", rc);
    3135        return -1;
     36    }
     37
     38    if (cr_server.fRootVrOn)
     39    {
     40        rc = CrVrScrCompositorInit(&mural->RootVrCompositor);
     41        if (!RT_SUCCESS(rc))
     42        {
     43            crWarning("CrVrScrCompositorInit failed, rc %d", rc);
     44            return -1;
     45        }
    3246    }
    3347
     
    3852    if (spuWindow < 0) {
    3953        CrVrScrCompositorTerm(&mural->Compositor);
     54        if (cr_server.fRootVrOn)
     55            CrVrScrCompositorTerm(&mural->RootVrCompositor);
    4056        return spuWindow;
    4157    }
     
    4965    Tex.hwid = 0;
    5066    CrVrScrCompositorEntryInit(&mural->CEntry, &Tex);
     67
     68    if (cr_server.fRootVrOn)
     69    {
     70        CrVrScrCompositorEntryInit(&mural->RootVrCEntry, &Tex);
     71        mural->fRootVrOn = GL_TRUE;
     72    }
    5173
    5274    defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
     
    83105
    84106    crServerSetupOutputRedirect(mural);
     107
     108    Rect.xLeft = 0;
     109    Rect.xRight = mural->width;
     110    Rect.yTop = 0;
     111    Rect.yBottom = mural->height;
     112    rc = CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->CEntry, NULL, 1, &Rect, NULL);
     113    if (!RT_SUCCESS(rc))
     114    {
     115        crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     116        return -1;
     117    }
     118
     119    if (mural->fRootVrOn)
     120    {
     121        uint32_t cRects;
     122        const RTRECT *pRects;
     123        int rc = crServerMuralSynchRootVr(mural, &cRects, &pRects);
     124        if (RT_SUCCESS(rc))
     125        {
     126            if (cRects != 1
     127                    || pRects[0].xLeft != 0 || pRects[0].yTop != 0
     128                    || pRects[0].xRight != mural->width || pRects[0].yBottom != mural->height)
     129            {
     130                /* do visible rects only ig they differ from the default */
     131                cr_server.head_spu->dispatch_table.WindowVisibleRegion(mural->spuWindow, cRects, pRects);
     132
     133                if (mural->pvOutputRedirectInstance)
     134                {
     135                    /* @todo the code assumes that RTRECT == four GLInts. */
     136                    cr_server.outputRedirect.CRORVisibleRegion(mural->pvOutputRedirectInstance,
     137                                                               cRects, pRects);
     138                }
     139            }
     140        }
     141    }
    85142
    86143    return windowID;
     
    165222}
    166223
     224static bool crServerVBoxTranslateIntersectRect(CRMuralInfo *mural, const RTRECT *pSrcRect, PRTRECT pDstRect)
     225{
     226    int32_t xLeft = RT_MAX(mural->gX, pSrcRect->xRight);
     227    int32_t yTop = RT_MAX(mural->gY, pSrcRect->yBottom);
     228    int32_t xRight = RT_MIN(mural->gX + mural->width, pSrcRect->xLeft);
     229    int32_t yBottom = RT_MIN(mural->gY + mural->height, pSrcRect->yTop);
     230
     231    if (xLeft < xRight && yTop < yBottom)
     232    {
     233        pDstRect->xLeft = xLeft;
     234        pDstRect->yTop = yTop;
     235        pDstRect->xRight = xRight;
     236        pDstRect->yBottom = yBottom;
     237        return true;
     238    }
     239
     240    return false;
     241}
     242
     243static void crServerVBoxRootVrTranslateForMural(CRMuralInfo *mural)
     244{
     245    int32_t dx = cr_server.RootVrCurPoint.x - mural->gX;
     246    int32_t dy = cr_server.RootVrCurPoint.y - mural->gY;
     247
     248    VBoxVrListTranslate(&cr_server.RootVr, dx, dy);
     249}
     250
    167251static int crServerRemoveClientWindow(CRClient *pClient, GLint window)
    168252{
     
    316400    CrVrScrCompositorTerm(&mural->Compositor);
    317401
     402    if (mural->fRootVrOn)
     403        CrVrScrCompositorTerm(&mural->RootVrCompositor);
     404
    318405    crHashtableDelete(cr_server.muralTable, window, crFree);
    319406}
    320407
     408int crServerMuralSynchRootVr(CRMuralInfo *mural, uint32_t *pcRects, const RTRECT **ppRects)
     409{
     410    int rc;
     411
     412    rc = CrVrScrCompositorEntryRegionsGet(&mural->Compositor, &mural->CEntry, pcRects, NULL, ppRects);
     413    if (!RT_SUCCESS(rc))
     414    {
     415        crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
     416        return rc;
     417    }
     418
     419    rc = CrVrScrCompositorEntryRegionsSet(&mural->RootVrCompositor, &mural->RootVrCEntry, NULL, *pcRects, *ppRects, NULL);
     420    if (!RT_SUCCESS(rc))
     421    {
     422        crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     423        return rc;
     424    }
     425
     426    crServerVBoxRootVrTranslateForMural(mural);
     427    rc = CrVrScrCompositorEntryListIntersect(&mural->RootVrCompositor, &mural->RootVrCEntry, &cr_server.RootVr, NULL);
     428    if (!RT_SUCCESS(rc))
     429    {
     430        crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     431        return rc;
     432    }
     433
     434    rc = CrVrScrCompositorEntryRegionsGet(&mural->RootVrCompositor, &mural->RootVrCEntry, pcRects, NULL, ppRects);
     435    if (!RT_SUCCESS(rc))
     436    {
     437        crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
     438        return rc;
     439    }
     440
     441    return VINF_SUCCESS;
     442}
     443
    321444void crServerMuralSize(CRMuralInfo *mural, GLint width, GLint height)
    322445{
    323446    if (mural->width != width || mural->height != height)
    324447    {
     448        uint32_t cRects;
     449        const RTRECT *pRects;
    325450        RTRECT Rect;
    326451        VBOXVR_TEXTURE Tex;
     452        int rc = VINF_SUCCESS;
    327453        Tex.width = width;
    328454        Tex.height = height;
     
    346472        /* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */
    347473        /* CrVrScrCompositorLock(&mural->Compositor); */
    348         CrVrScrCompositorEntryRemove(&mural->Compositor, &mural->CEntry);
     474        rc = CrVrScrCompositorEntryRemove(&mural->Compositor, &mural->CEntry);
     475        if (!RT_SUCCESS(rc))
     476        {
     477            crWarning("CrVrScrCompositorEntryRemove failed, rc %d", rc);
     478            return;
     479        }
    349480        CrVrScrCompositorEntryInit(&mural->CEntry, &Tex);
    350481        /* initially set regions to all visible since this is what some guest assume
     
    354485        Rect.yTop = 0;
    355486        Rect.yBottom = height;
    356         CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->CEntry, NULL, 1, &Rect);
     487        rc = CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->CEntry, NULL, 1, &Rect, NULL);
     488        if (!RT_SUCCESS(rc))
     489        {
     490            crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     491            return;
     492        }
    357493        /* CrVrScrCompositorUnlock(&mural->Compositor); */
    358494        mural->width = width;
     
    365501        }
    366502
     503        if (mural->fRootVrOn)
     504        {
     505            rc = CrVrScrCompositorEntryRemove(&mural->RootVrCompositor, &mural->RootVrCEntry);
     506            if (!RT_SUCCESS(rc))
     507            {
     508                crWarning("CrVrScrCompositorEntryRemove failed, rc %d", rc);
     509                return;
     510            }
     511            CrVrScrCompositorEntryInit(&mural->RootVrCEntry, &Tex);
     512            /* initially set regions to all visible since this is what some guest assume
     513             * and will not post any more visible regions command */
     514            Rect.xLeft = 0;
     515            Rect.xRight = width;
     516            Rect.yTop = 0;
     517            Rect.yBottom = height;
     518            rc = CrVrScrCompositorEntryRegionsSet(&mural->RootVrCompositor, &mural->RootVrCEntry, NULL, 1, &Rect, NULL);
     519            if (!RT_SUCCESS(rc))
     520            {
     521                crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     522                return;
     523            }
     524
     525            crServerVBoxRootVrTranslateForMural(mural);
     526            rc = CrVrScrCompositorEntryListIntersect(&mural->RootVrCompositor, &mural->RootVrCEntry, &cr_server.RootVr, NULL);
     527            if (!RT_SUCCESS(rc))
     528            {
     529                crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     530                return;
     531            }
     532
     533            rc = CrVrScrCompositorEntryRegionsGet(&mural->RootVrCompositor, &mural->RootVrCEntry, &cRects, NULL, &pRects);
     534            if (!RT_SUCCESS(rc))
     535            {
     536                crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
     537                return;
     538            }
     539        }
     540        else
     541        {
     542            rc = CrVrScrCompositorEntryRegionsGet(&mural->Compositor, &mural->CEntry, &cRects, NULL, &pRects);
     543            if (!RT_SUCCESS(rc))
     544            {
     545                crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
     546                return;
     547            }
     548        }
     549
    367550        crServerCheckMuralGeometry(mural);
    368551
    369552        cr_server.head_spu->dispatch_table.WindowSize(mural->spuWindow, width, height);
     553
     554        cr_server.head_spu->dispatch_table.WindowVisibleRegion(mural->spuWindow, cRects, pRects);
     555
     556        if (mural->pvOutputRedirectInstance)
     557        {
     558            /* @todo the code assumes that RTRECT == four GLInts. */
     559            cr_server.outputRedirect.CRORVisibleRegion(mural->pvOutputRedirectInstance,
     560                                                       cRects, (RTRECT *)pRects);
     561        }
    370562
    371563        /* 3. (so far not needed for resize, but in case it is in the future) re-set the compositor (see above comment) */
     
    404596{
    405597    CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
    406     RTPOINT Pos;
     598    GLboolean fForcePresent = GL_FALSE;
    407599    /*  crDebug("CRServer: Window %d pos %d, %d", window, x, y);*/
    408600    if (!mural) {
     
    427619        /* 2. do necessary modifications (see above comment) */
    428620        /* NOTE: we can do it even if mural->fUseFBO == CR_SERVER_REDIR_NONE to make sure the compositor data is always up to date */
    429         Pos.x = x;
    430         Pos.y = y;
    431 
    432         /* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */
    433         /* CrVrScrCompositorLock(&mural->Compositor); */
    434         /* no need to set position because the position is relative to window */
    435         /*CrVrScrCompositorEntryPosSet(&mural->Compositor, &mural->CEntry, &Pos);*/
    436         /*CrVrScrCompositorUnlock(&mural->Compositor);*/
    437 
    438         mural->gX = x;
    439         mural->gY = y;
     621
     622        if (mural->gX != x || mural->gY != y)
     623        {
     624            if (mural->fRootVrOn)
     625            {
     626                fForcePresent = crServerVBoxCompositionPresentNeeded(mural);
     627            }
     628
     629            mural->gX = x;
     630            mural->gY = y;
     631
     632            /* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */
     633            /* CrVrScrCompositorLock(&mural->Compositor); */
     634            /* no need to set position because the position is relative to window */
     635            /*CrVrScrCompositorEntryPosSet(&mural->Compositor, &mural->CEntry, &Pos);*/
     636            /*CrVrScrCompositorUnlock(&mural->Compositor);*/
     637
     638            if (mural->fRootVrOn)
     639            {
     640                uint32_t cRects;
     641                const RTRECT *pRects;
     642                int rc = crServerMuralSynchRootVr(mural, &cRects, &pRects);
     643
     644                if (RT_SUCCESS(rc))
     645                {
     646                    cr_server.head_spu->dispatch_table.WindowVisibleRegion(mural->spuWindow, cRects, pRects);
     647
     648                    if (mural->pvOutputRedirectInstance)
     649                    {
     650                        /* @todo the code assumes that RTRECT == four GLInts. */
     651                        cr_server.outputRedirect.CRORVisibleRegion(mural->pvOutputRedirectInstance,
     652                                                                   cRects, pRects);
     653                    }
     654                }
     655                else
     656                {
     657                    crWarning("crServerMuralSynchRootVr failed, rc %d", rc);
     658                }
     659            }
     660        }
    440661
    441662        crServerCheckMuralGeometry(mural);
    442663
    443664        /* 3. re-set the compositor (see above comment) */
    444         crServerVBoxCompositionReenable(mural, GL_FALSE);
     665        crServerVBoxCompositionReenable(mural, fForcePresent);
    445666    }
    446667}
    447668
    448669void SERVER_DISPATCH_APIENTRY
    449 crServerDispatchWindowVisibleRegion( GLint window, GLint cRects, GLint *pRects )
     670crServerDispatchWindowVisibleRegion( GLint window, GLint cRects, const GLint *pRects )
    450671{
    451672    CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
    452673    GLboolean fForcePresent = crServerVBoxCompositionPresentNeeded(mural);
     674    bool fRegionsChanged = false;
     675    int rc = VINF_SUCCESS;
    453676    if (!mural) {
    454677#if EXTRA_WARN
     
    470693
    471694    /* 2. do necessary modifications (see above comment) */
     695    if (mural->pVisibleRects)
     696    {
     697        crFree(mural->pVisibleRects);
     698        mural->pVisibleRects = NULL;
     699    }
     700
     701    mural->cVisibleRects = cRects;
     702    mural->bReceivedRects = GL_TRUE;
     703    if (cRects)
     704    {
     705        mural->pVisibleRects = (GLint*) crAlloc(4*sizeof(GLint)*cRects);
     706        if (!mural->pVisibleRects)
     707        {
     708            crError("Out of memory in crServerDispatchWindowVisibleRegion");
     709        }
     710        crMemcpy(mural->pVisibleRects, pRects, 4*sizeof(GLint)*cRects);
     711    }
     712
    472713    /* NOTE: we can do it even if mural->fUseFBO = CR_SERVER_REDIR_NONE to make sure the compositor data is always up to date */
    473714    /* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */
    474715    /* CrVrScrCompositorLock(&mural->Compositor); */
    475     CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->CEntry, NULL, cRects, (const RTRECT *)pRects);
     716    rc = CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->CEntry, NULL, cRects, (const RTRECT *)pRects, &fRegionsChanged);
    476717    /*CrVrScrCompositorUnlock(&mural->Compositor);*/
    477 
    478     if (mural->pVisibleRects)
    479     {
    480         crFree(mural->pVisibleRects);
    481         mural->pVisibleRects = NULL;
    482     }
    483 
    484     mural->cVisibleRects = cRects;
    485     mural->bReceivedRects = GL_TRUE;
    486     if (cRects)
    487     {
    488         mural->pVisibleRects = (GLint*) crAlloc(4*sizeof(GLint)*cRects);
    489         if (!mural->pVisibleRects)
    490         {
    491             crError("Out of memory in crServerDispatchWindowVisibleRegion");
    492         }
    493         crMemcpy(mural->pVisibleRects, pRects, 4*sizeof(GLint)*cRects);
    494     }
    495 
    496     cr_server.head_spu->dispatch_table.WindowVisibleRegion(mural->spuWindow, cRects, pRects);
    497 
    498     if (mural->pvOutputRedirectInstance)
    499     {
    500         /* @todo the code assumes that RTRECT == four GLInts. */
    501         cr_server.outputRedirect.CRORVisibleRegion(mural->pvOutputRedirectInstance,
    502                                                    cRects, (RTRECT *)pRects);
     718    if (!RT_SUCCESS(rc))
     719    {
     720        crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     721        return;
     722    }
     723
     724    if (fRegionsChanged)
     725    {
     726        if (mural->fRootVrOn)
     727        {
     728            rc = CrVrScrCompositorEntryRegionsSet(&mural->RootVrCompositor, &mural->RootVrCEntry, NULL, cRects, (const RTRECT *)pRects, NULL);
     729            if (!RT_SUCCESS(rc))
     730            {
     731                crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     732                return;
     733            }
     734
     735            crServerVBoxRootVrTranslateForMural(mural);
     736            rc = CrVrScrCompositorEntryListIntersect(&mural->RootVrCompositor, &mural->RootVrCEntry, &cr_server.RootVr, NULL);
     737            if (!RT_SUCCESS(rc))
     738            {
     739                crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     740                return;
     741            }
     742
     743            rc = CrVrScrCompositorEntryRegionsGet(&mural->RootVrCompositor, &mural->RootVrCEntry, &cRects, NULL, (const RTRECT **)&pRects);
     744            if (!RT_SUCCESS(rc))
     745            {
     746                crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
     747                return;
     748            }
     749        }
     750        else
     751        {
     752            rc = CrVrScrCompositorEntryRegionsGet(&mural->Compositor, &mural->CEntry, &cRects, NULL, (const RTRECT **)&pRects);
     753            if (!RT_SUCCESS(rc))
     754            {
     755                crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
     756                return;
     757            }
     758        }
     759
     760        cr_server.head_spu->dispatch_table.WindowVisibleRegion(mural->spuWindow, cRects, pRects);
     761
     762        if (mural->pvOutputRedirectInstance)
     763        {
     764            /* @todo the code assumes that RTRECT == four GLInts. */
     765            cr_server.outputRedirect.CRORVisibleRegion(mural->pvOutputRedirectInstance,
     766                                                       cRects, (RTRECT *)pRects);
     767        }
    503768    }
    504769
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c

    r45066 r45132  
    597597
    598598static void RENDER_APIENTRY
    599 renderspuWindowVisibleRegion(GLint win, GLint cRects, GLint *pRects)
     599renderspuWindowVisibleRegion(GLint win, GLint cRects, const GLint *pRects)
    600600{
    601601    WindowInfo *window;
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h

    r45066 r45132  
    378378extern void renderspu_SystemGetMaxWindowSize( WindowInfo *window, GLint *w, GLint *h );
    379379extern void renderspu_SystemWindowPosition( WindowInfo *window, GLint x, GLint y );
    380 extern void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, GLint* pRects);
    381 extern void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *window);
    382 #ifdef RT_OS_DARWIN
    383 extern void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *pRects);
    384 #endif
     380extern void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, const GLint* pRects);
    385381
    386382#ifdef GLX
     
    428424#endif
    429425DECLEXPORT(void) renderspuSetWindowId(uint64_t winId);
    430 DECLEXPORT(void) renderspuSetRootVisibleRegion(GLint cRects, GLint *pRects);
    431426DECLEXPORT(void) renderspuReparentWindow(GLint window);
    432427#ifdef __cplusplus
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c

    r45036 r45132  
    6565        DEBUG_MSG_RESULT(result, text); \
    6666    }
     67
     68static void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *window);
     69static void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *pRects);
    6770
    6871/* In some case (like compiz which doesn't provide us with clipping regions) we
     
    701704}
    702705
    703 void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, GLint* pRects)
     706void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, const GLint* pRects)
    704707{
    705708    CRASSERT(window);
     
    736739}
    737740
    738 void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *pRects)
     741static void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *pRects)
    739742{
    740743    /* Remember the visible region of the root window if there is one */
     
    763766
    764767/*Assumes that all regions are in the guest coordinates system*/
    765 void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *window)
     768static void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *window)
    766769{
    767770    ContextInfo *c = renderspuGetWindowContext(window);
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa.c

    r45066 r45132  
    177177}
    178178
    179 void renderspu_SystemWindowVisibleRegion(WindowInfo *pWinInfo, GLint cRects, GLint* paRects)
     179void renderspu_SystemWindowVisibleRegion(WindowInfo *pWinInfo, GLint cRects, const GLint* paRects)
    180180{
    181181    CRASSERT(pWinInfo);
     
    184184}
    185185
    186 void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *paRects)
    187 {
    188 }
    189 
    190186void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *pWinInfo)
    191187{
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.h

    r45066 r45132  
    4646
    4747void cocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx);
    48 void cocoaViewSetVisibleRegion(NativeNSViewRef pView, GLint cRects, GLint* paRects);
     48void cocoaViewSetVisibleRegion(NativeNSViewRef pView, GLint cRects, const GLint* paRects);
    4949void cocoaViewPresentComposition(NativeNSViewRef pView, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry);
    5050
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m

    r45066 r45132  
    349349
    350350- (void)clearVisibleRegions;
    351 - (void)setVisibleRegions:(GLint)cRects paRects:(GLint*)paRects;
     351- (void)setVisibleRegions:(GLint)cRects paRects:(const GLint*)paRects;
    352352
    353353- (NSView*)dockTileScreen;
     
    13801380}
    13811381
    1382 - (void)setVisibleRegions:(GLint)cRects paRects:(GLint*)paRects
     1382- (void)setVisibleRegions:(GLint)cRects paRects:(const GLint*)paRects
    13831383{
    13841384    GLint cOldRects = m_cClipRects;
     
    17291729}
    17301730
    1731 void cocoaViewSetVisibleRegion(NativeNSViewRef pView, GLint cRects, GLint* paRects)
     1731void cocoaViewSetVisibleRegion(NativeNSViewRef pView, GLint cRects, const GLint* paRects)
    17321732{
    17331733    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c

    r45066 r45132  
    18931893
    18941894void
    1895 renderspu_SystemWindowVisibleRegion( WindowInfo *window, GLint cRects, GLint *pRects )
     1895renderspu_SystemWindowVisibleRegion( WindowInfo *window, GLint cRects, const GLint *pRects )
    18961896{
    18971897#ifdef USE_OSMESA
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c

    r44913 r45132  
    538538    render_spu_parent_window_id = winId;
    539539}
    540 
    541 #ifdef RT_OS_DARWIN
    542 static void renderspuWindowVisibleRegionCB(unsigned long key, void *data1, void *data2)
    543 {
    544     WindowInfo *window = (WindowInfo *) data1;
    545     CRASSERT(window);
    546 
    547     renderspu_SystemWindowApplyVisibleRegion(window);
    548 }
    549 #endif
    550 
    551 DECLEXPORT(void) renderspuSetRootVisibleRegion(GLint cRects, GLint *pRects)
    552 {
    553 #ifdef RT_OS_DARWIN
    554     renderspu_SystemSetRootVisibleRegion(cRects, pRects);
    555 
    556     crHashtableWalk(render_spu.windowTable, renderspuWindowVisibleRegionCB, NULL);
    557 #endif
    558 }
    559 
    560 #ifndef RT_OS_DARWIN
    561 void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *window)
    562 {
    563 }
    564 #endif
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c

    r45066 r45132  
    15521552}
    15531553
    1554 void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, GLint* pRects)
     1554void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, const GLint* pRects)
    15551555{
    15561556    GLint i;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette