VirtualBox

Ignore:
Timestamp:
Feb 1, 2007 9:31:13 PM (18 years ago)
Author:
vboxsync
Message:

use the SDL-provided default bpp if there is one

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp

    r470 r523  
    9494    mFixedSDLHeight = u32FixedHeight;
    9595    mFixedSDLBPP    = u32FixedBPP;
     96    mDefaultSDLBPP  = 32;
    9697    mCenterXOffset  = 0;
    9798    mCenterYOffset  = 0;
     
    140141#endif
    141142
    142     if (mfShowSDLConfig)
    143     {
     143    const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
     144    Assert(videoInfo);
     145    if (videoInfo)
     146    {
     147        switch (videoInfo->vfmt->BitsPerPixel)
     148        {
     149            case 16: mDefaultSDLBPP = 16; break;
     150            case 24: mDefaultSDLBPP = 24; break;
     151            default:
     152            case 32: mDefaultSDLBPP = 32; break;
     153        }
     154
    144155        /* output what SDL is capable of */
    145         const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
    146         Assert(videoInfo);
    147         if (videoInfo)
    148         {
     156        if (mfShowSDLConfig)
    149157            RTPrintf("SDL capabilities:\n"
    150158                     "  Hardware surface support:                    %s\n"
     
    172180                         videoInfo->vfmt->BitsPerPixel,
    173181                         getenv("SDL_VIDEODRIVER"));
    174         }
    175182    }
    176183
     
    574581    AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
    575582
     583    int      cBitsPerPixel = 32;
     584    uint32_t Rmask, Gmask, Bmask, Amask = 0;
     585
    576586    /* pixel characteristics, default to fallback 32bpp format */
    577     int bitsPerPixel = 32;
    578     Uint32 Rmask = 0x00FF0000;
    579     Uint32 Gmask = 0x0000FF00;
    580     Uint32 Bmask = 0x000000FF;
    581     Uint32 Amask = 0;
    582 
    583     /* a different format we support directly? */
    584     switch (mPixelFormat)
    585     {
    586         case FramebufferPixelFormat_PixelFormatRGB24:
    587         {
    588             bitsPerPixel = 24;
    589             Rmask = 0x00FF0000;
    590             Gmask = 0x0000FF00;
    591             Bmask = 0x000000FF;
    592             break;
    593         }
    594 
    595         case FramebufferPixelFormat_PixelFormatRGB16:
    596         {
    597             bitsPerPixel = 16;
    598             Rmask = 0xF800;
    599             Gmask = 0x07E0;
    600             Bmask = 0x001F;
    601             break;
    602         }
     587    if (mPixelFormat == FramebufferPixelFormat_PixelFormatRGB16)
     588        cBitsPerPixel = 16;
     589    else if (mPixelFormat == FramebufferPixelFormat_PixelFormatRGB24)
     590        cBitsPerPixel = 24;
     591
     592    switch (cBitsPerPixel)
     593    {
     594        case 16: Rmask = 0xF8000000; Gmask = 0x000007E0; Bmask = 0x0000001F; break;
     595        default: Rmask = 0x00FF0000; Gmask = 0x0000FF00; Bmask = 0x000000FF; break;
    603596    }
    604597
     
    614607    {
    615608        /* Create a source surface from guest VRAM. */
    616         mSurfVRAM = SDL_CreateRGBSurfaceFrom(mPtrVRAM, mGuestXRes, mGuestYRes, bitsPerPixel, mLineSize,
    617                                              Rmask, Gmask, Bmask, Amask);
     609        mSurfVRAM = SDL_CreateRGBSurfaceFrom(mPtrVRAM, mGuestXRes, mGuestYRes, cBitsPerPixel,
     610                                             mLineSize, Rmask, Gmask, Bmask, Amask);
    618611    }
    619612    else
    620613    {
    621614        /* Create a software surface for which SDL allocates the RAM */
    622         mSurfVRAM = SDL_CreateRGBSurface(SDL_SWSURFACE, mGuestXRes, mGuestYRes, bitsPerPixel,
     615        mSurfVRAM = SDL_CreateRGBSurface(SDL_SWSURFACE, mGuestXRes, mGuestYRes, cBitsPerPixel,
    623616                                         Rmask, Gmask, Bmask, Amask);
    624617    }
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