VirtualBox

Ignore:
Timestamp:
Oct 8, 2010 10:07:30 AM (14 years ago)
Author:
vboxsync
Message:

VBoxDisp: properly clip reported VBVA rectangles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/vbva.c

    r28800 r33002  
    305305    {
    306306        VBVACMDHDR hdr;
    307 
    308         RECTL rect = *pRectOrig;
    309 
    310         if (rect.left < 0) rect.left = 0;
    311         if (rect.top < 0) rect.top = 0;
    312         if (rect.right > (int)ppdev->cxScreen) rect.right = ppdev->cxScreen;
    313         if (rect.bottom > (int)ppdev->cyScreen) rect.bottom = ppdev->cyScreen;
    314 
    315         hdr.x = (int16_t)rect.left;
    316         hdr.y = (int16_t)rect.top;
     307        RECTL rect;
     308
     309        /* Ensure correct order. */
     310        if (pRectOrig->left <= pRectOrig->right)
     311        {
     312            rect.left = pRectOrig->left;
     313            rect.right = pRectOrig->right;
     314        }
     315        else
     316        {
     317            rect.left = pRectOrig->right;
     318            rect.right = pRectOrig->left;
     319        }
     320
     321        if (pRectOrig->top <= pRectOrig->bottom)
     322        {
     323            rect.top = pRectOrig->top;
     324            rect.bottom = pRectOrig->bottom;
     325        }
     326        else
     327        {
     328            rect.top = pRectOrig->bottom;
     329            rect.bottom = pRectOrig->top;
     330        }
     331
     332        /* Clip the rectangle. */
     333        rect.left   = RT_CLAMP(rect.left,   0, (LONG)ppdev->cxScreen);
     334        rect.top    = RT_CLAMP(rect.top,    0, (LONG)ppdev->cyScreen);
     335        rect.right  = RT_CLAMP(rect.right,  0, (LONG)ppdev->cxScreen);
     336        rect.bottom = RT_CLAMP(rect.bottom, 0, (LONG)ppdev->cyScreen);
     337
     338        /* If the rectangle is empty, still report it. */
     339        if (rect.right < rect.left)
     340        {
     341            rect.right = rect.left;
     342        }
     343        if (rect.bottom < rect.top)
     344        {
     345            rect.bottom = rect.top;
     346        }
     347
     348        hdr.x = (int16_t)(rect.left + ppdev->ptlDevOrg.x);
     349        hdr.y = (int16_t)(rect.top + ppdev->ptlDevOrg.y);
    317350        hdr.w = (uint16_t)(rect.right - rect.left);
    318351        hdr.h = (uint16_t)(rect.bottom - rect.top);
    319 
    320         hdr.x += (int16_t)ppdev->ptlDevOrg.x;
    321         hdr.y += (int16_t)ppdev->ptlDevOrg.y;
    322352
    323353        vboxWrite (ppdev, &hdr, sizeof(hdr));
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