VirtualBox

Ignore:
Timestamp:
Nov 12, 2019 6:08:35 PM (5 years ago)
Author:
vboxsync
Message:

WDDM: exclude transparent pixels from the mouse pointer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp

    r81759 r81813  
    25452545    BYTE *pSrc, *pDst, bit;
    25462546
    2547     srcMaskW = pSetPointerShape->Width;
    2548     srcMaskH = pSetPointerShape->Height;
     2547    /* Windows always uses the maximum pointer size VBOXWDDM_C_POINTER_MAX_*
     2548     * Exclude zero pixels (which are transparent anyway) from the right and the bottom of the bitmap.
     2549     */
     2550    DWORD *pdwScanline = (DWORD *)pSetPointerShape->pPixels;
     2551    LONG iLastNonZeroScanline = -1;
     2552    LONG iMaxNonZeroPixel = -1;
     2553    for (y = 0; y < pSetPointerShape->Height; ++y)
     2554    {
     2555        LONG iLastNonZeroPixel = -1;
     2556        for (x = 0; x < pSetPointerShape->Width; ++x)
     2557        {
     2558            if (pdwScanline[x])
     2559                iLastNonZeroPixel = x;
     2560        }
     2561
     2562        iMaxNonZeroPixel = RT_MAX(iMaxNonZeroPixel, iLastNonZeroPixel);
     2563
     2564        if (iLastNonZeroPixel >= 0)
     2565        {
     2566            /* Scanline contains non-zero pixels. */
     2567            iLastNonZeroScanline = y;
     2568        }
     2569
     2570        pdwScanline = (DWORD *)((uint8_t *)pdwScanline + pSetPointerShape->Pitch);
     2571    }
     2572
     2573    /* Both variabled are zero based indexes, add 1 for width and height. */
     2574    srcMaskW = iMaxNonZeroPixel + 1;
     2575    srcMaskH = iLastNonZeroScanline + 1;
     2576
     2577    /* Align to 4 pixels. Bitmap is 16 bytes aligned (in case the host can't deal with unaligned data). */
     2578    srcMaskW = RT_ALIGN_T(srcMaskW, 4, ULONG);
     2579    srcMaskH = RT_ALIGN_T(srcMaskH, 4, ULONG);
     2580
     2581    /* Do not send bitmaps with zero dimensions. Actually make the min size 32x32. */
     2582    srcMaskW = RT_MAX(32, srcMaskW);
     2583    srcMaskH = RT_MAX(32, srcMaskH);
     2584
     2585    /* Make it square. */
     2586    srcMaskW = RT_MAX(srcMaskW, srcMaskH);
     2587    srcMaskH = srcMaskW;
    25492588
    25502589    /* truncate masks if we exceed supported size */
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