Changeset 98290 in vbox
- Timestamp:
- Jan 24, 2023 5:31:05 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155495
- Location:
- trunk/src/VBox/Frontends/VBoxSDL
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp
r98246 r98290 127 127 mScreenId = uScreenId; 128 128 mfUpdateImage = fUpdateImage; 129 mScreen = NULL;130 129 #ifdef VBOX_WITH_SDL2 131 130 mpWindow = NULL; … … 164 163 165 164 resizeGuest(); 166 Assert(mScreen);167 165 mfInitialized = true; 168 166 #ifdef RT_OS_WINDOWS … … 197 195 mSurfVRAM = NULL; 198 196 } 199 mScreen = NULL;200 197 201 198 #ifdef VBOX_SECURELABEL … … 245 242 #ifdef VBOX_WITH_SDL2 246 243 RT_NOREF(fShowSDLConfig); 247 #else248 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 }280 244 #endif /* !VBOX_WITH_SDL2 */ 281 282 #ifndef VBOX_WITH_SDL2283 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 #endif291 245 292 246 return true; … … 304 258 AssertMsg(gSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n")); 305 259 SDL_QuitSubSystem(SDL_INIT_VIDEO); 306 307 #ifndef VBOX_WITH_SDL2308 if (gWMIcon)309 {310 SDL_FreeSurface(gWMIcon);311 gWMIcon = NULL;312 }313 #endif314 260 } 315 261 } … … 841 787 else 842 788 AssertFailed(); /** @todo */ 843 #else844 845 /*846 * We request a hardware surface from SDL so that we can perform847 * accelerated system memory to VRAM blits. The way video handling848 * works it that on the one hand we have the screen surface from SDL849 * and on the other hand we have a software surface that we create850 * using guest VRAM memory for linear modes and using SDL allocated851 * system memory for text and non linear graphics modes. We never852 * directly write to the screen surface but always use SDL blitting853 * 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 #endif861 if (mfFullscreen)862 sdlFlags |= SDL_FULLSCREEN;863 864 /*865 * Now we have to check whether there are video mode restrictions866 */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 that876 * the modes are sorted from larger to smaller, so we just877 * take the first entry as the maximum.878 */879 mMaxScreenWidth = modes[0]->w;880 mMaxScreenHeight = modes[0]->h;881 }882 else883 {884 /* no restriction */885 mMaxScreenWidth = ~(uint32_t)0;886 mMaxScreenHeight = ~(uint32_t)0;887 }888 789 #endif /* VBOX_WITH_SDL2 */ 889 790 … … 973 874 AssertReleaseFailed(); 974 875 } 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 else995 {996 mScreen = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);997 AssertReleaseFailed();998 }999 1000 SDL_SetClipRect(mScreen, NULL);1001 1002 #else1003 /*1004 * Now set the screen resolution and get the surface pointer1005 * @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 # else1025 /* XXX ignore this for other architectures */1026 # endif1027 876 #endif /* VBOX_WITH_SDL2 */ 1028 877 #ifdef VBOX_SECURELABEL … … 1035 884 { 1036 885 /* 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) 1038 887 { 1039 mScreen = SDL_SetVideoMode(newWidth, newHeight - mLabelHeight, 0, sdlFlags);888 mScreenSurface = SDL_SetVideoMode(newWidth, newHeight - mLabelHeight, 0, sdlFlags); 1040 889 } 1041 890 else … … 1059 908 #endif /* VBOX_SECURELABEL */ 1060 909 1061 AssertMsg(mScreen, ("Error: SDL_SetVideoMode failed!\n"));1062 if (mScreen)1063 {1064 #ifdef VBOX_WIN32_UI1065 /* inform the UI code */1066 resizeUI(mScreen->w, mScreen->h);1067 #endif1068 if (mfShowSDLConfig)1069 RTPrintf("Resized to %dx%d\n", mScreen->w, mScreen->h);1070 }1071 910 } 1072 911 … … 1096 935 } 1097 936 1098 Assert(mScreen);1099 937 Assert(mSurfVRAM); 1100 if (!mS creen || !mSurfVRAM)938 if (!mSurfVRAM) 1101 939 { 1102 940 RTCritSectLeave(&mUpdateLock); … … 1164 1002 /* hardware surfaces don't need update notifications */ 1165 1003 #if defined(VBOX_WITH_SDL2) 1166 AssertRelease(mScreen->flags & SDL_PREALLOC);1167 1004 SDL_Texture *pNewTexture = SDL_CreateTextureFromSurface(mpRenderer, mSurfVRAM); 1168 1005 /** @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); 1170 1009 SDL_RenderCopy(mpRenderer, pNewTexture, &srcRect, &dstRect); 1171 1010 SDL_RenderPresent(mpRenderer); 1172 1011 SDL_DestroyTexture(pNewTexture); 1173 #else1174 /*1175 * Now we just blit1176 */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);1180 1012 #endif 1181 1013 … … 1196 1028 AssertMsg(gSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n")); 1197 1029 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 */); 1199 1035 } 1200 1036 … … 1220 1056 void VBoxSDLFB::getFullscreenGeometry(uint32_t *width, uint32_t *height) 1221 1057 { 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 1252 1059 SDL_DisplayMode dm; 1253 1060 int rc = SDL_GetDesktopDisplayMode(0, &dm); /** @BUGBUG Handle multi monitor setups! */ … … 1268 1075 } 1269 1076 #endif 1077 1270 1078 1271 1079 #ifdef VBOX_SECURELABEL … … 1374 1182 #endif /* VBOX_SECURELABEL */ 1375 1183 1184 1376 1185 // IFramebufferOverlay 1377 1186 /////////////////////////////////////////////////////////////////////////////////// -
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.h
r98103 r98290 130 130 #ifdef VBOX_WITH_SDL2 131 131 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; } 133 133 int setWindowTitle(const char *pcszTitle); 134 134 #endif … … 144 144 145 145 private: 146 /** current SDL framebuffer pointer (also includes screen width/height) */ 147 SDL_Surface *mScreen; 146 148 147 #ifdef VBOX_WITH_SDL2 149 148 /** the SDL window */
Note:
See TracChangeset
for help on using the changeset viewer.