void OSystem_SDL::initSize(uint w, uint h) { // Avoid redundant res changes if ((int)w == _screenWidth && (int)h == _screenHeight && _transactionMode != kTransactionCommit) return; _screenWidth = w; _screenHeight = h; _cksumNum = (_screenWidth * _screenHeight / (8 * 8)); if (_transactionMode == kTransactionActive) { _transactionDetails.w = w; _transactionDetails.h = h; _transactionDetails.sizeChanged = true; _transactionDetails.needUnload = true; return; } free(_dirtyChecksums); _dirtyChecksums = (uint32 *)calloc(_cksumNum * 2, sizeof(uint32)); if (_transactionMode != kTransactionCommit) { unloadGFXMode(); loadGFXMode(); // if initSize() gets called in the middle, overlay is not transparent clearOverlay(); } }
bool WINCESdlGraphicsManager::hotswapGFXMode() { if (!_screen) return false; // Keep around the old _screen & _tmpscreen so we can restore the screen data // after the mode switch. (also for the overlay) SDL_Surface *old_screen = _screen; SDL_Surface *old_tmpscreen = _tmpscreen; SDL_Surface *old_overlayscreen = _overlayscreen; SDL_Surface *old_tmpscreen2 = _tmpscreen2; // Release the HW screen surface SDL_FreeSurface(_hwscreen); // Release toolbars free(_toolbarLow->pixels); SDL_FreeSurface(_toolbarLow); if (_toolbarHigh) { free(_toolbarHigh->pixels); SDL_FreeSurface(_toolbarHigh); } // Setup the new GFX mode if (!loadGFXMode()) { unloadGFXMode(); _screen = old_screen; _overlayscreen = old_overlayscreen; return false; } // reset palette SDL_SetColors(_screen, _currentPalette, 0, 256); // Restore old screen content SDL_BlitSurface(old_screen, NULL, _screen, NULL); SDL_BlitSurface(old_tmpscreen, NULL, _tmpscreen, NULL); if (_overlayVisible) { SDL_BlitSurface(old_overlayscreen, NULL, _overlayscreen, NULL); SDL_BlitSurface(old_tmpscreen2, NULL, _tmpscreen2, NULL); } // Free the old surfaces SDL_FreeSurface(old_screen); SDL_FreeSurface(old_tmpscreen); SDL_FreeSurface(old_overlayscreen); SDL_FreeSurface(old_tmpscreen2); // Blit everything back to the screen _toolbarHighDrawn = false; internUpdateScreen(); // Make sure that a Common::EVENT_SCREEN_CHANGED gets sent later -> FIXME this crashes when no game has been loaded. // _modeChanged = true; return true; }
void WINCESdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) { if (_hasSmartphoneResolution && h == 240) h = 200; // mainly for the launcher if (_isSmartphone && !ConfMan.hasKey("landscape")) { ConfMan.setInt("landscape", 1); ConfMan.flushToDisk(); } _canBeAspectScaled = false; if (w == 320 && h == 200 && !_hasSmartphoneResolution) { _canBeAspectScaled = true; h = 240; // use the extra 40 pixels height for the toolbar } if (h == 400) // touche engine fixup h += 80; if (!_hasSmartphoneResolution) { if (h == 240) _toolbarHandler.setOffset(200); else _toolbarHandler.setOffset(400); } else { if (h == 240) _toolbarHandler.setOffset(200); else // 176x220 _toolbarHandler.setOffset(0); } if (w != (uint) _videoMode.screenWidth || h != (uint) _videoMode.screenHeight) _scalersChanged = false; _videoMode.overlayWidth = w; _videoMode.overlayHeight = h; SurfaceSdlGraphicsManager::initSize(w, h, format); if (_scalersChanged) { unloadGFXMode(); loadGFXMode(); _scalersChanged = false; } update_game_settings(); }
void OSystem_SDL::hotswapGFXMode() { if (!_screen) return; // Keep around the old _screen & _overlayscreen so we can restore the screen data // after the mode switch. SDL_Surface *old_screen = _screen; SDL_Surface *old_overlayscreen = _overlayscreen; // Release the HW screen surface SDL_FreeSurface(_hwscreen); SDL_FreeSurface(_tmpscreen); SDL_FreeSurface(_tmpscreen2); #ifdef USE_OSD // Release the OSD surface SDL_FreeSurface(_osdSurface); #endif // Setup the new GFX mode loadGFXMode(); // reset palette SDL_SetColors(_screen, _currentPalette, 0, 256); // Restore old screen content SDL_BlitSurface(old_screen, NULL, _screen, NULL); SDL_BlitSurface(old_overlayscreen, NULL, _overlayscreen, NULL); // Free the old surfaces SDL_FreeSurface(old_screen); SDL_FreeSurface(old_overlayscreen); // Update cursor to new scale blitCursor(); // Blit everything to the screen internUpdateScreen(); // Make sure that an EVENT_SCREEN_CHANGED gets sent later _modeChanged = true; }
void OSystem_SDL::endGFXTransaction(void) { // for each engine we run initCommonGFX() as first thing in the transaction // and initSize() is called later. If user runs launcher at 320x200 with // 2x overlay, setting to Nomral1x sclaler in that case will be suppressed // and backend is forced to 2x // // This leads to bad results such as 1280x960 window for 640x480 engines. // To prevent that we rerun setGraphicsMode() if there was 1x scaler request if (_transactionDetails.normal1xScaler) setGraphicsMode(GFX_NORMAL); assert (_transactionMode == kTransactionActive); _transactionMode = kTransactionCommit; if (_transactionDetails.modeChanged) setGraphicsMode(_transactionDetails.mode); if (_transactionDetails.sizeChanged) initSize(_transactionDetails.w, _transactionDetails.h); if (_transactionDetails.arChanged) setAspectRatioCorrection(_transactionDetails.ar); if (_transactionDetails.needUnload) { unloadGFXMode(); loadGFXMode(); clearOverlay(); } else { if (!_transactionDetails.fsChanged) { if (_transactionDetails.needHotswap) hotswapGFXMode(); else if (_transactionDetails.needUpdatescreen) internUpdateScreen(); } } if (_transactionDetails.fsChanged) setFullscreenMode(_transactionDetails.fs); _transactionMode = kTransactionNone; }