VirtualBox

Ignore:
Timestamp:
Jul 1, 2013 2:02:37 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86869
Message:

crOpenGL: TexPresent fixes

Location:
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h

    r46802 r46885  
    113113GLint crServerDispatchCreateContextEx(const char *dpyName, GLint visualBits, GLint shareCtx, GLint preloadCtxID, int32_t internalID);
    114114GLint crServerDispatchWindowCreateEx(const char *dpyName, GLint visBits, GLint preloadWinID);
    115 GLint crServerMuralInit(CRMuralInfo *mural, const char *dpyName, GLint visBits, GLint preloadWinID, GLboolean fSetVRegs);
     115GLint crServerMuralInit(CRMuralInfo *mural, const char *dpyName, GLint visBits, GLint preloadWinID, GLboolean fUseDefaultDEntry);
    116116void crServerMuralTerm(CRMuralInfo *mural);
    117117void crServerMuralSize(CRMuralInfo *mural, GLint width, GLint height);
    118 int crServerMuralSynchRootVr(CRMuralInfo *mural, uint32_t *pcRects, const RTRECT **ppRects);
     118void crServerMutalPosition(CRMuralInfo *mural, GLint x, GLint y);
     119void crServerMuralVisibleRegion( CRMuralInfo *mural, GLint cRects, const GLint *pRects );
     120void crServerMuralShow( CRMuralInfo *mural, GLint state );
     121int crServerMuralSynchRootVr(CRMuralInfo *mural);
    119122
    120123GLint crServerGenerateID(GLint *pCounter);
     
    186189                && mural->width
    187190                && mural->height
    188                 && !mural->fRootVrOn ? CrVrScrCompositorEntryIsInList(&mural->CEntry) : CrVrScrCompositorEntryIsInList(&mural->RootVrCEntry);
     191                && !mural->fRootVrOn ? !CrVrScrCompositorIsEmpty(&mural->Compositor) : !CrVrScrCompositorIsEmpty(&mural->RootVrCompositor);
    189192}
    190193
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r46801 r46885  
    27972797        PCR_DISPLAY pDisplay = crServerDisplayGetInitialized(sIndex);
    27982798        if (pDisplay)
    2799             CrDpResize(pDisplay, w, h, w, h);
     2799            CrDpResize(pDisplay, x, y, w, h);
    28002800    }
    28012801
     
    28182818        if (!pMI->fRootVrOn)
    28192819        {
    2820             VBOXVR_TEXTURE Tex = {0};
    2821 
    2822             rc = CrVrScrCompositorInit(&pMI->RootVrCompositor);
    2823             if (!RT_SUCCESS(rc))
    2824             {
    2825                 crWarning("CrVrScrCompositorInit failed, rc %d", rc);
    2826                 goto end;
    2827             }
    2828 
    2829 
    2830             Tex.width = pMI->width;
    2831             Tex.height = pMI->height;
    2832             Tex.target = GL_TEXTURE_2D;
    2833             Tex.hwid = 0;
    2834             CrVrScrCompositorEntryInit(&pMI->RootVrCEntry, &Tex);
    2835         }
    2836 
    2837         rc = crServerMuralSynchRootVr(pMI, &cRects, &pRects);
     2820            CrVrScrCompositorInit(&pMI->RootVrCompositor);
     2821        }
     2822
     2823        rc = crServerMuralSynchRootVr(pMI);
    28382824        if (!RT_SUCCESS(rc))
    28392825        {
     
    28422828        }
    28432829
    2844         if (!pMI->fRootVrOn)
    2845         {
    2846             rc = CrVrScrCompositorEntryTexUpdate(&pMI->RootVrCompositor, &pMI->RootVrCEntry, CrVrScrCompositorEntryTexGet(&pMI->CEntry));
    2847             if (!RT_SUCCESS(rc))
    2848             {
    2849                 crWarning("CrVrScrCompositorEntryTexUpdate failed, rc %d", rc);
    2850                 goto end;
    2851             }
    2852         }
    2853     }
    2854     else
    2855     {
    2856         CrVrScrCompositorTerm(&pMI->RootVrCompositor);
    2857         rc = CrVrScrCompositorEntryRegionsGet(&pMI->Compositor, &pMI->CEntry, &cRects, NULL, &pRects);
     2830        rc = CrVrScrCompositorRegionsGet(&pMI->RootVrCompositor, &cRects, NULL, &pRects, NULL);
    28582831        if (!RT_SUCCESS(rc))
    28592832        {
     
    28612834            goto end;
    28622835        }
    2863 
    2864         /* CEntry should always be in sync */
    2865 //        rc = CrVrScrCompositorEntryTexUpdate(&pMI->Compositor, &pMI->CEntry,  CrVrScrCompositorEntryTexGet(&pMI->RootVrCEntry));
    2866 //        if (!RT_SUCCESS(rc))
    2867 //        {
    2868 //            crWarning("CrVrScrCompositorEntryTexUpdate failed, rc %d", rc);
    2869 //            goto end;
    2870 //        }
     2836    }
     2837    else
     2838    {
     2839        CrVrScrCompositorClear(&pMI->RootVrCompositor);
     2840        rc = CrVrScrCompositorRegionsGet(&pMI->Compositor, &cRects, NULL, &pRects, NULL);
     2841        if (!RT_SUCCESS(rc))
     2842        {
     2843            crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
     2844            goto end;
     2845        }
    28712846    }
    28722847
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_muralfbo.c

    r46343 r46885  
    9090            const RTRECT *pRects;
    9191
    92             int rc = CrVrScrCompositorEntryRegionsGet(&mural->Compositor, &mural->CEntry, &cRects, NULL, &pRects);
     92            int rc = CrVrScrCompositorRegionsGet(&mural->Compositor, &cRects, NULL, &pRects, NULL);
    9393            if (!RT_SUCCESS(rc))
    9494            {
     
    120120    CRASSERT(mural->spuWindow != CR_RENDER_DEFAULT_WINDOW_ID);
    121121
     122    crServerVBoxCompositionDisableEnter(mural);
     123
    122124    if (!mural->width || !mural->height)
    123125    {
    124126        crServerRedirMuralFBO(mural, CR_SERVER_REDIR_F_NONE);
    125127        crServerDeleteMuralFBO(mural);
    126         return;
    127     }
    128 
    129     crServerVBoxCompositionDisableEnter(mural);
     128        crServerVBoxCompositionDisableLeave(mural, GL_FALSE);
     129        return;
     130    }
    130131
    131132    tlS = crServerGetPointScreen(mural->gX, mural->gY);
     
    208209    else if (overlappingScreenCount > 1)
    209210        fPresentMode = (fPresentMode | CR_SERVER_REDIR_F_FBO_RAM_VMFB | cr_server.fVramPresentModeDefault) & ~CR_SERVER_REDIR_F_DISPLAY;
     211
     212    if (!mural->fUseDefaultDEntry)
     213    {
     214        /* only display matters */
     215        fPresentMode &= CR_SERVER_REDIR_F_DISPLAY;
     216    }
    210217
    211218    fPresentMode = crServerRedirModeAdjust(fPresentMode);
     
    453460    CRASSERT(mural->aidFBOs[0]==0);
    454461    CRASSERT(mural->aidFBOs[1]==0);
    455     CRASSERT(mural->width == mural->CEntry.Tex.width);
    456     CRASSERT(mural->height == mural->CEntry.Tex.height);
     462    CRASSERT(mural->fUseDefaultDEntry);
     463    CRASSERT(mural->width == mural->DefaultDEntry.CEntry.Tex.width);
     464    CRASSERT(mural->height == mural->DefaultDEntry.CEntry.Tex.height);
    457465
    458466    pMuralContextInfo = cr_server.currentCtxInfo;
     
    566574    CRASSERT(mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
    567575
    568     CrVrScrCompositorEntryTexNameUpdate(&mural->CEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
    569 
    570     if (mural->fRootVrOn)
    571         CrVrScrCompositorEntryTexNameUpdate(&mural->RootVrCEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
     576    CrVrScrCompositorEntryTexNameUpdate(&mural->DefaultDEntry.CEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
     577
     578//    if (mural->fRootVrOn)
     579//        CrVrScrCompositorEntryTexNameUpdate(&mural->DefaultDEntry.RootVrCEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
    572580}
    573581
     
    668676    CRASSERT(curCtx == crStateGetCurrent());
    669677
    670     Assert(mural->fPresentMode & CR_SERVER_REDIR_F_FBO);
     678    Assert((mural->fPresentMode & CR_SERVER_REDIR_F_FBO) || !mural->fUseDefaultDEntry);
    671679    Assert(mural->fPresentMode & CR_SERVER_REDIR_F_DISPLAY);
    672680
     
    687695
    688696    if (!mural->fRootVrOn)
    689         cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, &mural->Compositor, &mural->CEntry);
     697        cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, &mural->Compositor, NULL);
    690698    else
    691         cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, &mural->RootVrCompositor, &mural->RootVrCEntry);
     699        cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, &mural->RootVrCompositor, NULL);
    692700
    693701    crStateSwitchPostprocess(curCtx, NULL, idDrawFBO, idReadFBO);
     
    703711static void crServerVBoxCompositionReenable(CRMuralInfo *mural, GLboolean fForcePresent)
    704712{
    705     if ((mural->fPresentMode & (CR_SERVER_REDIR_F_FBO | CR_SERVER_REDIR_F_DISPLAY)) != (CR_SERVER_REDIR_F_FBO | CR_SERVER_REDIR_F_DISPLAY)
     713    if (!(mural->fPresentMode & CR_SERVER_REDIR_F_DISPLAY)
     714            || (mural->fUseDefaultDEntry && !(mural->fPresentMode & CR_SERVER_REDIR_F_FBO))
    706715            || !mural->fDataPresented
    707716            || (!fForcePresent
     
    10361045    }
    10371046    Assert(mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
    1038     CrVrScrCompositorEntryTexNameUpdate(&mural->CEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
     1047    Assert(mural->fUseDefaultDEntry);
     1048    CrVrScrCompositorEntryTexNameUpdate(&mural->DefaultDEntry.CEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
    10391049    if (mural->fRootVrOn)
    1040         CrVrScrCompositorEntryTexNameUpdate(&mural->RootVrCEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
    1041 }
     1050        CrVrScrCompositorEntryTexNameUpdate(&mural->DefaultDEntry.RootVrCEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
     1051}
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp

    r46801 r46885  
    6868        return VERR_GENERAL_FAILURE;
    6969    }
    70 
     70    pDisplay->fForcePresent = GL_FALSE;
    7171    return VINF_SUCCESS;
    7272}
     
    7777}
    7878
    79 void CrDpResize(PCR_DISPLAY pDisplay, uint32_t width, uint32_t height,
    80         uint32_t stretchedWidth, uint32_t stretchedHeight)
    81 {
    82     float StretchX, StretchY;
    83     StretchX = ((float)stretchedWidth)/width;
    84     StretchY = ((float)stretchedHeight)/height;
    85     crServerMuralSize(&pDisplay->Mural, stretchedWidth, stretchedHeight);
    86     CrVrScrCompositorSetStretching(&pDisplay->Mural.Compositor, StretchX, StretchY);
     79void CrDpResize(PCR_DISPLAY pDisplay, int32_t xPos, int32_t yPos, uint32_t width, uint32_t height)
     80{
     81    crServerMuralVisibleRegion(&pDisplay->Mural, 0, NULL);
     82    crServerMutalPosition(&pDisplay->Mural, xPos, yPos);
     83    crServerMuralSize(&pDisplay->Mural, width, height);
     84    crServerMuralShow(&pDisplay->Mural, GL_TRUE);
     85    CrVrScrCompositorSetStretching(&pDisplay->Mural.Compositor, 1., 1.);
    8786}
    8887
    8988int CrDpEntryRegionsSet(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
    9089{
    91     int rc = CrVrScrCompositorEntryRegionsSet(&pDisplay->Mural.Compositor, pEntry ? &pEntry->CEntry : NULL, pPos, cRegions, paRegions, NULL);
     90    int rc = CrVrScrCompositorEntryRegionsSet(&pDisplay->Mural.Compositor, pEntry ? &pEntry->CEntry : NULL, pPos, cRegions, paRegions, false, NULL);
    9291    return rc;
    9392}
    9493
     94void crDbgDumpRect(uint32_t i, const RTRECT *pRect)
     95{
     96    crDebug("%d: (%d;%d) X (%d;%d)", i, pRect->xLeft, pRect->yTop, pRect->xRight, pRect->yBottom);
     97}
     98
     99void crDbgDumpRects(uint32_t cRects, const RTRECT *paRects)
     100{
     101    crDebug("Dumping rects (%d)", cRects);
     102    for (uint32_t i = 0; i < cRects; ++i)
     103    {
     104        crDbgDumpRect(i, &paRects[i]);
     105    }
     106    crDebug("End Dumping rects (%d)", cRects);
     107}
     108
    95109int CrDpEntryRegionsAdd(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
    96110{
    97     int rc = CrVrScrCompositorEntryRegionsAdd(&pDisplay->Mural.Compositor, pEntry ? &pEntry->CEntry : NULL, pPos, cRegions, paRegions, NULL);
     111    uint32_t fChangeFlags = 0;
     112    int rc = CrVrScrCompositorEntryRegionsAdd(&pDisplay->Mural.Compositor, pEntry ? &pEntry->CEntry : NULL, pPos, cRegions, paRegions, false, &fChangeFlags);
     113    if (RT_SUCCESS(rc))
     114    {
     115        if (fChangeFlags & VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED)
     116        {
     117            uint32_t cRects;
     118            const RTRECT *pRects;
     119            rc = CrVrScrCompositorRegionsGet(&pDisplay->Mural.Compositor, &cRects, NULL, &pRects, NULL);
     120            if (RT_SUCCESS(rc))
     121                crServerMuralVisibleRegion(&pDisplay->Mural, cRects, (GLint *)pRects);
     122            else
     123                crWarning("CrVrScrCompositorRegionsGet failed, rc %d", rc);
     124        }
     125    }
     126    else
     127        crWarning("CrVrScrCompositorEntryRegionsAdd failed, rc %d", rc);
     128
    98129    return rc;
    99130}
    100131
     132void CrDpEntryRegionsClear(PCR_DISPLAY pDisplay)
     133{
     134    bool fChanged = false;
     135    CrVrScrCompositorRegionsClear(&pDisplay->Mural.Compositor, &fChanged);
     136    if (fChanged)
     137    {
     138        crServerMuralVisibleRegion(&pDisplay->Mural, 0, NULL);
     139    }
     140}
     141
    101142void CrDpEntryInit(PCR_DISPLAY_ENTRY pEntry, const VBOXVR_TEXTURE *pTextureData)
    102143{
    103144    CrVrScrCompositorEntryInit(&pEntry->CEntry, pTextureData);
     145    CrVrScrCompositorEntryFlagsSet(&pEntry->CEntry, CRBLT_F_INVERT_SRC_YCOORDS);
     146    CrVrScrCompositorEntryInit(&pEntry->RootVrCEntry, pTextureData);
     147    CrVrScrCompositorEntryFlagsSet(&pEntry->RootVrCEntry, CRBLT_F_INVERT_SRC_YCOORDS);
    104148}
    105149
     
    111155void CrDpEnter(PCR_DISPLAY pDisplay)
    112156{
     157    pDisplay->fForcePresent = crServerVBoxCompositionPresentNeeded(&pDisplay->Mural);
    113158    crServerVBoxCompositionDisableEnter(&pDisplay->Mural);
    114159}
     
    117162{
    118163    pDisplay->Mural.fDataPresented = GL_TRUE;
    119     crServerVBoxCompositionDisableLeave(&pDisplay->Mural, GL_FALSE);
     164    crServerVBoxCompositionDisableLeave(&pDisplay->Mural, pDisplay->fForcePresent);
    120165}
    121166
     
    199244}
    200245
    201 #define CR_PRESENT_SCREEN_MASK 0xffff
    202 #define CR_PRESENT_FLAGS_OFFSET 16
    203 
    204 #define CR_PRESENT_GET_SCREEN(_cfg) ((_cfg) & CR_PRESENT_SCREEN_MASK)
    205 #define CR_PRESENT_GET_FLAGS(_cfg) ((_cfg) >> CR_PRESENT_FLAGS_OFFSET)
    206 
    207246PCR_DISPLAY crServerDisplayGetInitialized(uint32_t idScreen)
    208247{
     
    222261    if (ASMBitTest(cr_server.DisplaysInitMap, idScreen))
    223262        return &cr_server.aDispplays[idScreen];
    224 
    225     /* the display (screen id == 0) can be initialized while doing crServerCheckInitDisplayBlitter,
    226      * so re-check the bit map */
    227      if (ASMBitTest(cr_server.DisplaysInitMap, idScreen))
    228          return &cr_server.aDispplays[idScreen];
    229263
    230264     int rc = CrDpInit(&cr_server.aDispplays[idScreen]);
     
    232266     {
    233267         CrDpResize(&cr_server.aDispplays[idScreen],
    234                  cr_server.screen[idScreen].w, cr_server.screen[idScreen].h,
     268                 cr_server.screen[idScreen].x, cr_server.screen[idScreen].y,
    235269                 cr_server.screen[idScreen].w, cr_server.screen[idScreen].h);
    236270         ASMBitSet(cr_server.DisplaysInitMap, idScreen);
     
    388422    CrDpEnter(pDisplay);
    389423
    390     RTPOINT Point = {xPos, yPos};
    391     int rc = CrDpEntryRegionsAdd(pDisplay, pEntry, &Point, (uint32_t)cRects, (const RTRECT*)pRects);
    392     if (!RT_SUCCESS(rc))
    393     {
    394         crWarning("CrDpEntrySetRegions Failed rc %d", rc);
    395         return;
     424    if (!(cfg & CR_PRESENT_FLAG_CLEAR_RECTS))
     425    {
     426        RTPOINT Point = {xPos, yPos};
     427        int rc = CrDpEntryRegionsAdd(pDisplay, pEntry, &Point, (uint32_t)cRects, (const RTRECT*)pRects);
     428        if (!RT_SUCCESS(rc))
     429        {
     430            crWarning("CrDpEntrySetRegions Failed rc %d", rc);
     431            return;
     432        }
     433    }
     434    else
     435    {
     436        CrDpEntryRegionsClear(pDisplay);
    396437    }
    397438
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c

    r46801 r46885  
    1717}
    1818
    19 GLint crServerMuralInit(CRMuralInfo *mural, const char *dpyName, GLint visBits, GLint preloadWinID, GLboolean fSetVRegs)
     19GLint crServerMuralInit(CRMuralInfo *mural, const char *dpyName, GLint visBits, GLint preloadWinID, GLboolean fUseDefaultDEntry)
    2020{
    2121    CRMuralInfo *defaultMural;
     
    2323    GLint windowID = -1;
    2424    GLint spuWindow;
    25     VBOXVR_TEXTURE Tex = {0};
    2625    int rc;
    2726
    2827    crMemset(mural, 0, sizeof (*mural));
    2928
    30     rc = CrVrScrCompositorInit(&mural->Compositor);
    31     if (!RT_SUCCESS(rc))
    32     {
    33         crWarning("CrVrScrCompositorInit failed, rc %d", rc);
    34         return -1;
    35     }
     29    CrVrScrCompositorInit(&mural->Compositor);
    3630
    3731    if (cr_server.fRootVrOn)
    3832    {
    39         rc = CrVrScrCompositorInit(&mural->RootVrCompositor);
    40         if (!RT_SUCCESS(rc))
    41         {
    42             crWarning("CrVrScrCompositorInit failed, rc %d", rc);
    43             return -1;
    44         }
     33        CrVrScrCompositorInit(&mural->RootVrCompositor);
    4534    }
    4635
     
    5039    spuWindow = cr_server.head_spu->dispatch_table.WindowCreate( dpyName, visBits );
    5140    if (spuWindow < 0) {
    52         CrVrScrCompositorTerm(&mural->Compositor);
     41        CrVrScrCompositorClear(&mural->Compositor);
    5342        if (cr_server.fRootVrOn)
    54             CrVrScrCompositorTerm(&mural->RootVrCompositor);
     43            CrVrScrCompositorClear(&mural->RootVrCompositor);
    5544        return spuWindow;
    5645    }
     
    5948    cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, spuWindow, GL_INT, 2, dims);
    6049
    61     Tex.width = dims[0];
    62     Tex.height = dims[1];
    63     Tex.target = GL_TEXTURE_2D;
    64     Tex.hwid = 0;
    65     CrVrScrCompositorEntryInit(&mural->CEntry, &Tex);
    66 
    67     if (cr_server.fRootVrOn)
    68     {
    69         CrVrScrCompositorEntryInit(&mural->RootVrCEntry, &Tex);
    70         mural->fRootVrOn = GL_TRUE;
     50    if (fUseDefaultDEntry)
     51    {
     52        VBOXVR_TEXTURE Tex = {0};
     53        Tex.width = dims[0];
     54        Tex.height = dims[1];
     55        Tex.target = GL_TEXTURE_2D;
     56        Tex.hwid = 0;
     57        CrVrScrCompositorEntryInit(&mural->DefaultDEntry.CEntry, &Tex);
     58
     59        if (cr_server.fRootVrOn)
     60        {
     61            CrVrScrCompositorEntryInit(&mural->DefaultDEntry.RootVrCEntry, &Tex);
     62            mural->fRootVrOn = GL_TRUE;
     63        }
    7164    }
    7265
     
    8174    mural->screenId = 0;
    8275    mural->fHasParentWindow = !!cr_server.screen[0].winID;
    83     mural->bVisible = cr_server.bWindowsInitiallyHidden;
     76    mural->bVisible = !cr_server.bWindowsInitiallyHidden;
    8477    mural->fPresentMode = CR_SERVER_REDIR_F_NONE;
    8578
     
    10295    CR_STATE_SHAREDOBJ_USAGE_INIT(mural);
    10396
    104     if (fSetVRegs)
     97    if (fUseDefaultDEntry)
    10598    {
    10699        RTRECT Rect;
     
    109102        Rect.yTop = 0;
    110103        Rect.yBottom = mural->height;
    111         rc = CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->CEntry, NULL, 1, &Rect, NULL);
     104        rc = CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->DefaultDEntry.CEntry, NULL, 1, &Rect, false, NULL);
    112105        if (!RT_SUCCESS(rc))
    113106        {
     
    123116        uint32_t cRects;
    124117        const RTRECT *pRects;
    125         int rc = crServerMuralSynchRootVr(mural, &cRects, &pRects);
     118        int rc = crServerMuralSynchRootVr(mural);
    126119        if (RT_SUCCESS(rc))
    127120        {
    128             if (cRects != 1
    129                     || pRects[0].xLeft != 0 || pRects[0].yTop != 0
    130                     || pRects[0].xRight != mural->width || pRects[0].yBottom != mural->height)
    131             {
    132                 /* do visible rects only ig they differ from the default */
    133                 cr_server.head_spu->dispatch_table.WindowVisibleRegion(mural->spuWindow, cRects, (const GLint*)pRects);
     121            rc = CrVrScrCompositorRegionsGet(&mural->RootVrCompositor, &cRects, NULL, &pRects, NULL);
     122            if (RT_SUCCESS(rc))
     123            {
     124                if (cRects != 1
     125                        || pRects[0].xLeft != 0 || pRects[0].yTop != 0
     126                        || pRects[0].xRight != mural->width || pRects[0].yBottom != mural->height)
     127                {
     128                    /* do visible rects only ig they differ from the default */
     129                    cr_server.head_spu->dispatch_table.WindowVisibleRegion(mural->spuWindow, cRects, (const GLint*)pRects);
     130                }
     131            }
     132            else
     133            {
     134                crWarning("CrVrScrCompositorRegionsGet failed, rc %d", rc);
    134135            }
    135136        }
     
    296297        crFree(mural->CreateInfo.pszDpyName);
    297298
    298     CrVrScrCompositorTerm(&mural->Compositor);
     299    CrVrScrCompositorClear(&mural->Compositor);
    299300
    300301    if (mural->fRootVrOn)
    301         CrVrScrCompositorTerm(&mural->RootVrCompositor);
     302        CrVrScrCompositorClear(&mural->RootVrCompositor);
    302303}
    303304
     
    401402}
    402403
    403 int crServerMuralSynchRootVr(CRMuralInfo *mural, uint32_t *pcRects, const RTRECT **ppRects)
     404#define CR_DENTRY_FROM_CENTRY(_pCentry) ((CR_DISPLAY_ENTRY*)((uint8_t*)(_pCentry) - RT_OFFSETOF(CR_DISPLAY_ENTRY, CEntry)))
     405
     406static DECLCALLBACK(VBOXVR_SCR_COMPOSITOR_ENTRY*) crServerMuralGetRootVrCEntry(VBOXVR_SCR_COMPOSITOR_ENTRY*pEntry, void *pvContext)
     407{
     408    CR_DISPLAY_ENTRY *pDEntry = CR_DENTRY_FROM_CENTRY(pEntry);
     409    CrVrScrCompositorEntryInit(&pDEntry->RootVrCEntry, CrVrScrCompositorEntryTexGet(pEntry));
     410    return &pDEntry->RootVrCEntry;
     411}
     412
     413int crServerMuralSynchRootVr(CRMuralInfo *mural)
    404414{
    405415    int rc;
    406416
    407     rc = CrVrScrCompositorEntryRegionsGet(&mural->Compositor, &mural->CEntry, pcRects, NULL, ppRects);
     417    crServerVBoxRootVrTranslateForMural(mural);
     418
     419    rc = CrVrScrCompositorIntersectedList(&mural->Compositor, &cr_server.RootVr, &mural->RootVrCompositor, crServerMuralGetRootVrCEntry, NULL, NULL);
    408420    if (!RT_SUCCESS(rc))
    409421    {
    410         crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
    411         return rc;
    412     }
    413 
    414     rc = CrVrScrCompositorEntryRegionsSet(&mural->RootVrCompositor, &mural->RootVrCEntry, NULL, *pcRects, *ppRects, NULL);
    415     if (!RT_SUCCESS(rc))
    416     {
    417         crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
    418         return rc;
    419     }
    420 
    421     crServerVBoxRootVrTranslateForMural(mural);
    422     rc = CrVrScrCompositorEntryListIntersect(&mural->RootVrCompositor, &mural->RootVrCEntry, &cr_server.RootVr, NULL);
    423     if (!RT_SUCCESS(rc))
    424     {
    425         crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
    426         return rc;
    427     }
    428 
    429     rc = CrVrScrCompositorEntryRegionsGet(&mural->RootVrCompositor, &mural->RootVrCEntry, pcRects, NULL, ppRects);
    430     if (!RT_SUCCESS(rc))
    431     {
    432         crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
     422        crWarning("CrVrScrCompositorIntersectedList failed, rc %d", rc);
    433423        return rc;
    434424    }
     
    468458    /* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */
    469459    /* CrVrScrCompositorLock(&mural->Compositor); */
    470     if (!mural->bReceivedRects)
    471     {
    472         rc = CrVrScrCompositorEntryRemove(&mural->Compositor, &mural->CEntry);
    473         if (!RT_SUCCESS(rc))
    474         {
    475             crWarning("CrVrScrCompositorEntryRemove failed, rc %d", rc);
    476             goto end;
    477         }
    478         CrVrScrCompositorEntryInit(&mural->CEntry, &Tex);
    479         /* initially set regions to all visible since this is what some guest assume
    480          * and will not post any more visible regions command */
    481         Rect.xLeft = 0;
    482         Rect.xRight = width;
    483         Rect.yTop = 0;
    484         Rect.yBottom = height;
    485         rc = CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->CEntry, NULL, 1, &Rect, NULL);
    486         if (!RT_SUCCESS(rc))
    487         {
    488             crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
    489             goto end;
     460    if (mural->fUseDefaultDEntry)
     461    {
     462        if (!mural->bReceivedRects)
     463        {
     464            rc = CrVrScrCompositorEntryRemove(&mural->Compositor, &mural->DefaultDEntry.CEntry);
     465            if (!RT_SUCCESS(rc))
     466            {
     467                crWarning("CrVrScrCompositorEntryRemove failed, rc %d", rc);
     468                goto end;
     469            }
     470            CrVrScrCompositorEntryInit(&mural->DefaultDEntry.CEntry, &Tex);
     471            /* initially set regions to all visible since this is what some guest assume
     472             * and will not post any more visible regions command */
     473            Rect.xLeft = 0;
     474            Rect.xRight = width;
     475            Rect.yTop = 0;
     476            Rect.yBottom = height;
     477            rc = CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->DefaultDEntry.CEntry, NULL, 1, &Rect, false, NULL);
     478            if (!RT_SUCCESS(rc))
     479            {
     480                crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     481                goto end;
     482            }
     483        }
     484        else
     485        {
     486            rc = CrVrScrCompositorEntryTexUpdate(&mural->Compositor, &mural->DefaultDEntry.CEntry, &Tex);
     487            if (!RT_SUCCESS(rc))
     488            {
     489                crWarning("CrVrScrCompositorEntryTexUpdate failed, rc %d", rc);
     490                goto end;
     491            }
    490492        }
    491493    }
    492494    else
    493495    {
    494         rc = CrVrScrCompositorEntryTexUpdate(&mural->Compositor, &mural->CEntry, &Tex);
    495         if (!RT_SUCCESS(rc))
    496         {
    497             crWarning("CrVrScrCompositorEntryTexUpdate failed, rc %d", rc);
    498             goto end;
    499         }
     496        CrVrScrCompositorClear(&mural->Compositor);
    500497    }
    501498
     
    512509    }
    513510
    514     rc = CrVrScrCompositorEntryRegionsGet(&mural->Compositor, &mural->CEntry, &cRects, NULL, &pRects);
     511    rc = CrVrScrCompositorRegionsGet(&mural->Compositor, &cRects, NULL, &pRects, NULL);
    515512    if (!RT_SUCCESS(rc))
    516513    {
    517         crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
     514        crWarning("CrVrScrCompositorRegionsGet failed, rc %d", rc);
    518515        goto end;
    519516    }
     
    521518    if (mural->fRootVrOn)
    522519    {
    523         rc = CrVrScrCompositorEntryRemove(&mural->RootVrCompositor, &mural->RootVrCEntry);
     520        rc = crServerMuralSynchRootVr(mural);
    524521        if (!RT_SUCCESS(rc))
    525522        {
    526             crWarning("CrVrScrCompositorEntryRemove failed, rc %d", rc);
     523            crWarning("crServerMuralSynchRootVr failed, rc %d", rc);
    527524            goto end;
    528525        }
    529         CrVrScrCompositorEntryInit(&mural->RootVrCEntry, &Tex);
    530 
    531         rc = CrVrScrCompositorEntryRegionsSet(&mural->RootVrCompositor, &mural->RootVrCEntry, NULL, cRects, pRects, NULL);
     526
     527        rc = CrVrScrCompositorRegionsGet(&mural->RootVrCompositor, &cRects, NULL, &pRects, NULL);
    532528        if (!RT_SUCCESS(rc))
    533529        {
    534             crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     530            crWarning("CrVrScrCompositorRegionsGet failed, rc %d", rc);
    535531            goto end;
    536532        }
    537 
    538         crServerVBoxRootVrTranslateForMural(mural);
    539         rc = CrVrScrCompositorEntryListIntersect(&mural->RootVrCompositor, &mural->RootVrCEntry, &cr_server.RootVr, NULL);
    540         if (!RT_SUCCESS(rc))
    541         {
    542             crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
    543             goto end;
    544         }
    545 
    546         rc = CrVrScrCompositorEntryRegionsGet(&mural->RootVrCompositor, &mural->RootVrCEntry, &cRects, NULL, &pRects);
    547         if (!RT_SUCCESS(rc))
    548         {
    549             crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
    550             goto end;
    551         }
    552     }
    553     else
    554     {
    555533    }
    556534
     
    563541    if (mural->pvOutputRedirectInstance)
    564542    {
    565         if (mural->fRootVrOn)
    566         {
    567             rc = CrVrScrCompositorEntryRegionsGet(&mural->Compositor, &mural->CEntry, &cRects, NULL, &pRects);
     543        /* always get non-stretched rects for output redirect */
     544//        if (mural->fRootVrOn)
     545        {
     546            rc = CrVrScrCompositorRegionsGet(&mural->Compositor, &cRects, NULL, NULL, &pRects);
    568547            if (!RT_SUCCESS(rc))
    569548            {
    570                 crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
     549                crWarning("CrVrScrCompositorRegionsGet failed, rc %d", rc);
    571550                goto end;
    572551            }
     
    609588}
    610589
    611 
    612 void SERVER_DISPATCH_APIENTRY
    613 crServerDispatchWindowPosition( GLint window, GLint x, GLint y )
    614 {
    615     CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
     590void crServerMutalPosition(CRMuralInfo *mural, GLint x, GLint y)
     591{
    616592    GLboolean fForcePresent = GL_FALSE;
    617593    /*  crDebug("CRServer: Window %d pos %d, %d", window, x, y);*/
    618     if (!mural) {
    619 #if EXTRA_WARN
    620          crWarning("CRServer: invalid window %d passed to WindowPosition()", window);
    621 #endif
    622          return;
    623     }
     594
    624595//    if (mural->gX != x || mural->gY != y)
    625596    {
     
    648619            mural->gY = y;
    649620
    650             /* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */
    651             /* CrVrScrCompositorLock(&mural->Compositor); */
    652621            /* no need to set position because the position is relative to window */
    653622            /*CrVrScrCompositorEntryPosSet(&mural->Compositor, &mural->CEntry, &Pos);*/
    654             /*CrVrScrCompositorUnlock(&mural->Compositor);*/
    655623
    656624            if (mural->fRootVrOn)
     
    658626                uint32_t cRects;
    659627                const RTRECT *pRects;
    660                 int rc = crServerMuralSynchRootVr(mural, &cRects, &pRects);
    661 
     628                int rc = crServerMuralSynchRootVr(mural);
    662629                if (RT_SUCCESS(rc))
    663630                {
    664                     cr_server.head_spu->dispatch_table.WindowVisibleRegion(mural->spuWindow, cRects, (const GLint*)pRects);
     631                    rc = CrVrScrCompositorRegionsGet(&mural->RootVrCompositor, &cRects, NULL, &pRects, NULL);
     632                    if (RT_SUCCESS(rc))
     633                    {
     634                        cr_server.head_spu->dispatch_table.WindowVisibleRegion(mural->spuWindow, cRects, (const GLint*)pRects);
     635                    }
     636                    else
     637                    {
     638                        crWarning("CrVrScrCompositorRegionsGet failed, rc %d", rc);
     639                    }
    665640                }
    666641                else
     
    679654
    680655void SERVER_DISPATCH_APIENTRY
    681 crServerDispatchWindowVisibleRegion( GLint window, GLint cRects, const GLint *pRects )
     656crServerDispatchWindowPosition( GLint window, GLint x, GLint y )
    682657{
    683658    CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
     659    if (!mural) {
     660#if EXTRA_WARN
     661         crWarning("CRServer: invalid window %d passed to WindowPosition()", window);
     662#endif
     663         return;
     664    }
     665    crServerMutalPosition(mural, x, y);
     666}
     667
     668void crServerMuralVisibleRegion( CRMuralInfo *mural, GLint cRects, const GLint *pRects )
     669{
    684670    GLboolean fForcePresent = crServerVBoxCompositionPresentNeeded(mural);
    685671    bool fRegionsChanged = false;
    686672    int rc = VINF_SUCCESS;
    687     if (!mural) {
    688 #if EXTRA_WARN
    689          crWarning("CRServer: invalid window %d passed to WindowVisibleRegion()", window);
    690 #endif
    691          return;
    692     }
    693673
    694674    /* since we're going to change the current compositor & the window we need to avoid
     
    722702    }
    723703
    724     /* NOTE: we can do it even if !(mural->fPresentMode & CR_SERVER_REDIR_F_DISPLAY) to make sure the compositor data is always up to date */
    725     /* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */
    726     /* CrVrScrCompositorLock(&mural->Compositor); */
    727     rc = CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->CEntry, NULL, cRects, (const RTRECT *)pRects, &fRegionsChanged);
    728     /*CrVrScrCompositorUnlock(&mural->Compositor);*/
    729     if (!RT_SUCCESS(rc))
    730     {
    731         crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
    732         goto end;
     704    if (mural->fUseDefaultDEntry)
     705    {
     706        /* NOTE: we can do it even if !(mural->fPresentMode & CR_SERVER_REDIR_F_DISPLAY) to make sure the compositor data is always up to date */
     707        /* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */
     708        /* CrVrScrCompositorLock(&mural->Compositor); */
     709        rc = CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->DefaultDEntry.CEntry, NULL, cRects, (const RTRECT *)pRects, false, &fRegionsChanged);
     710        /*CrVrScrCompositorUnlock(&mural->Compositor);*/
     711        if (!RT_SUCCESS(rc))
     712        {
     713            crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     714            goto end;
     715        }
     716    }
     717    else
     718    {
     719        fRegionsChanged = true;
    733720    }
    734721
     
    740727        if (mural->fRootVrOn)
    741728        {
    742             rc = CrVrScrCompositorEntryRegionsSet(&mural->RootVrCompositor, &mural->RootVrCEntry, NULL, cRects, (const RTRECT *)pRects, NULL);
     729            rc = rc = crServerMuralSynchRootVr(mural);
    743730            if (!RT_SUCCESS(rc))
    744731            {
    745                 crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     732                crWarning("crServerMuralSynchRootVr failed, rc %d", rc);
    746733                goto end;
    747734            }
    748735
    749             crServerVBoxRootVrTranslateForMural(mural);
    750             rc = CrVrScrCompositorEntryListIntersect(&mural->RootVrCompositor, &mural->RootVrCEntry, &cr_server.RootVr, NULL);
     736            rc = CrVrScrCompositorRegionsGet(&mural->RootVrCompositor, &cRealRects, NULL, &pRealRects, NULL);
    751737            if (!RT_SUCCESS(rc))
    752738            {
    753                 crWarning("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc);
     739                crWarning("CrVrScrCompositorRegionsGet failed, rc %d", rc);
    754740                goto end;
    755741            }
    756 
    757             rc = CrVrScrCompositorEntryRegionsGet(&mural->RootVrCompositor, &mural->RootVrCEntry, &cRealRects, NULL, &pRealRects);
     742        }
     743        else
     744        {
     745            rc = CrVrScrCompositorRegionsGet(&mural->Compositor, &cRealRects, NULL, &pRealRects, NULL);
    758746            if (!RT_SUCCESS(rc))
    759747            {
    760                 crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
     748                crWarning("CrVrScrCompositorRegionsGet failed, rc %d", rc);
    761749                goto end;
    762750            }
    763751        }
    764         else
    765         {
    766             rc = CrVrScrCompositorEntryRegionsGet(&mural->Compositor, &mural->CEntry, &cRealRects, NULL, &pRealRects);
    767             if (!RT_SUCCESS(rc))
    768             {
    769                 crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
    770                 goto end;
    771             }
    772         }
    773752
    774753        cr_server.head_spu->dispatch_table.WindowVisibleRegion(mural->spuWindow, cRealRects, (const GLint*)pRealRects);
     
    776755        if (mural->pvOutputRedirectInstance)
    777756        {
    778             if (mural->fRootVrOn)
    779             {
    780                 rc = CrVrScrCompositorEntryRegionsGet(&mural->Compositor, &mural->CEntry, &cRealRects, NULL, &pRealRects);
     757//            if (mural->fRootVrOn)
     758            {
     759                /* always get unstretched regions here */
     760                rc = CrVrScrCompositorRegionsGet(&mural->Compositor, &cRealRects, NULL, NULL, &pRealRects);
    781761                if (!RT_SUCCESS(rc))
    782762                {
    783                     crWarning("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc);
     763                    crWarning("CrVrScrCompositorRegionsGet failed, rc %d", rc);
    784764                    goto end;
    785765                }
     
    792772    /* 3. re-set the compositor (see above comment) */
    793773    crServerVBoxCompositionDisableLeave(mural, fForcePresent);
     774}
     775
     776void SERVER_DISPATCH_APIENTRY
     777crServerDispatchWindowVisibleRegion( GLint window, GLint cRects, const GLint *pRects )
     778{
     779    CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
     780    if (!mural) {
     781#if EXTRA_WARN
     782         crWarning("CRServer: invalid window %d passed to WindowVisibleRegion()", window);
     783#endif
     784         return;
     785    }
     786
     787    crServerMuralVisibleRegion( mural, cRects, pRects );
     788}
     789
     790void crServerMuralShow( CRMuralInfo *mural, GLint state )
     791{
     792    if (mural->fPresentMode & CR_SERVER_REDIR_F_DISPLAY)
     793    {
     794        cr_server.head_spu->dispatch_table.WindowShow(mural->spuWindow, state);
     795
     796        if (state && mural->fHasParentWindow)
     797            crVBoxServerNotifyEvent(mural->screenId);
     798    }
     799
     800    mural->bVisible = !!state;
    794801}
    795802
     
    805812    }
    806813
    807     if (mural->fPresentMode & CR_SERVER_REDIR_F_DISPLAY)
    808     {
    809         cr_server.head_spu->dispatch_table.WindowShow(mural->spuWindow, state);
    810 
    811         if (state && mural->fHasParentWindow)
    812             crVBoxServerNotifyEvent(mural->screenId);
    813     }
    814 
    815     mural->bVisible = !!state;
    816 }
    817 
     814    crServerMuralShow( mural, state );
     815}
    818816
    819817GLint
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