VirtualBox

Changeset 9249 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 30, 2008 12:59:34 PM (17 years ago)
Author:
vboxsync
Message:

Additions/x11: some refactoring inside the X11 graphics driver

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/xgraphics/vboxutils.c

    r9016 r9249  
    3636#define VBOX_MAX_CURSOR_HEIGHT 64
    3737
    38 #if 0
    39 #define DEBUG_X
     38/**************************************************************************
     39* Debugging functions and macros                                          *
     40**************************************************************************/
     41
     42/* #define DEBUG_POINTER */
     43
     44#ifdef DEBUG_michael
     45# define DEBUG_VIDEO
    4046#endif
    41 #ifdef DEBUG_X
    42 #define TRACE_ENTRY() do \
    43     { \
    44         ErrorF ("%s\n", __FUNCTION__); \
    45     } while(0)
    46 #define TRACE_LINE() do \
     47
     48#define BOOL_STR(a) ((a) ? "TRUE" : "FALSE")
     49
     50#ifdef DEBUG_VIDEO
     51# define TRACE_ENTRY() \
     52do { \
     53    xf86Msg(X_INFO, __PRETTY_FUNCTION__); \
     54    xf86Msg(X_INFO, ": entering\n"); \
     55} while(0)
     56# define TRACE_EXIT() \
     57do { \
     58    xf86Msg(X_INFO, __PRETTY_FUNCTION__); \
     59    xf86Msg(X_INFO, ": leaving\n"); \
     60} while(0)
     61# define TRACE_LOG(...) \
     62do { \
     63    xf86Msg(X_INFO, __PRETTY_FUNCTION__); \
     64    xf86Msg(X_INFO, __VA_ARGS__); \
     65} while(0)
     66# define TRACE_LINE() do \
    4767    { \
    4868        ErrorF ("%s: line %d\n", __FUNCTION__, __LINE__); \
    4969    } while(0)
    50 #define PUT_PIXEL(c) ErrorF ("%c", c)
    51 #define dolog(...) ErrorF  (__VA_ARGS__)
    52 #else
    53 #define PUT_PIXEL(c) do { } while(0)
    54 #define TRACE_ENTRY() do { } while(0)
    55 #define TRACE_LINE() do { } while(0)
    56 #define dolog(...) do { } while(0)
    57 #endif
     70# define PUT_PIXEL(c) ErrorF ("%c", c)
     71#else /* DEBUG_VIDEO not defined */
     72# define PUT_PIXEL(c) do { } while(0)
     73# define TRACE_ENTRY() do { } while(0)
     74# define TRACE_EXIT() do { } while(0)
     75# define TRACE_LOG(...) do { } while(0)
     76# define TRACE_LINE() do { } while(0)
     77#endif /* DEBUG_VIDEO not defined */
    5878
    5979/** Macro to printf an error message and return from a function */
     
    6686    while (0)
    6787
    68 #ifdef DEBUG_X
     88#ifdef DEBUG_POINTER
    6989static void
    7090vbox_show_shape(unsigned short w, unsigned short h, CARD32 bg, unsigned char *image)
     
    103123#endif
    104124
     125/**************************************************************************
     126* Helper functions and macros                                             *
     127**************************************************************************/
    105128
    106129static Bool
     
    123146            rc = TRUE;
    124147    }
     148    TRACE_LOG("rc=%s\n", BOOL_STR(rc));
    125149    return rc;
    126150}
    127151
    128 
    129 void
    130 vbox_close(ScrnInfoPtr pScrn, VBOXPtr pVBox)
    131 {
    132     TRACE_ENTRY();
    133 
    134     xfree (pVBox->reqp);
    135     pVBox->reqp = NULL;
    136 }
    137 
     152/**
     153 * This function checks whether the X server agrees with us about whether
     154 * to use a host or a guest-drawn cursor and gives it a nudge if it doesn't.
     155 * Disabling and re-enabling framebuffer access was one of the few
     156 * reliable (although not particularly nice) methods I could find to
     157 * force the server to recheck whether to use a hardware or a software
     158 * cursor.
     159 */
     160static void
     161vboxRecheckHWCursor(ScrnInfoPtr pScrn)
     162{
     163    int vrc;
     164    uint32_t fFeatures;
     165    VBOXPtr pVBox = pScrn->driverPrivate;
     166
     167    TRACE_ENTRY();
     168    /* Check whether we are using the hardware cursor or not, and whether this
     169       has changed since the last time we checked. */
     170    vrc = VbglR3GetMouseStatus(&fFeatures, NULL, NULL);
     171    if (!!(fFeatures & VBOXGUEST_MOUSE_HOST_CAN_ABSOLUTE) != pVBox->usingHWCursor)
     172    {
     173        pVBox->usingHWCursor = !!(fFeatures & VBOXGUEST_MOUSE_HOST_CAN_ABSOLUTE);
     174        /* This triggers a cursor image reload */
     175        if (pVBox->accessEnabled)
     176        {
     177            pScrn->EnableDisableFBAccess(pScrn->scrnIndex, FALSE);
     178            pScrn->EnableDisableFBAccess(pScrn->scrnIndex, TRUE);
     179        }
     180    }
     181    TRACE_EXIT();
     182}
     183 
    138184/**
    139185 * Macro to disable VBVA extensions and return, for use when an
     
    149195    } \
    150196    while (0)
     197
     198/**************************************************************************
     199* Main functions                                                          *
     200**************************************************************************/
     201
     202void
     203vbox_close(ScrnInfoPtr pScrn, VBOXPtr pVBox)
     204{
     205    TRACE_ENTRY();
     206
     207    xfree (pVBox->reqp);
     208    pVBox->reqp = NULL;
     209    TRACE_EXIT();
     210}
    151211
    152212/**
     
    176236
    177237    pVBox = pScrn->driverPrivate;
     238    TRACE_ENTRY();
    178239    if (pVBox->useVbva == FALSE)
    179240        return;
     
    265326/**
    266327 * Initialise VirtualBox's accelerated video extensions.
    267  * Note that we assume that the PCI memory is 32bit mapped,
    268  * as X doesn't seem to support mapping 64bit memory.
    269328 *
    270329 * @returns TRUE on success, FALSE on failure
     
    276335    ADDRESS pciAddress;
    277336
     337    TRACE_ENTRY();
    278338    /* Locate the device.  It should already have been enabled by
    279339       the kernel driver. */
     
    325385    Bool rc = TRUE;
    326386    int vrc;
     387
     388    TRACE_ENTRY();
    327389    pVBox->useVbva = FALSE;
    328390    vrc = VbglR3Init();
     
    389451{
    390452    int rc;
     453
     454    TRACE_ENTRY();
    391455    pVBox->reqp->fFlags = 0;
    392456    rc = VbglR3SetPointerShapeReq(pVBox->reqp);
     
    399463{
    400464    int rc;
     465
     466    TRACE_ENTRY();
    401467    pVBox->reqp->fFlags = VBOX_MOUSE_POINTER_VISIBLE;
    402468    rc = VbglR3SetPointerShapeReq(pVBox->reqp);
     
    413479    reqp = (VMMDevReqMousePointer *)image;
    414480
    415     dolog("w=%d h=%d size=%d\n", reqp->width, reqp->height, reqp->header.size);
    416 #ifdef DEBUG_X
     481    TRACE_LOG("w=%d h=%d size=%d\n", reqp->width, reqp->height, reqp->header.size);
     482#ifdef DEBUG_POINTER
    417483    vbox_show_shape(reqp->width, reqp->height, 0, image);
    418484#endif
     
    434500}
    435501
     502/**
     503 * This function is called to set the position of the hardware cursor.
     504 * Since we already know the position (exactly where the host pointer is),
     505 * we only use this function to poll for whether we need to switch from a
     506 * hardware to a software cursor (that is, whether the user has disabled
     507 * pointer integration).  Sadly we this doesn't work the other way round,
     508 * as the server updates the software cursor itself without calling us.
     509 */
    436510static void
    437511vbox_set_cursor_position(ScrnInfoPtr pScrn, int x, int y)
    438512{
    439     VBOXPtr pVBox = pScrn->driverPrivate;
    440     int vrc;
    441     uint32_t fFeatures;
    442 
    443     TRACE_ENTRY();
    444     /* Check whether we are using the hardware cursor or not, and whether this
    445        has changed since the last time we checked. */
    446     vrc = VbglR3GetMouseStatus(&fFeatures, NULL, NULL);
    447     if (!!(fFeatures & VBOXGUEST_MOUSE_HOST_CAN_ABSOLUTE) != pVBox->usingHWCursor)
    448     {
    449         pVBox->usingHWCursor = !!(fFeatures & VBOXGUEST_MOUSE_HOST_CAN_ABSOLUTE);
    450         /* This triggers a cursor image reload */
    451         if (pVBox->accessEnabled)
    452         {
    453             pScrn->EnableDisableFBAccess(pScrn->scrnIndex, FALSE);
    454             pScrn->EnableDisableFBAccess(pScrn->scrnIndex, TRUE);
    455         }
    456     }
    457    
     513    vboxRecheckHWCursor(pScrn);
    458514    /* don't disable the mouse cursor if we go out of our visible area
    459515     * since the mouse cursor is drawn by the host anyway */
     
    534590    VMMDevReqMousePointer *reqp;
    535591
     592    TRACE_ENTRY();
    536593    pVBox = infoPtr->pScrn->driverPrivate;
    537594    bitsp = pCurs->bits;
     
    572629    cp = (CARD32 *)(m + sizeMask);
    573630
    574     dolog ("w=%d h=%d sm=%d sr=%d p=%d\n",
     631    TRACE_LOG ("w=%d h=%d sm=%d sr=%d p=%d\n",
    575632           w, h, (int) sizeMask, (int) sizeRgba, (int) dstPitch);
    576     dolog ("m=%p c=%p cp=%p\n", m, c, (void *)cp);
     633    TRACE_LOG ("m=%p c=%p cp=%p\n", m, c, (void *)cp);
    577634
    578635    fc = color_to_byte (pCurs->foreBlue)
     
    642699    reqp->header.size = sizeRequest;
    643700
    644 #ifdef DEBUG_X
     701#ifdef DEBUG_POINTER
    645702    ErrorF("shape = %p\n", p);
    646703    vbox_show_shape(w, h, bc, c);
     
    657714    Bool rc = TRUE;
    658715
     716    TRACE_ENTRY();
    659717    if (!vbox_host_uses_hwcursor(pScrn))
    660718        rc = FALSE;
     
    666724       )
    667725        rc = FALSE;
     726    TRACE_LOG("rc=%s\n", BOOL_STR(rc));
    668727    return rc;
    669728}
     
    684743    int scrnIndex;
    685744
     745    TRACE_ENTRY();
    686746    pVBox = pScrn->driverPrivate;
    687747    bitsp = pCurs->bits;
     
    766826    Bool rc;
    767827
     828    TRACE_ENTRY();
    768829    if (!pVBox->useDevice)
    769830        return FALSE;
     
    815876    VBOXPtr pVBox = pScrn->driverPrivate;
    816877
     878    TRACE_ENTRY();
    817879    if (pVBox->useVbva != TRUE)
    818880        return FALSE;
     
    847909    VBOXPtr pVBox = pScrn->driverPrivate;
    848910
     911    TRACE_ENTRY();
    849912    if (pVBox->useVbva != TRUE)  /* Ths function should not have been called */
    850913        return FALSE;
     
    870933vboxEnableGraphicsCap(VBOXPtr pVBox)
    871934{
     935    TRACE_ENTRY();
    872936    if (!pVBox->useDevice)
    873937        return FALSE;
     
    884948vboxDisableGraphicsCap(VBOXPtr pVBox)
    885949{
     950    TRACE_ENTRY();
    886951    if (!pVBox->useDevice)
    887952        return FALSE;
     
    905970                            VBOXPtr pVBox)
    906971{
     972    TRACE_ENTRY();
    907973    if (!pVBox->useDevice)
    908974        return FALSE;
     
    926992vboxHostLikesVideoMode(uint32_t cx, uint32_t cy, uint32_t cBits)
    927993{
     994    TRACE_ENTRY();
    928995    return VbglR3HostLikesVideoMode(cx, cy, cBits);
    929996}
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