VirtualBox

儲存庫 vbox 的更動 55283


忽略:
時間撮記:
2015-4-15 下午01:01:36 (10 年 以前)
作者:
vboxsync
訊息:

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

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.c

    r55262 r55283  
    145145static void VBOXSaveMode(ScrnInfoPtr pScrn);
    146146static void VBOXRestoreMode(ScrnInfoPtr pScrn);
     147
     148#ifndef XF86_SCRN_INTERFACE
     149# define xf86ScreenToScrn(pScreen) xf86Screens[(pScreen)->myNum]
     150# define xf86ScrnToScreen(pScrn) screenInfo.screens[(pScrn)->scrnIndex]
     151#endif
    147152
    148153static inline void VBOXSetRec(ScrnInfoPtr pScrn)
     
    261266};
    262267#endif /* !XORG_7X */
     268
     269/** Resize the virtual framebuffer. */
     270static Bool adjustScreenPixmap(ScrnInfoPtr pScrn, int width, int height)
     271{
     272    ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
     273    VBOXPtr pVBox = VBOXGetRec(pScrn);
     274    int adjustedWidth = pScrn->bitsPerPixel == 16 ? (width + 1) & ~1 : width;
     275    int cbLine = adjustedWidth * pScrn->bitsPerPixel / 8;
     276    PixmapPtr pPixmap;
     277    int rc;
     278
     279    TRACE_LOG("width=%d, height=%d\n", width, height);
     280    VBVXASSERT(width >= 0 && height >= 0, ("Invalid negative width (%d) or height (%d)\n", width, height));
     281    if (pScreen == NULL)  /* Not yet initialised. */
     282        return TRUE;
     283    pPixmap = pScreen->GetScreenPixmap(pScreen);
     284    VBVXASSERT(pPixmap != NULL, ("Failed to get the screen pixmap.\n"));
     285    TRACE_LOG("pPixmap=%p adjustedWidth=%d height=%d pScrn->depth=%d pScrn->bitsPerPixel=%d cbLine=%d pVBox->base=%p pPixmap->drawable.width=%d pPixmap->drawable.height=%d\n",
     286              pPixmap, adjustedWidth, height, pScrn->depth, pScrn->bitsPerPixel, cbLine, pVBox->base, pPixmap->drawable.width,
     287              pPixmap->drawable.height);
     288    if (   adjustedWidth != pPixmap->drawable.width
     289        || height != pPixmap->drawable.height)
     290    {
     291        if (   adjustedWidth > VBOX_VIDEO_MAX_VIRTUAL || height > VBOX_VIDEO_MAX_VIRTUAL
     292            || (unsigned)cbLine * (unsigned)height >= pVBox->cbFBMax)
     293        {
     294            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
     295                       "Virtual framebuffer %dx%d too large.  For information, video memory: %u Kb.\n",
     296                       adjustedWidth, height, (unsigned) pVBox->cbFBMax / 1024);
     297            return FALSE;
     298        }
     299        vbvxClearVRAM(pScrn, pScrn->virtualX * pScrn->virtualY * pScrn->bitsPerPixel / 8,
     300                      adjustedWidth * height * pScrn->bitsPerPixel / 8);
     301        pScreen->ModifyPixmapHeader(pPixmap, adjustedWidth, height, pScrn->depth, pScrn->bitsPerPixel, cbLine, pVBox->base);
     302    }
     303    pScrn->displayWidth = pScrn->virtualX = adjustedWidth;
     304    pScrn->virtualY = height;
     305#ifdef VBOX_DRI_OLD
     306    if (pVBox->useDRI)
     307        VBOXDRIUpdateStride(pScrn, pVBox);
     308#endif
     309    return TRUE;
     310}
    263311
    264312#ifdef VBOXVIDEO_13
     
    600648
    601649#ifndef XF86_SCRN_INTERFACE
    602 # define xf86ScreenToScrn(pScreen) xf86Screens[(pScreen)->myNum]
    603 # define xf86ScrnToScreen(pScrn) screenInfo.screens[(pScrn)->scrnIndex]
    604650# define SCRNINDEXAPI(pfn) pfn ## Index
    605651static Bool VBOXScreenInitIndex(int scrnIndex, ScreenPtr pScreen, int argc,
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette