VirtualBox

Changeset 53847 in vbox


Ignore:
Timestamp:
Jan 16, 2015 8:53:12 AM (10 years ago)
Author:
vboxsync
Message:

Host 3D: content scalling: export IDisplay interface and connect it to OpenGL HGCM service.

Location:
trunk
Files:
7 edited

Legend:

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

    r51330 r53847  
    5151#define SHCRGL_HOST_FN_WINDOWS_SHOW (25)
    5252#define SHCRGL_HOST_FN_CTL          (26)
     53#define SHCRGL_HOST_FN_SET_SCALE_FACTOR (27)
     54
    5355/* crOpenGL guest functions */
    5456#define SHCRGL_GUEST_FN_WRITE       (2)
     
    410412} CRVBOXHGCMTAKESCREENSHOT;
    411413
     414typedef struct
     415{
     416    uint32_t u32Screen;
     417    uint32_t u32ScaleFactorWMultiplied;
     418    uint32_t u32ScaleFactorHMultiplied;
     419} CRVBOXHGCMSETSCALEFACTOR;
     420
    412421#endif
  • trunk/include/VBox/VBoxOGL.h

    r53815 r53847  
    2727
    2828#include <iprt/cdefs.h>
     29#include <iprt/types.h>
    2930
    3031RT_C_DECLS_BEGIN
     32
     33/* GUI and VBox OpenGL code require scaling factor value to be stored in container
     34 * of type of 'double'. Communication between them is done via Main. In the same time,
     35 * currently, Main does not like type of 'double' to be used for an interface method parameter.
     36 * An integer type should be used instead. This value is used in order to specify scaling factor in type
     37 * of 'integer' units. It is assumed that GUI feeds Main with its internal scaling factor value
     38 * (which is originally of type of 'double') multiplied by this constant and converted resulting
     39 * value to type of 'uint32_t'. Then Main provides this data to OpenGL HGCM thread. Finally, VBox OpenGL
     40 * code divides received scalar by this constant and converts result to type of 'double'.
     41 * This constant can be increased (multiplied by 10^n) in order to get better precision
     42 * for scaling factor manipulations. */
     43#define VBOX_OGL_SCALE_FACTOR_MULTIPLIER    100.0
    3144
    3245bool RTCALL VBoxOglIsOfflineRenderingAppropriate(void);
    3346bool RTCALL VBoxOglIs3DAccelerationSupported(void);
    3447
     48DECLEXPORT(int) VBoxOglSetScaleFactor(uint32_t idScreen, double dScaleFactorW, double dScaleFactorH);
     49
    3550RT_C_DECLS_END
    3651
  • trunk/src/VBox/HostServices/SharedOpenGL/crserver/crservice.cpp

    r53103 r53847  
    3838#include <VBox/HostServices/VBoxCrOpenGLSvc.h>
    3939#include <VBox/vmm/ssm.h>
     40#include <VBox/VBoxOGL.h>
    4041
    4142#include "cr_mem.h"
     
    13661367            break;
    13671368        }
     1369        case SHCRGL_HOST_FN_SET_SCALE_FACTOR:
     1370        {
     1371            /* Verify parameter count and types. */
     1372            if (cParms != 1
     1373             || paParms[0].type != VBOX_HGCM_SVC_PARM_PTR
     1374             || paParms[0].u.pointer.size != sizeof(CRVBOXHGCMSETSCALEFACTOR)
     1375             || !paParms[0].u.pointer.addr)
     1376            {
     1377                WARN(("invalid parameter"));
     1378                rc = VERR_INVALID_PARAMETER;
     1379                break;
     1380            }
     1381
     1382            CRVBOXHGCMSETSCALEFACTOR *pData = (CRVBOXHGCMSETSCALEFACTOR *)paParms[0].u.pointer.addr;
     1383            double dScaleFactorW = (double)(pData->u32ScaleFactorWMultiplied) / VBOX_OGL_SCALE_FACTOR_MULTIPLIER;
     1384            double dScaleFactorH = (double)(pData->u32ScaleFactorHMultiplied) / VBOX_OGL_SCALE_FACTOR_MULTIPLIER;
     1385
     1386            rc = VBoxOglSetScaleFactor(pData->u32Screen, dScaleFactorW, dScaleFactorH);
     1387
     1388            /* Log scaling factor rounded to nearest 'int' value (not so precise). */
     1389            LogRel(("OpenGL: Set 3D content scale factor to (%u, %u), multiplier %d.\n",
     1390                pData->u32ScaleFactorWMultiplied,
     1391                pData->u32ScaleFactorHMultiplied,
     1392                (int)VBOX_OGL_SCALE_FACTOR_MULTIPLIER));
     1393
     1394            break;
     1395        }
    13681396        default:
    13691397            WARN(("svcHostCallPerform: unexpected u32Function %d", u32Function));
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/server_presenter.cpp

    r53158 r53847  
    18291829}
    18301830
     1831extern "C" DECLEXPORT(int) VBoxOglSetScaleFactor(uint32_t idScreen, double dScaleFactorW, double dScaleFactorH)
     1832{
     1833    if (idScreen >= CR_MAX_GUEST_MONITORS)
     1834    {
     1835        WARN(("invalid idScreen %d", idScreen));
     1836        return VERR_INVALID_PARAMETER;
     1837    }
     1838
     1839    CR_FBDISPLAY_INFO *pDpInfo = &g_CrPresenter.aDisplayInfos[idScreen];
     1840    if (pDpInfo->pDpWin)
     1841    {
     1842        CrFbWindow *pWin = pDpInfo->pDpWin->getWindow();
     1843        if (pWin)
     1844        {
     1845            bool rc;
     1846            rc = pWin->SetScaleFactor((GLdouble)dScaleFactorW, (GLdouble)dScaleFactorH);
     1847            return rc ? 0 : VERR_LOCK_FAILED;
     1848        }
     1849    }
     1850
     1851    return VERR_INVALID_PARAMETER;
     1852}
     1853
    18311854int CrPMgrScreenChanged(uint32_t idScreen)
    18321855{
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r53385 r53847  
    1581215812  <interface
    1581315813    name="IDisplay" extends="$unknown"
    15814     uuid="dc19253d-e6b8-4b2c-8923-c8ecf80d1909"
     15814    uuid="772FBD91-65B5-4CFB-814C-E40E61AC7070"
    1581515815    wsmap="managed"
    1581615816    wrap-hint-server-addinterfaces="IEventListener"
     
    1611216112      <param name="screenId" type="unsigned long" dir="in"/>
    1611316113      <param name="displaySourceBitmap" type="IDisplaySourceBitmap" dir="out"/>
     16114    </method>
     16115
     16116    <method name="notifyScaleFactorChange">
     16117      <desc>
     16118         Obtains the guest screen bitmap parameters.
     16119      </desc>
     16120      <param name="screenId" type="unsigned long" dir="in"/>
     16121      <param name="u32ScaleFactorWMultiplied" type="unsigned long" dir="in"/>
     16122      <param name="u32ScaleFactorHMultiplied" type="unsigned long" dir="in"/>
    1611416123    </method>
    1611516124
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r53748 r53847  
    55
    66/*
    7  * Copyright (C) 2006-2014 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    170170    void i_handleCrVRecScreenshotEnd(uint32_t uScreen, uint64_t u64TimeStamp);
    171171    void i_handleVRecCompletion();
     172    HRESULT notifyScaleFactorChange(uint32_t uScreen, uint32_t u32ScaleFactorWMultiplied, uint32_t u32ScaleFactorHMultiplied);
    172173#endif
    173174
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r53758 r53847  
    33983398    Assert(mfCrOglVideoRecState == CRVREC_STATE_SUBMITTED);
    33993399    ASMAtomicWriteU32(&mfCrOglVideoRecState, CRVREC_STATE_IDLE);
     3400}
     3401
     3402HRESULT Display::notifyScaleFactorChange(uint32_t uScreen, uint32_t u32ScaleFactorWMultiplied, uint32_t u32ScaleFactorHMultiplied)
     3403{
     3404#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
     3405    HRESULT hr = E_UNEXPECTED;
     3406
     3407    if (uScreen >= mcMonitors)
     3408        return E_INVALIDARG;
     3409
     3410    /* 3D acceleration enabled in VM config. */
     3411    if (mfIsCr3DEnabled)
     3412    {
     3413        /* VBoxSharedCrOpenGL HGCM host service is running. */
     3414        if (mhCrOglSvc)
     3415        {
     3416            VMMDev *pVMMDev = mParent->i_getVMMDev();
     3417            if (pVMMDev)
     3418            {
     3419                VBOXCRCMDCTL_HGCM *pCtl;
     3420                pCtl = (VBOXCRCMDCTL_HGCM *)RTMemAlloc(sizeof(CRVBOXHGCMSETSCALEFACTOR) + sizeof(VBOXCRCMDCTL_HGCM));
     3421                if (pCtl)
     3422                {
     3423                    CRVBOXHGCMSETSCALEFACTOR *pData = (CRVBOXHGCMSETSCALEFACTOR *)(pCtl + 1);
     3424                    int rc;
     3425
     3426                    pData->u32Screen                 = uScreen;
     3427                    pData->u32ScaleFactorWMultiplied = u32ScaleFactorWMultiplied;
     3428                    pData->u32ScaleFactorHMultiplied = u32ScaleFactorHMultiplied;
     3429
     3430                    pCtl->Hdr.enmType              = VBOXCRCMDCTL_TYPE_HGCM;
     3431                    pCtl->Hdr.u32Function          = SHCRGL_HOST_FN_SET_SCALE_FACTOR;
     3432                    pCtl->aParms[0].type           = VBOX_HGCM_SVC_PARM_PTR;
     3433                    pCtl->aParms[0].u.pointer.addr = pData;
     3434                    pCtl->aParms[0].u.pointer.size = sizeof(*pData);
     3435
     3436                    rc = i_crCtlSubmit(&pCtl->Hdr, sizeof(*pCtl), i_displayCrCmdFree, pCtl);
     3437                    if (RT_FAILURE(rc))
     3438                    {
     3439                        AssertMsgFailed(("crCtlSubmit failed (rc=%Rrc)\n", rc));
     3440                        RTMemFree(pCtl);
     3441                    }
     3442                    else
     3443                        hr = S_OK;
     3444                }
     3445                else
     3446                {
     3447                    Log(("Running out of memory on attempt to set OpenGL content scale factor. Ignored.\n"));
     3448                    hr = E_OUTOFMEMORY;
     3449                }
     3450            }
     3451            else
     3452                Log(("Internal error occurred on attempt to set OpenGL content scale factor. Ignored.\n"));
     3453        }
     3454        else
     3455            Log(("Attempt to specify OpenGL content scale factor while corresponding HGCM host service not yet runing. Ignored.\n"));
     3456    }
     3457    else
     3458        Log(("Attempt to specify OpenGL content scale factor while 3D acceleration is disabled in VM config. Ignored.\n"));
     3459
     3460    return hr;
     3461#else
     3462    Log(("Attempt to specify OpenGL content scale factor while corresponding functionality is disabled."));
     3463    return E_UNEXPECTED;
     3464#endif /* VBOX_WITH_HGCM && VBOX_WITH_CROGL */
    34003465}
    34013466
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