VirtualBox

Changeset 55241 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 14, 2015 11:31:05 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99553
Message:

Additions/x11/vboxvideo: cleaner vbvxSetMode() function.

Location:
trunk/src/VBox/Additions/x11/vboxvideo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/vboxvideo/setmode.c

    r55237 r55241  
    106106        cbNewFB = 0;
    107107    memset(pVBox->base, 0, max(cbOldFB, cbNewFB));
     108}
     109
     110/** Set a graphics mode.  Poke any required values into registers, do an HGSMI
     111 * mode set and tell the host we support advanced graphics functions.
     112 */
     113void vbvxSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth, unsigned
     114 cHeight, int x, int y, bool fEnabled,
     115                 bool fConnected, struct vbvxFrameBuffer *pFrameBuffer)
     116{
     117    VBOXPtr pVBox = VBOXGetRec(pScrn);
     118    uint32_t offStart;
     119    uint16_t fFlags;
     120    int rc;
     121    bool fEnabledAndVisible = fEnabled && x + cWidth <= pFrameBuffer->cWidth && y + cHeight <= pFrameBuffer->cHeight;
     122    /* Recent host code has a flag to blank the screen; older code needs BPP set to zero. */
     123    uint32_t cBPP = fEnabledAndVisible || pVBox->fHostHasScreenBlankingFlag ? pFrameBuffer->cBPP : 0;
     124
     125    TRACE_LOG("cDisplay=%u, cWidth=%u, cHeight=%u, x=%d, y=%d, fEnabled=%d, fConnected=%d, pFrameBuffer: { x0=%d, y0=%d, cWidth=%u, cHeight=%u, cBPP=%u }\n",
     126              cDisplay, cWidth, cHeight, x, y, fEnabled, fConnected, pFrameBuffer->x0, pFrameBuffer->y0, pFrameBuffer->cWidth,
     127              pFrameBuffer->cHeight, pFrameBuffer->cBPP);
     128    VBVXASSERT(cWidth != 0 && cHeight != 0, ("cWidth = 0 or cHeight = 0\n"));
     129    offStart = (y * pFrameBuffer->cWidth + x) * pFrameBuffer->cBPP / 8;
     130    if (cDisplay == 0 && fEnabled)
     131        VBoxVideoSetModeRegisters(cWidth, cHeight, pFrameBuffer->cWidth, pFrameBuffer->cBPP, 0, x, y);
     132    fFlags = VBVA_SCREEN_F_ACTIVE;
     133    fFlags |= (fConnected ? 0 : VBVA_SCREEN_F_DISABLED);
     134    fFlags |= (!fEnabledAndVisible && pVBox->fHostHasScreenBlankingFlag ? VBVA_SCREEN_F_BLANK : 0);
     135    VBoxHGSMIProcessDisplayInfo(&pVBox->guestCtx, cDisplay, x - pFrameBuffer->x0, y - pFrameBuffer->y0, offStart,
     136                                pFrameBuffer->cWidth * pFrameBuffer->cBPP / 8, cWidth, cHeight, cBPP, fFlags);
     137    rc = VBoxHGSMIUpdateInputMapping(&pVBox->guestCtx, 0 - pFrameBuffer->x0, 0 - pFrameBuffer->y0, pFrameBuffer->cWidth,
     138                                     pFrameBuffer->cHeight);
     139    if (RT_FAILURE(rc))
     140        FatalError("Failed to update the input mapping.\n");
    108141}
    109142
  • trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.h

    r55237 r55241  
    215215    /** Can we get mode hint and cursor integration information from HGSMI? */
    216216    bool fHaveHGSMIModeHints;
     217    /** Does the host support the screen blanking flag? */
     218    bool fHostHasScreenBlankingFlag;
    217219    /** Array of structures for receiving mode hints. */
    218220    VBVAMODEHINT *paVBVAModeHints;
     
    257259
    258260/* setmode.c */
     261
     262/** Structure describing the virtual frame buffer.  It starts at the beginning
     263 * of the video RAM. */
     264struct vbvxFrameBuffer {
     265    /** X offset of first screen in frame buffer. */
     266    int x0;
     267    /** Y offset of first screen in frame buffer. */
     268    int y0;
     269    /** Frame buffer virtual width. */
     270    unsigned cWidth;
     271    /** Frame buffer virtual height. */
     272    unsigned cHeight;
     273    /** Bits per pixel. */
     274    unsigned cBPP;
     275};
     276
     277extern void vbvxSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth, unsigned cHeight, int x, int y, bool fEnabled,
     278                         bool fConnected, struct vbvxFrameBuffer *pFrameBuffer);
    259279extern void vbvxClearVRAM(ScrnInfoPtr pScrn, size_t cbOldSize, size_t cbNewSize);
    260280extern void vbvxSetSolarisMouseRange(int width, int height);
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