VirtualBox

Changeset 82021 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 20, 2019 11:38:54 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134824
Message:

FE/Qt: bugref:9598: UISession: A bit of cleanup in mouse pointer shape related stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r81964 r82021  
    16561656void UISession::updateMousePointerShape()
    16571657{
     1658    /* Fetch incoming shape data: */
    16581659    const bool fHasAlpha = m_shapeData.hasAlpha();
    16591660    uint uXHot = m_shapeData.hotPoint().x();
    16601661    uint uYHot = m_shapeData.hotPoint().y();
    1661     uint uWidth = m_shapeData.shapeSize().width();
    1662     uint uHeight = m_shapeData.shapeSize().height();
     1662    const uint uWidth = m_shapeData.shapeSize().width();
     1663    const uint uHeight = m_shapeData.shapeSize().height();
    16631664    const uchar *pShapeData = m_shapeData.shape().constData();
    1664     AssertMsg(pShapeData, ("Shape data must not be NULL!\n"));
    1665 
     1665    AssertMsgReturnVoid(pShapeData, ("Shape data must not be NULL!\n"));
     1666
     1667    /* Invalidate mouse pointer shape initially: */
    16661668    m_fIsValidPointerShapePresent = false;
    1667     const uchar *srcAndMaskPtr = pShapeData;
    1668     uint andMaskSize = (uWidth + 7) / 8 * uHeight;
    1669     const uchar *srcShapePtr = pShapeData + ((andMaskSize + 3) & ~3);
    1670     uint srcShapePtrScan = uWidth * 4;
     1669
     1670    /* Parse incoming shape data: */
     1671    const uchar *pSrcAndMaskPtr = pShapeData;
     1672    const uint uAndMaskSize = (uWidth + 7) / 8 * uHeight;
     1673    const uchar *pSrcShapePtr = pShapeData + ((uAndMaskSize + 3) & ~3);
    16711674
    16721675    /* Remember initial cursor hotspot: */
     
    16751678#if defined (VBOX_WS_WIN)
    16761679
    1677     /* Create a ARGB image out of the shape data: */
    1678 
    1679     /*
    1680      * Qt5 QCursor recommends 32 x 32 cursor, therefore the original data is copied to
    1681      * a larger QImage if necessary. Cursors like 10x16 did not work correctly (Solaris 10 guest).
    1682      */
    1683     uint uCursorWidth = uWidth >= 32? uWidth: 32;
    1684     uint uCursorHeight = uHeight >= 32? uHeight: 32;
    1685     uint x, y;
     1680    /* Create an ARGB image out of the shape data: */
     1681
     1682    // WORKAROUND:
     1683    // Qt5 QCursor recommends 32 x 32 cursor, therefore the original data is copied to
     1684    // a larger QImage if necessary. Cursors like 10x16 did not work correctly (Solaris 10 guest).
     1685    const uint uCursorWidth = uWidth >= 32 ? uWidth : 32;
     1686    const uint uCursorHeight = uHeight >= 32 ? uHeight : 32;
    16861687
    16871688    if (fHasAlpha)
     
    16901691        memset(image.bits(), 0, image.byteCount());
    16911692
    1692         const uint32_t *pu32SrcShapeScanline = (uint32_t *)srcShapePtr;
    1693         for (y = 0; y < uHeight; ++y, pu32SrcShapeScanline += uWidth)
     1693        const uint32_t *pu32SrcShapeScanline = (uint32_t *)pSrcShapePtr;
     1694        for (uint y = 0; y < uHeight; ++y, pu32SrcShapeScanline += uWidth)
    16941695            memcpy(image.scanLine(y), pu32SrcShapeScanline, uWidth * sizeof(uint32_t));
    16951696
     
    17001701    else
    17011702    {
    1702         if (isPointer1bpp(srcShapePtr, uWidth, uHeight))
     1703        if (isPointer1bpp(pSrcShapePtr, uWidth, uHeight))
    17031704        {
    17041705            /* Incoming data consist of 32 bit BGR XOR mask and 1 bit AND mask.
     
    17341735            memset(mask.bits(), 0xFF, mask.byteCount());
    17351736
    1736             const uint8_t *pu8SrcAndScanline = srcAndMaskPtr;
    1737             const uint32_t *pu32SrcShapeScanline = (uint32_t *)srcShapePtr;
    1738             for (y = 0; y < uHeight; ++y)
     1737            const uint8_t *pu8SrcAndScanline = pSrcAndMaskPtr;
     1738            const uint32_t *pu32SrcShapeScanline = (uint32_t *)pSrcShapePtr;
     1739            for (uint y = 0; y < uHeight; ++y)
    17391740            {
    1740                 for (x = 0; x < uWidth; ++x)
     1741                for (uint x = 0; x < uWidth; ++x)
    17411742                {
    17421743                    const uint8_t u8Bit = (uint8_t)(1 << (7 - x % 8));
     
    17951796            memset(image.bits(), 0, image.byteCount());
    17961797
    1797             const uint8_t *pu8SrcAndScanline = srcAndMaskPtr;
    1798             const uint32_t *pu32SrcShapeScanline = (uint32_t *)srcShapePtr;
    1799 
    1800             for (y = 0; y < uHeight; ++y)
     1798            const uint8_t *pu8SrcAndScanline = pSrcAndMaskPtr;
     1799            const uint32_t *pu32SrcShapeScanline = (uint32_t *)pSrcShapePtr;
     1800
     1801            for (uint y = 0; y < uHeight; ++y)
    18011802            {
    18021803                uint32_t *pu32DstPixel = (uint32_t *)image.scanLine(y);
    18031804
    1804                 for (x = 0; x < uWidth; ++x)
     1805                for (uint x = 0; x < uWidth; ++x)
    18051806                {
    18061807                    const uint8_t u8Bit = (uint8_t)(1 << (7 - x % 8));
     
    18241825
    18251826    m_fIsValidPointerShapePresent = true;
    1826     NOREF(srcShapePtrScan);
    18271827
    18281828#elif defined(VBOX_WS_X11) || defined(VBOX_WS_MAC)
    18291829
    1830     /* Create a ARGB image out of the shape data: */
     1830    /* Create an ARGB image out of the shape data: */
    18311831    QImage image(uWidth, uHeight, QImage::Format_ARGB32);
    18321832
    18331833    if (fHasAlpha)
    18341834    {
    1835         memcpy(image.bits(), srcShapePtr, uHeight * uWidth * 4);
     1835        memcpy(image.bits(), pSrcShapePtr, uHeight * uWidth * 4);
    18361836    }
    18371837    else
    18381838    {
    1839         renderCursorPixels((uint32_t *)srcShapePtr, srcAndMaskPtr,
     1839        renderCursorPixels((uint32_t *)pSrcShapePtr, pSrcAndMaskPtr,
    18401840                           uWidth, uHeight,
    18411841                           (uint32_t *)image.bits(), uHeight * uWidth * 4);
     
    18471847    m_cursor = QCursor(m_cursorPixmap, uXHot, uYHot);
    18481848    m_fIsValidPointerShapePresent = true;
    1849     NOREF(srcShapePtrScan);
    18501849
    18511850#else
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