VirtualBox

Ignore:
Timestamp:
Feb 18, 2013 5:02:47 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83844
Message:

crOpenGL: OSX backend rework; oddscreen rendering generalization

Location:
trunk/src/VBox/HostServices/SharedOpenGL
Files:
1 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/Makefile.kmk

    r43888 r44740  
    134134        crserverlib/server_muralfbo.c \
    135135        crserverlib/server_texture.c \
    136         crserverlib/server_blitter.cpp \
    137136        crserverlib/server_presenter.cpp \
    138137        $(VBOX_PATH_CROGL_GENFILES)/server_dispatch.c \
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h

    r44390 r44740  
    145145#define CR_SERVER_FBO_FB_IDX(_mural) (((_mural)->iBbBuffer + 1) % ((_mural)->cBuffers))
    146146
    147 PCR_BLITTER crServerGetFBOPresentBlitter(CRMuralInfo*pMural);
    148 
    149147int32_t crVBoxServerInternalClientRead(CRClient *pClient, uint8_t *pBuffer, uint32_t *pcbBuffer);
    150148
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.c

    r44290 r44740  
    162162            int rc = crServerSetOffscreenRenderingMode(redir);
    163163            if (!RT_SUCCESS(rc))
    164                             crWarning("offscreen rendering unsupported, no offscreen rendering will be used..");
     164                crWarning("offscreen rendering unsupported, no offscreen rendering will be used..");
    165165        }
    166166        else
    167167            crWarning("invalid redir option %c", redir);
    168168    }
     169#ifdef RT_OS_DARWIN
     170    else
     171    {
     172        int rc = crServerSetOffscreenRenderingMode(CR_SERVER_REDIR_FBO_BLT);
     173        if (!RT_SUCCESS(rc))
     174            crWarning("offscreen rendering unsupported, no offscreen rendering will be used..");
     175
     176    }
     177#endif
    169178    cr_server.bOffscreenRenderingDefault = cr_server.bForceOffscreenRendering;
    170179
     
    300309            crWarning("invalid redir option %c", redir);
    301310    }
     311#ifdef RT_OS_DARWIN
     312    else
     313    {
     314        int rc = crServerSetOffscreenRenderingMode(CR_SERVER_REDIR_FBO_BLT);
     315        if (!RT_SUCCESS(rc))
     316            crWarning("offscreen rendering unsupported, no offscreen rendering will be used..");
     317
     318    }
     319#endif
    302320    cr_server.bOffscreenRenderingDefault = cr_server.bForceOffscreenRendering;
    303321
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r44392 r44740  
    1313#include "cr_mem.h"
    1414#include "cr_hash.h"
     15#include "cr_vreg.h"
    1516#include "cr_environment.h"
    1617#include "cr_pixeldata.h"
     
    198199
    199200    crNetTearDown();
     201
     202    VBoxVrTerm();
    200203}
    201204
     
    243246    char *mothership = NULL;
    244247    CRMuralInfo *defaultMural;
     248    int rc = VBoxVrInit();
     249    if (!RT_SUCCESS(rc))
     250    {
     251        crWarning("VBoxVrInit failed, rc %d", rc);
     252        return;
     253    }
    245254
    246255    for (i = 1 ; i < argc ; i++)
     
    349358{
    350359    CRMuralInfo *defaultMural;
     360
     361    int rc = VBoxVrInit();
     362    if (!RT_SUCCESS(rc))
     363    {
     364        crWarning("VBoxVrInit failed, rc %d", rc);
     365        return GL_FALSE;
     366    }
    351367
    352368#if DEBUG_FP_EXCEPTIONS
     
    10071023    else
    10081024    {
    1009         CR_BLITTER_TEXTURE Tex;
     1025        VBOXVR_TEXTURE Tex;
    10101026        void *pvData;
    10111027        GLuint idPBO = cr_server.bUsePBOForReadback ? pMural->idPBO : 0;
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_muralfbo.c

    r44529 r44740  
    2020#include "cr_string.h"
    2121#include "cr_mem.h"
     22#include "cr_vreg.h"
    2223#include "render/renderspu.h"
    2324
     
    315316    CRASSERT(mural->aidFBOs[0]==0);
    316317    CRASSERT(mural->aidFBOs[1]==0);
     318    CRASSERT(mural->width == mural->CEntry.Tex.width);
     319    CRASSERT(mural->height == mural->CEntry.Tex.height);
    317320
    318321    pMuralContextInfo = cr_server.currentCtxInfo;
     
    415418    }
    416419
     420    CRASSERT(mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
     421    CrVrScrCompositorEntryTexNameUpdate(&mural->CEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
     422
    417423    if (RestoreSpuWindow >= 0 && RestoreSpuContext >= 0)
    418424    {
     
    512518    GLuint idPBO;
    513519    CRContext *ctx = crStateGetCurrent();
    514     CR_BLITTER_TEXTURE Tex;
     520    VBOXVR_TEXTURE Tex;
    515521
    516522    CRASSERT(mural->fUseFBO);
     
    524530    if (!mural->width || !mural->height)
    525531    {
     532        return;
     533    }
     534
     535    if (!CrVrScrCompositorEntryIsInList(&mural->CEntry))
     536        return;
     537
     538    if (mural->fUseFBO == CR_SERVER_REDIR_FBO_BLT)
     539    {
     540        GLuint idDrawFBO, idReadFBO;
     541
     542        idDrawFBO = mural->aidFBOs[mural->iCurDrawBuffer];
     543        idReadFBO = mural->aidFBOs[mural->iCurReadBuffer];
     544
     545        crStateSwitchPrepare(NULL, ctx, idDrawFBO, idReadFBO);
     546
     547        cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, &mural->Compositor, &mural->CEntry);
     548
     549        crStateSwitchPostprocess(ctx, NULL, idDrawFBO, idReadFBO);
     550
    526551        return;
    527552    }
     
    532557    Tex.hwid = mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)];
    533558    CRASSERT(Tex.hwid);
    534 
    535     if (mural->fUseFBO == CR_SERVER_REDIR_FBO_BLT)
    536     {
    537         int rc;
    538         PCR_BLITTER pBlitter = crServerGetFBOPresentBlitter(mural);
    539         if (!pBlitter)
    540         {
    541             static int cPrintedWarnings = 0;
    542             if (++cPrintedWarnings <= 5)
    543             {
    544                 crWarning("crServerGetFBOPresentBlitter returned no blitter %d", cPrintedWarnings);
    545                 if (cPrintedWarnings == 5)
    546                     crWarning("won't print the above crServerGetFBOPresentBlitter warning any more", cPrintedWarnings);
    547             }
    548             return;
    549         }
    550 
    551         CrBltMuralSetCurrent(pBlitter, mural);
    552         rc = CrBltEnter(pBlitter, cr_server.currentCtxInfo, cr_server.currentMural);
    553         if (RT_SUCCESS(rc))
    554         {
    555             RTRECT Rect;
    556             Rect.xLeft = 0;
    557             Rect.yTop = 0;
    558             Rect.xRight = Tex.width;
    559             Rect.yBottom = Tex.height;
    560 
    561             CrBltBlitTexMural(pBlitter, &Tex, &Rect, &Rect, 1, 0);
    562             CrBltPresent(pBlitter);
    563 
    564             CrBltLeave(pBlitter);
    565         }
    566         else
    567         {
    568             crWarning("CrBltEnter failed rc %d", rc);
    569             return;
    570         }
    571         return;
    572     }
    573559
    574560    if (cr_server.bUsePBOForReadback && !mural->idPBO)
     
    687673        cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, mural->aidFBOs[mural->iCurReadBuffer]);
    688674    }
    689 }
     675    Assert(mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
     676    CrVrScrCompositorEntryTexNameUpdate(&mural->CEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
     677}
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp

    r44529 r44740  
    3232#include <iprt/mem.h>
    3333
    34 #define CR_DISPLAY_RECTS_UNDEFINED UINT32_MAX
    35 
    36 
    37 #define CR_PRESENTER_ENTRY_FROM_ENTRY(_p) ((PCR_PRESENTER_ENTRY)(((uint8_t*)(_p)) - RT_OFFSETOF(CR_PRESENTER_ENTRY, Ce)))
    38 #define CR_PRESENTER_FROM_COMPOSITOR(_p) ((PCR_PRESENTER)(((uint8_t*)(_p)) - RT_OFFSETOF(CR_PRESENTER, Compositor)))
    39 
    40 
    41 static int crPtRectsAssignBuffer(PCR_PRESENTER pPresenter, uint32_t cRects)
    42 {
    43     Assert(cRects);
    44 
    45     if (pPresenter->cRectsBuffer >= cRects)
    46     {
    47         pPresenter->cRects = cRects;
    48         return VINF_SUCCESS;
    49     }
    50 
    51     if (pPresenter->cRectsBuffer)
    52     {
    53         Assert(pPresenter->paSrcRects);
    54         RTMemFree(pPresenter->paSrcRects);
    55         Assert(pPresenter->paDstRects);
    56         RTMemFree(pPresenter->paDstRects);
    57     }
    58 
    59     pPresenter->paSrcRects = (PRTRECT)RTMemAlloc(sizeof (*pPresenter->paSrcRects) * cRects);
    60     if (pPresenter->paSrcRects)
    61     {
    62         pPresenter->paDstRects = (PRTRECT)RTMemAlloc(sizeof (*pPresenter->paDstRects) * cRects);
    63         if (pPresenter->paDstRects)
    64         {
    65             pPresenter->cRects = cRects;
    66             pPresenter->cRectsBuffer = cRects;
    67             return VINF_SUCCESS;
    68         }
    69         else
    70         {
    71             crWarning("RTMemAlloc failed!");
    72             RTMemFree(pPresenter->paSrcRects);
    73             pPresenter->paSrcRects = NULL;
    74         }
    75     }
    76     else
    77     {
    78         crWarning("RTMemAlloc failed!");
    79         pPresenter->paDstRects = NULL;
    80     }
    81 
    82     pPresenter->cRects = CR_DISPLAY_RECTS_UNDEFINED;
    83     pPresenter->cRectsBuffer = 0;
    84 
    85     return VERR_NO_MEMORY;
    86 }
    87 
    88 static void crPtRectsInvalidate(PCR_PRESENTER pPresenter)
    89 {
    90     pPresenter->cRects = CR_DISPLAY_RECTS_UNDEFINED;
    91 }
    92 
    93 static DECLCALLBACK(bool) crPtRectsCounterCb(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, void *pvVisitor)
    94 {
    95     uint32_t* pCounter = (uint32_t*)pvVisitor;
    96     Assert(VBoxVrListRectsCount(&pEntry->Vr));
    97     *pCounter += VBoxVrListRectsCount(&pEntry->Vr);
    98     return true;
    99 }
    100 
    101 typedef struct CR_PRESENTOR_RECTS_ASSIGNER
    102 {
    103     PRTRECT paSrcRects;
    104     PRTRECT paDstRects;
    105     uint32_t cRects;
    106 } CR_PRESENTOR_RECTS_ASSIGNER, *PCR_PRESENTOR_RECTS_ASSIGNER;
    107 
    108 static DECLCALLBACK(bool) crPtRectsAssignerCb(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pCEntry, void *pvVisitor)
    109 {
    110     PCR_PRESENTOR_RECTS_ASSIGNER pData = (PCR_PRESENTOR_RECTS_ASSIGNER)pvVisitor;
    111     PCR_PRESENTER pPresenter = CR_PRESENTER_FROM_COMPOSITOR(pCompositor);
    112     PCR_PRESENTER_ENTRY pEntry = CR_PRESENTER_ENTRY_FROM_ENTRY(pCEntry);
    113     pEntry->paSrcRects = pData->paSrcRects;
    114     pEntry->paDstRects = pData->paDstRects;
    115     uint32_t cRects = VBoxVrListRectsCount(&pCEntry->Vr);
    116     Assert(cRects);
    117     Assert(cRects >= pData->cRects);
    118     int rc = VBoxVrListRectsGet(&pCEntry->Vr, cRects, pEntry->paDstRects);
    119     AssertRC(rc);
    120     if (pPresenter->StretchX >= 1. && pPresenter->StretchY >= 1. /* <- stretching can not zero some rects */
    121             && !pEntry->Pos.x && !pEntry->Pos.y)
    122     {
    123         memcpy(pEntry->paSrcRects, pEntry->paDstRects, cRects * sizeof (*pEntry->paSrcRects));
    124     }
    125     else
    126     {
    127         for (uint32_t i = 0; i < cRects; ++i)
    128         {
    129             pEntry->paSrcRects[i].xLeft = (int32_t)((pEntry->paDstRects[i].xLeft - pEntry->Pos.x) * pPresenter->StretchX);
    130             pEntry->paSrcRects[i].yTop = (int32_t)((pEntry->paDstRects[i].yTop - pEntry->Pos.y) * pPresenter->StretchY);
    131             pEntry->paSrcRects[i].xRight = (int32_t)((pEntry->paDstRects[i].xRight - pEntry->Pos.x) * pPresenter->StretchX);
    132             pEntry->paSrcRects[i].yBottom = (int32_t)((pEntry->paDstRects[i].yBottom - pEntry->Pos.y) * pPresenter->StretchY);
    133         }
    134 
    135         bool canZeroX = (pPresenter->StretchX < 1);
    136         bool canZeroY = (pPresenter->StretchY < 1);
    137         if (canZeroX && canZeroY)
    138         {
    139             /* filter out zero rectangles*/
    140             uint32_t iOrig, iNew;
    141             for (iOrig = 0, iNew = 0; iOrig < cRects; ++iOrig)
    142             {
    143                 PRTRECT pOrigRect = &pEntry->paSrcRects[iOrig];
    144                 if (pOrigRect->xLeft == pOrigRect->xRight
    145                         || pOrigRect->yTop == pOrigRect->yBottom)
    146                     continue;
    147 
    148                 if (iNew != iOrig)
    149                 {
    150                     PRTRECT pNewRect = &pEntry->paSrcRects[iNew];
    151                     *pNewRect = *pOrigRect;
    152                 }
    153 
    154                 ++iNew;
    155             }
    156 
    157             Assert(iNew <= iOrig);
    158 
    159             uint32_t cDiff = iOrig - iNew;
    160 
    161             if (cDiff)
    162             {
    163                 pPresenter->cRects -= cDiff;
    164                 cRects -= cDiff;
    165             }
    166         }
    167     }
    168 
    169     pEntry->cRects = cRects;
    170     pData->paDstRects += cRects;
    171     pData->paSrcRects += cRects;
    172     pData->cRects -= cRects;
    173     return true;
    174 }
    175 
    176 static int crPtRectsCheckInit(PCR_PRESENTER pPresenter)
    177 {
    178     if (pPresenter->cRects != CR_DISPLAY_RECTS_UNDEFINED)
    179         return VINF_SUCCESS;
    180 
    181     uint32_t cRects = 0;
    182     VBoxVrCompositorVisit(&pPresenter->Compositor, crPtRectsCounterCb, &cRects);
    183 
    184     if (!cRects)
    185     {
    186         pPresenter->cRects = 0;
    187         return VINF_SUCCESS;
    188     }
    189 
    190     int rc = crPtRectsAssignBuffer(pPresenter, cRects);
    191     if (!RT_SUCCESS(rc))
    192         return rc;
    193 
    194     CR_PRESENTOR_RECTS_ASSIGNER AssignerData;
    195     AssignerData.paSrcRects = pPresenter->paSrcRects;
    196     AssignerData.paDstRects = pPresenter->paDstRects;
    197     AssignerData.cRects = pPresenter->cRects;
    198     VBoxVrCompositorVisit(&pPresenter->Compositor, crPtRectsAssignerCb, &AssignerData);
    199     Assert(!AssignerData.cRects);
    200     return VINF_SUCCESS;
    201 }
    202 
    203 DECLCALLBACK(int) CrPtCbDrawEntrySingle(struct CR_PRESENTER *pPresenter, struct CR_PRESENTER_ENTRY *pEntry, PCR_BLITTER pBlitter, bool *pfAllEntriesDrawn)
    204 {
    205     if (pfAllEntriesDrawn)
    206         *pfAllEntriesDrawn = false;
    207 
    208     int rc = crPtRectsCheckInit(pPresenter);
    209     if (!RT_SUCCESS(rc))
    210     {
    211         crWarning("crPtRectsCheckInit failed, rc %d", rc);
    212         return rc;
    213     }
    214 
    215     Assert(VBoxVrListRectsCount(&pEntry->Ce.Vr));
    216 
    217     if (!pEntry->cRects)
    218         return VINF_SUCCESS;
    219 
    220     rc = pPresenter->pfnDrawTexture(pPresenter, pBlitter, &pEntry->Texture, pEntry->paSrcRects, pEntry->paDstRects, pEntry->cRects);
    221     if (!RT_SUCCESS(rc))
    222     {
    223         crWarning("pfnDrawTexture failed, rc %d", rc);
    224         return rc;
    225     }
    226 
    227     return VINF_SUCCESS;
    228 }
    229 
    230 static DECLCALLBACK(bool) crPtDrawEntryAllCb(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pCEntry, void *pvVisitor)
    231 {
    232     struct CR_PRESENTER *pPresenter = CR_PRESENTER_FROM_COMPOSITOR(pCompositor);
    233     struct CR_PRESENTER_ENTRY *pEntry = CR_PRESENTER_ENTRY_FROM_ENTRY(pCEntry);
    234     PCR_BLITTER pBlitter = (PCR_BLITTER)pvVisitor;
    235     bool fAllEntriesDrawn;
    236     int rc = CrPtCbDrawEntrySingle(pPresenter, pEntry, pBlitter, &fAllEntriesDrawn);
    237     if (!RT_SUCCESS(rc))
    238     {
    239         crWarning("CrPtCbDrawEntrySingle failed, rc %d", rc);
    240     }
    241     return !fAllEntriesDrawn;
    242 }
    243 
    244 DECLCALLBACK(int) CrPtCbDrawEntryAll(struct CR_PRESENTER *pPresenter, struct CR_PRESENTER_ENTRY *pEntry, PCR_BLITTER pBlitter, bool *pfAllEntriesDrawn)
    245 {
    246     int rc = crPtRectsCheckInit(pPresenter);
    247     if (!RT_SUCCESS(rc))
    248     {
    249         crWarning("crPtRectsCheckInit failed, rc %d", rc);
    250         return rc;
    251     }
    252 
    253     VBoxVrCompositorVisit(&pPresenter->Compositor, crPtDrawEntryAllCb, pBlitter);
    254 
    255     if (pfAllEntriesDrawn)
    256         *pfAllEntriesDrawn = true;
    257 
    258     return VINF_SUCCESS;
    259 }
    260 
    261 static int crPtEntryRegionsAdd(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged)
    262 {
    263     uint32_t fChangedFlags = 0;
    264     int rc = VBoxVrCompositorEntryRegionsAdd(&pPresenter->Compositor, &pEntry->Ce, cRegions, paRegions, &fChangedFlags);
    265     if (!RT_SUCCESS(rc))
    266     {
    267         crWarning("VBoxVrCompositorEntryRegionsAdd failed, rc %d", rc);
    268         return rc;
    269     }
    270 
    271     if (fChangedFlags & VBOXVR_COMPOSITOR_CF_COMPOSITED_REGIONS_CHANGED)
    272     {
    273         crPtRectsInvalidate(pPresenter);
    274         rc = pPresenter->pfnRegionsChanged(pPresenter);
    275         if (!RT_SUCCESS(rc))
    276         {
    277             crWarning("pfnRegionsChanged failed, rc %d", rc);
    278             return rc;
    279         }
    280     }
    281 
    282     if (pfChanged)
    283         *pfChanged = !!fChangedFlags;
    284     return VINF_SUCCESS;
    285 }
    286 
    287 static int crPtEntryRegionsSet(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged)
    288 {
    289     bool fChanged;
    290     int rc = VBoxVrCompositorEntryRegionsSet(&pPresenter->Compositor, &pEntry->Ce, cRegions, paRegions, &fChanged);
    291     if (!RT_SUCCESS(rc))
    292     {
    293         crWarning("VBoxVrCompositorEntryRegionsSet failed, rc %d", rc);
    294         return rc;
    295     }
    296 
    297     if (fChanged)
    298     {
    299         crPtRectsInvalidate(pPresenter);
    300         rc = pPresenter->pfnRegionsChanged(pPresenter);
    301         if (!RT_SUCCESS(rc))
    302         {
    303             crWarning("pfnRegionsChanged failed, rc %d", rc);
    304             return rc;
    305         }
    306     }
    307 
    308     if (pfChanged)
    309         *pfChanged = fChanged;
    310     return VINF_SUCCESS;
    311 }
    312 
    313 static void crPtEntryPositionSet(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, const RTPOINT *pPos)
    314 {
    315     if (pEntry && (pEntry->Pos.x != pPos->x || pEntry->Pos.y != pPos->y))
    316     {
    317         if (VBoxVrCompositorEntryIsInList(&pEntry->Ce))
    318         {
    319             VBoxVrCompositorEntryRemove(&pPresenter->Compositor, &pEntry->Ce);
    320             crPtRectsInvalidate(pPresenter);
    321         }
    322         pEntry->Pos = *pPos;
    323     }
    324 }
    325 
    326 int CrPtPresentEntry(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, PCR_BLITTER pBlitter)
    327 {
    328     int rc = CrBltEnter(pBlitter, cr_server.currentCtxInfo, cr_server.currentMural);
    329     if (!RT_SUCCESS(rc))
    330     {
    331         crWarning("CrBltEnter failed, rc %d", rc);
    332         return rc;
    333     }
    334 
    335     rc = pPresenter->pfnDrawEntry(pPresenter, pEntry, pBlitter, NULL);
    336 
    337     CrBltLeave(pBlitter);
    338 
    339     if (!RT_SUCCESS(rc))
    340     {
    341         crWarning("pfnDraw failed, rc %d", rc);
    342         return rc;
    343     }
    344 
    345     return VINF_SUCCESS;
    346 }
    347 
    348 static DECLCALLBACK(bool) crPtPresentCb(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pCEntry, void *pvVisitor)
    349 {
    350     struct CR_PRESENTER *pPresenter = CR_PRESENTER_FROM_COMPOSITOR(pCompositor);
    351     struct CR_PRESENTER_ENTRY *pEntry = CR_PRESENTER_ENTRY_FROM_ENTRY(pCEntry);
    352     PCR_BLITTER pBlitter = (PCR_BLITTER)pvVisitor;
    353     bool fAllDrawn = false;
    354     int rc = pPresenter->pfnDrawEntry(pPresenter, pEntry, pBlitter, &fAllDrawn);
    355     if (!RT_SUCCESS(rc))
    356     {
    357         crWarning("pfnDrawEntry failed, rc %d", rc);
    358     }
    359     return !fAllDrawn;
    360 }
    361 
    362 int CrPtPresent(PCR_PRESENTER pPresenter, PCR_BLITTER pBlitter)
    363 {
    364     int rc = CrBltEnter(pBlitter, cr_server.currentCtxInfo, cr_server.currentMural);
    365     if (!RT_SUCCESS(rc))
    366     {
    367         crWarning("CrBltEnter failed, rc %d", rc);
    368         return rc;
    369     }
    370 
    371     VBoxVrCompositorVisit(&pPresenter->Compositor, crPtPresentCb, pBlitter);
    372 
    373     CrBltLeave(pBlitter);
    374 
    375     if (!RT_SUCCESS(rc))
    376     {
    377         crWarning("pfnDraw failed, rc %d", rc);
    378         return rc;
    379     }
    380 
    381     return VINF_SUCCESS;
    382 }
    383 
    384 int CrPtEntryRegionsAdd(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
    385 {
    386     crPtEntryPositionSet(pPresenter, pEntry, pPos);
    387 
    388     int rc = crPtEntryRegionsAdd(pPresenter, pEntry, cRegions, paRegions, NULL);
    389     if (!RT_SUCCESS(rc))
    390     {
    391         crWarning("crPtEntryRegionsAdd failed, rc %d", rc);
    392         return rc;
    393     }
    394 
    395     return VINF_SUCCESS;
    396 }
    397 
    398 int CrPtEntryRegionsSet(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
    399 {
    400     crPtEntryPositionSet(pPresenter, pEntry, pPos);
    401 
    402     int rc = crPtEntryRegionsSet(pPresenter, pEntry, cRegions, paRegions, NULL);
    403     if (!RT_SUCCESS(rc))
    404     {
    405         crWarning("crPtEntryRegionsAdd failed, rc %d", rc);
    406         return rc;
    407     }
    408 
    409     return VINF_SUCCESS;
    410 }
    411 
    412 int CrPtEntryRemove(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry)
    413 {
    414     if (!VBoxVrCompositorEntryRemove(&pPresenter->Compositor, &pEntry->Ce))
    415         return VINF_SUCCESS;
    416 
    417     crPtRectsInvalidate(pPresenter);
    418     int rc = pPresenter->pfnRegionsChanged(pPresenter);
    419     if (!RT_SUCCESS(rc))
    420     {
    421         crWarning("pfnRegionsChanged failed, rc %d", rc);
    422         return rc;
    423     }
    424     return VINF_SUCCESS;
    425 }
    426 
    427 int CrPtInit(PCR_PRESENTER pPresenter, PFNCRDISPLAY_REGIONS_CHANGED pfnRegionsChanged, PFNCRDISPLAY_DRAW_ENTRY pfnDrawEntry, PFNCRDISPLAY_DRAW_TEXTURE pfnDrawTexture)
    428 {
    429     memset(pPresenter, 0, sizeof (*pPresenter));
    430     VBoxVrCompositorInit(&pPresenter->Compositor, NULL);
    431     pPresenter->StretchX = 1.0;
    432     pPresenter->StretchY = 1.0;
    433     pPresenter->pfnRegionsChanged = pfnRegionsChanged;
    434     pPresenter->pfnDrawEntry = pfnDrawEntry;
    435     pPresenter->pfnDrawTexture = pfnDrawTexture;
    436     return VINF_SUCCESS;
    437 }
    438 
    439 void CrPtTerm(PCR_PRESENTER pPresenter)
    440 {
    441     VBoxVrCompositorTerm(&pPresenter->Compositor);
    442     if (pPresenter->paDstRects)
    443         RTMemFree(pPresenter->paDstRects);
    444     if (pPresenter->paSrcRects)
    445         RTMemFree(pPresenter->paSrcRects);
    446 }
    447 
    448 void CrPtSetStretching(PCR_PRESENTER pPresenter, float StretchX, float StretchY)
    449 {
    450     pPresenter->StretchX = StretchX;
    451     pPresenter->StretchY = StretchY;
    452     crPtRectsInvalidate(pPresenter);
    453 }
    454 
    455 int CrPtGetRegions(PCR_PRESENTER pPresenter, uint32_t *pcRegions, const RTRECT **ppaRegions)
    456 {
    457     int rc = crPtRectsCheckInit(pPresenter);
    458     if (!RT_SUCCESS(rc))
    459     {
    460         crWarning("crPtRectsCheckInit failed, rc %d", rc);
    461         return rc;
    462     }
    463 
    464     Assert(pPresenter->cRects != CR_DISPLAY_RECTS_UNDEFINED);
    465 
    466     *pcRegions = pPresenter->cRects;
    467     *ppaRegions = pPresenter->paDstRects;
    468     return VINF_SUCCESS;
    469 }
    47034
    47135/* DISPLAY */
    472 #define CR_DISPLAY_FROM_PRESENTER(_p) ((PCR_DISPLAY)(((uint8_t*)(_p)) - RT_OFFSETOF(CR_DISPLAY, Presenter)))
    473 
    474 static DECLCALLBACK(int) crDpCbRegionsChanged(struct CR_PRESENTER *pPresenter)
    475 {
    476     uint32_t cRegions;
    477     const RTRECT *paRegions;
    478     int rc = CrPtGetRegions(pPresenter, &cRegions, &paRegions);
    479     if (!RT_SUCCESS(rc))
    480     {
    481         crWarning("CrPtGetRegions failed, rc %d", rc);
    482         return rc;
    483     }
    484 
    485     PCR_DISPLAY pDisplay = CR_DISPLAY_FROM_PRESENTER(pPresenter);
    486 
    487     cr_server.head_spu->dispatch_table.WindowVisibleRegion(pDisplay->Mural.spuWindow, cRegions, (GLint*)paRegions);
    488 
    489     if (pDisplay->Mural.pvOutputRedirectInstance)
    490     {
    491         /* @todo the code assumes that RTRECT == four GLInts. */
    492         cr_server.outputRedirect.CRORVisibleRegion(pDisplay->Mural.pvOutputRedirectInstance,
    493                                                         cRegions, paRegions);
    494     }
    495 
    496     return VINF_SUCCESS;
    497 }
    498 
    499 static DECLCALLBACK(int) crDpCbDrawTextureWindow(struct CR_PRESENTER *pPresenter, PCR_BLITTER pBlitter,
    500                                             CR_BLITTER_TEXTURE *pTexture, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects)
    501 {
    502     Assert(CrBltIsEntered(pBlitter));
    503     CrBltBlitTexMural(pBlitter, pTexture, paSrcRects, paDstRects, cRects, 0);
    504     return VINF_SUCCESS;
    505 }
     36
     37//static DECLCALLBACK(int) crDpCbRegionsChanged(struct CR_PRESENTER *pPresenter)
     38//{
     39//    uint32_t cRegions;
     40//    const RTRECT *paRegions;
     41//    int rc = CrPtGetRegions(pPresenter, &cRegions, &paRegions);
     42//    if (!RT_SUCCESS(rc))
     43//    {
     44//        crWarning("CrPtGetRegions failed, rc %d", rc);
     45//        return rc;
     46//    }
     47//
     48//    PCR_DISPLAY pDisplay = CR_DISPLAY_FROM_PRESENTER(pPresenter);
     49//
     50//    cr_server.head_spu->dispatch_table.WindowVisibleRegion(pDisplay->Mural.spuWindow, cRegions, (GLint*)paRegions);
     51//
     52//    if (pDisplay->Mural.pvOutputRedirectInstance)
     53//    {
     54//        /* @todo the code assumes that RTRECT == four GLInts. */
     55//        cr_server.outputRedirect.CRORVisibleRegion(pDisplay->Mural.pvOutputRedirectInstance,
     56//                                                        cRegions, paRegions);
     57//    }
     58//
     59//    return VINF_SUCCESS;
     60//}
    50661
    50762int CrDpInit(PCR_DISPLAY pDisplay)
    50863{
    509     const GLint visBits = CR_RGB_BIT | CR_DOUBLE_BIT;
    510     int rc = CrPtInit(&pDisplay->Presenter, crDpCbRegionsChanged, CrPtCbDrawEntryAll, crDpCbDrawTextureWindow);
     64    int rc = CrVrScrCompositorInit(&pDisplay->Compositor);
    51165    if (RT_SUCCESS(rc))
    51266    {
     67        const GLint visBits = CR_RGB_BIT | CR_DOUBLE_BIT;
    51368        if (crServerMuralInit(&pDisplay->Mural, "", visBits, -1) >= 0)
    51469        {
     
    52176            rc = VERR_GENERAL_FAILURE;
    52277        }
    523         CrPtTerm(&pDisplay->Presenter);
     78        CrVrScrCompositorTerm(&pDisplay->Compositor);
     79    }
     80    else
     81    {
     82        crWarning("CrVrScrCompositorInit failed, rc %d", rc);
    52483    }
    52584    CRASSERT(RT_FAILURE(rc));
     
    52988void CrDpTerm(PCR_DISPLAY pDisplay)
    53089{
    531     CrPtTerm(&pDisplay->Presenter);
     90    CrVrScrCompositorTerm(&pDisplay->Compositor);
    53291    crServerMuralTerm(&pDisplay->Mural);
    533 }
    534 
    535 int CrDpBlitterTestWithMural(PCR_BLITTER pBlitter, CRMuralInfo *pMural)
    536 {
    537     CrBltMuralSetCurrent(pBlitter, pMural);
    538     /* try to enter to make sure the blitter is initialized completely and to make sure we actually can do that */
    539     int rc = CrBltEnter(pBlitter, cr_server.currentCtxInfo, cr_server.currentMural);
    540     if (RT_SUCCESS(rc))
    541     {
    542         CrBltLeave(pBlitter);
    543         return VINF_SUCCESS;
    544     }
    545     else
    546     {
    547         crWarning("CrBltEnter failed, rc %d", rc);
    548     }
    549     return rc;
    550 }
    551 
    552 int CrDpBlitterTest(PCR_DISPLAY pDisplay, PCR_BLITTER pBlitter)
    553 {
    554     return CrDpBlitterTestWithMural(pBlitter, &pDisplay->Mural);
    55592}
    55693
     
    56299    StretchY = ((float)stretchedHeight)/height;
    563100    crServerMuralSize(&pDisplay->Mural, stretchedWidth, stretchedHeight);
    564     CrPtSetStretching(&pDisplay->Presenter, StretchX, StretchY);
     101    CrVrScrCompositorSetStretching(&pDisplay->Compositor, StretchX, StretchY);
    565102}
    566103
    567104int CrDpEntryRegionsSet(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
    568105{
    569     return CrPtEntryRegionsSet(&pDisplay->Presenter, &pEntry->Pe, pPos, cRegions, paRegions);
     106    return CrVrScrCompositorEntryRegionsSet(&pDisplay->Compositor, &pEntry->CEntry, pPos, cRegions, paRegions);
    570107}
    571108
    572109int CrDpEntryRegionsAdd(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
    573110{
    574     return CrPtEntryRegionsAdd(&pDisplay->Presenter, &pEntry->Pe, pPos, cRegions, paRegions);
     111    return CrVrScrCompositorEntryRegionsAdd(&pDisplay->Compositor, &pEntry->CEntry, pPos, cRegions, paRegions);
    575112}
    576113
    577114int CrDpPresentEntry(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry)
    578115{
    579     return CrPtPresentEntry(&pDisplay->Presenter, &pEntry->Pe, pDisplay->pBlitter);
    580 }
    581 
    582 void CrDpEntryInit(PCR_DISPLAY_ENTRY pEntry, PCR_BLITTER_TEXTURE pTextureData)
    583 {
    584     CrPtEntryInit(&pEntry->Pe, pTextureData);
     116    GLuint idDrawFBO = 0, idReadFBO = 0;
     117    CRMuralInfo *pMural = cr_server.currentMural;
     118    CRContext *pCtx = cr_server.currentCtxInfo ? cr_server.currentCtxInfo->pContext : cr_server.MainContextInfo.pContext;
     119
     120    if (pMural)
     121    {
     122        idDrawFBO = pMural->aidFBOs[pMural->iCurDrawBuffer];
     123        idReadFBO = pMural->aidFBOs[pMural->iCurReadBuffer];
     124    }
     125
     126    crStateSwitchPrepare(NULL, pCtx, idDrawFBO, idReadFBO);
     127
     128    cr_server.head_spu->dispatch_table.VBoxPresentComposition(pDisplay->Mural.spuWindow, &pDisplay->Compositor, &pEntry->CEntry);
     129
     130    crStateSwitchPostprocess(pCtx, NULL, idDrawFBO, idReadFBO);
     131
     132    return VINF_SUCCESS;
     133}
     134
     135void CrDpEntryInit(PCR_DISPLAY_ENTRY pEntry, const PVBOXVR_TEXTURE pTextureData)
     136{
     137    CrVrScrCompositorEntryInit(&pEntry->CEntry, pTextureData);
    585138}
    586139
    587140void CrDpEntryCleanup(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry)
    588141{
    589     CrPtEntryRemove(&pDisplay->Presenter, &pEntry->Pe);
     142    CrVrScrCompositorEntryRemove(&pDisplay->Compositor, &pEntry->CEntry);
    590143}
    591144
     
    632185    }
    633186
    634     CR_BLITTER_TEXTURE TextureData;
     187    VBOXVR_TEXTURE TextureData;
    635188    TextureData.width = pTobj->level[0]->width;
    636189    TextureData.height = pTobj->level[0]->height;
     
    675228#define CR_PRESENT_GET_FLAGS(_cfg) ((_cfg) >> CR_PRESENT_FLAGS_OFFSET)
    676229
    677 int crServerBlitterInit(PCR_BLITTER pBlitter, CRMuralInfo*pMural)
    678 {
    679     int rc = CrBltInit(pBlitter, pMural);
    680     if (RT_SUCCESS(rc))
    681     {
    682         rc = CrDpBlitterTestWithMural(pBlitter, pMural);
    683         if (RT_SUCCESS(rc))
    684             return VINF_SUCCESS;
    685         else
    686             crWarning("CrDpBlitterTestWithMural failed, rc %d", rc);
    687         CrBltTerm(pBlitter);
    688     }
    689     else
    690         crWarning("CrBltInit failed, rc %d", rc);
    691     return rc;
    692 }
    693 
    694 PCR_BLITTER crServerGetFBOPresentBlitter(CRMuralInfo*pMural)
    695 {
    696     if (cr_server.fFBOModeBlitterInited > 0)
    697         return &cr_server.FBOModeBlitter;
    698     if (!cr_server.fFBOModeBlitterInited)
    699     {
    700         int rc = crServerBlitterInit(&cr_server.FBOModeBlitter, pMural);
    701         if (RT_SUCCESS(rc))
    702         {
    703             cr_server.fFBOModeBlitterInited = 1;
    704             return &cr_server.FBOModeBlitter;
    705         }
    706         crWarning("crServerBlitterInit failed rc %d", rc);
    707         cr_server.fFBOModeBlitterInited = -1;
    708     }
    709     return NULL;
    710 }
    711 
    712 static int8_t crServerCheckInitDisplayBlitter()
    713 {
    714     if (cr_server.fPresentBlitterInited)
    715         return cr_server.fPresentBlitterInited;
    716 
    717     crDebug("Display Functionality is requested");
    718     Assert(!ASMBitTest(cr_server.DisplaysInitMap, 0));
    719 
    720     int rc = CrDemInit(&cr_server.PresentTexturepMap);
    721     if (RT_SUCCESS(rc))
    722     {
    723         rc = CrDpInit(&cr_server.aDispplays[0]);
    724         if (RT_SUCCESS(rc))
    725         {
    726             CRMuralInfo*pMural = CrDpGetMural(&cr_server.aDispplays[0]);
    727             rc = crServerBlitterInit(&cr_server.PresentBlitter, pMural);
    728             if (RT_SUCCESS(rc))
    729             {
    730                 CrDpBlitterSet(&cr_server.aDispplays[0], &cr_server.PresentBlitter);
    731                 CrDpResize(&cr_server.aDispplays[0],
    732                             cr_server.screen[0].w, cr_server.screen[0].h,
    733                             cr_server.screen[0].w, cr_server.screen[0].h);
    734                 ASMBitSet(cr_server.DisplaysInitMap, 0);
    735                 cr_server.fPresentBlitterInited = 1;
    736                 return 1;
    737             }
    738             else
    739             {
    740                 crWarning("crServerBlitterInit failed, rc %d", rc);
    741             }
    742             CrDpTerm(&cr_server.aDispplays[0]);
    743         }
    744         else
    745         {
    746             crWarning("CrDpInit failed, rc %d", rc);
    747         }
    748         CrDemTerm(&cr_server.PresentTexturepMap);
    749     }
    750     else
    751     {
    752         crWarning("CrDemInit failed, rc %d", rc);
    753     }
    754 
    755     cr_server.fPresentBlitterInited = -1;
    756     return -1;
    757 }
    758 
    759 static bool crServerDisplayIsSupported()
    760 {
    761     return crServerCheckInitDisplayBlitter() > 0;
    762 }
    763 
    764230PCR_DISPLAY crServerDisplayGetInitialized(uint32_t idScreen)
    765231{
     
    780246        return &cr_server.aDispplays[idScreen];
    781247
    782     if (crServerCheckInitDisplayBlitter() > 0)
    783     {
    784         /* the display (screen id == 0) can be initialized while doing crServerCheckInitDisplayBlitter,
    785          * so re-check the bit map */
    786         if (ASMBitTest(cr_server.DisplaysInitMap, idScreen))
    787             return &cr_server.aDispplays[idScreen];
    788 
    789         int rc = CrDpInit(&cr_server.aDispplays[idScreen]);
    790         if (RT_SUCCESS(rc))
    791         {
    792             CrDpBlitterSet(&cr_server.aDispplays[idScreen], &cr_server.PresentBlitter);
    793             CrDpResize(&cr_server.aDispplays[idScreen],
    794                     cr_server.screen[idScreen].w, cr_server.screen[idScreen].h,
    795                     cr_server.screen[idScreen].w, cr_server.screen[idScreen].h);
    796             ASMBitSet(cr_server.DisplaysInitMap, idScreen);
    797             return &cr_server.aDispplays[idScreen];
    798         }
    799         else
    800         {
    801             crWarning("CrDpInit failed for screen %d", idScreen);
    802         }
    803     }
    804     else
    805     {
    806         crWarning("crServerCheckInitDisplayBlitter said \"UNSUPPORTED\"");
    807     }
     248    /* the display (screen id == 0) can be initialized while doing crServerCheckInitDisplayBlitter,
     249     * so re-check the bit map */
     250     if (ASMBitTest(cr_server.DisplaysInitMap, idScreen))
     251         return &cr_server.aDispplays[idScreen];
     252
     253     int rc = CrDpInit(&cr_server.aDispplays[idScreen]);
     254     if (RT_SUCCESS(rc))
     255     {
     256         CrDpResize(&cr_server.aDispplays[idScreen],
     257                 cr_server.screen[idScreen].w, cr_server.screen[idScreen].h,
     258                 cr_server.screen[idScreen].w, cr_server.screen[idScreen].h);
     259         ASMBitSet(cr_server.DisplaysInitMap, idScreen);
     260         return &cr_server.aDispplays[idScreen];
     261     }
     262     else
     263     {
     264         crWarning("CrDpInit failed for screen %d", idScreen);
     265     }
    808266
    809267    return NULL;
     
    828286}
    829287
    830 void* CrHlpGetTexImage(CRContext *pCurCtx, PCR_BLITTER_TEXTURE pTexture, GLuint idPBO)
     288void* CrHlpGetTexImage(CRContext *pCurCtx, PVBOXVR_TEXTURE pTexture, GLuint idPBO)
    831289{
    832290    void *pvData = NULL;
     
    885343
    886344void SERVER_DISPATCH_APIENTRY
    887 crServerDispatchTexPresent(GLuint texture, GLuint cfg, GLint xPos, GLint yPos, GLint cRects, GLint *pRects)
     345crServerDispatchVBoxTexPresent(GLuint texture, GLuint cfg, GLint xPos, GLint yPos, GLint cRects, GLint *pRects)
    888346{
    889347    uint32_t idScreen = CR_PRESENT_GET_SCREEN(cfg);
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_special

    r44388 r44740  
    250250DrawBuffer
    251251ReadBuffer
    252 TexPresent
     252VBoxTexPresent
    253253GetError
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c

    r44389 r44740  
    2222    GLint dims[2];
    2323    GLint windowID = -1;
     24    GLint spuWindow;
     25    VBOXVR_TEXTURE Tex = {0};
     26
     27    int rc = CrVrScrCompositorInit(&mural->Compositor);
     28    if (!RT_SUCCESS(rc))
     29    {
     30        crWarning("CrVrScrCompositorInit failed, rc %d", rc);
     31        return -1;
     32    }
     33
    2434    /*
    2535     * Have first SPU make a new window.
    2636     */
    27     GLint spuWindow = cr_server.head_spu->dispatch_table.WindowCreate( dpyName, visBits );
     37    spuWindow = cr_server.head_spu->dispatch_table.WindowCreate( dpyName, visBits );
    2838    if (spuWindow < 0) {
    29         crServerReturnValue( &spuWindow, sizeof(spuWindow) );
     39        CrVrScrCompositorTerm(&mural->Compositor);
    3040        return spuWindow;
    3141    }
     
    3343    /* get initial window size */
    3444    cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, spuWindow, GL_INT, 2, dims);
     45
     46    Tex.width = dims[0];
     47    Tex.height = dims[1];
     48    Tex.target = GL_TEXTURE_2D;
     49    Tex.hwid = 0;
     50    CrVrScrCompositorEntryInit(&mural->CEntry, &Tex);
    3551
    3652    defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
     
    118134    {
    119135        crWarning("crServerMuralInit failed!");
     136        crServerReturnValue( &windowID, sizeof(windowID) );
    120137        crFree(mural);
    121138        return windowID;
     
    290307    }
    291308
     309    CrVrScrCompositorTerm(&mural->Compositor);
     310
    292311    crHashtableDelete(cr_server.muralTable, window, crFree);
    293312}
     
    295314void crServerMuralSize(CRMuralInfo *mural, GLint width, GLint height)
    296315{
    297     mural->width = width;
    298     mural->height = height;
     316    if (mural->width != width || mural->height != height)
     317    {
     318        VBOXVR_TEXTURE Tex;
     319        Tex.width = width;
     320        Tex.height = height;
     321        Tex.target = GL_TEXTURE_2D;
     322        Tex.hwid = 0;
     323        CrVrScrCompositorEntryRemove(&mural->Compositor, &mural->CEntry);
     324        CrVrScrCompositorEntryInit(&mural->CEntry, &Tex);
     325        mural->width = width;
     326        mural->height = height;
     327    }
    299328
    300329    if (cr_server.curClient && cr_server.curClient->currentMural == mural)
     
    342371{
    343372    CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
     373    RTPOINT Pos;
    344374    /*  crDebug("CRServer: Window %d pos %d, %d", window, x, y);*/
    345375    if (!mural) {
     
    352382    mural->gY = y;
    353383
     384    Pos.x = x;
     385    Pos.y = y;
     386
     387    CrVrScrCompositorEntryPosSet(&mural->Compositor, &mural->CEntry, &Pos);
     388
    354389    crServerCheckMuralGeometry(mural);
    355390}
     
    392427                                                   cRects, (RTRECT *)pRects);
    393428    }
     429
     430    CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->CEntry, NULL, cRects, (const RTRECT *)pRects);
    394431}
    395432
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c

    r44377 r44740  
    1010#include "cr_mem.h"
    1111#include "cr_spu.h"
     12#include "cr_environment.h"
    1213#include "renderspu.h"
    1314#include "cr_extstring.h"
     
    128129}
    129130
     131static ContextInfo * renderspuCreateContextInternal(const char *dpyName, GLint visBits, ContextInfo * sharedContext)
     132{
     133    ContextInfo *context;
     134    VisualInfo *visual;
     135
     136    if (!dpyName || crStrlen(render_spu.display_string)>0)
     137        dpyName = render_spu.display_string;
     138
     139    visual = renderspuFindVisual(dpyName, visBits);
     140    if (!visual)
     141        return NULL;
     142
     143    context = (ContextInfo *) crCalloc(sizeof(ContextInfo));
     144    if (!context)
     145        return NULL;
     146    context->BltInfo.Base.id = render_spu.context_id;
     147    context->shared = sharedContext;
     148    if (!renderspu_SystemCreateContext(visual, context, sharedContext))
     149        return NULL;
     150
     151    crHashtableAdd(render_spu.contextTable, render_spu.context_id, context);
     152    render_spu.context_id++;
     153
     154    context->BltInfo.Base.visualBits = visual->visAttribs;
     155    /*
     156    crDebug("Render SPU: CreateContext(%s, 0x%x) returning %d",
     157                    dpyName, visBits, context->BltInfo.Base.id);
     158    */
     159
     160    return context;
     161}
     162
    130163/*
    131164 * Context functions
     
    136169{
    137170    ContextInfo *context, *sharedContext = NULL;
    138     VisualInfo *visual;
    139 
    140     if (shareCtx > 0) {
     171    bool fHasShared;
     172
     173    if (shareCtx > 0)
     174        fHasShared = true;
     175    else if (shareCtx == -1)
     176    {
     177        shareCtx = 0;
     178        fHasShared = true;
     179    }
     180    else
     181        fHasShared = false;
     182
     183    if (fHasShared) {
    141184        sharedContext
    142185            = (ContextInfo *) crHashtableSearch(render_spu.contextTable, shareCtx);
    143     }
    144 
    145     if (!dpyName || crStrlen(render_spu.display_string)>0)
    146         dpyName = render_spu.display_string;
    147 
    148     visual = renderspuFindVisual(dpyName, visBits);
    149     if (!visual)
    150         return -1;
    151 
    152     context = (ContextInfo *) crCalloc(sizeof(ContextInfo));
    153     if (!context)
    154         return -1;
    155     context->id = render_spu.context_id;
    156     context->shared = sharedContext;
    157     if (!renderspu_SystemCreateContext(visual, context, sharedContext))
    158         return -1;
    159 
    160     crHashtableAdd(render_spu.contextTable, render_spu.context_id, context);
    161     render_spu.context_id++;
    162 
    163     /*
    164     crDebug("Render SPU: CreateContext(%s, 0x%x) returning %d",
    165                     dpyName, visBits, context->id);
    166     */
    167 
    168     return context->id;
    169 }
    170 
     186        CRASSERT(sharedContext);
     187    }
     188
     189    context = renderspuCreateContextInternal(dpyName, visBits, sharedContext);
     190    if (context)
     191        return context->BltInfo.Base.id;
     192    return -1;
     193}
    171194
    172195static void RENDER_APIENTRY
     
    306329
    307330    crHashtableAdd(render_spu.windowTable, render_spu.window_id, window);
    308     window->id = render_spu.window_id;
     331    window->BltInfo.Base.id = render_spu.window_id;
    309332    render_spu.window_id++;
    310333
    311334    window->x = render_spu.defaultX;
    312335    window->y = render_spu.defaultY;
    313     window->width  = render_spu.defaultWidth;
    314     window->height = render_spu.defaultHeight;
     336    window->BltInfo.width  = render_spu.defaultWidth;
     337    window->BltInfo.height = render_spu.defaultHeight;
    315338
    316339    if (render_spu.force_hidden_wdn_create
     
    318341        showIt = 0;
    319342    else
    320         showIt = window->id > 0;
     343        showIt = window->BltInfo.Base.id > 0;
    321344
    322345    /* Set window->title, replacing %i with the window ID number */
     
    328351            for (i = 0; render_spu.window_title[i] != '%'; i++)
    329352                window->title[i] = render_spu.window_title[i];
    330             k = sprintf(window->title + i, "%d", window->id);
     353            k = sprintf(window->title + i, "%d", window->BltInfo.Base.id);
    331354            CRASSERT(k < 10);
    332355            i++; /* skip the 'i' after the '%' */
     
    341364
    342365    /*
    343     crDebug("Render SPU: Creating window (visBits=0x%x, id=%d)", visBits, window->id);
     366    crDebug("Render SPU: Creating window (visBits=0x%x, id=%d)", visBits, window->BltInfo.Base.id);
    344367    */
    345368    /* Have GLX/WGL/AGL create the window */
     
    353376    CRASSERT(window->visual == visual);
    354377
    355     return window->id;
     378    window->BltInfo.Base.visualBits = visual->visAttribs;
     379
     380    return window->BltInfo.Base.id;
    356381}
    357382
     
    364389    if (pCtx->currentWindow==pWindow)
    365390    {
    366         renderspuMakeCurrent(0, 0, pCtx->id);
     391        renderspuMakeCurrent(0, 0, pCtx->BltInfo.Base.id);
    367392        pCtx->currentWindow=0;
    368393    }
     
    396421            if (pNewCtx!=pOldCtx)
    397422            {
    398                 renderspuMakeCurrent(pOldCtx&&pOldCtx->currentWindow ? pOldCtx->currentWindow->id:0, 0,
    399                                      pOldCtx ? pOldCtx->id:0);
     423                renderspuMakeCurrent(pOldCtx&&pOldCtx->currentWindow ? pOldCtx->currentWindow->BltInfo.Base.id:0, 0,
     424                                     pOldCtx ? pOldCtx->BltInfo.Base.id:0);
    400425            }
    401426        }
     
    415440    if (window) {
    416441        renderspu_SystemWindowSize( window, w, h );
     442        window->BltInfo.width  = w;
     443        window->BltInfo.height = h;
    417444    }
    418445    else {
     
    475502}
    476503
     504static void RENDER_APIENTRY
     505renderspuVBoxPresentComposition( GLint win, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
     506{
     507    WindowInfo *window;
     508    CRASSERT(win >= 0);
     509    window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, win);
     510    if (window) {
     511        renderspu_SystemVBoxPresentComposition(window, pCompositor, pChangedEntry);
     512    }
     513    else {
     514        crDebug("Render SPU: Attempt to PresentComposition for invalid window (%d)", win);
     515    }
     516}
     517
     518void renderspuVBoxCompositorBlitStretched ( struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter, GLfloat scaleX, GLfloat scaleY)
     519{
     520    VBOXVR_SCR_COMPOSITOR_ITERATOR CIter;
     521    PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
     522    CrVrScrCompositorIterInit(pCompositor, &CIter);
     523    while ((pEntry = CrVrScrCompositorIterNext(&CIter)) != NULL)
     524    {
     525        uint32_t cRegions;
     526        const RTRECT *paSrcRegions, *paDstRegions;
     527        int rc = CrVrScrCompositorEntryRegionsGet(pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions);
     528        if (RT_SUCCESS(rc))
     529        {
     530            uint32_t i;
     531            for (i = 0; i < pEntry->cRects; ++i)
     532            {
     533                RTRECT DstRect;
     534                DstRect.xLeft = paDstRegions[i].xLeft * scaleX;
     535                DstRect.yTop = paDstRegions[i].yTop * scaleY;
     536                DstRect.xRight = paDstRegions[i].xRight * scaleX;
     537                DstRect.yBottom = paDstRegions[i].yBottom * scaleY;
     538                CrBltBlitTexMural(pBlitter, &pEntry->Tex, &paSrcRegions[i], &DstRect, 1, CRBLT_F_LINEAR);
     539            }
     540        }
     541        else
     542        {
     543            crWarning("BlitStretched: CrVrScrCompositorEntryRegionsGet failed rc %d", rc);
     544        }
     545    }
     546}
     547
     548void renderspuVBoxCompositorBlit ( struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter)
     549{
     550    VBOXVR_SCR_COMPOSITOR_ITERATOR CIter;
     551    PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
     552    CrVrScrCompositorIterInit(pCompositor, &CIter);
     553    while ((pEntry = CrVrScrCompositorIterNext(&CIter)) != NULL)
     554    {
     555        uint32_t cRegions;
     556        const RTRECT *paSrcRegions, *paDstRegions;
     557        int rc = CrVrScrCompositorEntryRegionsGet(pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions);
     558        if (RT_SUCCESS(rc))
     559        {
     560            CrBltBlitTexMural(pBlitter, &pEntry->Tex, paSrcRegions, paDstRegions, cRegions, CRBLT_F_LINEAR);
     561        }
     562        else
     563        {
     564            crWarning("Blit: CrVrScrCompositorEntryRegionsGet failed rc %d", rc);
     565        }
     566    }
     567}
     568
     569PCR_BLITTER renderspuVBoxPresentBlitterGet( WindowInfo *window )
     570{
     571    PCR_BLITTER pBlitter = window->pBlitter;
     572    if (!pBlitter)
     573    {
     574        if (render_spu.blitterTable)
     575        {
     576            pBlitter = (PCR_BLITTER)crHashtableSearch(render_spu.blitterTable, window->visual->visAttribs);
     577        }
     578
     579        if (!pBlitter)
     580        {
     581            int rc;
     582            CR_BLITTER_CONTEXT ctx;
     583            pBlitter = (PCR_BLITTER)crCalloc(sizeof (*pBlitter));
     584            if (!pBlitter)
     585            {
     586                crWarning("failed to allocate blitter");
     587                return NULL;
     588            }
     589
     590            /* @todo: this is the assumption that crserverlib uses context 1 as a default one
     591             * need to do it in a more proper way */
     592            ctx.Base.id = 1;
     593            ctx.Base.visualBits = window->visual->visAttribs;
     594            rc = CrBltInit(pBlitter, &ctx, true, render_spu.blitterDispatch);
     595            if (!RT_SUCCESS(rc))
     596            {
     597                crWarning("CrBltInit failed, rc %d", rc);
     598                crFree(pBlitter);
     599                return NULL;
     600            }
     601        }
     602
     603        Assert(pBlitter);
     604        window->pBlitter = pBlitter;
     605    }
     606
     607    CrBltMuralSetCurrent(pBlitter, &window->BltInfo);
     608    return pBlitter;
     609}
     610
     611int renderspuVBoxPresentBlitterEnter( PCR_BLITTER pBlitter )
     612{
     613    int rc;
     614    GET_CONTEXT(pCtx);
     615
     616    if (!pCtx)
     617    {
     618        crWarning("renderspuVBoxPresentBlitterEnter: no current context!");
     619        return VERR_INVALID_STATE;
     620    }
     621
     622    if (!pCtx->currentWindow)
     623    {
     624        crWarning("renderspuVBoxPresentBlitterEnter: no current window!");
     625        return VERR_INVALID_STATE;
     626    }
     627
     628    rc = CrBltEnter(pBlitter, &pCtx->BltInfo, &pCtx->currentWindow->BltInfo);
     629    if (!RT_SUCCESS(rc))
     630    {
     631        crWarning("CrBltEnter failed, rc %d", rc);
     632        return rc;
     633    }
     634    return VINF_SUCCESS;
     635}
     636
     637PCR_BLITTER renderspuVBoxPresentBlitterGetAndEnter( WindowInfo *window )
     638{
     639    PCR_BLITTER pBlitter = renderspuVBoxPresentBlitterGet(window);
     640    if (pBlitter)
     641    {
     642        int rc = renderspuVBoxPresentBlitterEnter(pBlitter);
     643        if (RT_SUCCESS(rc))
     644        {
     645            return pBlitter;
     646        }
     647    }
     648    return NULL;
     649}
     650
     651void renderspuVBoxPresentCompositionGeneric( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
     652{
     653    PCR_BLITTER pBlitter = renderspuVBoxPresentBlitterGetAndEnter(window);
     654    if (!pBlitter)
     655        return;
     656
     657    renderspuVBoxCompositorBlit(pCompositor, pBlitter);
     658
     659    CrBltPresent(pBlitter);
     660
     661    CrBltLeave(pBlitter);
     662}
    477663
    478664/*
     
    10831269}
    10841270
    1085 #if defined(DARWIN)
    1086 # ifdef VBOX_WITH_COCOA_QT
    1087 void renderspuFlush()
    1088 {
    1089     renderspu_SystemFlush();
    1090 }
    1091 
    1092 void renderspuFinish()
    1093 {
    1094     renderspu_SystemFinish();
    1095 }
    1096 
    1097 void renderspuBindFramebufferEXT(GLenum target, GLuint framebuffer)
    1098 {
    1099     renderspu_SystemBindFramebufferEXT(target, framebuffer);
    1100 }
    1101 
    1102 void renderspuCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
    1103 {
    1104     renderspu_SystemCopyPixels(x, y, width, height, type);
    1105 }
    1106 
    1107 void renderspuGetIntegerv(GLenum pname, GLint * params)
    1108 {
    1109     renderspu_SystemGetIntegerv(pname, params);
    1110 }
    1111 
    1112 void renderspuDrawBuffer(GLenum mode)
    1113 {
    1114     renderspu_SystemDrawBuffer(mode);
    1115 }
    1116 
    1117 void renderspuReadBuffer(GLenum mode)
    1118 {
    1119     renderspu_SystemReadBuffer(mode);
    1120 }
    1121 # endif
    1122 #endif
    1123 
    11241271#define FILLIN( NAME, FUNC ) \
    11251272  table[i].name = crStrdup(NAME); \
     
    11581305    FILLIN( "GetChromiumParametervCR", renderspuGetChromiumParametervCR );
    11591306    FILLIN( "GetString", renderspuGetString );
    1160 #if defined(DARWIN)
    1161 # ifdef VBOX_WITH_COCOA_QT
    1162     FILLIN( "Flush", renderspuFlush );
    1163     FILLIN( "Finish", renderspuFinish );
    1164     FILLIN( "BindFramebufferEXT", renderspuBindFramebufferEXT );
    1165     FILLIN( "CopyPixels", renderspuCopyPixels );
    1166     FILLIN( "GetIntegerv", renderspuGetIntegerv );
    1167     FILLIN( "ReadBuffer", renderspuReadBuffer );
    1168     FILLIN( "DrawBuffer", renderspuDrawBuffer );
    1169 # endif
    1170 #endif
     1307    FILLIN( "VBoxPresentComposition", renderspuVBoxPresentComposition );
     1308
    11711309    return i;
    11721310}
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h

    r43748 r44740  
    2828#include "cr_hash.h"
    2929#include "cr_server.h"
     30#include "cr_blitter.h"
    3031
    3132#include <iprt/cdefs.h>
     
    7980typedef struct {
    8081    int x, y;
    81     int width, height;
    82     int id; /**< integer window ID */
     82//    int width, height;
     83//    int id; /**< integer window ID */
     84    CR_BLITTER_WINDOW BltInfo;
     85
    8386    VisualInfo *visual;
    8487    GLboolean mapPending;
     
    8689    GLboolean everCurrent; /**< has this window ever been bound? */
    8790    char *title;
     91
     92    PCR_BLITTER pBlitter;
    8893#if defined(WINDOWS)
    8994    HDC nativeWindow; /**< for render_to_app_window */
     
    125130 */
    126131typedef struct _ContextInfo {
    127     int id; /**< integer context ID */
     132//    int id; /**< integer context ID */
     133    CR_BLITTER_CONTEXT BltInfo;
    128134    VisualInfo *visual;
    129135    GLboolean everCurrent;
     
    218224    CRConnection **swap_conns;
    219225
     226    SPUDispatchTable *blitterDispatch;
     227    CRHashTable *blitterTable;
     228
    220229#ifdef USE_OSMESA
    221230    /** Off screen rendering hooks.  */
     
    293302
    294303#define GET_CONTEXT(T)  ContextInfo *T = GET_CONTEXT_VAL()
     304
     305
    295306
    296307extern void renderspuSetVBoxConfiguration( RenderSPU *spu );
     
    311322#ifdef RT_OS_DARWIN
    312323extern void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *pRects);
    313 # ifdef VBOX_WITH_COCOA_QT
    314 extern void renderspu_SystemFlush();
    315 extern void renderspu_SystemFinish();
    316 extern void renderspu_SystemBindFramebufferEXT(GLenum target, GLuint framebuffer);
    317 extern void renderspu_SystemCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
    318 extern void renderspu_SystemGetIntegerv(GLenum pname, GLint *params);
    319 extern void renderspu_SystemReadBuffer(GLenum mode);
    320 extern void renderspu_SystemDrawBuffer(GLenum mode);
    321 # endif
    322324#endif
    323325extern void renderspu_SystemShowWindow( WindowInfo *window, GLboolean showIt );
     
    325327extern void renderspu_SystemSwapBuffers( WindowInfo *window, GLint flags );
    326328extern void renderspu_SystemReparentWindow(WindowInfo *window);
     329extern void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry );
    327330extern void renderspu_GCWindow(void);
    328331extern int renderspuCreateFunctions( SPUNamedFunctionTable table[] );
     332extern void renderspuVBoxPresentCompositionGeneric( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry );
     333extern PCR_BLITTER renderspuVBoxPresentBlitterGet( WindowInfo *window );
     334extern int renderspuVBoxPresentBlitterEnter( PCR_BLITTER pBlitter );
     335extern PCR_BLITTER renderspuVBoxPresentBlitterGetAndEnter( WindowInfo *window );
     336extern void renderspuVBoxCompositorBlit ( struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter);
     337extern void renderspuVBoxCompositorBlitStretched ( struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter, GLfloat scaleX, GLfloat scaleY);
    329338
    330339extern GLint RENDER_APIENTRY renderspuWindowCreate( const char *dpyName, GLint visBits );
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c

    r33540 r44740  
    341341        return render_spu.ws.aglSetCurrentContext( NULL );
    342342
    343 /*    DEBUG_MSG_POETZSCH (("WindowAttachContext %d\n", wi->id));*/
     343/*    DEBUG_MSG_POETZSCH (("WindowAttachContext %d\n", wi->BltInfo.Base.id));*/
    344344
    345345    /* Flush old context first */
     
    350350    if (wi->bufferName == -1)
    351351    {
    352         DEBUG_MSG_POETZSCH (("WindowAttachContext: create context %d\n", wi->id));
     352        DEBUG_MSG_POETZSCH (("WindowAttachContext: create context %d\n", wi->BltInfo.Base.id));
    353353        /* Use the same visual bits as those in the context structure */
    354354        AGLPixelFormat pix;
     
    520520    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): SendEventToEventTarget Failed");
    521521
    522     DEBUG_MSG_POETZSCH (("Size %d visible %d\n", window->id, IsWindowVisible (window->window)));
     522    DEBUG_MSG_POETZSCH (("Size %d visible %d\n", window->BltInfo.Base.id, IsWindowVisible (window->window)));
    523523    /* save the new size */
    524     window->width = w;
    525     window->height = h;
     524    window->BltInfo.width = w;
     525    window->BltInfo.height = h;
    526526}
    527527
     
    607607}
    608608
     609void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
     610{
     611    renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry);
     612}
     613
    609614void
    610615renderspu_SystemMakeCurrent(WindowInfo *window, GLint nativeWindow,
     
    612617{
    613618    Boolean result;
    614 /*    DEBUG_MSG_POETZSCH (("makecurrent %d: \n", window->id));*/
     619/*    DEBUG_MSG_POETZSCH (("makecurrent %d: \n", window->BltInfo.Base.id));*/
    615620
    616621    CRASSERT(render_spu.ws.aglSetCurrentContext);
     
    670675
    671676    RTSemFastMutexRequest(render_spu.syncMutex);
    672 //    DEBUG_MSG_POETZSCH (("Swapped %d context %x visible: %d\n", window->id, context->context, IsWindowVisible (window->window)));
     677//    DEBUG_MSG_POETZSCH (("Swapped %d context %x visible: %d\n", window->BltInfo.Base.id, context->context, IsWindowVisible (window->window)));
    673678    if (context->visual &&
    674679        context->visual->visAttribs & CR_DOUBLE_BIT)
     
    778783        SetRectRgn(rgn,
    779784                   window->x, window->y,
    780                    window->x + window->width,
    781                    window->y + window->height);
     785                   window->x + window->BltInfo.width,
     786                   window->y + window->BltInfo.height);
    782787        SectRgn(render_spu.hRootVisibleRegion, rgn, rgn);
    783788        /* Because the clipping is done in the coordinate space of the OpenGL
     
    791796         * region with the size of the target window. This covers all
    792797         * needed/possible space. */
    793         SetRectRgn(rgn, 0, 0, window->width, window->height);
     798        SetRectRgn(rgn, 0, 0, window->BltInfo.width, window->BltInfo.height);
    794799    }
    795800
     
    839844    windowRect.left = window->x;
    840845    windowRect.top = window->y;
    841     windowRect.right = window->x + window->width;
    842     windowRect.bottom = window->y + window->height;
     846    windowRect.right = window->x + window->BltInfo.width;
     847    windowRect.bottom = window->y + window->BltInfo.height;
    843848
    844849    status = CreateNewWindow(winClass, winAttr, &windowRect, &window->window);
     
    849854    title_string = CFStringCreateWithCStringNoCopy(NULL, window->title,
    850855                                                   kCFStringEncodingMacRoman, NULL);
    851     SetWindowTitleWithCFString(window->window, title_string);
     856    SetWindowTitleWithCFString(window->BltInfo.window, title_string);
    852857    CFRelease(title_string);
    853858
     
    874879
    875880    crDebug("Render SPU (renderspu_SystemVBoxCreateWindow): actual window (x, y, width, height): %d, %d, %d, %d",
    876             window->x, window->y, window->width, window->height);
     881            window->x, window->y, window->BltInfo.width, window->BltInfo.height);
    877882
    878883    return GL_TRUE;
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa.c

    r44529 r44740  
    152152}
    153153
     154void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
     155{
     156    cocoaViewPresentComposition(window->window, pCompositor, pChangedEntry);
     157}
     158
    154159void renderspu_SystemMakeCurrent(WindowInfo *pWinInfo, GLint nativeWindow, ContextInfo *pCtxInfo)
    155160{
     
    184189{
    185190}
    186 
    187 void renderspu_SystemFlush()
    188 {
    189     cocoaFlush();
    190 }
    191 
    192 void renderspu_SystemFinish()
    193 {
    194     cocoaFinish();
    195 }
    196 
    197 void renderspu_SystemBindFramebufferEXT(GLenum target, GLuint framebuffer)
    198 {
    199     cocoaBindFramebufferEXT(target, framebuffer);
    200 }
    201 
    202 void renderspu_SystemCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
    203 {
    204     cocoaCopyPixels(x, y, width, height, type);
    205 }
    206 
    207 void renderspu_SystemGetIntegerv(GLenum pname, GLint * params)
    208 {
    209     cocoaGetIntegerv(pname, params);
    210 }
    211 
    212 void renderspu_SystemReadBuffer(GLenum mode)
    213 {
    214     cocoaReadBuffer(mode);
    215 }
    216 
    217 void renderspu_SystemDrawBuffer(GLenum mode)
    218 {
    219     cocoaDrawBuffer(mode);
    220 }
    221 
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.h

    r44528 r44740  
    2222#include <VBox/VBoxCocoa.h>
    2323#include <OpenGL/OpenGL.h>
     24#include <cr_vreg.h>
    2425
    2526RT_C_DECLS_BEGIN
     
    4445void cocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx);
    4546void cocoaViewSetVisibleRegion(NativeNSViewRef pView, GLint cRects, GLint* paRects);
    46 
    47 /* OpenGL wrapper */
    48 void cocoaFlush(void);
    49 void cocoaFinish(void);
    50 void cocoaBindFramebufferEXT(GLenum target, GLuint framebuffer);
    51 void cocoaCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
    52 void cocoaGetIntegerv(GLenum pname, GLint *params);
    53 void cocoaReadBuffer(GLenum mode);
    54 void cocoaDrawBuffer(GLenum mode);
     47void cocoaViewPresentComposition(NativeNSViewRef pView, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry);
    5548
    5649RT_C_DECLS_END
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m

    r44528 r44740  
    2626#include <iprt/mem.h>
    2727#include <iprt/time.h>
     28
     29#include <cr_vreg.h>
    2830
    2931/** @page pg_opengl_cocoa  OpenGL - Cocoa Window System Helper
     
    159161    } \
    160162    while(0);
     163   
     164static NSOpenGLContext *g_pVBoxCurrentContext = NULL;
     165#ifdef DEBUG
     166static NSView *g_pVBoxCurrentView = NULL;
     167#endif
     168
     169static NSOpenGLContext * vboxCtxGetCurrent()
     170{
     171#ifdef DEBUG
     172    if (g_pVBoxCurrentContext)
     173    {
     174        Assert(g_pVBoxCurrentView == [g_pVBoxCurrentContext view]);
     175    }
     176#endif
     177    return g_pVBoxCurrentContext;
     178}
     179
     180static void vboxCtxSetCurrent(NSOpenGLContext * pCtx)
     181{
     182        g_pVBoxCurrentContext = pCtx;
     183        if (pCtx)
     184        {
     185#ifdef DEBUG
     186                g_pVBoxCurrentView = [g_pVBoxCurrentContext view];
     187#endif
     188                [pCtx makeCurrentContext];
     189        }
     190        else
     191        {
     192#ifdef DEBUG
     193                g_pVBoxCurrentView = NULL;
     194#endif
     195                [NSOpenGLContext clearCurrentContext];
     196        }
     197}
    161198
    162199/** Custom OpenGL context class.
     
    194231    RTTHREAD         mThread;
    195232
    196 #ifdef FBO
    197233    GLuint           m_FBOId;
    198     /* FBO handling */
    199     GLuint           m_FBOTexBackId;
    200     GLuint           m_FBOTexFrontId;
    201     GLuint           m_FBOAttBackId;
    202     GLuint           m_FBOAttFrontId;
    203     GLuint           m_FBODepthStencilPackedId;
    204     NSSize           m_FBOTexSize;
    205 
    206     bool             m_fFrontDrawing;
    207 #endif
    208234
    209235    /** The corresponding dock tile view of this OpenGL view & all helper
     
    211237    DockOverlayView *m_DockTileView;
    212238
    213     GLuint           m_FBOThumbId;
    214     GLuint           m_FBOThumbTexId;
    215239    GLfloat          m_FBOThumbScaleX;
    216240    GLfloat          m_FBOThumbScaleY;
     
    227251    /** This is necessary for clipping on the root window */
    228252    NSPoint          m_RootShift;
     253   
     254    PVBOXVR_SCR_COMPOSITOR m_pCompositor;
     255    bool m_fNeedViewportUpdate;
     256    bool m_fNeedCtxUpdate;
    229257}
    230258- (id)initWithFrame:(NSRect)frame thread:(RTTHREAD)aThread parentView:(NSView*)pParentView;
     
    241269- (void)setSize:(NSSize)size;
    242270- (NSSize)size;
    243 - (void)updateViewport;
     271- (void)updateViewportCS;
    244272- (void)reshape;
    245273
    246 - (void)createFBO;
    247 - (void)deleteFBO;
    248 
    249 - (bool)isCurrentFBO;
    250 - (void)updateFBO;
     274- (void)createDockTile;
     275- (void)deleteDockTile;
     276
    251277- (void)makeCurrentFBO;
    252278- (void)swapFBO;
    253 - (void)flushFBO;
    254 - (void)stateInfo:(GLenum)pname withParams:(GLint*)params;
    255 - (void)finishFBO;
    256 - (void)bindFBO:(GLenum)target withFrameBuffer:(GLuint)framebuffer;
    257279- (void)tryDraw;
    258 - (void)renderFBOToView;
    259 - (void)renderFBOToDockTile;
     280- (void)vboxPresent;
     281- (void)vboxPresentCS;
     282- (void)vboxPresentToDockTileCS;
     283- (void)vboxPresentToViewCS;
     284- (void)presentComposition:(PVBOXVR_SCR_COMPOSITOR)pCompositor withChangedEntry:(PVBOXVR_SCR_COMPOSITOR_ENTRY)pChangedEntry;
     285- (void)performSelectorMakingCurrent:(NSOpenGLContext*)pCtx idSel:(SEL)selector;
    260286
    261287- (void)clearVisibleRegions;
     
    466492    DEBUG_MSG(("OCTX(%p): setView: new view: %p\n", (void*)self, (void*)view));
    467493
    468 #ifdef FBO
     494#if 1 /* def FBO */
    469495    m_pView = view;;
    470496#else
     
    475501-(NSView*)view
    476502{
    477 #ifdef FBO
     503#if 1 /* def FBO */
    478504    return m_pView;
    479505#else
     
    646672    m_pSharedGLCtx            = nil;
    647673    mThread                   = aThread;
    648 #ifdef FBO
    649674    m_FBOId                   = 0;
    650     m_FBOTexBackId            = 0;
    651     m_FBOTexFrontId           = 0;
    652     m_FBOAttBackId            = GL_COLOR_ATTACHMENT0_EXT;
    653     m_FBOAttFrontId           = GL_COLOR_ATTACHMENT1_EXT;
    654     m_FBODepthStencilPackedId = 0;
    655     m_FBOTexSize              = NSZeroSize;
    656 #endif
    657     m_FBOThumbId              = 0;
    658     m_FBOThumbTexId           = 0;
    659675    m_cClipRects              = 0;
    660676    m_paClipRects             = NULL;
     
    662678    m_Size                    = NSMakeSize(1, 1);
    663679    m_RootShift               = NSZeroPoint;
    664 
     680    m_pCompositor             = NULL;
     681    m_fNeedViewportUpdate     = true;       
     682    m_fNeedCtxUpdate          = true;
     683   
    665684    self = [super initWithFrame:frame];
    666685
     
    672691- (void)cleanupData
    673692{
    674     [self deleteFBO];
    675 
     693    [self deleteDockTile];
     694   
    676695    if (m_pGLCtx)
    677696    {
     
    768787    m_Size = size;
    769788
    770 #ifdef FBO
    771     if (m_FBOId)
    772789    {
    773790        DEBUG_MSG(("OVIW(%p): setSize: new size: %dx%d\n", (void*)self, (int)size.width, (int)size.height));
    774791        [self reshape];
    775         [self updateFBO];
     792        [self createDockTile];
    776793        /* have to rebind GL_TEXTURE_RECTANGLE_ARB as m_FBOTexId could be changed in updateFBO call */
    777         [self updateViewport];
    778     }
    779     else
    780 #endif
    781     {
    782         DEBUG_MSG(("OVIW(%p): setSize (no FBO): new size: %dx%d\n", (void*)self, (int)size.width, (int)size.height));
    783         [self reshape];
    784         [self updateFBO];
     794        m_fNeedViewportUpdate = true;
     795        m_fNeedCtxUpdate = true;
    785796    }
    786797}
     
    791802}
    792803
    793 - (void)updateViewport
     804- (void)updateViewportCS
    794805{
    795806    NSRect r;
     
    797808    DEBUG_MSG(("OVIW(%p): updateViewport\n", (void*)self));
    798809
    799 #ifdef FBO
    800     if (m_pSharedGLCtx)
    801810    {
    802811        /* Update the viewport for our OpenGL view */
    803         DEBUG_MSG(("OVIW(%p): makeCurrent (shared) %p\n", (void*)self, (void*)m_pSharedGLCtx));
    804         [m_pSharedGLCtx makeCurrentContext];
    805812        [m_pSharedGLCtx update];
    806813
     
    821828        /* Clear background to transparent */
    822829        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    823 
    824         DEBUG_MSG(("OVIW(%p): makeCurrent (non shared) %p\n", (void*)self, (void*)m_pGLCtx));
    825         [m_pGLCtx makeCurrentContext];
    826     }
    827 #endif
     830    }
    828831}
    829832
     
    889892
    890893    /* Make sure the context is updated according */
    891     [self updateViewport];
    892 }
    893 
    894 - (void)createFBO
    895 {
    896     GLint   oldTexId         = 0;
    897     GLint   oldFBId          = 0;
    898     NSView *pDockScreen      = nil;
    899     GLint   maxTexSize       = 0;
    900     GLfloat imageAspectRatio = 0;
    901     GLint   filter           = GL_NEAREST;
    902 
    903     [self deleteFBO];
    904 
    905 #ifdef FBO
    906     DEBUG_MSG(("OVIW(%p): createFBO\n", (void*)self));
    907 
    908     glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &oldTexId);
    909     glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &oldFBId);
    910 
    911     /* If not previously setup generate IDs for FBO and its associated texture. */
    912     if (!m_FBOId)
    913     {
    914         /* Make sure the framebuffer extension is supported */
    915         const GLubyte* strExt;
    916         GLboolean isFBO;
    917         /* Get the extension name string. It is a space-delimited list of the
    918          * OpenGL extensions that are supported by the current renderer. */
    919         strExt = glGetString(GL_EXTENSIONS);
    920         isFBO = gluCheckExtension((const GLubyte*)"GL_EXT_framebuffer_object", strExt);
    921         if (!isFBO)
    922         {
    923             DEBUG_MSG(("Your system does not support the GL_EXT_framebuffer_object extension\n"));
    924         }
    925         isFBO = gluCheckExtension((const GLubyte*)"GL_EXT_framebuffer_blit", strExt);
    926         if (!isFBO)
    927         {
    928             DEBUG_MSG(("Your system does not support the GL_EXT_framebuffer_blit extension\n"));
    929         }
    930 
    931         /* Create FBO object */
    932         glGenFramebuffersEXT(1, &m_FBOId);
    933         /* & the texture as well the depth/stencil render buffer */
    934         glGenTextures(1, &m_FBOTexBackId);
    935         glGenTextures(1, &m_FBOTexFrontId);
    936         DEBUG_MSG(("OVIW(%p): gen numbers: FBOId=%d FBOTexBackId=%d FBOTexFrontId=%d\n", (void*)self, m_FBOId, m_FBOTexBackId, m_FBOTexFrontId));
    937 
    938         glGenRenderbuffersEXT(1, &m_FBODepthStencilPackedId);
    939     }
    940 
    941     m_FBOTexSize = m_Size;
    942     /* Bind to FBO */
    943     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FBOId);
    944 
    945     /*
    946     glEnable(GL_TEXTURE_RECTANGLE_ARB);
    947      */
    948 
    949     imageAspectRatio = m_FBOTexSize.width / m_FBOTexSize.height;
    950 
    951     /* Sanity check against maximum OpenGL texture size. If bigger adjust to
    952      * maximum possible size while maintain the aspect ratio. */
    953     glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
    954     if (m_FBOTexSize.width > maxTexSize || m_FBOTexSize.height > maxTexSize)
    955     {
    956         filter = GL_LINEAR;
    957         if (imageAspectRatio > 1)
    958         {
    959             m_FBOTexSize.width = maxTexSize;
    960             m_FBOTexSize.height = maxTexSize / imageAspectRatio;
    961         }
    962         else
    963         {
    964             m_FBOTexSize.width = maxTexSize * imageAspectRatio;
    965             m_FBOTexSize.height = maxTexSize;
    966         }
    967     }
    968 
    969     DEBUG_MSG(("OVIW(%p): tex size is: %dx%d\n", (void*)self, (int)m_FBOTexSize.width, (int)m_FBOTexSize.height));
    970 
    971     /* Initialize FBO Textures */
    972     /* The GPUs like the GL_BGRA / GL_UNSIGNED_INT_8_8_8_8_REV combination
    973      * others are also valid, but might incur a costly software translation. */
    974     glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_FBOTexBackId);
    975     glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, m_FBOTexSize.width, m_FBOTexSize.height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
    976     glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_FBOTexFrontId);
    977     glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, m_FBOTexSize.width, m_FBOTexSize.height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
    978 
    979     /* Now attach the textures to the FBO as its color destinations */
    980     glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, m_FBOAttBackId,  GL_TEXTURE_RECTANGLE_ARB, m_FBOTexBackId, 0);
    981     glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, m_FBOAttFrontId, GL_TEXTURE_RECTANGLE_ARB, m_FBOTexFrontId, 0);
    982 
    983     glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_FBODepthStencilPackedId);
    984     glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, m_FBOTexSize.width, m_FBOTexSize.height);
    985     glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_FBODepthStencilPackedId);
    986 
    987     /* Bind the FBOs for reading and drawing. */
    988     glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_FBOId);
    989     glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_FBOId);
    990 
    991     /* Explicitly clear the textures otherwise they would contain old memory stuff. */
    992     glDrawBuffer(m_FBOAttBackId);
    993     glClear(GL_COLOR_BUFFER_BIT);
    994     glDrawBuffer(m_FBOAttFrontId);
    995     glClear(GL_COLOR_BUFFER_BIT);
    996 
    997     /* Now initially reading/drawing to the back buffer. */
    998     glReadBuffer(m_FBOAttBackId);
    999     glDrawBuffer(m_FBOAttBackId);
    1000 
    1001     /* Make sure the FBO was created successfully. */
    1002     if (GL_FRAMEBUFFER_COMPLETE_EXT != glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT))
    1003         DEBUG_MSG(("OVIW(%p): Framebuffer Object creation or update failed!\n", (void*)self));
    1004 
    1005 //    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
    1006     glBindTexture(GL_TEXTURE_RECTANGLE_ARB, oldTexId);
    1007     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, (GLuint)oldFBId ? (GLuint)oldFBId : m_FBOId);
    1008 
    1009     /* Is there a dock tile preview enabled in the GUI? If so setup a
     894    /* [self updateViewport]; */
     895    if (m_pSharedGLCtx)
     896    {
     897        [self performSelectorMakingCurrent:m_pSharedGLCtx idSel:@selector(updateViewportCS)];
     898    }
     899}
     900
     901- (void)createDockTile
     902{
     903        NSView *pDockScreen      = nil;
     904        [self deleteDockTile];
     905       
     906        /* Is there a dock tile preview enabled in the GUI? If so setup a
    1010907     * additional thumbnail view for the dock tile. */
    1011     pDockScreen = [self dockTileScreen];
    1012     if (pDockScreen)
    1013     {
    1014         if (!m_FBOThumbId)
    1015         {
    1016             glGenFramebuffersEXT(1, &m_FBOThumbId);
    1017             glGenTextures(1, &m_FBOThumbTexId);
    1018         }
    1019 
    1020         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FBOThumbId);
    1021         /* Initialize FBO Texture */
    1022         glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_FBOThumbTexId);
    1023         glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    1024         glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    1025         glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
    1026         glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
    1027 
    1028         /* The GPUs like the GL_BGRA / GL_UNSIGNED_INT_8_8_8_8_REV combination
    1029          * others are also valid, but might incur a costly software translation. */
    1030         glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, m_FBOTexSize.width * m_FBOThumbScaleX, m_FBOTexSize.height * m_FBOThumbScaleY, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
    1031 
    1032         /* Now attach texture to the FBO as its color destination */
    1033         glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, m_FBOThumbTexId, 0);
    1034 
    1035         /* Make sure the FBO was created successfully. */
    1036         if (GL_FRAMEBUFFER_COMPLETE_EXT != glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT))
    1037             DEBUG_MSG(("OVIW(%p): Framebuffer \"Thumb\" Object creation or update failed!\n", (void*)self));
    1038 
    1039         glBindTexture(GL_TEXTURE_RECTANGLE_ARB, oldTexId);
    1040         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, (GLuint)oldFBId ? (GLuint)oldFBId : m_FBOId);
    1041 
     908        pDockScreen = [self dockTileScreen];
     909        if (pDockScreen)
     910    {
    1042911        m_DockTileView = [[DockOverlayView alloc] init];
    1043912        [self reshapeDockTile];
    1044913        [pDockScreen addSubview:m_DockTileView];
    1045914    }
    1046 
    1047     /* Initialize with one big visual region over the full size */
    1048     [self clearVisibleRegions];
    1049     m_cClipRects = 1;
    1050     m_paClipRects = (GLint*)RTMemAlloc(sizeof(GLint) * 4);
    1051     m_paClipRects[0] = 0;
    1052     m_paClipRects[1] = 0;
    1053     m_paClipRects[2] = m_FBOTexSize.width;
    1054     m_paClipRects[3] = m_FBOTexSize.height;
    1055 #endif
    1056 }
    1057 
    1058 - (void)deleteFBO
    1059 {
    1060     DEBUG_MSG(("OVIW(%p): deleteFBO\n", (void*)self));
    1061 
    1062     if (m_pSharedGLCtx)
    1063     {
    1064         DEBUG_MSG(("OVIW(%p): makeCurrent (shared) %p\n", (void*)self, (void*)m_pSharedGLCtx));
    1065         [m_pSharedGLCtx makeCurrentContext];
    1066         [m_pSharedGLCtx update];
    1067 
    1068         glEnable(GL_TEXTURE_RECTANGLE_ARB);
    1069         glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
    1070     }
    1071 
    1072     if (m_pGLCtx)
    1073     {
    1074         DEBUG_MSG(("OVIW(%p): makeCurrent (non shared) %p\n", (void*)self, (void*)m_pGLCtx));
    1075         [m_pGLCtx makeCurrentContext];
    1076 
    1077 #ifdef FBO
    1078         if (m_FBODepthStencilPackedId > 0)
    1079         {
    1080             glDeleteRenderbuffersEXT(1, &m_FBODepthStencilPackedId);
    1081             m_FBODepthStencilPackedId = 0;
    1082         }
    1083         if (m_FBOTexBackId > 0)
    1084         {
    1085             glDeleteTextures(1, &m_FBOTexBackId);
    1086             m_FBOTexBackId = 0;
    1087         }
    1088         if (m_FBOTexFrontId > 0)
    1089         {
    1090             glDeleteTextures(1, &m_FBOTexFrontId);
    1091             m_FBOTexFrontId = 0;
    1092         }
    1093         if (m_FBOId > 0)
    1094         {
    1095             if ([self isCurrentFBO])
    1096                 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    1097 
    1098             glDeleteFramebuffersEXT(1, &m_FBOId);
    1099             m_FBOId = 0;
    1100         }
    1101 #endif
    1102     }
    1103 
    1104     if (m_DockTileView != nil)
     915}
     916
     917- (void)deleteDockTile
     918{
     919        if (m_DockTileView != nil)
    1105920    {
    1106921        [m_DockTileView removeFromSuperview];
     
    1110925}
    1111926
    1112 - (void)updateFBO
    1113 {
    1114     DEBUG_MSG(("OVIW(%p): updateFBO\n", (void*)self));
    1115 
    1116     [self makeCurrentFBO];
    1117 
    1118     if (m_pGLCtx)
    1119     {
    1120 #ifdef FBO
    1121         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    1122         [self createFBO];
    1123         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FBOId);
    1124 #endif
    1125         [m_pGLCtx update];
    1126     }
    1127 }
    1128 
    1129927- (void)makeCurrentFBO
    1130928{
    1131929    DEBUG_MSG(("OVIW(%p): makeCurrentFBO\n", (void*)self));
    1132930
    1133 #ifdef FBO
    1134     DEBUG_MSG(("OVIW(%p): FBOId=%d CTX=%p\n", (void*)self, m_FBOId, (void*)m_pGLCtx));
    1135     if([NSOpenGLContext currentContext] != 0)
    1136         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FBOId);
    1137 #endif
    1138931    if (m_pGLCtx)
    1139932    {
     
    1150943        */
    1151944        {
    1152             [m_pGLCtx makeCurrentContext];
     945            vboxCtxSetCurrent(m_pGLCtx);
    1153946            CHECK_GL_ERROR();
    1154             /*
    1155             [m_pGLCtx update];
    1156             */
     947            if (m_fNeedCtxUpdate == true)
     948            {
     949                [m_pGLCtx update];
     950                m_fNeedCtxUpdate = false;
     951            }
    1157952        }
    1158     }
    1159 #ifdef FBO
    1160     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FBOId);
    1161 #endif
    1162 }
    1163 
    1164 - (bool)isCurrentFBO
    1165 {
    1166 #ifdef FBO
    1167     GLint curFBOId = 0;
    1168 
    1169     glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &curFBOId);
    1170     DEBUG_MSG_1(("OVIW(%p): isCurrentFBO: curFBOId=%d FBOId=%d\n", (void*)self, curFBOId, m_FBOId));
    1171     return (GLuint)curFBOId == m_FBOId;
    1172 #else
    1173     return false;
    1174 #endif
     953       
     954        if (!m_FBOId)
     955        {
     956            glGenFramebuffersEXT(1, &m_FBOId);
     957            Assert(m_FBOId);
     958        }
     959       
     960    }
    1175961}
    1176962
     
    1179965    if ([self lockFocusIfCanDraw])
    1180966    {
    1181         [self renderFBOToView];
     967        [self vboxPresent];
    1182968        [self unlockFocus];
    1183969    }
     
    1186972- (void)swapFBO
    1187973{
    1188     GLint sw     = 0;
    1189     GLint readFBOId = 0;
    1190     GLint drawFBOId = 0;
    1191     GLint readId = 0;
    1192     GLint drawId = 0;
    1193 
    1194     DEBUG_MSG(("OVIW(%p): swapFBO\n", (void*)self));
    1195 
    1196 #ifdef FBO
    1197     /* Don't use flush buffers cause we are using FBOs here! */
    1198 
    1199     /* Before we swap make sure everything is done (This is really
    1200      * important. Don't remove.) */
    1201     glFlush();
    1202 
    1203     /* Fetch the current used read and draw buffers. */
    1204     glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &readFBOId);
    1205     glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFBOId);
    1206     glGetIntegerv(GL_READ_BUFFER, &readId);
    1207     glGetIntegerv(GL_DRAW_BUFFER, &drawId);
    1208 
    1209     /* Do the swapping of our internal ids */
    1210     sw              = m_FBOTexFrontId;
    1211     m_FBOTexFrontId = m_FBOTexBackId;
    1212     m_FBOTexBackId  = sw;
    1213     sw              = m_FBOAttFrontId;
    1214     m_FBOAttFrontId = m_FBOAttBackId;
    1215     m_FBOAttBackId  = sw;
    1216 
    1217     DEBUG_MSG_1(("read FBO: %d draw FBO: %d readId: %d drawId: %d\n", readFBOId, drawFBOId, readId, drawId));
    1218     /* We also have to swap the real ids on the current context. */
    1219     if ((GLuint)readFBOId == m_FBOId)
    1220     {
    1221         if ((GLuint)readId == m_FBOAttFrontId)
    1222             glReadBuffer(m_FBOAttBackId);
    1223         if ((GLuint)readId == m_FBOAttBackId)
    1224             glReadBuffer(m_FBOAttFrontId);
    1225     }
    1226     if ((GLuint)drawFBOId == m_FBOId)
    1227     {
    1228         if ((GLuint)drawId == m_FBOAttFrontId)
    1229             glDrawBuffer(m_FBOAttBackId);
    1230         if ((GLuint)drawId == m_FBOAttBackId)
    1231             glDrawBuffer(m_FBOAttFrontId);
    1232     }
    1233 
    1234     if (m_cClipRects)
    1235         [self tryDraw];
    1236 #else
    1237974    [m_pGLCtx flushBuffer];
    1238 #endif
    1239 }
    1240 
    1241 - (void)flushFBO
    1242 {
    1243     GLint drawId = 0;
    1244     GLint FBOId  = 0;
    1245 
    1246     DEBUG_MSG(("OVIW(%p): flushFBO\n", (void*)self));
    1247 
    1248     glFlush();
    1249 #ifdef FBO
    1250     /* If at any time OpenGl operations where done in the front buffer, we need
    1251      * to reflect this in the FBO as well. This is something which on real
    1252      * hardware happens and unfortunately some applications rely on it (grrr ... Compiz). */
    1253     if (   m_fFrontDrawing
    1254         && [self isCurrentFBO])
    1255     {
    1256         /* Only reset if we aren't currently front. */
    1257         glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &FBOId);
    1258         glGetIntegerv(GL_DRAW_BUFFER, &drawId);
    1259         if (!(   (GLuint)FBOId  == m_FBOId
    1260               && (GLuint)drawId == m_FBOAttFrontId))
    1261             m_fFrontDrawing = false;
    1262         if (m_cClipRects)
    1263             [self tryDraw];
    1264     }
    1265 #endif
    1266 }
    1267 
    1268 - (void)finishFBO
    1269 {
    1270     DEBUG_MSG(("OVIW(%p): finishFBO\n", (void*)self));
    1271 
    1272     glFinish();
    1273 #ifdef FBO
    1274     if (m_cClipRects && [self isCurrentFBO])
    1275         [self tryDraw];
    1276 #endif
    1277 }
    1278 
    1279 - (void)stateInfo:(GLenum)pname withParams:(GLint*)params
    1280 {
    1281     GLint test;
    1282 //    DEBUG_MSG_1(("StateInfo requested: %d\n", pname));
    1283 
    1284     glGetIntegerv(pname, params);
    1285 #ifdef FBO
    1286     switch(pname)
    1287     {
    1288         case GL_FRAMEBUFFER_BINDING_EXT:
    1289         case GL_READ_FRAMEBUFFER_BINDING:
    1290         case GL_READ_FRAMEBUFFER_EXT:
    1291         case GL_DRAW_FRAMEBUFFER_EXT:
    1292         {
    1293             if ((GLuint)*params == m_FBOId)
    1294                 *params = 0;
    1295             break;
    1296         }
    1297         case GL_READ_BUFFER:
    1298         {
    1299             glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &test);
    1300             if ((GLuint)test == m_FBOId)
     975}
     976
     977- (void)vboxPresent
     978{
     979    GLint opaque       = 0;
     980
     981    DEBUG_MSG(("OVIW(%p): renderFBOToView\n", (void*)self));
     982   
     983    if (!m_pCompositor)
     984        return;
     985
     986#ifdef DEBUG
    1301987            {
    1302                 if ((GLuint)*params == m_FBOAttFrontId)
    1303                     *params = GL_FRONT;
    1304                 else
    1305                     if ((GLuint)*params == m_FBOAttBackId)
    1306                         *params = GL_BACK;
     988                NSOpenGLContext *pTstOldCtx = [NSOpenGLContext currentContext];
     989                NSView *pTstOldView = (pTstOldCtx ? [pTstOldCtx view] : nil);
     990                Assert(pTstOldCtx == m_pGLCtx);
     991                Assert(pTstOldView == self);
    1307992            }
    1308             break;
    1309         }
    1310         case GL_DRAW_BUFFER:
    1311         {
    1312             glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &test);
    1313             if ((GLuint)test == m_FBOId)
    1314             {
    1315                 if ((GLuint)*params == m_FBOAttFrontId)
    1316                     *params = GL_FRONT;
    1317                 else
    1318                     if ((GLuint)*params == m_FBOAttBackId)
    1319                         *params = GL_BACK;
    1320             }
    1321             break;
    1322         }
    1323     }
    1324 #endif
    1325 }
    1326 
    1327 - (void)readBuffer:(GLenum)mode
    1328 {
    1329 #ifdef FBO
    1330     /*
    1331     if ([self isCurrentFBO])
    1332     */
    1333     {
    1334         if (mode == GL_FRONT)
    1335         {
    1336             glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_FBOId);
    1337             glReadBuffer(m_FBOAttFrontId);
    1338         }
    1339         else if (mode == GL_BACK)
    1340         {
    1341             glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_FBOId);
    1342             glReadBuffer(m_FBOAttBackId);
    1343         }
    1344         else
    1345             glReadBuffer(mode);
    1346     }
    1347 #else
    1348     glReadBuffer(mode);
    1349 #endif
    1350 }
    1351 
    1352 - (void)drawBuffer:(GLenum)mode
    1353 {
    1354 #ifdef FBO
    1355     /*
    1356     if ([self isCurrentFBO])
    1357     */
    1358     {
    1359         if (mode == GL_FRONT)
    1360         {
    1361             DEBUG_MSG(("OVIW(%p): front\n", (void*)self));
    1362             glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_FBOId);
    1363             glDrawBuffer(m_FBOAttFrontId);
    1364             m_fFrontDrawing = true;
    1365         }
    1366         else if (mode == GL_BACK)
    1367         {
    1368             DEBUG_MSG(("OVIW(%p): back\n", (void*)self));
    1369             glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_FBOId);
    1370             glDrawBuffer(m_FBOAttBackId);
    1371         }
    1372         else
    1373         {
    1374             DEBUG_MSG(("OVIW(%p): other: %d\n", (void*)self, mode));
    1375             glDrawBuffer(mode);
    1376         }
    1377     }
    1378 #else
    1379     glDrawBuffer(mode);
    1380 #endif
    1381 }
    1382 
    1383 - (void)bindFBO:(GLenum)target withFrameBuffer:(GLuint)framebuffer
    1384 {
    1385 #ifdef FBO
    1386     if (framebuffer != 0)
    1387         glBindFramebufferEXT(target, framebuffer);
    1388     else
    1389         glBindFramebufferEXT(target, m_FBOId);
    1390 #else
    1391     glBindFramebufferEXT(target, framebuffer);
    1392 #endif
    1393 }
    1394 
    1395 - (void)renderFBOToView
    1396 {
    1397     GLint opaque       = 0;
    1398     GLint i            = 0;
    1399     GLint oldReadFBOId = 0;
    1400     GLint oldDrawFBOId = 0;
    1401     GLint oldReadId    = 0;
    1402     GLint oldDrawId    = 0;
    1403 
    1404     DEBUG_MSG(("OVIW(%p): renderFBOToView\n", (void*)self));
    1405 
    1406 #ifdef FBO
    1407 
    1408     /* Fetch the current used read and draw buffers. */
    1409     glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &oldReadFBOId);
    1410     glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &oldDrawFBOId);
    1411     glGetIntegerv(GL_READ_BUFFER, &oldReadId);
    1412     glGetIntegerv(GL_DRAW_BUFFER, &oldDrawId);
     993#endif
    1413994
    1414995    if (!m_pSharedGLCtx)
     
    14211002        /* Set this view as the drawable for the new context */
    14221003        [m_pSharedGLCtx setView: self];
    1423         [self updateViewport];
    1424     }
    1425 
    1426     if (m_pSharedGLCtx)
    1427     {
     1004        m_fNeedViewportUpdate = true;
     1005    }
     1006   
     1007#ifdef DEBUG
     1008            {
     1009                NSOpenGLContext *pTstOldCtx = [NSOpenGLContext currentContext];
     1010                NSView *pTstOldView = (pTstOldCtx ? [pTstOldCtx view] : nil);
     1011                Assert(pTstOldCtx == m_pGLCtx);
     1012                Assert(pTstOldView == self);
     1013            }
     1014#endif
     1015   
     1016    [self performSelectorMakingCurrent:m_pSharedGLCtx idSel:@selector(vboxPresentCS)];
     1017}
     1018
     1019- (void)vboxPresentCS
     1020{
    14281021        NSRect r = [self frame];
    14291022        DEBUG_MSG(("OVIW(%p): rF2V frame: [%i, %i, %i, %i]\n", (void*)self, (int)r.origin.x, (int)r.origin.y, (int)r.size.width, (int)r.size.height));
    14301023
    1431         if (m_FBOTexFrontId > 0)
    14321024        {
    14331025            if ([m_pSharedGLCtx view] != self)
     
    14351027                DEBUG_MSG(("OVIW(%p): not current view of shared ctx! Switching ...\n", (void*)self));
    14361028                [m_pSharedGLCtx setView: self];
    1437                 [self updateViewport];
     1029                m_fNeedViewportUpdate = true;
    14381030            }
    1439 
    1440             [m_pSharedGLCtx makeCurrentContext];
    1441 
     1031           
     1032            if (m_fNeedViewportUpdate)
     1033            {
     1034                [self updateViewportCS];
     1035                m_fNeedViewportUpdate = false;
     1036            }
     1037           
     1038            /* Render FBO content to the dock tile when necessary. */
     1039            [self vboxPresentToDockTileCS];
     1040           
     1041            [self vboxPresentToViewCS];
     1042        }
     1043}
     1044
     1045- (void)vboxPresentToViewCS
     1046{
     1047#if 1 /* Set to 0 to see the docktile instead of the real output */
     1048    VBOXVR_SCR_COMPOSITOR_ITERATOR CIter;
     1049    PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
     1050       
     1051    CrVrScrCompositorIterInit(m_pCompositor, &CIter);
     1052       
     1053    glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
     1054    glDrawBuffer(GL_BACK);
     1055
     1056    /* Clear background to transparent */
     1057    glClear(GL_COLOR_BUFFER_BIT);
     1058       
     1059    while ((pEntry = CrVrScrCompositorIterNext(&CIter)) != NULL)
     1060    {
     1061        uint32_t cRegions;
     1062        const RTRECT *paSrcRegions, *paDstRegions;
     1063        int rc = CrVrScrCompositorEntryRegionsGet(m_pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions);
     1064        if (RT_SUCCESS(rc))
     1065        {
     1066            uint32_t i;
     1067                   
    14421068            glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_FBOId);
    1443             glReadBuffer(m_FBOAttFrontId);
    1444             glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
    1445             glDrawBuffer(GL_BACK);
    1446 
    1447             /* Render FBO content to the dock tile when necessary. */
    1448             [self renderFBOToDockTile];
    1449 
    1450 #if 1 /* Set to 0 to see the docktile instead of the real output */
    1451             /* Clear background to transparent */
    1452             glClear(GL_COLOR_BUFFER_BIT);
    1453 
    1454             /* Blit the content of the FBO to the screen. */
    1455             for (i = 0; i < m_cClipRects; ++i)
     1069            glFramebufferTexture2DEXT(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, pEntry->Tex.target, pEntry->Tex.hwid, 0);
     1070            glReadBuffer(GL_COLOR_ATTACHMENT0);
     1071                   
     1072            for (i = 0; i < pEntry->cRects; ++i)
    14561073            {
    1457                 GLint x1 = m_paClipRects[4*i];
    1458                 GLint y1 = r.size.height - m_paClipRects[4*i+1];
    1459                 GLint x2 = m_paClipRects[4*i+2];
    1460                 GLint y2 = r.size.height - m_paClipRects[4*i+3];
    1461                 glBlitFramebufferEXT(x1, y1 + m_RootShift.y, x2, y2 + m_RootShift.y,
    1462                                      x1 - m_RootShift.x, y1, x2 - m_RootShift.x, y2,
    1463                                      GL_COLOR_BUFFER_BIT, GL_NEAREST);
     1074                const RTRECT * pSrcRect = &paSrcRegions[i];
     1075                const RTRECT * pDstRect = &paDstRegions[i];
     1076                       
     1077                glBlitFramebufferEXT(pSrcRect->xLeft, pSrcRect->yTop, pSrcRect->xRight, pSrcRect->yBottom,
     1078                                            pDstRect->xLeft, pDstRect->yTop, pDstRect->xRight, pDstRect->yBottom,
     1079                                            GL_COLOR_BUFFER_BIT, GL_LINEAR);
    14641080            }
     1081        }
     1082        else
     1083        {
     1084            Assert(0);
     1085            DEBUG_MSG_1(("BlitStretched: CrVrScrCompositorEntryRegionsGet failed rc %d\n", rc));
     1086        }
     1087    }
    14651088#endif
    14661089            /*
     
    14691092            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    14701093            [m_pSharedGLCtx flushBuffer];
    1471 
    1472             [m_pGLCtx makeCurrentContext];
    1473             /* Reset to previous buffer bindings. */
    1474             glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, oldReadFBOId);
    1475             glReadBuffer(oldReadId);
    1476             glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, oldDrawFBOId);
    1477             glDrawBuffer(oldDrawId);
     1094}
     1095
     1096- (void)performSelectorMakingCurrent:(NSOpenGLContext*)pCtx idSel:(SEL)selector
     1097{
     1098    NSOpenGLContext *pOldCtx = vboxCtxGetCurrent();
     1099    NSView *pOldView = (pOldCtx ? [pOldCtx view] : nil);
     1100    NSView *pView = [pCtx view];
     1101    bool fNeedCtxSwitch = (pOldCtx != pCtx || pOldView != pView);
     1102    Assert(pCtx);
     1103    Assert(pOldCtx == m_pGLCtx);
     1104    Assert(pOldView == self);
     1105    Assert(fNeedCtxSwitch);
     1106    if (fNeedCtxSwitch)
     1107    {
     1108        if(pOldCtx != nil)
     1109            glFlush();
     1110       
     1111        vboxCtxSetCurrent(pCtx);
     1112    }
     1113   
     1114    [self performSelector:selector];
     1115   
     1116    if (fNeedCtxSwitch)
     1117    {
     1118        glFlush();
     1119        if (pOldCtx != nil)
     1120        {
     1121            if ([pOldCtx view] != pOldView)
     1122            {
     1123                [pOldCtx setView: pOldView];
     1124            }
     1125       
     1126                vboxCtxSetCurrent(pOldCtx);
     1127           
     1128#ifdef DEBUG
     1129            {
     1130                NSOpenGLContext *pTstOldCtx = [NSOpenGLContext currentContext];
     1131                NSView *pTstOldView = (pTstOldCtx ? [pTstOldCtx view] : nil);
     1132                Assert(pTstOldCtx == pOldCtx);
     1133                Assert(pTstOldView == pOldView);
     1134            }
     1135#endif
    14781136        }
    1479     }
    1480 #else
    1481     [m_pGLCtx flushBuffer];
    1482 #endif
    1483 }
    1484 
    1485 - (void)renderFBOToDockTile
     1137        else
     1138        {
     1139            [NSOpenGLContext clearCurrentContext];
     1140        }
     1141    }
     1142}
     1143
     1144- (void)presentComposition:(PVBOXVR_SCR_COMPOSITOR)pCompositor withChangedEntry:(PVBOXVR_SCR_COMPOSITOR_ENTRY)pChangedEntry
     1145{
     1146    m_pCompositor = pCompositor;
     1147   
     1148    [self tryDraw];
     1149}
     1150
     1151- (void)vboxPresentToDockTileCS
    14861152{
    14871153    NSRect r        = [self frame];
     
    14901156    NSDockTile *pDT = nil;
    14911157
    1492 #ifdef FBO
    1493     if (   m_FBOThumbId
    1494         && m_FBOThumbTexId
    1495         && [m_DockTileView thumbBitmap] != nil)
     1158    if ([m_DockTileView thumbBitmap] != nil)
    14961159    {
    14971160        /* Only update after at least 200 ms, cause glReadPixels is
    14981161         * heavy performance wise. */
    14991162        uint64_t uiNewTime = RTTimeMilliTS();
     1163        VBOXVR_SCR_COMPOSITOR_ITERATOR CIter;
     1164        PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
     1165       
    15001166        if (uiNewTime - m_uiDockUpdateTime > 200)
    15011167        {
     
    15171183                          GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
    15181184#endif
     1185            glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
     1186            glDrawBuffer(GL_BACK);
     1187
    15191188            /* Clear background to transparent */
    15201189            glClear(GL_COLOR_BUFFER_BIT);
    15211190
    15221191            rr = [m_DockTileView frame];
    1523 
    1524             for (i = 0; i < m_cClipRects; ++i)
     1192           
     1193            CrVrScrCompositorIterInit(m_pCompositor, &CIter);
     1194            while ((pEntry = CrVrScrCompositorIterNext(&CIter)) != NULL)
    15251195            {
    1526                 GLint x1 = m_paClipRects[4*i];
    1527                 GLint y1 = r.size.height - m_paClipRects[4*i+1];
    1528                 GLint x2 = m_paClipRects[4*i+2];
    1529                 GLint y2 = r.size.height - m_paClipRects[4*i+3];
    1530 
    1531                 glBlitFramebufferEXT(x1, y1 + m_RootShift.y, x2, y2 + m_RootShift.y,
    1532                                      x1 * m_FBOThumbScaleX, y1 * m_FBOThumbScaleY, x2 * m_FBOThumbScaleX, y2 * m_FBOThumbScaleY,
    1533                                      GL_COLOR_BUFFER_BIT, GL_LINEAR);
     1196                uint32_t cRegions;
     1197                const RTRECT *paSrcRegions, *paDstRegions;
     1198                int rc = CrVrScrCompositorEntryRegionsGet(m_pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions);
     1199                if (RT_SUCCESS(rc))
     1200                {
     1201                    uint32_t i;
     1202                   
     1203                    glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_FBOId);
     1204                    glFramebufferTexture2DEXT(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, pEntry->Tex.target, pEntry->Tex.hwid, 0);
     1205                    glReadBuffer(GL_COLOR_ATTACHMENT0);
     1206                   
     1207                    for (i = 0; i < pEntry->cRects; ++i)
     1208                    {
     1209                        const RTRECT * pSrcRect = &paSrcRegions[i];
     1210                        const RTRECT * pDstRect = &paDstRegions[i];
     1211                       
     1212                        glBlitFramebufferEXT(pSrcRect->xLeft, pSrcRect->yTop, pSrcRect->xRight, pSrcRect->yBottom,
     1213                                            pDstRect->xLeft * m_FBOThumbScaleX, pDstRect->yTop * m_FBOThumbScaleY, pDstRect->xRight * m_FBOThumbScaleX, pDstRect->yBottom * m_FBOThumbScaleY,
     1214                                            GL_COLOR_BUFFER_BIT, GL_LINEAR);
     1215                    }
     1216                }
     1217                else
     1218                {
     1219                    Assert(0);
     1220                    DEBUG_MSG_1(("BlitStretched: CrVrScrCompositorEntryRegionsGet failed rc %d\n", rc));
     1221                }
    15341222            }
     1223           
    15351224            glFinish();
    15361225
     
    15471236            [m_DockTileView unlock];
    15481237
    1549             glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_FBOId);
    1550             glReadBuffer(m_FBOAttFrontId);
    1551 
    15521238            pDT = [[NSApplication sharedApplication] dockTile];
    15531239
    15541240            /* Send a display message to the dock tile in the main thread */
    15551241            [[[NSApplication sharedApplication] dockTile] performSelectorOnMainThread:@selector(display) withObject:nil waitUntilDone:NO];
    1556 
    15571242        }
    15581243    }
    1559 #endif
    15601244}
    15611245
     
    15901274        memcpy(m_paClipRects, paRects, sizeof(GLint) * 4 * cRects);
    15911275    }
     1276#if 0
     1277    /* todo: handle pending m_fNeedCtxUpdate */
    15921278    else if (cOldRects)
    15931279        [self tryDraw];
     1280#endif
    15941281}
    15951282
     
    17791466        {
    17801467            [[pParentView window] addChildWindow:[pOView overlayWin] ordered:NSWindowAbove];
    1781             [pOView createFBO];
     1468            [pOView createDockTile];
    17821469        }
    17831470    }
     
    18871574}
    18881575
     1576void cocoaViewPresentComposition(NativeNSViewRef pView, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry)
     1577{
     1578    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
     1579
     1580    [(OverlayView*)pView presentComposition:pCompositor withChangedEntry:pChangedEntry];
     1581
     1582    [pPool release];
     1583}
     1584
    18891585void cocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx)
    18901586{
     
    19071603    [pPool release];
    19081604}
    1909 
    1910 /********************************************************************************
    1911 *
    1912 * Additional OpenGL wrapper
    1913 *
    1914 ********************************************************************************/
    1915 static void performSelectorOnView(SEL selector)
    1916 {
    1917     NSOpenGLContext *pCtx = [NSOpenGLContext currentContext];
    1918 
    1919     if (pCtx)
    1920     {
    1921         NSView *pView = [pCtx view];
    1922         if (pView)
    1923         {
    1924             if ([pView respondsToSelector:selector])
    1925                 [pView performSelector:selector];
    1926         }
    1927     }
    1928 }
    1929 
    1930 static void performSelectorOnViewOneArg(SEL selector, id arg1)
    1931 {
    1932     NSOpenGLContext *pCtx = [NSOpenGLContext currentContext];
    1933 
    1934     if (pCtx)
    1935     {
    1936         NSView *pView = [pCtx view];
    1937         if (pView)
    1938         {
    1939             if ([pView respondsToSelector:selector])
    1940                 [pView performSelector:selector withObject:arg1];
    1941         }
    1942     }
    1943 }
    1944 
    1945 static void performSelectorOnViewTwoArgs(SEL selector, id arg1, id arg2)
    1946 {
    1947     NSOpenGLContext *pCtx = [NSOpenGLContext currentContext];
    1948 
    1949     if (pCtx)
    1950     {
    1951         NSView *pView = [pCtx view];
    1952         if (pView)
    1953         {
    1954             if ([pView respondsToSelector:selector])
    1955                 [pView performSelector:selector withObject:arg1 withObject:arg2];
    1956         }
    1957     }
    1958 }
    1959 
    1960 void cocoaFlush(void)
    1961 {
    1962     NSOpenGLContext *pCtx = nil;
    1963 
    1964     NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    1965 
    1966     DEBUG_MSG_1(("glFlush called\n"));
    1967 
    1968     performSelectorOnView(@selector(flushFBO));
    1969 
    1970     [pPool release];
    1971 }
    1972 
    1973 void cocoaFinish(void)
    1974 {
    1975     NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    1976 
    1977     DEBUG_MSG_1(("glFinish called\n"));
    1978 
    1979     performSelectorOnView(@selector(finishFBO));
    1980 
    1981     [pPool release];
    1982 }
    1983 
    1984 void cocoaBindFramebufferEXT(GLenum target, GLuint framebuffer)
    1985 {
    1986     NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    1987 
    1988     DEBUG_MSG_1(("glBindFramebufferEXT called target: %d  fb: %d\n", target, framebuffer));
    1989 
    1990     performSelectorOnViewTwoArgs(@selector(bindFBO:withFrameBuffer:), (id)target, (id)framebuffer);
    1991 
    1992     [pPool release];
    1993 }
    1994 
    1995 void cocoaCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
    1996 {
    1997     NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    1998     GLbitfield mask = GL_COLOR_BUFFER_BIT;
    1999 
    2000     DEBUG_MSG_1(("glCopyPixels called: %d,%d-%dx%d type: %d\n", x, y, width, height, type));
    2001 
    2002 #ifdef FBO
    2003     if (type == GL_DEPTH)
    2004         mask = GL_DEPTH_BUFFER_BIT;
    2005     else if (type == GL_STENCIL)
    2006         mask = GL_STENCIL_BUFFER_BIT;
    2007     glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, mask, GL_NEAREST);
    2008 #else
    2009     glCopyPixels(x, y, width, height, type);
    2010 #endif
    2011 
    2012     [pPool release];
    2013 }
    2014 
    2015 void cocoaGetIntegerv(GLenum pname, GLint *params)
    2016 {
    2017     NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    2018 
    2019 //    DEBUG_MSG_1(("getIntergerv called: %d\n", pname));
    2020 
    2021     performSelectorOnViewTwoArgs(@selector(stateInfo:withParams:), (id)pname, (id)params);
    2022 
    2023     [pPool release];
    2024 }
    2025 
    2026 void cocoaReadBuffer(GLenum mode)
    2027 {
    2028     NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    2029 
    2030     DEBUG_MSG_1(("glReadBuffer called: %d\n", mode));
    2031 
    2032     performSelectorOnViewOneArg(@selector(readBuffer:), (id)mode);
    2033 
    2034     [pPool release];
    2035 }
    2036 
    2037 void cocoaDrawBuffer(GLenum mode)
    2038 {
    2039     NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    2040 
    2041     DEBUG_MSG_1(("glDrawBuffer called: %d\n", mode));
    2042 
    2043     performSelectorOnViewOneArg(@selector(drawBuffer:), (id)mode);
    2044 
    2045     [pPool release];
    2046 }
    2047 
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c

    r44714 r44740  
    641641        window->x = 0;
    642642        window->y = 0;
    643         window->width  = xwa.width;
    644         window->height = xwa.height;
     643        window->BltInfo.width  = xwa.width;
     644        window->BltInfo.height = xwa.height;
    645645    }
    646646
    647647    /* i've changed default window size to be 0,0 but X doesn't like it */
    648     /*CRASSERT(window->width >= 1);
    649     CRASSERT(window->height >= 1);*/
    650     if (window->width < 1) window->width = 1;
    651     if (window->height < 1) window->height = 1;
     648    /*CRASSERT(window->BltInfo.width >= 1);
     649    CRASSERT(window->BltInfo.height >= 1);*/
     650    if (window->BltInfo.width < 1) window->BltInfo.width = 1;
     651    if (window->BltInfo.height < 1) window->BltInfo.height = 1;
    652652
    653653    /*
     
    708708        window->window = XCreateWindow(dpy, render_spu_parent_window_id,
    709709                                       window->x, window->y,
    710                                        window->width, window->height,
     710                                       window->BltInfo.width, window->BltInfo.height,
    711711                                       0, visual->visual->depth, InputOutput,
    712712                                       visual->visual->visual, flags, &swa);
     
    721721        window->window = XCreateWindow(dpy, RootWindow(dpy, visual->visual->screen),
    722722                                       window->x, window->y,
    723                                        window->width, window->height,
     723                                       window->BltInfo.width, window->BltInfo.height,
    724724                                       0, visual->visual->depth, InputOutput,
    725725                                       visual->visual->visual, flags, &swa);
     
    791791    hints.x = window->x;
    792792    hints.y = window->y;
    793     hints.width = window->width;
    794     hints.height = window->height;
     793    hints.width = window->BltInfo.width;
     794    hints.height = window->BltInfo.height;
    795795    hints.min_width = hints.width;
    796796    hints.min_height = hints.height;
     
    836836         * which form a mural are in the same swap group.
    837837         */
    838         GLuint group = 0; /*render_spu.nvSwapGroup + window->id;*/
     838        GLuint group = 0; /*render_spu.nvSwapGroup + window->BltInfo.Base.id;*/
    839839        GLuint barrier = 0;
    840840        JoinSwapGroup(dpy, visual->visual->screen, window->window, group, barrier);
     
    845845     */
    846846    crDebug( "Render SPU: actual window x, y, width, height: %d, %d, %d, %d",
    847                      window->x, window->y, window->width, window->height );
     847                     window->x, window->y, window->BltInfo.width, window->BltInfo.height );
    848848
    849849    XSync(dpy, 0);
     
    861861    window->nativeWindow = 0;
    862862
    863     CRASSERT(window->width > 0);
    864     CRASSERT(window->height > 0);
     863    CRASSERT(window->BltInfo.width > 0);
     864    CRASSERT(window->BltInfo.height > 0);
    865865
    866866#ifdef GLX_VERSION_1_3
     
    868868        int attribs[100], i = 0, w, h;
    869869        CRASSERT(visual->fbconfig);
    870         w = window->width;
    871         h = window->height;
     870        w = window->BltInfo.width;
     871        h = window->BltInfo.height;
    872872        attribs[i++] = GLX_PRESERVED_CONTENTS;
    873873        attribs[i++] = True;
     
    897897{
    898898    if (visual->visAttribs & CR_PBUFFER_BIT) {
    899         window->width = render_spu.defaultWidth;
    900         window->height = render_spu.defaultHeight;
     899        window->BltInfo.width = render_spu.defaultWidth;
     900        window->BltInfo.height = render_spu.defaultHeight;
    901901        return createPBuffer(visual, window);
    902902    }
     
    10011001        crDebug("Render SPU: Created %s context (%d) on display %s for visAttribs 0x%x",
    10021002                        is_direct ? "DIRECT" : "INDIRECT",
    1003                         context->id,
     1003                        context->BltInfo.Base.id,
    10041004                        DisplayString(visual->dpy),
    10051005                        visual->visAttribs);
     
    11531153check_buffer_size( WindowInfo *window )
    11541154{
    1155     if (window->width != window->in_buffer_width
    1156         || window->height != window->in_buffer_height
     1155    if (window->BltInfo.width != window->in_buffer_width
     1156        || window->BltInfo.height != window->in_buffer_height
    11571157        || ! window->buffer) {
    11581158        crFree(window->buffer);
    11591159
    1160         window->buffer = crCalloc(window->width * window->height
     1160        window->buffer = crCalloc(window->BltInfo.width * window->BltInfo.height
    11611161                                                            * 4 * sizeof (GLubyte));
    11621162       
    1163         window->in_buffer_width = window->width;
    1164         window->in_buffer_height = window->height;
    1165 
    1166         crDebug("Render SPU: dimensions changed to %d x %d", window->width, window->height);
     1163        window->in_buffer_width = window->BltInfo.width;
     1164        window->in_buffer_height = window->BltInfo.height;
     1165
     1166        crDebug("Render SPU: dimensions changed to %d x %d", window->BltInfo.width, window->BltInfo.height);
    11671167    }
    11681168}
     
    11861186        render_spu.OSMesaMakeCurrent( (OSMesaContext) context->context,
    11871187                                                                    window->buffer, GL_UNSIGNED_BYTE,
    1188                                                                     window->width, window->height);
     1188                                                                    window->BltInfo.width, window->BltInfo.height);
    11891189        return;
    11901190    }
     
    11941194        if (window->visual != context->visual) {
    11951195            crDebug("Render SPU: MakeCurrent visual mismatch (win(%d) bits:0x%x != ctx(%d) bits:0x%x); remaking window.",
    1196                             window->id, window->visual->visAttribs,
    1197                             context->id, context->visual->visAttribs);
     1196                            window->BltInfo.Base.id, window->visual->visAttribs,
     1197                            context->BltInfo.Base.id, context->visual->visAttribs);
    11981198            /*
    11991199             * XXX have to revisit this issue!!!
     
    12741274                    crWarning("Render SPU: Can't bind context %d to CRUT/native window "
    12751275                                        "0x%x because of different X visuals (0x%x != 0x%x)!",
    1276                                         context->id, (int) nativeWindow,
     1276                                        context->BltInfo.Base.id, (int) nativeWindow,
    12771277                                        vid, (int) context->visual->visual->visualid);
    12781278                    crWarning("Render SPU: Trying to recreate GLX context to match.");
     
    13281328                                    window->visual->dpy,
    13291329                                    (int) window->window, (void *) context->context,
    1330                                     window->id, context->id );
     1330                                    window->BltInfo.Base.id, context->BltInfo.Base.id );
    13311331            }
    13321332            /*CRASSERT(b);*/
     
    13611361#ifdef USE_OSMESA
    13621362    if (render_spu.use_osmesa) {
    1363         window->width = w;
    1364         window->height = h;
     1363        window->BltInfo.width = w;
     1364        window->BltInfo.height = h;
    13651365        check_buffer_size(window);
    13661366        return;
     
    13951395        }
    13961396
    1397         if (window->width != w || window->height != h) {
     1397        if (window->BltInfo.width != w || window->BltInfo.height != h) {
    13981398            /* Only resize if the new dimensions really are different */
    13991399#ifdef CHROMIUM_THREADSAFE
     
    14041404            /* Can't resize pbuffers, so destroy it and make a new one */
    14051405            render_spu.ws.glXDestroyPbuffer(window->visual->dpy, window->window);
    1406             window->width = w;
    1407             window->height = h;
     1406            window->BltInfo.width = w;
     1407            window->BltInfo.height = h;
    14081408            crDebug("Render SPU: Creating new %d x %d PBuffer (id=%d)",
    1409                             w, h, window->id);
     1409                            w, h, window->BltInfo.Base.id);
    14101410            if (!createPBuffer(window->visual, window)) {
    14111411                crWarning("Render SPU: Unable to create PBuffer (out of VRAM?)!");
     
    14471447
    14481448    /* finally, save the new size */
    1449     window->width = w;
    1450     window->height = h;
     1449    window->BltInfo.width = w;
     1450    window->BltInfo.height = h;
    14511451}
    14521452
     
    14581458#ifdef USE_OSMESA
    14591459    if (render_spu.use_osmesa) {
    1460         *w = window->width;
    1461         *h = window->height;
     1460        *w = window->BltInfo.width;
     1461        *h = window->BltInfo.height;
    14621462        return;
    14631463    }
     
    14711471        *x = 0;
    14721472        *y = 0;
    1473         *w = window->width;
    1474         *h = window->height;
     1473        *w = window->BltInfo.width;
     1474        *h = window->BltInfo.height;
    14751475    }
    14761476    else
     
    16221622}
    16231623
     1624void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
     1625{
     1626    renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry);
     1627}
    16241628
    16251629static void
     
    16331637        gc = XCreateGC(w->visual->dpy, w->nativeWindow, GCFunction, &gcValues);
    16341638    }
    1635     XDrawLine(w->visual->dpy, w->nativeWindow, gc, 0, 0, w->width, w->height);
     1639    XDrawLine(w->visual->dpy, w->nativeWindow, gc, 0, 0, w->BltInfo.width, w->BltInfo.height);
    16361640}
    16371641
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c

    r40318 r44740  
    1010#include "cr_string.h"
    1111#include "cr_url.h"
     12#include "cr_environment.h"
    1213#include "renderspu.h"
    1314#include <stdio.h>
     
    139140    GLint defaultWin, defaultCtx;
    140141    WindowInfo *windowInfo;
     142    const char * pcpwSetting;
    141143
    142144    (void) child;
     
    200202    render_spu.contextTable = crAllocHashtable();
    201203    render_spu.windowTable = crAllocHashtable();
     204
     205    pcpwSetting = crGetenv("CR_RENDER_ENABLE_PRESENT_CONTEXT_PER_WINDOW");
     206    if (pcpwSetting)
     207    {
     208        if (pcpwSetting[0] == '0')
     209            pcpwSetting = NULL;
     210    }
     211    else
     212    {
     213        /* default is enable for OSX */
     214#if defined(DARWIN) && defined(VBOX_WITH_COCOA_QT)
     215        pcpwSetting = (char*)1;
     216#endif
     217
     218    }
     219
     220    if (pcpwSetting)
     221    {
     222        render_spu.blitterTable = crAllocHashtable();
     223        CRASSERT(render_spu.blitterTable);
     224    }
     225    else
     226        render_spu.blitterTable = NULL;
    202227
    203228    CRASSERT(render_spu.default_visual & CR_RGB_BIT);
     
    353378}
    354379
    355 
    356380static void renderSPUSelfDispatch(SPUDispatchTable *self)
    357381{
    358382    crSPUInitDispatchTable( &(render_spu.self) );
    359383    crSPUCopyDispatchTable( &(render_spu.self), self );
     384
     385    render_spu.blitterDispatch = &(render_spu.self);
    360386
    361387    render_spu.server = (CRServer *)(self->server);
     
    387413    renderspu_SystemDestroyWindow(window);
    388414    crFree(window);
     415}
     416
     417static void DeleteBlitterCallback( void *data )
     418{
     419    PCR_BLITTER pBlitter = (PCR_BLITTER) data;
     420    CrBltTerm(pBlitter);
     421    crFree(pBlitter);
    389422}
    390423
     
    397430    crFreeHashtable(render_spu.barrierHash, crFree);
    398431    render_spu.barrierHash = NULL;
     432
     433    if (render_spu.blitterTable)
     434        crFreeHashtable(render_spu.blitterTable, DeleteBlitterCallback);
    399435
    400436#ifdef RT_OS_DARWIN
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c

    r44290 r44740  
    783783        int smCyCaption = GetSystemMetrics( SM_CYCAPTION );
    784784
    785         window->width = GetSystemMetrics( SM_CXSCREEN ) ;
    786         window->height = GetSystemMetrics( SM_CYSCREEN ) ;
    787 
    788         crDebug( "Render SPU: Window Dims: %d, %d", window->width, window->height );
     785        window->BltInfo.width = GetSystemMetrics( SM_CXSCREEN ) ;
     786        window->BltInfo.height = GetSystemMetrics( SM_CYSCREEN ) ;
     787
     788        crDebug( "Render SPU: Window Dims: %d, %d", window->BltInfo.width, window->BltInfo.height );
    789789
    790790        window->x = render_spu->defaultX - smCxFixedFrame - 1;
    791791        window->y = render_spu->defaultY - smCyFixedFrame - smCyCaption;
    792792
    793         window_plus_caption_width = window->width + 2 * smCxFixedFrame;
    794         window_plus_caption_height = window->height + 2 * smCyFixedFrame + smCyCaption;
     793        window_plus_caption_width = window->BltInfo.width + 2 * smCxFixedFrame;
     794        window_plus_caption_height = window->BltInfo.height + 2 * smCyFixedFrame + smCyCaption;
    795795
    796796#else
     
    798798         * with these parameters. */
    799799
    800         window->width = GetSystemMetrics( SM_CXSCREEN ) ;
    801         window->height = GetSystemMetrics( SM_CYSCREEN ) ;
     800        window->BltInfo.width = GetSystemMetrics( SM_CXSCREEN ) ;
     801        window->BltInfo.height = GetSystemMetrics( SM_CYSCREEN ) ;
    802802        window->x = 0;
    803803        window->y = 0;
    804         window_plus_caption_width = window->width;
    805         window_plus_caption_height = window->height;
     804        window_plus_caption_width = window->BltInfo.width;
     805        window_plus_caption_height = window->BltInfo.height;
    806806
    807807#endif
     
    820820        crDebug( "Render SPU: Got the Caption " );
    821821
    822         window_plus_caption_width = window->width + 2 * smCxFixedFrame;
    823         window_plus_caption_height = window->height + 2 * smCyFixedFrame + smCyCaption;
     822        window_plus_caption_width = window->BltInfo.width + 2 * smCxFixedFrame;
     823        window_plus_caption_height = window->BltInfo.height + 2 * smCyFixedFrame + smCyCaption;
    824824
    825825        window->x = render_spu.defaultX - smCxFixedFrame;
     
    846846    {
    847847        renderspu_SystemShowWindow( window, 0 );
    848         if (window->height <= 0 || window->width <= 0)
     848        if (window->BltInfo.height <= 0 || window->BltInfo.width <= 0)
    849849        {
    850850            renderspu_SystemWindowSize(window,
    851                     window->width > 0 ? window->width : 4,
    852                     window->height > 0 ? window->height : 4);
     851                    window->BltInfo.width > 0 ? window->BltInfo.width : 4,
     852                    window->BltInfo.height > 0 ? window->BltInfo.height : 4);
    853853        }
    854854    }
     
    999999        int smCyCaption = GetSystemMetrics( SM_CYCAPTION );
    10001000
    1001         window->width = GetSystemMetrics( SM_CXSCREEN ) ;
    1002         window->height = GetSystemMetrics( SM_CYSCREEN ) ;
    1003 
    1004         crDebug( "Render SPU: Window Dims: %d, %d", window->width, window->height );
     1001        window->BltInfo.width = GetSystemMetrics( SM_CXSCREEN ) ;
     1002        window->BltInfo.height = GetSystemMetrics( SM_CYSCREEN ) ;
     1003
     1004        crDebug( "Render SPU: Window Dims: %d, %d", window->BltInfo.width, window->BltInfo.height );
    10051005
    10061006        window->x = render_spu->defaultX - smCxFixedFrame - 1;
    10071007        window->y = render_spu->defaultY - smCyFixedFrame - smCyCaption;
    10081008
    1009         window_plus_caption_width = window->width + 2 * smCxFixedFrame;
    1010         window_plus_caption_height = window->height + 2 * smCyFixedFrame + smCyCaption;
     1009        window_plus_caption_width = window->BltInfo.width + 2 * smCxFixedFrame;
     1010        window_plus_caption_height = window->BltInfo.height + 2 * smCyFixedFrame + smCyCaption;
    10111011
    10121012#else
     
    10141014         * with these parameters. */
    10151015
    1016         window->width = GetSystemMetrics( SM_CXSCREEN ) ;
    1017         window->height = GetSystemMetrics( SM_CYSCREEN ) ;
     1016        window->BltInfo.width = GetSystemMetrics( SM_CXSCREEN ) ;
     1017        window->BltInfo.height = GetSystemMetrics( SM_CYSCREEN ) ;
    10181018        window->x = 0;
    10191019        window->y = 0;
    1020         window_plus_caption_width = window->width;
    1021         window_plus_caption_height = window->height;
     1020        window_plus_caption_width = window->BltInfo.width;
     1021        window_plus_caption_height = window->BltInfo.height;
    10221022
    10231023#endif
     
    10351035        crDebug( "Render SPU: Got the Caption " );
    10361036
    1037         window_plus_caption_width = window->width + 2 * smCxFixedFrame;
    1038         window_plus_caption_height = window->height + 2 * smCyFixedFrame + smCyCaption;
     1037        window_plus_caption_width = window->BltInfo.width + 2 * smCxFixedFrame;
     1038        window_plus_caption_height = window->BltInfo.height + 2 * smCyFixedFrame + smCyCaption;
    10391039
    10401040        window->x = render_spu.defaultX;
     
    10471047            window_style,
    10481048            window->x, window->y,
    1049             window->width,
    1050             window->height,
     1049            window->BltInfo.width,
     1050            window->BltInfo.height,
    10511051            (void*) render_spu_parent_window_id, NULL, hinstance, &render_spu );*/
    10521052    {
     
    10611061        cs.x            = window->x;
    10621062        cs.y            = window->y;
    1063         cs.cx           = window->width;
    1064         cs.cy           = window->height;
     1063        cs.cx           = window->BltInfo.width;
     1064        cs.cy           = window->BltInfo.height;
    10651065        cs.hwndParent   = (void*) render_spu_parent_window_id;
    10661066        cs.hMenu        = NULL;
     
    11111111    {
    11121112        renderspu_SystemShowWindow( window, 0 );
    1113         if (window->height <= 0 || window->width <= 0)
     1113        if (window->BltInfo.height <= 0 || window->BltInfo.width <= 0)
    11141114        {
    11151115            renderspu_SystemWindowSize(window,
    1116                     window->width > 0 ? window->width : 4,
    1117                     window->height > 0 ? window->height : 4);
     1116                    window->BltInfo.width > 0 ? window->BltInfo.width : 4,
     1117                    window->BltInfo.height > 0 ? window->BltInfo.height : 4);
    11181118        }
    11191119    }
     
    11281128    /* Intel drivers require a window to be visible for proper 3D rendering,
    11291129     * so set it visible and handle the visibility with visible regions (see below) */
    1130     if (window->id)
     1130    if (window->BltInfo.Base.id)
    11311131    {
    11321132        ShowWindow( window->hWnd, SW_SHOWNORMAL );
     
    11411141
    11421142    SetWindowPos( window->hWnd, HWND_TOP, window->x, window->y,
    1143                   window->width, window->height,
     1143                  window->BltInfo.width, window->BltInfo.height,
    11441144                  ( render_spu.fullscreen ?
    11451145                    (SWP_SHOWWINDOW | SWP_NOSENDCHANGING | SWP_NOREDRAW | SWP_NOACTIVATE ) : SWP_NOACTIVATE
    11461146                  ) );
    11471147    crDebug("Render SPU: SetWindowPos (%x, %d, %d, %d, %d)", window->hWnd,
    1148             window->x, window->y, window->width, window->height);
     1148            window->x, window->y, window->BltInfo.width, window->BltInfo.height);
    11491149
    11501150    if ( render_spu.fullscreen )
     
    11831183}
    11841184
     1185void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
     1186{
     1187    renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry);
     1188}
     1189
    11851190GLboolean renderspu_SystemCreateContext( VisualInfo *visual, ContextInfo *context, ContextInfo *sharedContext )
    11861191{
     
    12221227        return GL_TRUE;
    12231228
    1224     CRASSERT(sharedContext->id);
     1229    CRASSERT(sharedContext->BltInfo.Base.id);
    12251230
    12261231    if (sharedContext->shared)
     
    13401345
    13411346                /*Requery ext function pointers, we skip dummy ctx as it should never be used with ext functions*/
    1342                 if (0 && context->id)
     1347                if (0 && context->BltInfo.Base.id)
    13431348                {
    13441349                    int numFuncs, i;
     
    13991404    }
    14001405    /* save the new size */
    1401     window->width = w;
    1402     window->height = h;
     1406    window->BltInfo.width = w;
     1407    window->BltInfo.height = h;
    14031408}
    14041409
     
    14421447
    14431448    if (!SetWindowPos( window->hWnd, HWND_TOP,
    1444             x, y, window->width, window->height, winprop )) {
    1445         crWarning("!!!FAILED!!! Render SPU: SetWindowPos (%x, %d, %d, %d, %d)", window->hWnd, x, y, window->width, window->height);
     1449            x, y, window->BltInfo.width, window->BltInfo.height, winprop )) {
     1450        crWarning("!!!FAILED!!! Render SPU: SetWindowPos (%x, %d, %d, %d, %d)", window->hWnd, x, y, window->BltInfo.width, window->BltInfo.height);
    14461451    } else {
    14471452        crDebug("Render SPU: SetWindowPos (%x, %d, %d, %d, %d)", window->hWnd,
    1448                 x, y, window->width, window->height);
     1453                x, y, window->BltInfo.width, window->BltInfo.height);
    14491454    }
    14501455    /* save the new position */
     
    15171522        LONG ws;
    15181523
    1519         hRgn1 = CreateRectRgn(0, 0, w->width, w->height);
     1524        hRgn1 = CreateRectRgn(0, 0, w->BltInfo.width, w->BltInfo.height);
    15201525        hRgn2 = CreateRectRgn(50, 50, 100, 100);
    15211526        hRgn3 = CreateRectRgn(0, 0, 0, 0);
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