VirtualBox

Changeset 57088 in vbox


Ignore:
Timestamp:
Jul 26, 2015 11:36:29 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
101810
Message:

DisplayImpl.cpp: Free the screen shot data in the correct way. pu8Data -> pbData and other cleanups.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmifs.h

    r56439 r57088  
    563563     *
    564564     * @param   pInterface          Pointer to this interface.
    565      * @param   ppu8Data            Where to store the pointer to the allocated buffer.
     565     * @param   ppbData             Where to store the pointer to the allocated
     566     *                              buffer.
    566567     * @param   pcbData             Where to store the actual size of the bitmap.
    567568     * @param   pcx                 Where to store the width of the bitmap.
     
    569570     * @thread  The emulation thread.
    570571     */
    571     DECLR3CALLBACKMEMBER(int, pfnTakeScreenshot,(PPDMIDISPLAYPORT pInterface, uint8_t **ppu8Data, size_t *pcbData, uint32_t *pcx, uint32_t *pcy));
     572    DECLR3CALLBACKMEMBER(int, pfnTakeScreenshot,(PPDMIDISPLAYPORT pInterface, uint8_t **ppbData, size_t *pcbData, uint32_t *pcx, uint32_t *pcy));
    572573
    573574    /**
     
    577578     *
    578579     * @param   pInterface          Pointer to this interface.
    579      * @param   ppu8Data            Pointer to the buffer returned by pfnTakeScreenshot.
     580     * @param   pbData              Pointer to the buffer returned by
     581     *                              pfnTakeScreenshot.
    580582     * @thread  Any.
    581583     */
    582     DECLR3CALLBACKMEMBER(void, pfnFreeScreenshot,(PPDMIDISPLAYPORT pInterface, uint8_t *pu8Data));
     584    DECLR3CALLBACKMEMBER(void, pfnFreeScreenshot,(PPDMIDISPLAYPORT pInterface, uint8_t *pbData));
    583585
    584586    /**
     
    678680     * @thread  Schedules on the emulation thread.
    679681     */
    680     DECLR3CALLBACKMEMBER(int, pfnSendModeHint,
    681                          (PPDMIDISPLAYPORT pInterface, uint32_t cx, uint32_t cy,
    682                           uint32_t cBPP, uint32_t iDisplay, uint32_t dx,
    683                           uint32_t dy, uint32_t fEnabled, uint32_t fNotifyGuest));
     682    DECLR3CALLBACKMEMBER(int, pfnSendModeHint, (PPDMIDISPLAYPORT pInterface, uint32_t cx, uint32_t cy,
     683                                                uint32_t cBPP, uint32_t iDisplay, uint32_t dx,
     684                                                uint32_t dy, uint32_t fEnabled, uint32_t fNotifyGuest));
    684685
    685686    /**
     
    748749     * @thread  The emulation thread.
    749750     */
    750     DECLR3CALLBACKMEMBER(int, pfnResize,(PPDMIDISPLAYCONNECTOR pInterface, uint32_t cBits, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy));
     751    DECLR3CALLBACKMEMBER(int, pfnResize,(PPDMIDISPLAYCONNECTOR pInterface, uint32_t cBits, void *pvVRAM, uint32_t cbLine,
     752                                         uint32_t cx, uint32_t cy));
    751753
    752754    /**
     
    797799     * @thread  The emulation thread.
    798800     */
    799     DECLR3CALLBACKMEMBER(void, pfnLFBModeChange, (PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled));
     801    DECLR3CALLBACKMEMBER(void, pfnLFBModeChange,(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled));
    800802
    801803    /**
     
    809811     * @thread  The emulation thread.
    810812     */
    811     DECLR3CALLBACKMEMBER(void, pfnProcessAdapterData, (PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize));
     813    DECLR3CALLBACKMEMBER(void, pfnProcessAdapterData,(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize));
    812814
    813815    /**
     
    821823     * @thread  The emulation thread.
    822824     */
    823     DECLR3CALLBACKMEMBER(void, pfnProcessDisplayData, (PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId));
     825    DECLR3CALLBACKMEMBER(void, pfnProcessDisplayData,(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId));
    824826
    825827    /**
     
    833835     * @thread  The emulation thread.
    834836     */
    835     DECLR3CALLBACKMEMBER(int, pfnVHWACommandProcess, (PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCmd));
     837    DECLR3CALLBACKMEMBER(int, pfnVHWACommandProcess,(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCmd));
    836838
    837839    /**
     
    842844     * @thread  The emulation thread.
    843845     */
    844     DECLR3CALLBACKMEMBER(void, pfnCrHgsmiCommandProcess, (PPDMIDISPLAYCONNECTOR pInterface, struct VBOXVDMACMD_CHROMIUM_CMD* pCmd, uint32_t cbCmd));
     846    DECLR3CALLBACKMEMBER(void, pfnCrHgsmiCommandProcess,(PPDMIDISPLAYCONNECTOR pInterface, struct VBOXVDMACMD_CHROMIUM_CMD* pCmd, uint32_t cbCmd));
    845847
    846848    /**
     
    851853     * @thread  The emulation thread.
    852854     */
    853     DECLR3CALLBACKMEMBER(void, pfnCrHgsmiControlProcess, (PPDMIDISPLAYCONNECTOR pInterface, struct VBOXVDMACMD_CHROMIUM_CTL* pCtl, uint32_t cbCtl));
     855    DECLR3CALLBACKMEMBER(void, pfnCrHgsmiControlProcess,(PPDMIDISPLAYCONNECTOR pInterface, struct VBOXVDMACMD_CHROMIUM_CTL* pCtl, uint32_t cbCtl));
    854856
    855857    /**
     
    858860     * @param   pInterface          Pointer to this interface.
    859861     * @param   pCmd                Video HW Acceleration Command to be processed.
    860      * @thread  The emulation thread.
    861      */
    862     DECLR3CALLBACKMEMBER(int, pfnCrHgcmCtlSubmit, (PPDMIDISPLAYCONNECTOR pInterface,
    863                                             struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd,
    864                                             PFNCRCTLCOMPLETION pfnCompletion,
    865                                             void *pvCompletion));
     862     * @param   cbCmd               Undocumented!
     863     * @param   pfnCompletion       Undocumented!
     864     * @param   pvCompletion        Undocumented!
     865     * @thread  The emulation thread.
     866     */
     867    DECLR3CALLBACKMEMBER(int, pfnCrHgcmCtlSubmit,(PPDMIDISPLAYCONNECTOR pInterface, struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd,
     868                                                  PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion));
    866869
    867870    /**
     
    870873     * @param   pInterface          Pointer to this interface.
    871874     * @param   uScreenId           The screen updates are for.
     875     * @param   pHostFlags          Undocumented!
    872876     * @param   fRenderThreadMode   if true - the graphics device has a separate thread that does all rendering.
    873877     *                              This means that:
     
    879883     * @thread  if fRenderThreadMode is TRUE - the render thread, otherwise - the emulation thread.
    880884     */
    881     DECLR3CALLBACKMEMBER(int, pfnVBVAEnable,(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, PVBVAHOSTFLAGS pHostFlags, bool fRenderThreadMode));
     885    DECLR3CALLBACKMEMBER(int, pfnVBVAEnable,(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
     886                                             PVBVAHOSTFLAGS pHostFlags, bool fRenderThreadMode));
    882887
    883888    /**
     
    905910     *
    906911     * @param   pInterface          Pointer to this interface.
     912     * @param   uScreenId           The screen updates are for.
    907913     * @param   pCmd                Video HW Acceleration Command to be processed.
     914     * @param   cbCmd               Undocumented!
    908915     * @thread  if render thread mode is on (fRenderThreadMode that was passed to pfnVBVAEnable is TRUE) - the render thread pfnVBVAEnable was called in,
    909916     *          otherwise - the emulation thread.
    910917     */
    911     DECLR3CALLBACKMEMBER(void, pfnVBVAUpdateProcess,(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, const PVBVACMDHDR pCmd, size_t cbCmd));
     918    DECLR3CALLBACKMEMBER(void, pfnVBVAUpdateProcess,(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
     919                                                     const PVBVACMDHDR pCmd, size_t cbCmd));
    912920
    913921    /**
     
    964972     */
    965973    DECLR3CALLBACKMEMBER(int, pfnVBVAMousePointerShape,(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha,
    966                                                         uint32_t xHot, uint32_t yHot,
    967                                                         uint32_t cx, uint32_t cy,
     974                                                        uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy,
    968975                                                        const void *pvShape));
    969976
     
    983990     */
    984991    /** Pointer to the display data buffer. */
    985     uint8_t        *pu8Data;
     992    uint8_t        *pbData;
    986993    /** Size of a scanline in the data buffer. */
    987994    uint32_t        cbScanline;
  • trunk/src/VBox/Devices/Graphics/DevVGA.cpp

    r57085 r57088  
    18701870    vga_draw_glyph9 = vga_draw_glyph9_table[depth_index];
    18711871
    1872     dest = pDrv->pu8Data;
     1872    dest = pDrv->pbData;
    18731873    linesize = pDrv->cbScanline;
    18741874    ch_attr_ptr = pThis->last_ch_attr;
     
    21972197    uint32_t offDst = (xStart * RT_ALIGN(s->pDrv->cBits, 8)) / 8 + s->pDrv->cbScanline * yStart;
    21982198
    2199     uint8_t       *pbDst = s->pDrv->pu8Data      + offDst;
     2199    uint8_t       *pbDst = s->pDrv->pbData       + offDst;
    22002200    uint8_t const *pbSrc = s->CTX_SUFF(vram_ptr) + offSrc;
    22012201
     
    22742274    page_min = 0x7fffffff;
    22752275    page_max = -1;
    2276     d = pDrv->pu8Data;
     2276    d = pDrv->pbData;
    22772277    linesize = pDrv->cbScanline;
    22782278
     
    24522452    page_min = 0x7fffffff;
    24532453    page_max = -1;
    2454     d = pDrv->pu8Data;
     2454    d = pDrv->pbData;
    24552455    linesize = pDrv->cbScanline;
    24562456
     
    25312531    uint32_t cbScanline = pDrv->cbScanline;
    25322532
    2533     if (pDrv->pu8Data == pThis->vram_ptrR3) /* Do not clear the VRAM itself. */
     2533    if (pDrv->pbData == pThis->vram_ptrR3) /* Do not clear the VRAM itself. */
    25342534        return;
    25352535    if (!full_update)
     
    25422542        val = 0;
    25432543    w = pThis->last_scr_width * ((pDrv->cBits + 7) >> 3);
    2544     d = pDrv->pu8Data;
     2544    d = pDrv->pbData;
    25452545    if (pThis->fRenderVRAM)
    25462546    {
     
    48314831            PDMIDISPLAYCONNECTOR Connector;
    48324832            RT_ZERO(Connector);
    4833             Connector.pu8Data       = pbData;
     4833            Connector.pbData        = pbData;
    48344834            Connector.cBits         = 32;
    48354835            Connector.cx            = pThis->last_scr_width;
     
    49694969            uint8_t    *pbSrc       = (uint8_t *)pvData;
    49704970            size_t      cbLineDst   = pThis->pDrv->cbScanline;
    4971             uint8_t    *pbDst       = pThis->pDrv->pu8Data + y * cbLineDst + x * cbPixelDst;
     4971            uint8_t    *pbDst       = pThis->pDrv->pbData + y * cbLineDst + x * cbPixelDst;
    49724972            uint32_t    cyLeft      = cy;
    49734973            vga_draw_line_func *pfnVgaDrawLine = vga_draw_line_table[VGA_DRAW_LINE32 * 4 + get_depth_index(pThis->pDrv->cBits)];
     
    50315031
    50325032    Assert(pThis->pDrv);
    5033     Assert(pThis->pDrv->pu8Data);
     5033    Assert(pThis->pDrv->pbData);
    50345034
    50355035    /* Correct negative x and y coordinates. */
     
    51145114    cbPixelDst = (pThis->pDrv->cBits + 7) / 8;
    51155115    cbLineDst  = pThis->pDrv->cbScanline;
    5116     pbDst      = pThis->pDrv->pu8Data + y * cbLineDst + x * cbPixelDst;
     5116    pbDst      = pThis->pDrv->pbData + y * cbLineDst + x * cbPixelDst;
    51175117
    51185118    cbPixelSrc = (pThis->get_bpp(pThis) + 7) / 8;
     
    51455145}
    51465146
    5147 static DECLCALLBACK(int) vgaPortCopyRect (PPDMIDISPLAYPORT pInterface,
    5148                                           uint32_t w,
    5149                                           uint32_t h,
    5150                                           const uint8_t *pbSrc,
    5151                                           int32_t xSrc,
    5152                                           int32_t ySrc,
    5153                                           uint32_t u32SrcWidth,
    5154                                           uint32_t u32SrcHeight,
    5155                                           uint32_t u32SrcLineSize,
    5156                                           uint32_t u32SrcBitsPerPixel,
    5157                                           uint8_t *pbDst,
    5158                                           int32_t xDst,
    5159                                           int32_t yDst,
    5160                                           uint32_t u32DstWidth,
    5161                                           uint32_t u32DstHeight,
    5162                                           uint32_t u32DstLineSize,
    5163                                           uint32_t u32DstBitsPerPixel)
     5147
     5148static DECLCALLBACK(int)
     5149vgaPortCopyRect(PPDMIDISPLAYPORT pInterface,
     5150                uint32_t cx,
     5151                uint32_t cy,
     5152                const uint8_t *pbSrc, int32_t xSrc, int32_t ySrc, uint32_t cxSrc, uint32_t cySrc,
     5153                uint32_t cbSrcLine, uint32_t cSrcBitsPerPixel,
     5154                uint8_t *pbDst, int32_t xDst, int32_t yDst, uint32_t cxDst, uint32_t cyDst,
     5155                uint32_t cbDstLine, uint32_t cDstBitsPerPixel)
    51645156{
    51655157    uint32_t v;
     
    51675159
    51685160#ifdef DEBUG_sunlover
    5169     LogFlow(("vgaPortCopyRect: %d,%d %dx%d -> %d,%d\n", xSrc, ySrc, w, h, xDst, yDst));
     5161    LogFlow(("vgaPortCopyRect: %d,%d %dx%d -> %d,%d\n", xSrc, ySrc, cx, cy, xDst, yDst));
    51705162#endif /* DEBUG_sunlover */
    51715163
     
    51755167    Assert(pThis->pDrv);
    51765168
    5177     int32_t xSrcCorrected = xSrc;
    5178     int32_t ySrcCorrected = ySrc;
    5179     uint32_t wCorrected = w;
    5180     uint32_t hCorrected = h;
     5169    int32_t  xSrcCorrected = xSrc;
     5170    int32_t  ySrcCorrected = ySrc;
     5171    uint32_t cxCorrected = cx;
     5172    uint32_t cyCorrected = cy;
    51815173
    51825174    /* Correct source coordinates to be within the source bitmap. */
    51835175    if (xSrcCorrected < 0)
    51845176    {
    5185         xSrcCorrected += wCorrected; /* Compute xRight which is also the new width. */
    5186         wCorrected = (xSrcCorrected < 0) ? 0 : xSrcCorrected;
     5177        xSrcCorrected += cxCorrected; /* Compute xRight which is also the new width. */
     5178        cxCorrected = (xSrcCorrected < 0) ? 0 : xSrcCorrected;
    51875179        xSrcCorrected = 0;
    51885180    }
     
    51905182    if (ySrcCorrected < 0)
    51915183    {
    5192         ySrcCorrected += hCorrected; /* Compute yBottom, which is also the new height. */
    5193         hCorrected = (ySrcCorrected < 0) ? 0 : ySrcCorrected;
     5184        ySrcCorrected += cyCorrected; /* Compute yBottom, which is also the new height. */
     5185        cyCorrected = (ySrcCorrected < 0) ? 0 : ySrcCorrected;
    51945186        ySrcCorrected = 0;
    51955187    }
    51965188
    51975189    /* Also check if coords are greater than the display resolution. */
    5198     if (xSrcCorrected + wCorrected > u32SrcWidth)
     5190    if (xSrcCorrected + cxCorrected > cxSrc)
    51995191    {
    52005192        /* xSrcCorrected < 0 is not possible here */
    5201         wCorrected = u32SrcWidth > (uint32_t)xSrcCorrected? u32SrcWidth - xSrcCorrected: 0;
    5202     }
    5203 
    5204     if (ySrcCorrected + hCorrected > u32SrcHeight)
     5193        cxCorrected = cxSrc > (uint32_t)xSrcCorrected ? cxSrc - xSrcCorrected : 0;
     5194    }
     5195
     5196    if (ySrcCorrected + cyCorrected > cySrc)
    52055197    {
    52065198        /* y < 0 is not possible here */
    5207         hCorrected = u32SrcHeight > (uint32_t)ySrcCorrected? u32SrcHeight - ySrcCorrected: 0;
     5199        cyCorrected = cySrc > (uint32_t)ySrcCorrected ? cySrc - ySrcCorrected : 0;
    52085200    }
    52095201
    52105202#ifdef DEBUG_sunlover
    5211     LogFlow(("vgaPortCopyRect: %d,%d %dx%d (corrected coords)\n", xSrcCorrected, ySrcCorrected, wCorrected, hCorrected));
     5203    LogFlow(("vgaPortCopyRect: %d,%d %dx%d (corrected coords)\n", xSrcCorrected, ySrcCorrected, cxCorrected, cyCorrected));
    52125204#endif /* DEBUG_sunlover */
    52135205
    52145206    /* Check if there is something to do at all. */
    5215     if (wCorrected == 0 || hCorrected == 0)
     5207    if (cxCorrected == 0 || cyCorrected == 0)
    52165208    {
    52175209        /* Empty rectangle. */
    52185210#ifdef DEBUG_sunlover
    5219         LogFlow(("vgaPortUpdateDisplayRectEx: nothing to do: %dx%d\n", wCorrected, hCorrected));
     5211        LogFlow(("vgaPortUpdateDisplayRectEx: nothing to do: %dx%d\n", cxCorrected, cyCorrected));
    52205212#endif /* DEBUG_sunlover */
    52215213        return VINF_SUCCESS;
     
    52275219    if (   xDst < 0
    52285220        || yDst < 0
    5229         || xDst + wCorrected > u32DstWidth
    5230         || yDst + hCorrected > u32DstHeight)
     5221        || xDst + cxCorrected > cxDst
     5222        || yDst + cyCorrected > cyDst)
    52315223    {
    52325224        return VERR_INVALID_PARAMETER;
     
    52345226
    52355227    /* Choose the rendering function. */
    5236     switch(u32SrcBitsPerPixel)
     5228    switch (cSrcBitsPerPixel)
    52375229    {
    52385230        default:
     
    52675259    }
    52685260
    5269     vga_draw_line = vga_draw_line_table[v * 4 + get_depth_index(u32DstBitsPerPixel)];
     5261    vga_draw_line = vga_draw_line_table[v * 4 + get_depth_index(cDstBitsPerPixel)];
    52705262
    52715263    /* Compute source and destination addresses and pitches. */
    5272     uint32_t cbPixelDst = (u32DstBitsPerPixel + 7) / 8;
    5273     uint32_t cbLineDst  = u32DstLineSize;
     5264    uint32_t cbPixelDst = (cDstBitsPerPixel + 7) / 8;
     5265    uint32_t cbLineDst  = cbDstLine;
    52745266    uint8_t *pbDstCur   = pbDst + yDst * cbLineDst + xDst * cbPixelDst;
    52755267
    5276     uint32_t cbPixelSrc = (u32SrcBitsPerPixel + 7) / 8;
    5277     uint32_t cbLineSrc  = u32SrcLineSize;
     5268    uint32_t cbPixelSrc = (cSrcBitsPerPixel + 7) / 8;
     5269    uint32_t cbLineSrc  = cbSrcLine;
    52785270    const uint8_t *pbSrcCur = pbSrc + ySrcCorrected * cbLineSrc + xSrcCorrected * cbPixelSrc;
    52795271
     
    52825274#endif /* DEBUG_sunlover */
    52835275
    5284     while (hCorrected-- > 0)
    5285     {
    5286         vga_draw_line (pThis, pbDstCur, pbSrcCur, wCorrected);
     5276    while (cyCorrected-- > 0)
     5277    {
     5278        vga_draw_line(pThis, pbDstCur, pbSrcCur, cxCorrected);
    52875279        pbDstCur += cbLineDst;
    52885280        pbSrcCur += cbLineSrc;
     
    58025794                if (pThis->pDrv)
    58035795                {
    5804                     /* pThis->pDrv->pu8Data can be NULL when there is no framebuffer. */
     5796                    /* pThis->pDrv->pbData can be NULL when there is no framebuffer. */
    58055797                    if (    pThis->pDrv->pfnRefresh
    58065798                        &&  pThis->pDrv->pfnResize
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r56468 r57088  
    448448public:
    449449
    450     static int i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppu8Data, size_t *pcbData,
    451                                           uint32_t *pu32Width, uint32_t *pu32Height);
    452 
     450    static int i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppbData, size_t *pcbData,
     451                                          uint32_t *pcx, uint32_t *pcy, bool *pfMemFree);
    453452#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
    454     static BOOL  i_displayCheckTakeScreenshotCrOgl(Display *pDisplay, ULONG aScreenId, uint8_t *pu8Data,
     453    static BOOL  i_displayCheckTakeScreenshotCrOgl(Display *pDisplay, ULONG aScreenId, uint8_t *pbData,
    455454                                                   uint32_t u32Width, uint32_t u32Height);
    456455    int i_crCtlSubmit(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion);
     
    513512
    514513/* helper function, code in DisplayPNGUtul.cpp */
    515 int DisplayMakePNG(uint8_t *pu8Data, uint32_t cx, uint32_t cy,
     514int DisplayMakePNG(uint8_t *pbData, uint32_t cx, uint32_t cy,
    516515                   uint8_t **ppu8PNG, uint32_t *pcbPNG, uint32_t *pcxPNG, uint32_t *pcyPNG,
    517516                     uint8_t fLimitSize);
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r56853 r57088  
    186186 * Save thumbnail and screenshot of the guest screen.
    187187 */
    188 static int displayMakeThumbnail(uint8_t *pu8Data, uint32_t cx, uint32_t cy,
     188static int displayMakeThumbnail(uint8_t *pbData, uint32_t cx, uint32_t cy,
    189189                                uint8_t **ppu8Thumbnail, uint32_t *pcbThumbnail, uint32_t *pcxThumbnail, uint32_t *pcyThumbnail)
    190190{
     
    215215    {
    216216        uint8_t *dst = pu8Thumbnail;
    217         uint8_t *src = pu8Data;
     217        uint8_t *src = pbData;
    218218        int dstW = cxThumbnail;
    219219        int dstH = cyThumbnail;
     
    303303    if (ptrVM.isOk())
    304304    {
    305         /* Query RGB bitmap. */
    306         uint8_t *pu8Data = NULL;
    307         size_t cbData = 0;
    308         uint32_t cx = 0;
    309         uint32_t cy = 0;
    310 
    311305#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
    312306        BOOL f3DSnapshot = FALSE;
     
    318312            if (pVMMDev)
    319313            {
    320                 VBOX_DISPLAY_SAVESCREENSHOT_DATA *pScreenshot =
    321                     (VBOX_DISPLAY_SAVESCREENSHOT_DATA*)RTMemAllocZ(sizeof(*pScreenshot));
     314                VBOX_DISPLAY_SAVESCREENSHOT_DATA *pScreenshot;
     315                pScreenshot = (VBOX_DISPLAY_SAVESCREENSHOT_DATA*)RTMemAllocZ(sizeof(*pScreenshot));
    322316                if (pScreenshot)
    323317                {
     
    373367#endif
    374368        {
     369            /* Query RGB bitmap. */
    375370            /* SSM code is executed on EMT(0), therefore no need to use VMR3ReqCallWait. */
    376             int rc = Display::i_displayTakeScreenshotEMT(that, VBOX_VIDEO_PRIMARY_SCREEN, &pu8Data, &cbData, &cx, &cy);
     371            uint8_t *pbData = NULL;
     372            size_t cbData = 0;
     373            uint32_t cx = 0;
     374            uint32_t cy = 0;
     375            bool fFreeMem = false;
     376            int rc = Display::i_displayTakeScreenshotEMT(that, VBOX_VIDEO_PRIMARY_SCREEN, &pbData, &cbData, &cx, &cy, &fFreeMem);
    377377
    378378            /*
     
    380380             * (no display attached if a VM is running with VBoxHeadless on OSE for example)
    381381             */
    382             if (RT_SUCCESS(rc) && pu8Data)
     382            if (RT_SUCCESS(rc) && pbData)
    383383            {
    384384                Assert(cx && cy);
    385385
    386386                /* Prepare a small thumbnail and a PNG screenshot. */
    387                 displayMakeThumbnail(pu8Data, cx, cy, &pu8Thumbnail, &cbThumbnail, &cxThumbnail, &cyThumbnail);
    388                 rc = DisplayMakePNG(pu8Data, cx, cy, &pu8PNG, &cbPNG, &cxPNG, &cyPNG, 1);
     387                displayMakeThumbnail(pbData, cx, cy, &pu8Thumbnail, &cbThumbnail, &cxThumbnail, &cyThumbnail);
     388                rc = DisplayMakePNG(pbData, cx, cy, &pu8PNG, &cbPNG, &cxPNG, &cyPNG, 1);
    389389                if (RT_FAILURE(rc))
    390390                {
     
    399399                }
    400400
    401                 /* This can be called from any thread. */
    402                 that->mpDrv->pUpPort->pfnFreeScreenshot(that->mpDrv->pUpPort, pu8Data);
     401                if (fFreeMem)
     402                    RTMemFree(pbData);
     403                else
     404                    that->mpDrv->pUpPort->pfnFreeScreenshot(that->mpDrv->pUpPort, pbData);
    403405            }
    404406        }
     
    908910        mpDrv->pUpPort->pfnSetRenderVRAM(mpDrv->pUpPort, false);
    909911
    910         mpDrv->IConnector.pu8Data    = NULL;
     912        mpDrv->IConnector.pbData     = NULL;
    911913        mpDrv->IConnector.cbScanline = 0;
    912914        mpDrv->IConnector.cBits      = 32; /* DevVGA does not work with cBits == 0. */
     
    18401842
    18411843#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
    1842 BOOL Display::i_displayCheckTakeScreenshotCrOgl(Display *pDisplay, ULONG aScreenId, uint8_t *pu8Data,
     1844BOOL Display::i_displayCheckTakeScreenshotCrOgl(Display *pDisplay, ULONG aScreenId, uint8_t *pbData,
    18431845                                                uint32_t u32Width, uint32_t u32Height)
    18441846{
     
    18501852        if (pVMMDev)
    18511853        {
    1852             CRVBOXHGCMTAKESCREENSHOT *pScreenshot = (CRVBOXHGCMTAKESCREENSHOT*)RTMemAlloc(sizeof(*pScreenshot));
     1854            CRVBOXHGCMTAKESCREENSHOT *pScreenshot = (CRVBOXHGCMTAKESCREENSHOT *)RTMemAlloc(sizeof(*pScreenshot));
    18531855            if (pScreenshot)
    18541856            {
     
    18581860                pScreenshot->u32Height = u32Height;
    18591861                pScreenshot->u32Pitch = u32Width * 4;
    1860                 pScreenshot->pvBuffer = pu8Data;
     1862                pScreenshot->pvBuffer = pbData;
    18611863                pScreenshot->pvContext = NULL;
    18621864                pScreenshot->pfnScreenshotBegin = NULL;
     
    18871889#endif
    18881890
    1889 int Display::i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppu8Data, size_t *pcbData,
    1890                                         uint32_t *pu32Width, uint32_t *pu32Height)
     1891/* static */
     1892int Display::i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppbData, size_t *pcbData,
     1893                                        uint32_t *pcx, uint32_t *pcy, bool *pfMemFree)
    18911894{
    18921895    int rc;
    1893 
    18941896    if (   aScreenId == VBOX_VIDEO_PRIMARY_SCREEN
    18951897        && pDisplay->maFramebuffers[aScreenId].fVBVAEnabled == false) /* A non-VBVA mode. */
    18961898    {
    1897         rc = pDisplay->mpDrv->pUpPort->pfnTakeScreenshot(pDisplay->mpDrv->pUpPort, ppu8Data, pcbData, pu32Width, pu32Height);
     1899        rc = pDisplay->mpDrv->pUpPort->pfnTakeScreenshot(pDisplay->mpDrv->pUpPort, ppbData, pcbData, pcx, pcy);
     1900        *pfMemFree = false;
    18981901    }
    18991902    else if (aScreenId < pDisplay->mcMonitors)
     
    19091912        if (cbRequired)
    19101913        {
    1911             uint8_t *pu8Data = (uint8_t *)RTMemAlloc(cbRequired);
    1912 
    1913             if (pu8Data == NULL)
    1914             {
    1915                 rc = VERR_NO_MEMORY;
    1916             }
    1917             else
     1914            uint8_t *pbDst = (uint8_t *)RTMemAlloc(cbRequired);
     1915            if (pbDst != NULL)
    19181916            {
    19191917                /* Copy guest VRAM to the allocated 32bpp buffer. */
     
    19261924                uint32_t u32SrcBitsPerPixel = pFBInfo->u16BitsPerPixel;
    19271925
    1928                 uint8_t *pu8Dst             = pu8Data;
    19291926                int32_t xDst                = 0;
    19301927                int32_t yDst                = 0;
     
    19401937                                                           u32SrcWidth, u32SrcHeight,
    19411938                                                           u32SrcLineSize, u32SrcBitsPerPixel,
    1942                                                            pu8Dst,
     1939                                                           pbDst,
    19431940                                                           xDst, yDst,
    19441941                                                           u32DstWidth, u32DstHeight,
     
    19461943                if (RT_SUCCESS(rc))
    19471944                {
    1948                     *ppu8Data = pu8Data;
     1945                    *ppbData = pbDst;
    19491946                    *pcbData = cbRequired;
    1950                     *pu32Width = width;
    1951                     *pu32Height = height;
     1947                    *pcx = width;
     1948                    *pcy = height;
     1949                    *pfMemFree = true;
    19521950                }
    19531951                else
    19541952                {
    1955                     RTMemFree(pu8Data);
     1953                    RTMemFree(pbDst);
    19561954
    19571955                    /* CopyRect can fail if VBVA was paused in VGA device, retry using the generic method. */
     
    19591957                        && aScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
    19601958                    {
    1961                         rc = pDisplay->mpDrv->pUpPort->pfnTakeScreenshot(pDisplay->mpDrv->pUpPort,
    1962                                                                          ppu8Data, pcbData, pu32Width, pu32Height);
     1959                        rc = pDisplay->mpDrv->pUpPort->pfnTakeScreenshot(pDisplay->mpDrv->pUpPort, ppbData, pcbData, pcx, pcy);
     1960                        *pfMemFree = false;
    19631961                    }
    19641962                }
    19651963            }
     1964            else
     1965                rc = VERR_NO_MEMORY;
    19661966        }
    19671967        else
    19681968        {
    19691969            /* No image. */
    1970             *ppu8Data = NULL;
     1970            *ppbData = NULL;
    19711971            *pcbData = 0;
    1972             *pu32Width = 0;
    1973             *pu32Height = 0;
     1972            *pcx = 0;
     1973            *pcy = 0;
     1974            *pfMemFree = true;
    19741975            rc = VINF_SUCCESS;
    19751976        }
    19761977    }
    19771978    else
    1978     {
    19791979        rc = VERR_INVALID_PARAMETER;
    1980     }
    1981 
    19821980    return rc;
    19831981}
     
    19861984                                   BYTE *address, ULONG width, ULONG height)
    19871985{
    1988     uint8_t *pu8Data = NULL;
     1986#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
     1987    /*
     1988     * CrOgl screenshot hook/hack.
     1989     */
     1990    if (Display::i_displayCheckTakeScreenshotCrOgl(pDisplay, aScreenId, (uint8_t *)address, width, height))
     1991        return VINF_SUCCESS;
     1992#endif
     1993
     1994    uint8_t *pbData = NULL;
    19891995    size_t cbData = 0;
    19901996    uint32_t cx = 0;
    19911997    uint32_t cy = 0;
     1998    bool fFreeMem = false;
    19921999    int vrc = VINF_SUCCESS;
    19932000
    1994 # if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
    1995     if (Display::i_displayCheckTakeScreenshotCrOgl(pDisplay, aScreenId, (uint8_t*)address, width, height))
    1996         return VINF_SUCCESS;
    1997 #endif
    1998 
    19992001    int cRetries = 5;
    2000 
    20012002    while (cRetries-- > 0)
    20022003    {
     
    20042005                 it would be nice to have an accurate screenshot for the bug
    20052006                 report if the VM deadlocks. */
    2006         vrc = VMR3ReqPriorityCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)Display::i_displayTakeScreenshotEMT, 6,
    2007                                        pDisplay, aScreenId, &pu8Data, &cbData, &cx, &cy);
     2007        vrc = VMR3ReqPriorityCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)Display::i_displayTakeScreenshotEMT, 7,
     2008                                       pDisplay, aScreenId, &pbData, &cbData, &cx, &cy, &fFreeMem);
    20082009        if (vrc != VERR_TRY_AGAIN)
    20092010        {
     
    20142015    }
    20152016
    2016     if (RT_SUCCESS(vrc) && pu8Data)
     2017    if (RT_SUCCESS(vrc) && pbData)
    20172018    {
    20182019        if (cx == width && cy == height)
    20192020        {
    20202021            /* No scaling required. */
    2021             memcpy(address, pu8Data, cbData);
     2022            memcpy(address, pbData, cbData);
    20222023        }
    20232024        else
     
    20272028
    20282029            uint8_t *dst = address;
    2029             uint8_t *src = pu8Data;
     2030            uint8_t *src = pbData;
    20302031            int dstW = width;
    20312032            int dstH = height;
     
    20412042        }
    20422043
    2043         if (aScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
     2044        if (fFreeMem)
     2045            RTMemFree(pbData);
     2046        else
    20442047        {
    20452048            /* This can be called from any thread. */
    2046             pDrv->pUpPort->pfnFreeScreenshot(pDrv->pUpPort, pu8Data);
    2047         }
    2048         else
    2049         {
    2050             RTMemFree(pu8Data);
     2049            pDrv->pUpPort->pfnFreeScreenshot(pDrv->pUpPort, pbData);
    20512050        }
    20522051    }
     
    27642763                                     &bitmapFormat);
    27652764
    2766                 mpDrv->IConnector.pu8Data    = pAddress;
     2765                mpDrv->IConnector.pbData     = pAddress;
    27672766                mpDrv->IConnector.cbScanline = ulBytesPerLine;
    27682767                mpDrv->IConnector.cBits      = ulBitsPerPixel;
     
    28592858
    28602859    size_t cbData = RT_UOFFSETOF(VBOXCRCMDCTL_HGCM, aParms[5]);
    2861     VBOXCRCMDCTL_HGCM *pData = (VBOXCRCMDCTL_HGCM*)alloca(cbData);
     2860    VBOXCRCMDCTL_HGCM *pData = (VBOXCRCMDCTL_HGCM *)alloca(cbData);
    28622861
    28632862    pData->Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
     
    31023101                                                  pFBInfo->pu8FramebufferVRAM, u64Now);
    31033102                    }
    3104                     else if (uScreenId == VBOX_VIDEO_PRIMARY_SCREEN && pDrv->IConnector.pu8Data)
     3103                    else if (uScreenId == VBOX_VIDEO_PRIMARY_SCREEN && pDrv->IConnector.pbData)
    31053104                    {
    31063105                        rc = VideoRecCopyToIntBuf(pDisplay->mpVideoRecCtx, uScreenId, 0, 0,
     
    31083107                                                  pDrv->IConnector.cBits,
    31093108                                                  pDrv->IConnector.cbScanline, pDrv->IConnector.cx,
    3110                                                   pDrv->IConnector.cy, pDrv->IConnector.pu8Data, u64Now);
     3109                                                  pDrv->IConnector.cy, pDrv->IConnector.pbData, u64Now);
    31113110                    }
    31123111                    if (rc == VINF_TRY_AGAIN)
     
    41194118    pThis->pUpPort->pfnSetRenderVRAM(pThis->pUpPort, false);
    41204119
    4121     pThis->IConnector.pu8Data    = NULL;
     4120    pThis->IConnector.pbData     = NULL;
    41224121    pThis->IConnector.cbScanline = 0;
    41234122    pThis->IConnector.cBits      = 32;
Note: See TracChangeset for help on using the changeset viewer.

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