~ubuntu-branches/ubuntu/vivid/virtualbox/vivid

« back to all changes in this revision

Viewing changes to src/VBox/Additions/common/crOpenGL/glx.c

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2011-12-29 12:29:25 UTC
  • mfrom: (3.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20111229122925-8ota2o33fuk0bkf8
Tags: 4.1.8-dfsg-1
* New upstream release.
* Move all transitional packages to section oldlibs and priority extra.
* Refresh 16-no-update.patch.
* Drop 36-kernel-3.2.patch, applied upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1042
1042
 
1043
1043
DECLEXPORT(GLXContext) VBOXGLXTAG(glXGetCurrentContext)( void )
1044
1044
{
1045
 
    if (stub.currentContext)
1046
 
        return (GLXContext) stub.currentContext->id;
 
1045
    ContextInfo *context = stubGetCurrentContext();
 
1046
    if (context)
 
1047
        return (GLXContext) context->id;
1047
1048
    else
1048
1049
        return (GLXContext) NULL;
1049
1050
}
1181
1182
#ifndef VBOX_NO_NATIVEGL
1182
1183
DECLEXPORT(void) VBOXGLXTAG(glXUseXFont)( Font font, int first, int count, int listBase )
1183
1184
{
1184
 
    if (stub.currentContext->type == CHROMIUM)
 
1185
    ContextInfo *context = stubGetCurrentContext();
 
1186
    if (context->type == CHROMIUM)
1185
1187
    {
1186
1188
        Display *dpy = stub.wsInterface.glXGetCurrentDisplay();
1187
1189
        if (dpy) {
1200
1202
#else /* not 0 */
1201
1203
DECLEXPORT(void) VBOXGLXTAG(glXUseXFont)( Font font, int first, int count, int listBase )
1202
1204
{
1203
 
    Display *dpy = stub.currentContext->dpy;
 
1205
    ContextInfo *context = stubGetCurrentContext();
 
1206
    Display *dpy = context->dpy;
1204
1207
    if (dpy) {
1205
1208
        stubUseXFont( dpy, font, first, count, listBase );
1206
1209
    }
2478
2481
    //crDebug("got type: 0x%x", event->type);
2479
2482
    if (event->type==damage_evb+XDamageNotify)
2480
2483
    {
 
2484
        ContextInfo *context = stubGetCurrentContext();
2481
2485
        XDamageNotifyEvent *e = (XDamageNotifyEvent *) event;
2482
2486
        /* we're interested in pixmaps only...and those have e->drawable set to 0 or other strange value for some odd reason 
2483
2487
         * so have to walk glxpixmaps hashtable to find if we have damage event handle assigned to some pixmap
2485
2489
        /*crDebug("Event: Damage for drawable 0x%x, handle 0x%x (level=%i) [%i,%i,%i,%i]",
2486
2490
                (unsigned int) e->drawable, (unsigned int) e->damage, (int) e->level,
2487
2491
                e->area.x, e->area.y, e->area.width, e->area.height);*/
2488
 
        CRASSERT(stub.currentContext);
2489
 
        crHashtableWalk(stub.currentContext->pGLXPixmapsHash, checkdamageCB, e);
 
2492
        CRASSERT(context);
 
2493
        crHashtableWalk(context->pGLXPixmapsHash, checkdamageCB, e);
2490
2494
    }
2491
2495
    return False;
2492
2496
}
2497
2501
{
2498
2502
    static int cnt=0;
2499
2503
    XImage dummyimg;
 
2504
    ContextInfo *context = stubGetCurrentContext();
2500
2505
 
2501
2506
    GLX_Pixmap_t *pGlxPixmap;
2502
2507
 
2503
 
    if (!stub.currentContext)
 
2508
    if (!context)
2504
2509
    {
2505
2510
        crWarning("glXBindTexImageEXT called without current context");
2506
2511
        return;
2507
2512
    }
2508
2513
 
2509
 
    pGlxPixmap = (GLX_Pixmap_t *) crHashtableSearch(stub.currentContext->pGLXPixmapsHash, (unsigned int) draw);
 
2514
    pGlxPixmap = (GLX_Pixmap_t *) crHashtableSearch(context->pGLXPixmapsHash, (unsigned int) draw);
2510
2515
    if (!pGlxPixmap)
2511
2516
    {
2512
2517
        pGlxPixmap = (GLX_Pixmap_t *) crHashtableSearch(stub.pGLXPixmapsHash, (unsigned int) draw);
2515
2520
            crDebug("Unknown drawable 0x%x in glXBindTexImageEXT!", (unsigned int) draw);
2516
2521
            return;
2517
2522
        }
2518
 
        pGlxPixmap = stubInitGlxPixmap(pGlxPixmap, dpy, draw, stub.currentContext);
 
2523
        pGlxPixmap = stubInitGlxPixmap(pGlxPixmap, dpy, draw, context);
2519
2524
        if (!pGlxPixmap)
2520
2525
        {
2521
2526
            crDebug("glXBindTexImageEXT failed to get pGlxPixmap");
2524
2529
    }
2525
2530
 
2526
2531
    /* If there's damage extension, then process incoming events as we need the information right now */
2527
 
    if (stub.currentContext->damageDpy)
 
2532
    if (context->damageDpy)
2528
2533
    {
2529
2534
        /* Sync connections, note that order of syncs is important here.
2530
2535
         * First make sure client commands are finished, then make sure we get all the damage events back*/
2531
2536
        XLOCK(dpy);
2532
2537
        XSync(dpy, False);
2533
2538
        XUNLOCK(dpy);
2534
 
        XSync(stub.currentContext->damageDpy, False);
 
2539
        XSync(context->damageDpy, False);
2535
2540
 
2536
 
        while (XPending(stub.currentContext->damageDpy))
 
2541
        while (XPending(context->damageDpy))
2537
2542
        {
2538
2543
            XEvent event;
2539
 
            XNextEvent(stub.currentContext->damageDpy, &event);
2540
 
            if (event.type==stub.currentContext->damageEventsBase+XDamageNotify)
 
2544
            XNextEvent(context->damageDpy, &event);
 
2545
            if (event.type==context->damageEventsBase+XDamageNotify)
2541
2546
            {
2542
 
                crHashtableWalk(stub.currentContext->pGLXPixmapsHash, stubCheckXDamageCB, &event);
 
2547
                crHashtableWalk(context->pGLXPixmapsHash, stubCheckXDamageCB, &event);
2543
2548
            }
2544
2549
        }
2545
2550
    }
2589
2594
    else /* Use shm to get pixmap data */
2590
2595
    {
2591
2596
        /* Check if we have damage extension */
2592
 
        if (stub.currentContext->damageDpy)
 
2597
        if (context->damageDpy)
2593
2598
        {
2594
2599
            if (pGlxPixmap->bPixmapImageDirty)
2595
2600
            {