VirtualBox

Ignore:
Timestamp:
Nov 15, 2012 9:23:50 PM (12 years ago)
Author:
vboxsync
Message:

crOpenGL: more new present mechanism

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c

    r43744 r43888  
    1717}
    1818
     19GLint crServerMuralInit(CRMuralInfo *mural, const char *dpyName, GLint visBits, GLint preloadWinID)
     20{
     21    CRMuralInfo *defaultMural;
     22    GLint dims[2];
     23    GLint windowID = -1;
     24    /*
     25     * Have first SPU make a new window.
     26     */
     27    GLint spuWindow = cr_server.head_spu->dispatch_table.WindowCreate( dpyName, visBits );
     28    if (spuWindow < 0) {
     29        crServerReturnValue( &spuWindow, sizeof(spuWindow) );
     30        return spuWindow;
     31    }
     32
     33    /* get initial window size */
     34    cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, spuWindow, GL_INT, 2, dims);
     35
     36    defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
     37    CRASSERT(defaultMural);
     38    mural->gX = 0;
     39    mural->gY = 0;
     40    mural->width = dims[0];
     41    mural->height = dims[1];
     42
     43    mural->spuWindow = spuWindow;
     44    mural->screenId = 0;
     45    mural->bVisible = GL_FALSE;
     46    mural->bUseFBO = GL_FALSE;
     47
     48    mural->cVisibleRects = 0;
     49    mural->pVisibleRects = NULL;
     50    mural->bReceivedRects = GL_FALSE;
     51
     52    mural->pvOutputRedirectInstance = NULL;
     53
     54    /* generate ID for this new window/mural (special-case for file conns) */
     55    if (cr_server.curClient && cr_server.curClient->conn->type == CR_FILE)
     56        windowID = spuWindow;
     57    else
     58        windowID = preloadWinID<0 ? crServerGenerateID(&cr_server.idsPool.freeWindowID) : preloadWinID;
     59
     60    crServerSetupOutputRedirect(mural);
     61
     62    return windowID;
     63}
    1964
    2065GLint
     
    2368    CRMuralInfo *mural;
    2469    GLint windowID = -1;
    25     GLint spuWindow;
    26     GLint dims[2];
    2770    CRCreateInfo_t *pCreateInfo;
    2871
     
    5598    }
    5699
    57     /*
    58      * Have first SPU make a new window.
    59      */
    60     spuWindow = cr_server.head_spu->dispatch_table.WindowCreate( dpyName, visBits );
    61     if (spuWindow < 0) {
    62         crServerReturnValue( &spuWindow, sizeof(spuWindow) );
    63         return spuWindow;
    64     }
    65 
    66     /* get initial window size */
    67     cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, spuWindow, GL_INT, 2, dims);
    68100
    69101    /*
     
    71103     */
    72104    mural = (CRMuralInfo *) crCalloc(sizeof(CRMuralInfo));
    73     if (mural) {
    74         CRMuralInfo *defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
    75         CRASSERT(defaultMural);
    76         mural->gX = 0;
    77         mural->gY = 0;
    78         mural->width = dims[0];
    79         mural->height = dims[1];
    80 
    81         mural->spuWindow = spuWindow;
    82         mural->screenId = 0;
    83         mural->bVisible = GL_FALSE;
    84         mural->bUseFBO = GL_FALSE;
    85 
    86         mural->cVisibleRects = 0;
    87         mural->pVisibleRects = NULL;
    88         mural->bReceivedRects = GL_FALSE;
    89 
    90         mural->pvOutputRedirectInstance = NULL;
    91 
    92         /* generate ID for this new window/mural (special-case for file conns) */
    93         if (cr_server.curClient && cr_server.curClient->conn->type == CR_FILE)
    94             windowID = spuWindow;
    95         else
    96             windowID = preloadWinID<0 ? crServerGenerateID(&cr_server.idsPool.freeWindowID) : preloadWinID;
    97         crHashtableAdd(cr_server.muralTable, windowID, mural);
    98 
    99         pCreateInfo = (CRCreateInfo_t *) crAlloc(sizeof(CRCreateInfo_t));
    100         pCreateInfo->pszDpyName = dpyName ? crStrdup(dpyName) : NULL;
    101         pCreateInfo->visualBits = visBits;
    102         crHashtableAdd(cr_server.pWindowCreateInfoTable, windowID, pCreateInfo);
    103 
    104         crServerSetupOutputRedirect(mural);
    105     }
     105    if (!mural)
     106    {
     107        crWarning("crCalloc failed!");
     108        return -1;
     109    }
     110
     111    windowID = crServerMuralInit(mural, dpyName, visBits, preloadWinID);
     112    if (windowID < 0)
     113    {
     114        crWarning("crServerMuralInit failed!");
     115        crFree(mural);
     116        return windowID;
     117    }
     118
     119    crHashtableAdd(cr_server.muralTable, windowID, mural);
     120
     121    pCreateInfo = (CRCreateInfo_t *) crAlloc(sizeof(CRCreateInfo_t));
     122    pCreateInfo->pszDpyName = dpyName ? crStrdup(dpyName) : NULL;
     123    pCreateInfo->visualBits = visBits;
     124    crHashtableAdd(cr_server.pWindowCreateInfoTable, windowID, pCreateInfo);
    106125
    107126    crDebug("CRServer: client %p created new window %d (SPU window %d)",
    108                     cr_server.curClient, windowID, spuWindow);
     127                    cr_server.curClient, windowID, mural->spuWindow);
    109128
    110129    if (windowID != -1 && !cr_server.bIsInLoadingState) {
     
    138157}
    139158
     159void crServerMuralTerm(CRMuralInfo *mural)
     160{
     161    if (mural->pvOutputRedirectInstance)
     162    {
     163        cr_server.outputRedirect.CROREnd(mural->pvOutputRedirectInstance);
     164        mural->pvOutputRedirectInstance = NULL;
     165    }
     166
     167    crServerRedirMuralFBO(mural, GL_FALSE);
     168    crServerDeleteMuralFBO(mural);
     169
     170    cr_server.head_spu->dispatch_table.WindowDestroy( mural->spuWindow );
     171
     172    if (mural->pVisibleRects)
     173    {
     174        crFree(mural->pVisibleRects);
     175    }
     176}
     177
    140178void SERVER_DISPATCH_APIENTRY
    141179crServerDispatchWindowDestroy( GLint window )
     
    158196    }
    159197
    160     if (mural->pvOutputRedirectInstance)
    161     {
    162         cr_server.outputRedirect.CROREnd(mural->pvOutputRedirectInstance);
    163         mural->pvOutputRedirectInstance = NULL;
    164     }
     198    crDebug("CRServer: Destroying window %d (spu window %d)", window, mural->spuWindow);
     199
     200    crServerMuralTerm(mural);
    165201
    166202    if (cr_server.currentWindow == window)
    167203    {
    168204        cr_server.currentWindow = -1;
    169     }
    170 
    171     crServerRedirMuralFBO(mural, GL_FALSE);
    172     crServerDeleteMuralFBO(mural);
    173 
    174     crDebug("CRServer: Destroying window %d (spu window %d)", window, mural->spuWindow);
    175     cr_server.head_spu->dispatch_table.WindowDestroy( mural->spuWindow );
     205        CRASSERT(cr_server.currentMural == mural);
     206        cr_server.currentMural = NULL;
     207    }
     208    else
     209    {
     210        CRASSERT(cr_server.currentMural != mural);
     211    }
    176212
    177213    if (cr_server.curClient)
     
    236272    crHashtableDelete(cr_server.pWindowCreateInfoTable, window, crServerCreateInfoDeleteCB);
    237273
    238     if (mural->pVisibleRects)
    239     {
    240         crFree(mural->pVisibleRects);
    241     }
    242274    crHashtableDelete(cr_server.muralTable, window, crFree);
     275}
     276
     277void crServerMuralSize(CRMuralInfo *mural, GLint width, GLint height)
     278{
     279    mural->width = width;
     280    mural->height = height;
     281
     282    if (cr_server.curClient && cr_server.curClient->currentMural == mural)
     283    {
     284        crStateGetCurrent()->buffer.width = mural->width;
     285        crStateGetCurrent()->buffer.height = mural->height;
     286    }
     287
     288    crServerCheckMuralGeometry(mural);
     289
     290    cr_server.head_spu->dispatch_table.WindowSize(mural->spuWindow, width, height);
    243291}
    244292
     
    257305    }
    258306
    259     mural->width = width;
    260     mural->height = height;
    261 
    262     if (cr_server.curClient && cr_server.curClient->currentMural == mural)
    263     {
    264         crStateGetCurrent()->buffer.width = mural->width;
    265         crStateGetCurrent()->buffer.height = mural->height;
    266     }
    267 
    268     crServerCheckMuralGeometry(mural);
    269 
    270     cr_server.head_spu->dispatch_table.WindowSize(mural->spuWindow, width, height);
     307    crServerMuralSize(mural, width, height);
    271308
    272309    /* Work-around Intel driver bug */
Note: See TracChangeset for help on using the changeset viewer.

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