VirtualBox

Changeset 98290 in vbox


Ignore:
Timestamp:
Jan 24, 2023 5:31:05 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
155495
Message:

FE/SDL. bugref:9449. Removing SDL 1.2 specific code.

Location:
trunk/src/VBox/Frontends/VBoxSDL
Files:
2 edited

Legend:

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

    r98246 r98290  
    127127    mScreenId       = uScreenId;
    128128    mfUpdateImage   = fUpdateImage;
    129     mScreen         = NULL;
    130129#ifdef VBOX_WITH_SDL2
    131130    mpWindow        = NULL;
     
    164163
    165164    resizeGuest();
    166     Assert(mScreen);
    167165    mfInitialized = true;
    168166#ifdef RT_OS_WINDOWS
     
    197195        mSurfVRAM = NULL;
    198196    }
    199     mScreen = NULL;
    200197
    201198#ifdef VBOX_SECURELABEL
     
    245242#ifdef VBOX_WITH_SDL2
    246243    RT_NOREF(fShowSDLConfig);
    247 #else
    248     const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
    249     AssertPtr(videoInfo);
    250     if (videoInfo)
    251     {
    252         /* output what SDL is capable of */
    253         if (fShowSDLConfig)
    254             RTPrintf("SDL capabilities:\n"
    255                      "  Hardware surface support:                    %s\n"
    256                      "  Window manager available:                    %s\n"
    257                      "  Screen to screen blits accelerated:          %s\n"
    258                      "  Screen to screen colorkey blits accelerated: %s\n"
    259                      "  Screen to screen alpha blits accelerated:    %s\n"
    260                      "  Memory to screen blits accelerated:          %s\n"
    261                      "  Memory to screen colorkey blits accelerated: %s\n"
    262                      "  Memory to screen alpha blits accelerated:    %s\n"
    263                      "  Color fills accelerated:                     %s\n"
    264                      "  Video memory in kilobytes:                   %d\n"
    265                      "  Optimal bpp mode:                            %d\n"
    266                      "SDL video driver:                              %s\n",
    267                          videoInfo->hw_available ? "yes" : "no",
    268                          videoInfo->wm_available ? "yes" : "no",
    269                          videoInfo->blit_hw ? "yes" : "no",
    270                          videoInfo->blit_hw_CC ? "yes" : "no",
    271                          videoInfo->blit_hw_A ? "yes" : "no",
    272                          videoInfo->blit_sw ? "yes" : "no",
    273                          videoInfo->blit_sw_CC ? "yes" : "no",
    274                          videoInfo->blit_sw_A ? "yes" : "no",
    275                          videoInfo->blit_fill ? "yes" : "no",
    276                          videoInfo->video_mem,
    277                          videoInfo->vfmt->BitsPerPixel,
    278                          RTEnvGet("SDL_VIDEODRIVER"));
    279     }
    280244#endif /* !VBOX_WITH_SDL2 */
    281 
    282 #ifndef VBOX_WITH_SDL2
    283     gWMIcon = SDL_AllocSurface(SDL_SWSURFACE, 64, 64, 24, 0xff, 0xff00, 0xff0000, 0);
    284     /** @todo make it as simple as possible. No PNM interpreter here... */
    285     if (gWMIcon)
    286     {
    287         memcpy(gWMIcon->pixels, g_abIco64x01+32, g_cbIco64x01-32);
    288         SDL_WM_SetIcon(gWMIcon, NULL);
    289     }
    290 #endif
    291245
    292246    return true;
     
    304258        AssertMsg(gSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
    305259        SDL_QuitSubSystem(SDL_INIT_VIDEO);
    306 
    307 #ifndef VBOX_WITH_SDL2
    308         if (gWMIcon)
    309         {
    310             SDL_FreeSurface(gWMIcon);
    311             gWMIcon = NULL;
    312         }
    313 #endif
    314260    }
    315261}
     
    841787    else
    842788        AssertFailed(); /** @todo */
    843 #else
    844 
    845     /*
    846      * We request a hardware surface from SDL so that we can perform
    847      * accelerated system memory to VRAM blits. The way video handling
    848      * works it that on the one hand we have the screen surface from SDL
    849      * and on the other hand we have a software surface that we create
    850      * using guest VRAM memory for linear modes and using SDL allocated
    851      * system memory for text and non linear graphics modes. We never
    852      * directly write to the screen surface but always use SDL blitting
    853      * functions to blit from our system memory surface to the VRAM.
    854      * Therefore, SDL can take advantage of hardware acceleration.
    855      */
    856     int sdlFlags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL;
    857 #ifndef RT_OS_OS2 /* doesn't seem to work for some reason... */
    858     if (mfResizable)
    859         sdlFlags |= SDL_RESIZABLE;
    860 #endif
    861     if (mfFullscreen)
    862         sdlFlags |= SDL_FULLSCREEN;
    863 
    864     /*
    865      * Now we have to check whether there are video mode restrictions
    866      */
    867     SDL_Rect **modes;
    868     /* Get available fullscreen/hardware modes */
    869     modes = SDL_ListModes(NULL, sdlFlags);
    870     Assert(modes != NULL);
    871     /* -1 means that any mode is possible (usually non fullscreen) */
    872     if (modes != (SDL_Rect **)-1)
    873     {
    874         /*
    875          * according to the SDL documentation, the API guarantees that
    876          * the modes are sorted from larger to smaller, so we just
    877          * take the first entry as the maximum.
    878          */
    879         mMaxScreenWidth  = modes[0]->w;
    880         mMaxScreenHeight = modes[0]->h;
    881     }
    882     else
    883     {
    884         /* no restriction */
    885         mMaxScreenWidth  = ~(uint32_t)0;
    886         mMaxScreenHeight = ~(uint32_t)0;
    887     }
    888789#endif /* VBOX_WITH_SDL2 */
    889790
     
    973874            AssertReleaseFailed();
    974875    }
    975 
    976     void *pixels;
    977     int pitch;
    978     int w, h, bpp;
    979     uint32_t Rmask, Gmask, Bmask, Amask;
    980     uint32_t format;
    981 
    982     if (SDL_QueryTexture(mpTexture, &format, NULL, &w, &h) < 0)
    983         AssertReleaseFailed();
    984 
    985     if (!SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask))
    986         AssertReleaseFailed();
    987 
    988     if (SDL_LockTexture(mpTexture, NULL /* SDL_Rect */, &pixels, &pitch) == 0)
    989     {
    990         mScreen = SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch,
    991                                            Rmask, Gmask, Bmask, Amask);
    992         SDL_UnlockTexture(mpTexture); /** @BUGBUG See: https://bugzilla.libsdl.org/show_bug.cgi?id=1586 */
    993     }
    994     else
    995     {
    996         mScreen = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
    997         AssertReleaseFailed();
    998     }
    999 
    1000     SDL_SetClipRect(mScreen, NULL);
    1001 
    1002 #else
    1003     /*
    1004      * Now set the screen resolution and get the surface pointer
    1005      * @todo BPP is not supported!
    1006      */
    1007     mScreen = SDL_SetVideoMode(newWidth, newHeight, 0, sdlFlags);
    1008 
    1009     /*
    1010      * Set the Window ID. Currently used for OpenGL accelerated guests.
    1011      */
    1012 # if defined (RT_OS_WINDOWS)
    1013     SDL_SysWMinfo info;
    1014     SDL_VERSION(&info.version);
    1015     if (SDL_GetWMInfo(&info))
    1016         mWinId = (intptr_t) info.window;
    1017 # elif defined (RT_OS_LINUX)
    1018     SDL_SysWMinfo info;
    1019     SDL_VERSION(&info.version);
    1020     if (SDL_GetWMInfo(&info))
    1021         mWinId = (LONG64) info.info.x11.wmwindow;
    1022 # elif defined(RT_OS_DARWIN)
    1023     mWinId = (intptr_t)VBoxSDLGetDarwinWindowId();
    1024 # else
    1025     /* XXX ignore this for other architectures */
    1026 # endif
    1027876#endif /* VBOX_WITH_SDL2 */
    1028877#ifdef VBOX_SECURELABEL
     
    1035884    {
    1036885        /* if it didn't work, then we have to go for the original resolution and paint over the guest */
    1037         if (!mScreen)
     886        if (!mScreenSurface)
    1038887        {
    1039             mScreen = SDL_SetVideoMode(newWidth, newHeight - mLabelHeight, 0, sdlFlags);
     888            mScreenSurface = SDL_SetVideoMode(newWidth, newHeight - mLabelHeight, 0, sdlFlags);
    1040889        }
    1041890        else
     
    1059908#endif /* VBOX_SECURELABEL */
    1060909
    1061     AssertMsg(mScreen, ("Error: SDL_SetVideoMode failed!\n"));
    1062     if (mScreen)
    1063     {
    1064 #ifdef VBOX_WIN32_UI
    1065         /* inform the UI code */
    1066         resizeUI(mScreen->w, mScreen->h);
    1067 #endif
    1068         if (mfShowSDLConfig)
    1069             RTPrintf("Resized to %dx%d\n", mScreen->w, mScreen->h);
    1070     }
    1071910}
    1072911
     
    1096935    }
    1097936
    1098     Assert(mScreen);
    1099937    Assert(mSurfVRAM);
    1100     if (!mScreen || !mSurfVRAM)
     938    if (!mSurfVRAM)
    1101939    {
    1102940        RTCritSectLeave(&mUpdateLock);
     
    11641002    /* hardware surfaces don't need update notifications */
    11651003#if defined(VBOX_WITH_SDL2)
    1166     AssertRelease(mScreen->flags & SDL_PREALLOC);
    11671004    SDL_Texture *pNewTexture = SDL_CreateTextureFromSurface(mpRenderer, mSurfVRAM);
    11681005    /** @todo Do we need to update the dirty rect for the texture for SDL2 here as well? */
    1169     //SDL_RenderClear(mpRenderer);
     1006    // SDL_RenderClear(mpRenderer);
     1007    //SDL_UpdateTexture(mpTexture, &dstRect, mSurfVRAM->pixels, mSurfVRAM->pitch);
     1008    // SDL_RenderCopy(mpRenderer, mpTexture, NULL, NULL);
    11701009    SDL_RenderCopy(mpRenderer, pNewTexture, &srcRect, &dstRect);
    11711010    SDL_RenderPresent(mpRenderer);
    11721011    SDL_DestroyTexture(pNewTexture);
    1173 #else
    1174     /*
    1175      * Now we just blit
    1176      */
    1177     SDL_BlitSurface(mSurfVRAM, &srcRect, mScreen, &dstRect);
    1178     if ((mScreen->flags & SDL_HWSURFACE) == 0)
    1179         SDL_UpdateRect(mScreen, dstRect.x, dstRect.y, dstRect.w, dstRect.h);
    11801012#endif
    11811013
     
    11961028    AssertMsg(gSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
    11971029    LogFlow(("VBoxSDLFB::repaint\n"));
    1198     update(0, 0, mScreen->w, mScreen->h, false /* fGuestRelative */);
     1030    int w, h;
     1031    uint32_t format;
     1032    int access;
     1033    SDL_QueryTexture(mpTexture, &format, &access, &w, &h);
     1034    update(0, 0, w, h, false /* fGuestRelative */);
    11991035}
    12001036
     
    12201056void VBoxSDLFB::getFullscreenGeometry(uint32_t *width, uint32_t *height)
    12211057{
    1222 #ifndef VBOX_WITH_SDL2
    1223     SDL_Rect **modes;
    1224 
    1225     /* Get available fullscreen/hardware modes */
    1226     modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
    1227     Assert(modes != NULL);
    1228     /* -1 means that any mode is possible (usually non fullscreen) */
    1229     if (modes != (SDL_Rect **)-1)
    1230     {
    1231         /*
    1232          * According to the SDL documentation, the API guarantees that the modes
    1233          * are sorted from larger to smaller, so we just take the first entry as
    1234          * the maximum.
    1235          *
    1236          * XXX Crude Xinerama hack :-/
    1237          */
    1238         if (   modes[0]->w > (16*modes[0]->h/9)
    1239             && modes[1]
    1240             && modes[1]->h == modes[0]->h)
    1241         {
    1242             *width  = modes[1]->w;
    1243             *height = modes[1]->h;
    1244         }
    1245         else
    1246         {
    1247             *width  = modes[0]->w;
    1248             *height = modes[0]->w;
    1249         }
    1250     }
    1251 #else
     1058#ifdef VBOX_WITH_SDL2
    12521059    SDL_DisplayMode dm;
    12531060    int rc = SDL_GetDesktopDisplayMode(0, &dm); /** @BUGBUG Handle multi monitor setups! */
     
    12681075}
    12691076#endif
     1077
    12701078
    12711079#ifdef VBOX_SECURELABEL
     
    13741182#endif /* VBOX_SECURELABEL */
    13751183
     1184
    13761185// IFramebufferOverlay
    13771186///////////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.h

    r98103 r98290  
    130130#ifdef VBOX_WITH_SDL2
    131131    SDL_Window *getWindow() { return mpWindow; }
    132     bool hasWindow(uint32_t id) { return mScreen && SDL_GetWindowID(mpWindow) == id; }
     132    bool hasWindow(uint32_t id) { return SDL_GetWindowID(mpWindow) == id; }
    133133    int setWindowTitle(const char *pcszTitle);
    134134#endif
     
    144144
    145145private:
    146     /** current SDL framebuffer pointer (also includes screen width/height) */
    147     SDL_Surface *mScreen;
     146
    148147#ifdef VBOX_WITH_SDL2
    149148    /** the SDL window */
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