VirtualBox

Changeset 18637 in vbox


Ignore:
Timestamp:
Apr 2, 2009 1:49:59 PM (15 years ago)
Author:
vboxsync
Message:

crOpenGL: add seamless mode clip regions to opengl ones

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/HostServices/VBoxCrOpenGLSvc.h

    r12806 r18637  
    3838/* crOpenGL host functions */
    3939#define SHCRGL_HOST_FN_SET_FRAMEBUFFER (1)
     40#define SHCRGL_HOST_FN_SET_VISIBLE_REGION (5)
    4041/* crOpenGL guest functions */
    4142#define SHCRGL_GUEST_FN_WRITE       (2)
     
    4546/* Parameters count */
    4647#define SHCRGL_CPARMS_SET_FRAMEBUFFER (1)
     48#define SHCRGL_CPARMS_SET_VISIBLE_REGION (2)
    4749#define SHCRGL_CPARMS_WRITE      (1)
    4850#define SHCRGL_CPARMS_READ       (2)
  • trunk/src/VBox/HostServices/SharedOpenGL/crserver/crservice.cpp

    r17021 r18637  
    412412            break;
    413413        }
     414        case SHCRGL_HOST_FN_SET_VISIBLE_REGION:
     415        {
     416            Log(("svcCall: SHCRGL_HOST_FN_SET_VISIBLE_REGION\n"));
     417
     418            if (cParms != SHCRGL_CPARMS_SET_VISIBLE_REGION)
     419            {
     420                rc = VERR_INVALID_PARAMETER;
     421                break;
     422            }
     423
     424            if (    paParms[0].type != VBOX_HGCM_SVC_PARM_PTR     /* pRects */
     425                 || paParms[1].type != VBOX_HGCM_SVC_PARM_32BIT   /* cRects */
     426               )
     427            {
     428                rc = VERR_INVALID_PARAMETER;
     429                break;
     430            }
     431
     432            Assert(sizeof(RTRECT)==4*sizeof(GLint));
     433
     434            renderspuSetRootVisibleRegion(paParms[1].u.uint32, (GLint*)paParms[0].u.pointer.addr);
     435            break;
     436        }
    414437        default:
    415438            rc = VERR_NOT_IMPLEMENTED;
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h

    r15532 r18637  
    7070    GLint bufferName;
    7171    AGLContext dummyContext;
     72    RgnHandle hVisibleRegion;
    7273    /* unsigned long context_ptr; */
    7374#elif defined(GLX)
     
    195196    DWORD dwWinThreadId;
    196197    HANDLE hWinThreadReadyEvent;
     198#endif
     199
     200#ifdef DARWIN
     201    RgnHandle hRootVisibleRegion;
    197202#endif
    198203} RenderSPU;
     
    245250extern void renderspu_SystemWindowPosition( WindowInfo *window, GLint x, GLint y );
    246251extern void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, GLint* pRects);
     252extern void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *window);
     253#ifdef RT_OS_DARWIN
     254extern void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *pRects);
     255#endif
    247256extern void renderspu_SystemShowWindow( WindowInfo *window, GLboolean showIt );
    248257extern void renderspu_SystemMakeCurrent( WindowInfo *window, GLint windowInfor, ContextInfo *context );
     
    260269#endif
    261270DECLEXPORT(void) renderspuSetWindowId(unsigned int winId);
     271DECLEXPORT(void) renderspuSetRootVisibleRegion(GLint cRects, GLint *pRects);
    262272#ifdef __cplusplus
    263273}
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c

    r18610 r18637  
    425425    window->visual = NULL;
    426426    window->window = NULL;
     427
     428    if (window->hVisibleRegion)
     429    {
     430        DisposeRgn(window->hVisibleRegion);
     431        window->hVisibleRegion = 0;
     432    }
    427433}
    428434
     
    702708
    703709    DEBUG_MSG_POETZSCH (("Visible region \n"));
    704     ContextInfo *c;
    705     c = renderspuGetWindowContext (window);
    706     if (c &&
    707         c->context)
     710
     711    if (window->hVisibleRegion)
     712    {
     713        DisposeRgn(window->hVisibleRegion);
     714        window->hVisibleRegion = 0;
     715    }
     716
     717    if (cRects>0)
    708718    {
    709719        int i;
     
    720730        }
    721731        DisposeRgn (tmpRgn);
    722 
    723         GLboolean result = true;
    724         /* Set the clip region to the context */
    725         result = render_spu.ws.aglSetInteger(c->context, AGL_CLIP_REGION, (const GLint*)rgn);
    726         CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowVisibleRegion): SetInteger Failed");
    727         result = render_spu.ws.aglEnable(c->context, AGL_CLIP_REGION);
    728         CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowVisibleRegion): Enable Failed");
    729         /* Clear the region structure */
    730         DisposeRgn (rgn);
    731     }
     732        window->hVisibleRegion = rgn;
     733    }
     734
     735    renderspu_SystemWindowApplyVisibleRegion(window);
     736}
     737
     738void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *pRects)
     739{
     740    if (render_spu.hRootVisibleRegion)
     741    {
     742        DisposeRgn(render_spu.hRootVisibleRegion);
     743        render_spu.hRootVisibleRegion = 0;
     744    }
     745
     746    if (cRects>0)
     747    {
     748        int i;
     749        render_spu.hRootVisibleRegion = NewRgn();
     750        SetEmptyRgn (render_spu.hRootVisibleRegion);
     751        RgnHandle tmpRgn = NewRgn();
     752        for (i=0; i<cRects; ++i)
     753        {
     754            SetRectRgn (tmpRgn,
     755                        pRects[4*i]  , pRects[4*i+1],
     756                        pRects[4*i+2], pRects[4*i+3]);
     757            UnionRgn (render_spu.hRootVisibleRegion, tmpRgn, render_spu.hRootVisibleRegion);
     758        }
     759        DisposeRgn (tmpRgn);
     760    }
     761}
     762
     763/*Assumes that all regions are in the guest coordinates system*/
     764void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *window)
     765{
     766    ContextInfo *c = renderspuGetWindowContext(window);
     767    RgnHandle rgn;
     768    GLboolean result = true;
     769
     770    if (!c || !c->context) return;
     771
     772    rgn = NewRgn();
     773    SetEmptyRgn (rgn);
     774
     775    if (render_spu.hRootVisibleRegion)
     776    {
     777        CopyRgn(render_spu.hRootVisibleRegion, rgn);
     778    }
     779    else /*@todo create tmp region rect with size of underlying framebuffer */
     780    {
     781        /* SetRectRgn(0,0,fb->width,fb->height); */
     782        SetRectRgn(rgn,0,0,4000,4000);
     783    }
     784
     785    if (window->hVisibleRegion)
     786    {
     787        SectRgn(rgn, window->hVisibleRegion, rgn);
     788    }
     789
     790    /* If we'd need to set clip region in host screen coordinates, than shift it*/
     791    /* OffsetRgn(rgn, fb->hostleft, fb->hosttop); */
     792
     793    /* Set the clip region to the context */
     794    result = render_spu.ws.aglSetInteger(c->context, AGL_CLIP_REGION, (const GLint*)rgn);
     795    CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowVisibleRegion): SetInteger Failed");
     796    result = render_spu.ws.aglEnable(c->context, AGL_CLIP_REGION);
     797    CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowVisibleRegion): Enable Failed");
     798    /* Clear the region structure */
     799    DisposeRgn (rgn);
    732800}
    733801
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c

    r17484 r18637  
    207207        }
    208208    }
     209#endif
     210
     211#ifdef DARWIN
     212    render_spu.hRootVisibleRegion = 0;
    209213#endif
    210214
     
    326330    render_spu.barrierHash = NULL;
    327331
     332#ifdef RT_OS_DARWIN
     333    if (render_spu.hRootVisibleRegion)
     334    {
     335        DisposeRgn(render_spu.hRootVisibleRegion);
     336        render_spu.hRootVisibleRegion = 0;
     337    }
     338#endif
     339
    328340#ifdef RT_OS_WINDOWS
    329341    if (render_spu.dwWinThreadId)
     
    357369}
    358370
    359 void renderspuSetWindowId(unsigned int winId)
     371DECLEXPORT(void) renderspuSetWindowId(unsigned int winId)
    360372{
    361373    render_spu_parent_window_id = winId;
    362374}
     375
     376static void renderspuWindowVisibleRegionCB(unsigned long key, void *data1, void *data2)
     377{
     378    WindowInfo *window = (WindowInfo *) data1;
     379    CRASSERT(window);
     380
     381    renderspu_SystemWindowApplyVisibleRegion(window);
     382}
     383
     384DECLEXPORT(void) renderspuSetRootVisibleRegion(GLint cRects, GLint *pRects)
     385{
     386#ifdef RT_OS_DARWIN
     387    renderspu_SystemSetRootVisibleRegion(cRects, pRects);
     388
     389    crHashtableWalk(render_spu.windowTable, renderspuWindowVisibleRegionCB, NULL);
     390#endif
     391}
     392
     393#ifndef RT_OS_DARWIN
     394void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *window)
     395{
     396}
     397#endif
  • trunk/src/VBox/Main/VMMDevInterface.cpp

    r16468 r18637  
    3636#include "hgcm/HGCM.h"
    3737#include "hgcm/HGCMObjects.h"
     38# if defined(RT_OS_DARWIN) && defined(VBOX_WITH_CROGL)
     39#  include <VBox/HostServices/VBoxCrOpenGLSvc.h>
     40# endif
    3841#endif
    3942
     
    350353    IFramebuffer *framebuffer = pDrv->pVMMDev->getParent()->getDisplay()->getFramebuffer();
    351354    if (framebuffer)
     355    {
    352356        framebuffer->SetVisibleRegion((BYTE *)pRect, cRect);
     357#if defined(RT_OS_DARWIN) && defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
     358        {
     359            BOOL is3denabled;
     360
     361            pDrv->pVMMDev->getParent()->machine()->COMGETTER(Accelerate3DEnabled)(&is3denabled);
     362
     363            if (is3denabled)
     364            {
     365                VBOXHGCMSVCPARM parms[2];
     366
     367                parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
     368                parms[0].u.pointer.addr = pRect;
     369                parms[0].u.pointer.size = 0;  /* We don't actually care. */
     370                parms[1].type = VBOX_HGCM_SVC_PARM_32BIT;
     371                parms[1].u.uint32 = cRect;
     372
     373                int rc = pDrv->pVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_VISIBLE_REGION, 2, &parms[0]);
     374                return rc;
     375            }
     376        }
     377#endif
     378    }
    353379
    354380    return VINF_SUCCESS;
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