VirtualBox

Ignore:
Timestamp:
Jul 5, 2009 7:50:18 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49547
Message:

VBoxGuest.h/VMMDev.h/VBoxGuestLib.h usage cleanup.

File:
1 edited

Legend:

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

    r18246 r21227  
    3131#include "driver.h"
    3232
    33 #include <VBox/VBoxGuest.h> /* for VBOX_MOUSE_POINTER_* flags */
     33#include <VBox/VMMDev.h> /* for VMMDEV_MOUSE_POINTER_* flags */
    3434
    3535#ifndef SPS_ALPHA
     
    165165
    166166    DISPDBG((0, "DISP bSetHardwarePointerShape SPS_ALPHA = %d\n", fl & SPS_ALPHA));
    167    
     167
    168168    // We don't use the exclusion rectangle because we only support
    169169    // hardware Pointers. If we were doing our own Pointer simulations
     
    279279     * High word will contain hot spot info and low word - flags.
    280280     */
    281    
     281
    282282    pPointerAttributes->Enable |= (ppdev->ptlHotSpot.y & 0xFF) << 24;
    283283    pPointerAttributes->Enable |= (ppdev->ptlHotSpot.x & 0xFF) << 16;
    284    
     284
    285285    if (fl & SPS_ALPHA)
    286286    {
    287287        pPointerAttributes->Enable |= VBOX_MOUSE_POINTER_ALPHA;
    288288    }
    289    
     289
    290290    //
    291291    // set animate flags
     
    297297        pPointerAttributes->Flags |= VIDEO_MODE_ANIMATE_UPDATE;
    298298    }
    299    
     299
    300300
    301301    //
     
    314314        return(FALSE);
    315315    }
    316    
     316
    317317    //
    318318    // Set new pointer position
    319319    //
    320    
     320
    321321    if (x != -1) {
    322322        VIDEO_POINTER_POSITION vpp;
    323        
     323
    324324        vpp.Column = pPointerAttributes->Column;
    325325        vpp.Row = pPointerAttributes->Row;
    326        
     326
    327327        if (EngDeviceIoControl(ppdev->hDriver,
    328328                               IOCTL_VIDEO_SET_POINTER_POSITION,
     
    332332                               0,
    333333                               &returnedDataLength)) {
    334            
     334
    335335            // Should never fail, informational message.
    336336            DISPDBG((1, "DISP:Failed IOCTL_VIDEO_SET_POINTER_POSITION call\n"));
    337         }   
    338     }
    339    
     337        }
     338    }
     339
    340340    return(TRUE);
    341341}
     
    356356{
    357357    PBYTE pjSrc = NULL;
    358    
     358
    359359    ULONG cy = 0;
    360    
     360
    361361    PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes;
    362    
     362
    363363    PBYTE pjDstAnd = pPointerAttributes->Pixels;
    364364    ULONG cjAnd = 0;
     
    367367    ULONG cxSrc = psoMask->sizlBitmap.cx;
    368368    ULONG cySrc = psoMask->sizlBitmap.cy / 2; /* /2 because both masks are in there */
    369    
     369
    370370    // Make sure the new pointer isn't too big to handle,
    371371    // strip the size to 64x64 if necessary
     
    374374        cxSrc = ppdev->PointerCapabilities.MaxWidth;
    375375    }
    376    
     376
    377377    if (cySrc > ppdev->PointerCapabilities.MaxHeight)
    378378    {
     
    382382    /* Size of AND mask in bytes */
    383383    cjAnd = ((cxSrc + 7) / 8) * cySrc;
    384    
     384
    385385    /* Pointer to XOR mask is 4-bytes aligned */
    386386    pjDstXor += (cjAnd + 3) & ~3;
    387    
     387
    388388    pPointerAttributes->Width = cxSrc;
    389389    pPointerAttributes->Height = cySrc;
    390390    pPointerAttributes->WidthInBytes = cxSrc * 4;
    391    
     391
    392392    /* Init AND mask to 1 */
    393393    RtlFillMemory (pjDstAnd, cjAnd, 0xFF);
    394    
    395     /* 
     394
     395    /*
    396396     * Copy AND mask.
    397397     */
    398          
     398
    399399    DISPDBG((0, "DISP bCopyMonoPointer going to copy AND mask\n"));
    400        
     400
    401401    pjSrc = (PBYTE)psoMask->pvScan0;
    402        
     402
    403403    for (cy = 0; cy < cySrc; cy++)
    404404    {
    405405        RtlCopyMemory (pjDstAnd, pjSrc, (cxSrc + 7) / 8);
    406    
     406
    407407        // Point to next source and dest scans
    408408        pjSrc += psoMask->lDelta;
    409409        pjDstAnd += (cxSrc + 7) / 8;
    410410    }
    411        
     411
    412412    DISPDBG((0, "DISP bCopyMonoPointer AND mask copied\n"));
    413        
     413
    414414    DISPDBG((0, "DISP bCopyMonoPointer going to create RGB0 XOR mask\n"));
    415    
     415
    416416    for (cy = 0; cy < cySrc; ++cy)
    417417    {
    418418        ULONG cx;
    419        
     419
    420420        UCHAR bitmask = 0x80;
    421                        
     421
    422422        for (cx = 0; cx < cxSrc; cx++, bitmask >>= 1)
    423423        {
     
    426426                bitmask = 0x80;
    427427            }
    428        
     428
    429429            if (pjSrc[cx / 8] & bitmask)
    430430            {
     
    441441        pjDstXor += cxSrc * 4;
    442442    }
    443    
     443
    444444    DISPDBG((0, "DISP bCopyMonoPointer created RGB0 XOR mask\n"));
    445445
     
    473473     *
    474474     */
    475      
     475
    476476    /* To simplify this function we use the following method:
    477477     *   for pointers with alpha channel
     
    481481     *     copy AND mask and new BGR0 XOR mask to pPointerAttributes->Pixels
    482482     */
    483    
     483
    484484    HSURF hsurf32bpp  = NULL;
    485485    SURFOBJ *pso32bpp = NULL;
     
    487487    PBYTE pjSrcAnd = NULL;
    488488    PBYTE pjSrcXor = NULL;
    489    
     489
    490490    ULONG cy = 0;
    491    
     491
    492492    PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes;
    493    
     493
    494494    PBYTE pjDstAnd = pPointerAttributes->Pixels;
    495495    ULONG cjAnd = 0;
     
    498498    ULONG cxSrc = psoColor->sizlBitmap.cx;
    499499    ULONG cySrc = psoColor->sizlBitmap.cy;
    500    
     500
    501501    // Make sure the new pointer isn't too big to handle,
    502502    // strip the size to 64x64 if necessary
     
    505505        cxSrc = ppdev->PointerCapabilities.MaxWidth;
    506506    }
    507    
     507
    508508    if (cySrc > ppdev->PointerCapabilities.MaxHeight)
    509509    {
     
    513513    /* Size of AND mask in bytes */
    514514    cjAnd = ((cxSrc + 7) / 8) * cySrc;
    515    
     515
    516516    /* Pointer to XOR mask is 4-bytes aligned */
    517517    pjDstXor += (cjAnd + 3) & ~3;
    518    
     518
    519519    pPointerAttributes->Width = cxSrc;
    520520    pPointerAttributes->Height = cySrc;
    521521    pPointerAttributes->WidthInBytes = cxSrc * 4;
    522    
     522
    523523    /* Init AND mask to 1 */
    524524    RtlFillMemory (pjDstAnd, cjAnd, 0xFF);
     
    527527    {
    528528        PBYTE pjSrcAlpha = (PBYTE)psoColor->pvScan0;
    529        
     529
    530530        DISPDBG((0, "DISP bCopyColorPointer SPS_ALPHA\n"));
    531        
     531
    532532        pso32bpp = psoColor;
    533        
    534         /* 
    535          * Emulate AND mask to provide viewable mouse pointer for 
     533
     534        /*
     535         * Emulate AND mask to provide viewable mouse pointer for
    536536         * hardware which does not support alpha channel.
    537537         */
    538        
     538
    539539        DISPDBG((0, "DISP bCopyColorPointer going to emulate AND mask\n"));
    540        
     540
    541541        for (cy = 0; cy < cySrc; cy++)
    542542        {
    543543            ULONG cx;
    544            
     544
    545545            UCHAR bitmask = 0x80;
    546            
     546
    547547            for (cx = 0; cx < cxSrc; cx++, bitmask >>= 1)
    548548            {
     
    551551                    bitmask = 0x80;
    552552                }
    553                
     553
    554554                if (pjSrcAlpha[cx * 4 + 3] > 0x7f)
    555555                {
     
    557557                }
    558558            }
    559    
     559
    560560            // Point to next source and dest scans
    561561            pjSrcAlpha += pso32bpp->lDelta;
    562562            pjDstAnd += (cxSrc + 7) / 8;
    563563        }
    564        
     564
    565565        DISPDBG((0, "DISP bCopyColorPointer AND mask emulated\n"));
    566566    }
     
    572572            return (FALSE);
    573573        }
    574        
    575         /* 
     574
     575        /*
    576576         * Copy AND mask.
    577577         */
    578          
     578
    579579        DISPDBG((0, "DISP bCopyColorPointer going to copy AND mask\n"));
    580        
     580
    581581        pjSrcAnd = (PBYTE)psoMask->pvScan0;
    582        
     582
    583583        for (cy = 0; cy < cySrc; cy++)
    584584        {
    585585            RtlCopyMemory (pjDstAnd, pjSrcAnd, (cxSrc + 7) / 8);
    586    
     586
    587587            // Point to next source and dest scans
    588588            pjSrcAnd += psoMask->lDelta;
    589589            pjDstAnd += (cxSrc + 7) / 8;
    590590        }
    591        
     591
    592592        DISPDBG((0, "DISP bCopyColorPointer AND mask copied\n"));
    593        
    594         /* 
     593
     594        /*
    595595         * Convert given psoColor to 32 bit BGR0.
    596596         */
    597          
     597
    598598        DISPDBG((0, "DISP bCopyColorPointer psoScreen t = %d, f = %d, psoColor t = %d, f = %d, pxlo = %p, psoColor->lDelta = %d, ->cx = %d\n",
    599599                 psoScreen->iType, psoScreen->iBitmapFormat, psoColor->iType, psoColor->iBitmapFormat, pxlo, psoColor->lDelta, psoColor->sizlBitmap.cx));
    600        
     600
    601601        if (psoColor->iType == STYPE_BITMAP
    602602            && psoColor->iBitmapFormat == BMF_32BPP)
     
    610610            HSURF hsurfBitmap  = NULL;
    611611            SURFOBJ *psoBitmap = NULL;
    612            
     612
    613613            SIZEL sizl = psoColor->sizlBitmap;
    614            
     614
    615615            if ((pxlo != NULL && pxlo->flXlate != XO_TRIVIAL)
    616616                || (psoColor->iType != STYPE_BITMAP))
    617617            {
    618618                /* Convert the unknown format to a screen format bitmap. */
    619                
     619
    620620                RECTL rclDst;
    621621                POINTL ptlSrc;
    622            
     622
    623623                DISPDBG((0, "DISP bCopyColorPointer going to convert XOR mask to bitmap\n"));
    624            
     624
    625625                hsurfBitmap = (HSURF)EngCreateBitmap (sizl, 0, psoScreen->iBitmapFormat, BMF_TOPDOWN, NULL);
    626            
     626
    627627                if (hsurfBitmap == NULL)
    628628                {
    629629                    return FALSE;
    630630                }
    631              
     631
    632632                psoBitmap = EngLockSurface (hsurfBitmap);
    633            
     633
    634634                if (psoBitmap == NULL)
    635635                {
     
    637637                    return FALSE;
    638638                }
    639            
     639
    640640                /* Now do the bitmap conversion using EngCopyBits(). */
    641            
     641
    642642                rclDst.left = 0;
    643643                rclDst.top = 0;
    644644                rclDst.right = sizl.cx;
    645645                rclDst.bottom = sizl.cy;
    646            
     646
    647647                ptlSrc.x = 0;
    648648                ptlSrc.y = 0;
    649                
     649
    650650                if (!EngCopyBits (psoBitmap, psoColor, NULL, pxlo, &rclDst, &ptlSrc))
    651651                {
     
    654654                    return FALSE;
    655655                }
    656            
     656
    657657                DISPDBG((0, "DISP bCopyColorPointer XOR mask converted to bitmap\n"));
    658658            }
     
    662662                psoBitmap = psoColor;
    663663            }
    664            
     664
    665665            /* Create 32 bpp surface for XOR mask */
    666666            hsurf32bpp = (HSURF)EngCreateBitmap (sizl, 0, BMF_32BPP, BMF_TOPDOWN, NULL);
    667            
     667
    668668            if (hsurf32bpp != NULL)
    669669            {
    670670                pso32bpp = EngLockSurface (hsurf32bpp);
    671            
     671
    672672                if (pso32bpp == NULL)
    673673                {
     
    676676                }
    677677            }
    678            
     678
    679679            if (pso32bpp)
    680680            {
     
    684684                    PBYTE src = (PBYTE)psoBitmap->pvScan0;
    685685                    PBYTE dst = (PBYTE)pso32bpp->pvScan0;
    686                    
     686
    687687                    PPALETTEENTRY pPal = ppdev->pPal;
    688688                    ULONG cPalette = 256; /* 256 is hardcoded in the driver in palette.c */
    689                    
     689
    690690                    DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 8 bpp to 32 bpp palette: %d entries\n", cPalette));
    691                    
     691
    692692                    for (cy = 0; cy < (ULONG)sizl.cy; cy++)
    693693                    {
    694694                        ULONG cx;
    695                        
     695
    696696                        PBYTE d = dst;
    697                        
     697
    698698                        for (cx = 0; cx < (ULONG)sizl.cx; cx++)
    699699                        {
    700700                            BYTE index = src[cx];
    701                            
     701
    702702                            *d++ = pPal[index].peBlue;  /* B */
    703703                            *d++ = pPal[index].peGreen; /* G */
     
    710710                        dst += pso32bpp->lDelta;
    711711                    }
    712                    
     712
    713713                    DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 8 bpp to 32 bpp completed\n"));
    714714                }
     
    717717                    PBYTE src = (PBYTE)psoBitmap->pvScan0;
    718718                    PBYTE dst = (PBYTE)pso32bpp->pvScan0;
    719                    
     719
    720720                    DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 16 bpp to 32 bpp\n"));
    721                    
     721
    722722                    for (cy = 0; cy < (ULONG)sizl.cy; cy++)
    723723                    {
    724724                        ULONG cx;
    725                    
     725
    726726                        PBYTE d = dst;
    727                        
     727
    728728                        for (cx = 0; cx < (ULONG)sizl.cx; cx++)
    729729                        {
    730730                            USHORT usSrc = *(USHORT *)&src[cx * 2];
    731                            
     731
    732732                            *d++ = (BYTE)( usSrc        << 3); /* B */
    733733                            *d++ = (BYTE)((usSrc >> 5)  << 2); /* G */
     
    740740                        dst += pso32bpp->lDelta;
    741741                    }
    742                    
     742
    743743                    DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 16 bpp to 32 bpp completed\n"));
    744744                }
     
    747747                    PBYTE src = (PBYTE)psoBitmap->pvScan0;
    748748                    PBYTE dst = (PBYTE)pso32bpp->pvScan0;
    749                    
     749
    750750                    DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 24 bpp to 32 bpp\n"));
    751                    
     751
    752752                    for (cy = 0; cy < (ULONG)sizl.cy; cy++)
    753753                    {
    754754                        ULONG cx;
    755                        
     755
    756756                        PBYTE s = src;
    757757                        PBYTE d = dst;
    758                        
     758
    759759                        for (cx = 0; cx < (ULONG)sizl.cx; cx++)
    760760                        {
     
    769769                        dst += pso32bpp->lDelta;
    770770                    }
    771                    
     771
    772772                    DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 24 bpp to 32 bpp completed\n"));
    773773                }
     
    775775                {
    776776                    DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 32 bpp to 32 bpp, pso32bpp->cjBits = %d, psoBitmap->cjBits = %d\n", pso32bpp->cjBits, psoBitmap->cjBits));
    777                    
     777
    778778                    RtlCopyMemory (pso32bpp->pvBits, psoBitmap->pvBits, min(pso32bpp->cjBits, psoBitmap->cjBits));
    779                    
     779
    780780                    DISPDBG((0, "DISP bCopyColorPointer XOR mask conv 32 bpp to 32 bpp completed\n"));
    781781                }
     
    783783                {
    784784                    DISPDBG((0, "DISP bCopyColorPointer XOR mask unsupported bpp\n"));
    785                    
     785
    786786                    EngUnlockSurface (pso32bpp);
    787787                    pso32bpp = NULL;
     
    790790                }
    791791            }
    792            
     792
    793793            if (hsurfBitmap)
    794794            {
     
    800800        }
    801801    }
    802    
     802
    803803    if (!pso32bpp)
    804804    {
    805805         return (FALSE);
    806806    }
    807    
    808     /* 
    809      * pso is 32 bit BGRX bitmap. Copy it to Pixels 
     807
     808    /*
     809     * pso is 32 bit BGRX bitmap. Copy it to Pixels
    810810     */
    811    
     811
    812812    pjSrcXor = (PBYTE)pso32bpp->pvScan0;
    813    
     813
    814814    for (cy = 0; cy < cySrc; cy++)
    815815    {
    816816        /* 32 bit bitmap is being copied */
    817         RtlCopyMemory (pjDstXor, pjSrcXor, cxSrc * 4); 
     817        RtlCopyMemory (pjDstXor, pjSrcXor, cxSrc * 4);
    818818
    819819        /* Point to next source and dest scans */
     
    821821        pjDstXor += pPointerAttributes->WidthInBytes;
    822822    }
    823    
     823
    824824    if (pso32bpp != psoColor)
    825825    {
     
    828828        EngDeleteSurface (hsurf32bpp);
    829829    }
    830    
     830
    831831    return (TRUE);
    832832}
     
    893893       pdevinfo->flGraphicsCaps &= ~GCAPS_ASYNCMOVE;
    894894    }
    895    
     895
    896896    /* VBOX supports pointers with alpha channel */
    897897    pdevinfo->flGraphicsCaps2 |= GCAPS2_ALPHACURSOR;
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