Ticket #8926: sdl_transaction_rollback_v3.patch
File sdl_transaction_rollback_v3.patch, 39.9 KB (added by , 16 years ago) |
---|
-
common/system.h
391 391 */ 392 392 virtual void beginGFXTransaction() {} 393 393 394 /** 395 * This type is able to save the different errors which can happen while 396 * changing GFX config values inside GFX transactions. 397 * 398 * endGFXTransaction returns a ORed combination of the '*Failed' values 399 * if any problem occures, on success 0. 400 * 401 * @see endGFXTransaction 402 */ 403 enum kTransactionError { 404 kTransactionSuccess = 0, /**< Everything fine (use EQUAL check for this one!) */ 405 kTransactionAspectRatioFailed = (1 << 0), /**< Failed switchting aspect ratio correction mode */ 406 kTransactionFullscreenFailed = (1 << 1), /**< Failed switchting fullscreen mode */ 407 kTransactionModeSwitchFailed = (1 << 2), /**< Failed switchting the GFX graphics mode (setGraphicsMode) */ 408 kTransactionSizeChangeFailed = (1 << 3) /**< Failed switchting the screen dimensions (initSize) */ 409 }; 394 410 395 411 /** 396 412 * End (and thereby commit) the current GFX transaction. 397 413 * @see beginGFXTransaction 414 * @see kTransactionError 415 * @return returns a ORed combination of kTransactionError values or 0 on success 398 416 */ 399 virtual void endGFXTransaction() {}417 virtual kTransactionError endGFXTransaction() { return kTransactionSuccess; } 400 418 401 419 402 420 /** -
backends/platform/sdl/graphics.cpp
49 49 }; 50 50 51 51 // Table of relative scalers magnitudes 52 // [definedScale - 1][ _scaleFactor - 1]52 // [definedScale - 1][scaleFactor - 1] 53 53 static ScalerProc *scalersMagn[3][3] = { 54 54 #ifndef DISABLE_SCALERS 55 55 { Normal1x, AdvMame2x, AdvMame3x }, … … 86 86 } 87 87 88 88 void OSystem_SDL::beginGFXTransaction(void) { 89 assert 89 assert(_transactionMode == kTransactionNone); 90 90 91 91 _transactionMode = kTransactionActive; 92 92 93 _transactionDetails.modeChanged = false;94 93 _transactionDetails.sizeChanged = false; 95 _transactionDetails.arChanged = false;96 _transactionDetails.fsChanged = false;97 94 98 95 _transactionDetails.needHotswap = false; 99 96 _transactionDetails.needUpdatescreen = false; 100 _transactionDetails.needUnload = false;101 97 102 98 _transactionDetails.normal1xScaler = false; 99 100 _oldVideoMode = _videoMode; 103 101 } 104 102 105 void OSystem_SDL::endGFXTransaction(void) { 106 // for each engine we run initCommonGFX() as first thing in the transaction 107 // and initSize() is called later. If user runs launcher at 320x200 with 108 // 2x overlay, setting to Nomral1x sclaler in that case will be suppressed 109 // and backend is forced to 2x 110 // 111 // This leads to bad results such as 1280x960 window for 640x480 engines. 112 // To prevent that we rerun setGraphicsMode() if there was 1x scaler request 113 if (_transactionDetails.normal1xScaler) 114 setGraphicsMode(GFX_NORMAL); 103 OSystem::kTransactionError OSystem_SDL::endGFXTransaction(void) { 104 int errors = kTransactionSuccess; 115 105 116 assert (_transactionMode == kTransactionActive);106 assert(_transactionMode != kTransactionNone); 117 107 118 _transactionMode = kTransactionCommit;119 if (_transactionDetails.modeChanged)120 setGraphicsMode(_transactionDetails.mode);108 if (_transactionMode == kTransactionRollback) { 109 if (_videoMode.fullscreen != _oldVideoMode.fullscreen) { 110 errors |= kTransactionFullscreenFailed; 121 111 122 if (_transactionDetails.sizeChanged) 123 initSize(_transactionDetails.w, _transactionDetails.h); 112 _videoMode.fullscreen = _oldVideoMode.fullscreen; 113 } else if (_videoMode.aspectRatio != _oldVideoMode.aspectRatio) { 114 errors |= kTransactionAspectRatioFailed; 124 115 125 if (_transactionDetails.arChanged) 126 setAspectRatioCorrection(_transactionDetails.ar); 116 _videoMode.aspectRatio = _oldVideoMode.aspectRatio; 117 } else if (_videoMode.mode != _oldVideoMode.mode) { 118 errors |= kTransactionModeSwitchFailed; 127 119 128 if (_transactionDetails.needUnload) { 120 _videoMode.mode = _oldVideoMode.mode; 121 _videoMode.scaleFactor = _oldVideoMode.scaleFactor; 122 } else if (_videoMode.screenWidth != _oldVideoMode.screenWidth || _videoMode.screenHeight != _oldVideoMode.screenHeight) { 123 errors |= kTransactionSizeChangeFailed; 124 125 _videoMode.screenWidth = _oldVideoMode.screenWidth; 126 _videoMode.screenHeight = _oldVideoMode.screenHeight; 127 128 // Since this is the last resort of falling back to the old 129 // video mode setup, we invalidate the old mode here, because 130 // of the way we handle gfx rollback 131 _oldVideoMode.setup = false; 132 } 133 } 134 135 if (_transactionDetails.sizeChanged) { 129 136 unloadGFXMode(); 130 loadGFXMode(); 131 clearOverlay(); 132 } else { 133 if (!_transactionDetails.fsChanged) { 134 if (_transactionDetails.needHotswap) 135 hotswapGFXMode(); 136 else if (_transactionDetails.needUpdatescreen) 137 if (!loadGFXMode()) { 138 if (_oldVideoMode.setup) { 139 _transactionMode = kTransactionRollback; 140 errors |= endGFXTransaction(); 141 } 142 } else { 143 setGraphicsModeIntern(); 144 clearOverlay(); 145 146 _videoMode.setup = true; 147 _modeChanged = true; 148 } 149 } else if (_transactionDetails.needHotswap) { 150 setGraphicsModeIntern(); 151 if (!hotswapGFXMode()) { 152 if (_oldVideoMode.setup) { 153 _transactionMode = kTransactionRollback; 154 errors |= endGFXTransaction(); 155 } 156 } else { 157 _videoMode.setup = true; 158 _modeChanged = true; 159 160 if (_transactionDetails.needUpdatescreen) 137 161 internUpdateScreen(); 138 162 } 139 163 } 140 164 141 if (_transactionDetails.fsChanged)142 setFullscreenMode(_transactionDetails.fs);143 144 165 _transactionMode = kTransactionNone; 166 return (kTransactionError)errors; 145 167 } 146 168 147 169 bool OSystem_SDL::setGraphicsMode(int mode) { 148 170 Common::StackLock lock(_graphicsMutex); 149 171 172 assert(_transactionMode == kTransactionActive); 173 174 if (_oldVideoMode.setup && _oldVideoMode.mode == mode) 175 return true; 176 150 177 int newScaleFactor = 1; 151 ScalerProc *newScalerProc;152 178 153 179 switch(mode) { 154 180 case GFX_NORMAL: 155 181 newScaleFactor = 1; 156 newScalerProc = Normal1x;157 182 break; 158 183 #ifndef DISABLE_SCALERS 159 184 case GFX_DOUBLESIZE: 160 185 newScaleFactor = 2; 161 newScalerProc = Normal2x;162 186 break; 163 187 case GFX_TRIPLESIZE: 164 188 newScaleFactor = 3; 165 newScalerProc = Normal3x;166 189 break; 167 190 168 191 case GFX_2XSAI: 169 192 newScaleFactor = 2; 170 newScalerProc = _2xSaI;171 193 break; 172 194 case GFX_SUPER2XSAI: 173 195 newScaleFactor = 2; 174 newScalerProc = Super2xSaI;175 196 break; 176 197 case GFX_SUPEREAGLE: 177 198 newScaleFactor = 2; 178 newScalerProc = SuperEagle;179 199 break; 180 200 case GFX_ADVMAME2X: 181 201 newScaleFactor = 2; 182 newScalerProc = AdvMame2x;183 202 break; 184 203 case GFX_ADVMAME3X: 185 204 newScaleFactor = 3; 186 newScalerProc = AdvMame3x;187 205 break; 188 206 #ifndef DISABLE_HQ_SCALERS 189 207 case GFX_HQ2X: 190 208 newScaleFactor = 2; 191 newScalerProc = HQ2x;192 209 break; 193 210 case GFX_HQ3X: 194 211 newScaleFactor = 3; 195 newScalerProc = HQ3x;196 212 break; 197 213 #endif 198 214 case GFX_TV2X: 199 215 newScaleFactor = 2; 200 newScalerProc = TV2x;201 216 break; 202 217 case GFX_DOTMATRIX: 203 218 newScaleFactor = 2; 204 newScalerProc = DotMatrix;205 219 break; 206 220 #endif // DISABLE_SCALERS 207 221 … … 211 225 } 212 226 213 227 _transactionDetails.normal1xScaler = (mode == GFX_NORMAL); 228 if (_oldVideoMode.setup && _oldVideoMode.scaleFactor != newScaleFactor) 229 _transactionDetails.needHotswap = true; 214 230 215 _mode = mode; 216 _scalerProc = newScalerProc; 231 _transactionDetails.needUpdatescreen = true; 217 232 218 if (_transactionMode == kTransactionActive) { 219 _transactionDetails.mode = mode; 220 _transactionDetails.modeChanged = true; 233 _videoMode.mode = mode; 234 _videoMode.scaleFactor = newScaleFactor; 221 235 222 if (newScaleFactor != _scaleFactor) { 223 _transactionDetails.needHotswap = true; 224 _scaleFactor = newScaleFactor; 225 } 236 return true; 237 } 226 238 227 _transactionDetails.needUpdatescreen = true; 239 void OSystem_SDL::setGraphicsModeIntern() { 240 Common::StackLock lock(_graphicsMutex); 241 ScalerProc *newScalerProc = 0; 228 242 229 return true; 230 } 243 switch (_videoMode.mode) { 244 case GFX_NORMAL: 245 newScalerProc = Normal1x; 246 break; 247 #ifndef DISABLE_SCALERS 248 case GFX_DOUBLESIZE: 249 newScalerProc = Normal2x; 250 break; 251 case GFX_TRIPLESIZE: 252 newScalerProc = Normal3x; 253 break; 231 254 232 // NOTE: This should not be executed at transaction commit 233 // Otherwise there is some unsolicited setGraphicsMode() call 234 // which should be properly removed 235 if (newScaleFactor != _scaleFactor) { 236 assert(_transactionMode != kTransactionCommit); 255 case GFX_2XSAI: 256 newScalerProc = _2xSaI; 257 break; 258 case GFX_SUPER2XSAI: 259 newScalerProc = Super2xSaI; 260 break; 261 case GFX_SUPEREAGLE: 262 newScalerProc = SuperEagle; 263 break; 264 case GFX_ADVMAME2X: 265 newScalerProc = AdvMame2x; 266 break; 267 case GFX_ADVMAME3X: 268 newScalerProc = AdvMame3x; 269 break; 270 #ifndef DISABLE_HQ_SCALERS 271 case GFX_HQ2X: 272 newScalerProc = HQ2x; 273 break; 274 case GFX_HQ3X: 275 newScalerProc = HQ3x; 276 break; 277 #endif 278 case GFX_TV2X: 279 newScalerProc = TV2x; 280 break; 281 case GFX_DOTMATRIX: 282 newScalerProc = DotMatrix; 283 break; 284 #endif // DISABLE_SCALERS 237 285 238 _scaleFactor = newScaleFactor;239 hotswapGFXMode();286 default: 287 error("Unknown gfx mode %d", _videoMode.mode); 240 288 } 241 289 242 // Determine the "scaler type", i.e. essentially an index into the243 // s_gfxModeSwitchTable array defined in events.cpp.244 if (_ mode != GFX_NORMAL) {290 _scalerProc = newScalerProc; 291 292 if (_videoMode.mode != GFX_NORMAL) { 245 293 for (int i = 0; i < ARRAYSIZE(s_gfxModeSwitchTable); i++) { 246 if (s_gfxModeSwitchTable[i][1] == _ mode || s_gfxModeSwitchTable[i][2] == _mode) {294 if (s_gfxModeSwitchTable[i][1] == _videoMode.mode || s_gfxModeSwitchTable[i][2] == _videoMode.mode) { 247 295 _scalerType = i; 248 296 break; 249 297 } 250 298 } 251 299 } 252 300 253 if (!_screen )254 return true;301 if (!_screen || !_hwscreen) 302 return; 255 303 256 304 // Blit everything to the screen 257 305 _forceFull = true; … … 259 307 // Even if the old and new scale factors are the same, we may have a 260 308 // different scaler for the cursor now. 261 309 blitCursor(); 262 263 if (_transactionMode != kTransactionCommit)264 internUpdateScreen();265 266 // Make sure that an Common::EVENT_SCREEN_CHANGED gets sent later267 _modeChanged = true;268 269 return true;270 310 } 271 311 272 312 int OSystem_SDL::getGraphicsMode() const { 273 313 assert (_transactionMode == kTransactionNone); 274 return _ mode;314 return _videoMode.mode; 275 315 } 276 316 277 317 void OSystem_SDL::initSize(uint w, uint h) { 318 assert(_transactionMode == kTransactionActive); 319 278 320 // Avoid redundant res changes 279 if ((int)w == _screenWidth && (int)h == _screenHeight && 280 _transactionMode != kTransactionCommit) 321 if ((int)w == _videoMode.screenWidth && (int)h == _videoMode.screenHeight) 281 322 return; 282 323 283 _ screenWidth = w;284 _ screenHeight = h;324 _videoMode.screenWidth = w; 325 _videoMode.screenHeight = h; 285 326 286 _cksumNum = ( _screenWidth * _screenHeight/ (8 * 8));327 _cksumNum = (w * h / (8 * 8)); 287 328 288 if (_transactionMode == kTransactionActive) { 289 _transactionDetails.w = w; 290 _transactionDetails.h = h; 291 _transactionDetails.sizeChanged = true; 329 _transactionDetails.sizeChanged = true; 292 330 293 _transactionDetails.needUnload = true;294 295 return;296 }297 298 331 free(_dirtyChecksums); 299 332 _dirtyChecksums = (uint32 *)calloc(_cksumNum * 2, sizeof(uint32)); 300 301 if (_transactionMode != kTransactionCommit) {302 unloadGFXMode();303 loadGFXMode();304 305 // if initSize() gets called in the middle, overlay is not transparent306 clearOverlay();307 }308 333 } 309 334 310 voidOSystem_SDL::loadGFXMode() {335 bool OSystem_SDL::loadGFXMode() { 311 336 assert(_inited); 312 337 _forceFull = true; 313 338 314 339 int hwW, hwH; 315 340 316 341 #ifndef __MAEMO__ 317 _ overlayWidth = _screenWidth * _scaleFactor;318 _ overlayHeight = _screenHeight * _scaleFactor;342 _videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor; 343 _videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor; 319 344 320 if (_ screenHeight != 200 && _screenHeight != 400)321 _ adjustAspectRatio = false;345 if (_videoMode.screenHeight != 200 && _videoMode.screenHeight != 400) 346 _videoMode.aspectRatio = false; 322 347 323 if (_ adjustAspectRatio)324 _ overlayHeight = real2Aspect(_overlayHeight);348 if (_videoMode.aspectRatio) 349 _videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight); 325 350 326 hwW = _ screenWidth * _scaleFactor;351 hwW = _videoMode.screenWidth * _videoMode.scaleFactor; 327 352 hwH = effectiveScreenHeight(); 328 353 #else 329 hwW = _ overlayWidth;330 hwH = _ overlayHeight;354 hwW = _videoMode.overlayWidth; 355 hwH = _videoMode.overlayHeight; 331 356 #endif 332 357 333 358 // 334 359 // Create the surface that contains the 8 bit game data 335 360 // 336 _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _ screenWidth, _screenHeight, 8, 0, 0, 0, 0);361 _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, 8, 0, 0, 0, 0); 337 362 if (_screen == NULL) 338 363 error("allocating _screen failed"); 339 364 … … 342 367 // 343 368 344 369 _hwscreen = SDL_SetVideoMode(hwW, hwH, 16, 345 _ fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE370 _videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE 346 371 ); 347 372 if (_hwscreen == NULL) { 348 373 // DON'T use error(), as this tries to bring up the debug 349 374 // console, which WON'T WORK now that _hwscreen is hosed. 350 375 351 // FIXME: We should be able to continue the game without 352 // shutting down or bringing up the debug console, but at 353 // this point we've already screwed up all our member vars. 354 // We need to find a way to call SDL_SetVideoMode *before* 355 // that happens and revert to all the old settings if we 356 // can't pull off the switch to the new settings. 357 // 358 // Fingolfin says: the "easy" way to do that is not to modify 359 // the member vars before we are sure everything is fine. Think 360 // of "transactions, commit, rollback" style... we use local vars 361 // in place of the member vars, do everything etc. etc.. In case 362 // of a failure, rollback is trivial. Only if everything worked fine 363 // do we "commit" the changed values to the member vars. 364 warning("SDL_SetVideoMode says we can't switch to that mode (%s)", SDL_GetError()); 365 quit(); 376 if (!_oldVideoMode.setup) { 377 warning("SDL_SetVideoMode says we can't switch to that mode (%s)", SDL_GetError()); 378 quit(); 379 } else { 380 return false; 381 } 366 382 } 367 383 368 384 // … … 376 392 InitScalers(565); 377 393 378 394 // Need some extra bytes around when using 2xSaI 379 _tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _ screenWidth + 3, _screenHeight + 3,395 _tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth + 3, _videoMode.screenHeight + 3, 380 396 16, 381 397 _hwscreen->format->Rmask, 382 398 _hwscreen->format->Gmask, … … 386 402 if (_tmpscreen == NULL) 387 403 error("allocating _tmpscreen failed"); 388 404 389 _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _ overlayWidth, _overlayHeight,405 _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.overlayWidth, _videoMode.overlayHeight, 390 406 16, 391 407 _hwscreen->format->Rmask, 392 408 _hwscreen->format->Gmask, … … 396 412 if (_overlayscreen == NULL) 397 413 error("allocating _overlayscreen failed"); 398 414 399 _tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _ overlayWidth + 3, _overlayHeight + 3,415 _tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.overlayWidth + 3, _videoMode.overlayHeight + 3, 400 416 16, 401 417 _hwscreen->format->Rmask, 402 418 _hwscreen->format->Gmask, … … 421 437 #endif 422 438 423 439 // keyboard cursor control, some other better place for it? 424 _km.x_max = _ screenWidth * _scaleFactor - 1;440 _km.x_max = _videoMode.screenWidth * _videoMode.scaleFactor - 1; 425 441 _km.y_max = effectiveScreenHeight() - 1; 426 442 _km.delay_time = 25; 427 443 _km.last_time = 0; 444 445 return true; 428 446 } 429 447 430 448 void OSystem_SDL::unloadGFXMode() { … … 462 480 DestroyScalers(); 463 481 } 464 482 465 voidOSystem_SDL::hotswapGFXMode() {483 bool OSystem_SDL::hotswapGFXMode() { 466 484 if (!_screen) 467 return ;485 return false; 468 486 469 487 // Keep around the old _screen & _overlayscreen so we can restore the screen data 470 488 // after the mode switch. 471 489 SDL_Surface *old_screen = _screen; 472 490 SDL_Surface *old_overlayscreen = _overlayscreen; 491 _screen = NULL; 492 _overlayscreen = NULL; 473 493 474 494 // Release the HW screen surface 475 SDL_FreeSurface(_hwscreen); 495 SDL_FreeSurface(_hwscreen); _hwscreen = NULL; 476 496 477 SDL_FreeSurface(_tmpscreen); 478 SDL_FreeSurface(_tmpscreen2); 497 SDL_FreeSurface(_tmpscreen); _tmpscreen = NULL; 498 SDL_FreeSurface(_tmpscreen2); _tmpscreen2 = NULL; 479 499 480 500 #ifdef USE_OSD 481 501 // Release the OSD surface 482 SDL_FreeSurface(_osdSurface); 502 SDL_FreeSurface(_osdSurface); _osdSurface = NULL; 483 503 #endif 484 504 485 505 // Setup the new GFX mode 486 loadGFXMode(); 506 if (!loadGFXMode()) { 507 unloadGFXMode(); 487 508 509 _screen = old_screen; 510 _overlayscreen = old_overlayscreen; 511 512 return false; 513 } 514 488 515 // reset palette 489 516 SDL_SetColors(_screen, _currentPalette, 0, 256); 490 517 … … 502 529 // Blit everything to the screen 503 530 internUpdateScreen(); 504 531 505 // Make sure that an Common::EVENT_SCREEN_CHANGED gets sent later 506 _modeChanged = true; 532 return true; 507 533 } 508 534 509 535 void OSystem_SDL::updateScreen() { … … 527 553 528 554 // If the shake position changed, fill the dirty area with blackness 529 555 if (_currentShakePos != _newShakePos) { 530 SDL_Rect blackrect = {0, 0, _ screenWidth * _scaleFactor, _newShakePos * _scaleFactor};556 SDL_Rect blackrect = {0, 0, _videoMode.screenWidth * _videoMode.scaleFactor, _newShakePos * _videoMode.scaleFactor}; 531 557 532 if (_ adjustAspectRatio && !_overlayVisible)558 if (_videoMode.aspectRatio && !_overlayVisible) 533 559 blackrect.h = real2Aspect(blackrect.h - 1) + 1; 534 560 535 561 SDL_FillRect(_hwscreen, &blackrect, 0); … … 574 600 if (!_overlayVisible) { 575 601 origSurf = _screen; 576 602 srcSurf = _tmpscreen; 577 width = _ screenWidth;578 height = _ screenHeight;603 width = _videoMode.screenWidth; 604 height = _videoMode.screenHeight; 579 605 scalerProc = _scalerProc; 580 scale1 = _ scaleFactor;606 scale1 = _videoMode.scaleFactor; 581 607 } else { 582 608 origSurf = _overlayscreen; 583 609 srcSurf = _tmpscreen2; 584 width = _ overlayWidth;585 height = _ overlayHeight;610 width = _videoMode.overlayWidth; 611 height = _videoMode.overlayHeight; 586 612 scalerProc = Normal1x; 587 613 588 614 scale1 = 1; … … 635 661 orig_dst_y = dst_y; 636 662 dst_y = dst_y * scale1; 637 663 638 if (_ adjustAspectRatio && !_overlayVisible)664 if (_videoMode.aspectRatio && !_overlayVisible) 639 665 dst_y = real2Aspect(dst_y); 640 666 641 667 assert(scalerProc != NULL); … … 649 675 r->h = dst_h * scale1; 650 676 651 677 #ifndef DISABLE_SCALERS 652 if (_ adjustAspectRatio && orig_dst_y < height && !_overlayVisible)678 if (_videoMode.aspectRatio && orig_dst_y < height && !_overlayVisible) 653 679 r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1); 654 680 #endif 655 681 } … … 692 718 void OSystem_SDL::setFullscreenMode(bool enable) { 693 719 Common::StackLock lock(_graphicsMutex); 694 720 695 if (_ fullscreen == enable)721 if (_oldVideoMode.setup && _oldVideoMode.fullscreen == enable) 696 722 return; 697 723 698 if (_transactionMode == kTransactionCommit) { 699 assert(_hwscreen != 0); 700 _fullscreen = enable; 701 702 // Switch between fullscreen and windowed mode by invoking hotswapGFXMode(). 703 // We used to use SDL_WM_ToggleFullScreen() in the past, but this caused various 704 // problems. E.g. on OS X, it was implemented incorrectly for a long time; on 705 // the MAEMO platform, it seems to have caused problems, too. 706 // And on Linux, there were some troubles, too (see bug #1705410). 707 // So, we just do it "manually" now. There shouldn't be any drawbacks to that 708 // anyway. 709 hotswapGFXMode(); 710 } else if (_transactionMode == kTransactionActive) { 711 _transactionDetails.fs = enable; 712 _transactionDetails.fsChanged = true; 713 724 if (_transactionMode == kTransactionActive) { 725 _videoMode.fullscreen = enable; 714 726 _transactionDetails.needHotswap = true; 715 727 } 716 728 } 717 729 718 730 void OSystem_SDL::setAspectRatioCorrection(bool enable) { 719 if (((_screenHeight == 200 || _screenHeight == 400) && _adjustAspectRatio != enable) || 720 _transactionMode == kTransactionCommit) { 721 Common::StackLock lock(_graphicsMutex); 731 Common::StackLock lock(_graphicsMutex); 722 732 723 //assert(_hwscreen != 0);724 _adjustAspectRatio = enable;733 if (_oldVideoMode.setup && _oldVideoMode.aspectRatio == enable) 734 return; 725 735 726 if (_transactionMode == kTransactionActive) { 727 _transactionDetails.ar = enable; 728 _transactionDetails.arChanged = true; 729 730 _transactionDetails.needHotswap = true; 731 732 return; 733 } else { 734 if (_transactionMode != kTransactionCommit) 735 hotswapGFXMode(); 736 } 737 738 // Make sure that an Common::EVENT_SCREEN_CHANGED gets sent later 739 _modeChanged = true; 736 if (_transactionMode == kTransactionActive) { 737 _videoMode.aspectRatio = enable; 738 _transactionDetails.needHotswap = true; 740 739 } 741 740 } 742 741 … … 751 750 752 751 Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends 753 752 754 assert(x >= 0 && x < _ screenWidth);755 assert(y >= 0 && y < _ screenHeight);756 assert(h > 0 && y + h <= _ screenHeight);757 assert(w > 0 && x + w <= _ screenWidth);753 assert(x >= 0 && x < _videoMode.screenWidth); 754 assert(y >= 0 && y < _videoMode.screenHeight); 755 assert(h > 0 && y + h <= _videoMode.screenHeight); 756 assert(w > 0 && x + w <= _videoMode.screenWidth); 758 757 759 if (((long)src & 3) == 0 && pitch == _ screenWidth && x == 0 && y == 0 &&760 w == _ screenWidth && h == _screenHeight && _modeFlags & DF_WANT_RECT_OPTIM) {758 if (((long)src & 3) == 0 && pitch == _videoMode.screenWidth && x == 0 && y == 0 && 759 w == _videoMode.screenWidth && h == _videoMode.screenHeight && _modeFlags & DF_WANT_RECT_OPTIM) { 761 760 /* Special, optimized case for full screen updates. 762 761 * It tries to determine what areas were actually changed, 763 762 * and just updates those, on the actual display. */ … … 776 775 y = 0; 777 776 } 778 777 779 if (w > _ screenWidth - x) {780 w = _ screenWidth - x;778 if (w > _videoMode.screenWidth - x) { 779 w = _videoMode.screenWidth - x; 781 780 } 782 781 783 if (h > _ screenHeight - y) {784 h = _ screenHeight - y;782 if (h > _videoMode.screenHeight - y) { 783 h = _videoMode.screenHeight - y; 785 784 } 786 785 787 786 if (w <= 0 || h <= 0) … … 795 794 if (SDL_LockSurface(_screen) == -1) 796 795 error("SDL_LockSurface failed: %s", SDL_GetError()); 797 796 798 byte *dst = (byte *)_screen->pixels + y * _ screenWidth + x;797 byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth + x; 799 798 800 if (_ screenWidth == pitch && pitch == w) {799 if (_videoMode.screenWidth == pitch && pitch == w) { 801 800 memcpy(dst, src, h*w); 802 801 } else { 803 802 do { 804 803 memcpy(dst, src, w); 805 804 src += pitch; 806 dst += _ screenWidth;805 dst += _videoMode.screenWidth; 807 806 } while (--h); 808 807 } 809 808 … … 863 862 int height, width; 864 863 865 864 if (!_overlayVisible && !realCoordinates) { 866 width = _ screenWidth;867 height = _ screenHeight;865 width = _videoMode.screenWidth; 866 height = _videoMode.screenHeight; 868 867 } else { 869 width = _ overlayWidth;870 height = _ overlayHeight;868 width = _videoMode.overlayWidth; 869 height = _videoMode.overlayHeight; 871 870 } 872 871 873 872 // Extend the dirty region by 1 pixel for scalers … … 899 898 } 900 899 901 900 #ifndef DISABLE_SCALERS 902 if (_ adjustAspectRatio && !_overlayVisible && !realCoordinates) {901 if (_videoMode.aspectRatio && !_overlayVisible && !realCoordinates) { 903 902 makeRectStretchable(x, y, w, h); 904 903 } 905 904 #endif … … 924 923 assert(buf); 925 924 uint32 *sums = _dirtyChecksums; 926 925 uint x,y; 927 const uint last_x = (uint)_ screenWidth / 8;928 const uint last_y = (uint)_ screenHeight / 8;926 const uint last_x = (uint)_videoMode.screenWidth / 8; 927 const uint last_y = (uint)_videoMode.screenHeight / 8; 929 928 930 929 const uint BASE = 65521; /* largest prime smaller than 65536 */ 931 930 932 931 /* the 8x8 blocks in buf are enumerated starting in the top left corner and 933 932 * reading each line at a time from left to right */ 934 for (y = 0; y != last_y; y++, buf += _ screenWidth * (8 - 1))933 for (y = 0; y != last_y; y++, buf += _videoMode.screenWidth * (8 - 1)) 935 934 for (x = 0; x != last_x; x++, buf += 8) { 936 935 // Adler32 checksum algorithm (from RFC1950, used by gzip and zlib). 937 936 // This computes the Adler32 checksum of a 8x8 pixel block. Note … … 947 946 s1 += ptr[subX]; 948 947 s2 += s1; 949 948 } 950 ptr += _ screenWidth;949 ptr += _videoMode.screenWidth; 951 950 } 952 951 953 952 s1 %= BASE; … … 977 976 int x, y, w; 978 977 uint32 *ck = _dirtyChecksums; 979 978 980 for (y = 0; y != _ screenHeight / 8; y++) {981 for (x = 0; x != _ screenWidth / 8; x++, ck++) {979 for (y = 0; y != _videoMode.screenHeight / 8; y++) { 980 for (x = 0; x != _videoMode.screenWidth / 8; x++, ck++) { 982 981 if (ck[0] != ck[_cksumNum]) { 983 982 /* found a dirty 8x8 block, now go as far to the right as possible, 984 983 and at the same time, unmark the dirty status by setting old to new. */ … … 986 985 do { 987 986 ck[w + _cksumNum] = ck[w]; 988 987 w++; 989 } while (x + w != _ screenWidth / 8 && ck[w] != ck[w + _cksumNum]);988 } while (x + w != _videoMode.screenWidth / 8 && ck[w] != ck[w + _cksumNum]); 990 989 991 990 addDirtyRect(x * 8, y * 8, w * 8, 8); 992 991 … … 1003 1002 } 1004 1003 1005 1004 int16 OSystem_SDL::getHeight() { 1006 return _ screenHeight;1005 return _videoMode.screenHeight; 1007 1006 } 1008 1007 1009 1008 int16 OSystem_SDL::getWidth() { 1010 return _ screenWidth;1009 return _videoMode.screenWidth; 1011 1010 } 1012 1011 1013 1012 void OSystem_SDL::setPalette(const byte *colors, uint start, uint num) { … … 1093 1092 1094 1093 // Since resolution could change, put mouse to adjusted position 1095 1094 // Fixes bug #1349059 1096 x = _mouseCurState.x * _ scaleFactor;1097 if (_ adjustAspectRatio)1098 y = real2Aspect(_mouseCurState.y) * _ scaleFactor;1095 x = _mouseCurState.x * _videoMode.scaleFactor; 1096 if (_videoMode.aspectRatio) 1097 y = real2Aspect(_mouseCurState.y) * _videoMode.scaleFactor; 1099 1098 else 1100 y = _mouseCurState.y * _ scaleFactor;1099 y = _mouseCurState.y * _videoMode.scaleFactor; 1101 1100 1102 1101 warpMouse(x, y); 1103 1102 … … 1116 1115 1117 1116 // Since resolution could change, put mouse to adjusted position 1118 1117 // Fixes bug #1349059 1119 x = _mouseCurState.x / _ scaleFactor;1120 y = _mouseCurState.y / _ scaleFactor;1121 if (_ adjustAspectRatio)1118 x = _mouseCurState.x / _videoMode.scaleFactor; 1119 y = _mouseCurState.y / _videoMode.scaleFactor; 1120 if (_videoMode.aspectRatio) 1122 1121 y = aspect2Real(y); 1123 1122 1124 1123 warpMouse(x, y); … … 1140 1139 SDL_Rect src, dst; 1141 1140 src.x = src.y = 0; 1142 1141 dst.x = dst.y = 1; 1143 src.w = dst.w = _ screenWidth;1144 src.h = dst.h = _ screenHeight;1142 src.w = dst.w = _videoMode.screenWidth; 1143 src.h = dst.h = _videoMode.screenHeight; 1145 1144 if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0) 1146 1145 error("SDL_BlitSurface failed: %s", SDL_GetError()); 1147 1146 1148 1147 SDL_LockSurface(_tmpscreen); 1149 1148 SDL_LockSurface(_overlayscreen); 1150 1149 _scalerProc((byte *)(_tmpscreen->pixels) + _tmpscreen->pitch + 2, _tmpscreen->pitch, 1151 (byte *)_overlayscreen->pixels, _overlayscreen->pitch, _ screenWidth, _screenHeight);1150 (byte *)_overlayscreen->pixels, _overlayscreen->pitch, _videoMode.screenWidth, _videoMode.screenHeight); 1152 1151 1153 1152 #ifndef DISABLE_SCALERS 1154 if (_ adjustAspectRatio)1153 if (_videoMode.aspectRatio) 1155 1154 stretch200To240((uint8 *)_overlayscreen->pixels, _overlayscreen->pitch, 1156 _ overlayWidth, _screenHeight * _scaleFactor, 0, 0, 0);1155 _videoMode.overlayWidth, _videoMode.screenHeight * _videoMode.scaleFactor, 0, 0, 0); 1157 1156 #endif 1158 1157 SDL_UnlockSurface(_tmpscreen); 1159 1158 SDL_UnlockSurface(_overlayscreen); … … 1171 1170 error("SDL_LockSurface failed: %s", SDL_GetError()); 1172 1171 1173 1172 byte *src = (byte *)_overlayscreen->pixels; 1174 int h = _ overlayHeight;1173 int h = _videoMode.overlayHeight; 1175 1174 do { 1176 memcpy(buf, src, _ overlayWidth * 2);1175 memcpy(buf, src, _videoMode.overlayWidth * 2); 1177 1176 src += _overlayscreen->pitch; 1178 1177 buf += pitch; 1179 1178 } while (--h); … … 1199 1198 y = 0; 1200 1199 } 1201 1200 1202 if (w > _ overlayWidth - x) {1203 w = _ overlayWidth - x;1201 if (w > _videoMode.overlayWidth - x) { 1202 w = _videoMode.overlayWidth - x; 1204 1203 } 1205 1204 1206 if (h > _ overlayHeight - y) {1207 h = _ overlayHeight - y;1205 if (h > _videoMode.overlayHeight - y) { 1206 h = _videoMode.overlayHeight - y; 1208 1207 } 1209 1208 1210 1209 if (w <= 0 || h <= 0) … … 1260 1259 void OSystem_SDL::warpMouse(int x, int y) { 1261 1260 int y1 = y; 1262 1261 1263 if (_ adjustAspectRatio && !_overlayVisible)1262 if (_videoMode.aspectRatio && !_overlayVisible) 1264 1263 y1 = real2Aspect(y); 1265 1264 1266 1265 if (_mouseCurState.x != x || _mouseCurState.y != y) { 1267 1266 if (!_overlayVisible) 1268 SDL_WarpMouse(x * _ scaleFactor, y1 * _scaleFactor);1267 SDL_WarpMouse(x * _videoMode.scaleFactor, y1 * _videoMode.scaleFactor); 1269 1268 else 1270 1269 SDL_WarpMouse(x, y1); 1271 1270 … … 1368 1367 1369 1368 int rW, rH; 1370 1369 1371 if (_cursorTargetScale >= _ scaleFactor) {1370 if (_cursorTargetScale >= _videoMode.scaleFactor) { 1372 1371 // The cursor target scale is greater or equal to the scale at 1373 1372 // which the rest of the screen is drawn. We do not downscale 1374 1373 // the cursor image, we draw it at its original size. It will … … 1381 1380 1382 1381 // The virtual dimensions may be larger than the original. 1383 1382 1384 _mouseCurState.vW = w * _cursorTargetScale / _ scaleFactor;1385 _mouseCurState.vH = h * _cursorTargetScale / _ scaleFactor;1383 _mouseCurState.vW = w * _cursorTargetScale / _videoMode.scaleFactor; 1384 _mouseCurState.vH = h * _cursorTargetScale / _videoMode.scaleFactor; 1386 1385 _mouseCurState.vHotX = _mouseCurState.hotX * _cursorTargetScale / 1387 _ scaleFactor;1386 _videoMode.scaleFactor; 1388 1387 _mouseCurState.vHotY = _mouseCurState.hotY * _cursorTargetScale / 1389 _ scaleFactor;1388 _videoMode.scaleFactor; 1390 1389 } else { 1391 1390 // The cursor target scale is smaller than the scale at which 1392 1391 // the rest of the screen is drawn. We scale up the cursor 1393 1392 // image to make it appear correct. 1394 1393 1395 rW = w * _ scaleFactor / _cursorTargetScale;1396 rH = h * _ scaleFactor / _cursorTargetScale;1397 _mouseCurState.rHotX = _mouseCurState.hotX * _ scaleFactor /1394 rW = w * _videoMode.scaleFactor / _cursorTargetScale; 1395 rH = h * _videoMode.scaleFactor / _cursorTargetScale; 1396 _mouseCurState.rHotX = _mouseCurState.hotX * _videoMode.scaleFactor / 1398 1397 _cursorTargetScale; 1399 _mouseCurState.rHotY = _mouseCurState.hotY * _ scaleFactor /1398 _mouseCurState.rHotY = _mouseCurState.hotY * _videoMode.scaleFactor / 1400 1399 _cursorTargetScale; 1401 1400 1402 1401 // The virtual dimensions will be the same as the original. … … 1411 1410 int rH1 = rH; // store original to pass to aspect-correction function later 1412 1411 #endif 1413 1412 1414 if (_ adjustAspectRatio && _cursorTargetScale == 1) {1413 if (_videoMode.aspectRatio && _cursorTargetScale == 1) { 1415 1414 rH = real2Aspect(rH - 1) + 1; 1416 1415 _mouseCurState.rHotY = real2Aspect(_mouseCurState.rHotY); 1417 1416 } … … 1446 1445 // the game. This only works well with the non-blurring scalers so we 1447 1446 // actually only use the 1x, 1.5x, 2x and AdvMame scalers. 1448 1447 1449 if (_cursorTargetScale == 1 && (_ mode == GFX_DOUBLESIZE || _mode == GFX_TRIPLESIZE))1448 if (_cursorTargetScale == 1 && (_videoMode.mode == GFX_DOUBLESIZE || _videoMode.mode == GFX_TRIPLESIZE)) 1450 1449 scalerProc = _scalerProc; 1451 1450 else 1452 scalerProc = scalersMagn[_cursorTargetScale - 1][_ scaleFactor - 1];1451 scalerProc = scalersMagn[_cursorTargetScale - 1][_videoMode.scaleFactor - 1]; 1453 1452 1454 1453 scalerProc((byte *)_mouseOrigSurface->pixels + _mouseOrigSurface->pitch + 2, 1455 1454 _mouseOrigSurface->pitch, (byte *)_mouseSurface->pixels, _mouseSurface->pitch, 1456 1455 _mouseCurState.w, _mouseCurState.h); 1457 1456 1458 1457 #ifndef DISABLE_SCALERS 1459 if (_ adjustAspectRatio && _cursorTargetScale == 1)1458 if (_videoMode.aspectRatio && _cursorTargetScale == 1) 1460 1459 cursorStretch200To240((uint8 *)_mouseSurface->pixels, _mouseSurface->pitch, rW, rH1, 0, 0, 0); 1461 1460 #endif 1462 1461 … … 1499 1498 1500 1499 // When we switch bigger overlay off mouse jumps. Argh! 1501 1500 // This is intended to prevent undrawing offscreen mouse 1502 if (!_overlayVisible && (x >= _ screenWidth || y >= _screenHeight)) {1501 if (!_overlayVisible && (x >= _videoMode.screenWidth || y >= _videoMode.screenHeight)) { 1503 1502 return; 1504 1503 } 1505 1504 … … 1522 1521 dst.y = _mouseCurState.y; 1523 1522 1524 1523 if (!_overlayVisible) { 1525 scale = _ scaleFactor;1526 width = _ screenWidth;1527 height = _ screenHeight;1524 scale = _videoMode.scaleFactor; 1525 width = _videoMode.screenWidth; 1526 height = _videoMode.screenHeight; 1528 1527 dst.w = _mouseCurState.vW; 1529 1528 dst.h = _mouseCurState.vH; 1530 1529 hotX = _mouseCurState.vHotX; 1531 1530 hotY = _mouseCurState.vHotY; 1532 1531 } else { 1533 1532 scale = 1; 1534 width = _ overlayWidth;1535 height = _ overlayHeight;1533 width = _videoMode.overlayWidth; 1534 height = _videoMode.overlayHeight; 1536 1535 dst.w = _mouseCurState.rW; 1537 1536 dst.h = _mouseCurState.rH; 1538 1537 hotX = _mouseCurState.rHotX; … … 1554 1553 dst.y += _currentShakePos; 1555 1554 } 1556 1555 1557 if (_ adjustAspectRatio && !_overlayVisible)1556 if (_videoMode.aspectRatio && !_overlayVisible) 1558 1557 dst.y = real2Aspect(dst.y); 1559 1558 1560 1559 dst.x = scale * dst.x - _mouseCurState.rHotX; … … 1670 1669 void OSystem_SDL::handleScalerHotkeys(const SDL_KeyboardEvent &key) { 1671 1670 // Ctrl-Alt-a toggles aspect ratio correction 1672 1671 if (key.keysym.sym == 'a') { 1673 setFeatureState(kFeatureAspectRatioCorrection, !_adjustAspectRatio); 1672 beginGFXTransaction(); 1673 setFeatureState(kFeatureAspectRatioCorrection, !_videoMode.aspectRatio); 1674 endGFXTransaction(); 1674 1675 #ifdef USE_OSD 1675 1676 char buffer[128]; 1676 if (_ adjustAspectRatio)1677 if (_videoMode.aspectRatio) 1677 1678 sprintf(buffer, "Enabled aspect ratio correction\n%d x %d -> %d x %d", 1678 _ screenWidth, _screenHeight,1679 _videoMode.screenWidth, _videoMode.screenHeight, 1679 1680 _hwscreen->w, _hwscreen->h 1680 1681 ); 1681 1682 else 1682 1683 sprintf(buffer, "Disabled aspect ratio correction\n%d x %d -> %d x %d", 1683 _ screenWidth, _screenHeight,1684 _videoMode.screenWidth, _videoMode.screenHeight, 1684 1685 _hwscreen->w, _hwscreen->h 1685 1686 ); 1686 1687 displayMessageOnOSD(buffer); … … 1690 1691 } 1691 1692 1692 1693 int newMode = -1; 1693 int factor = _ scaleFactor - 1;1694 int factor = _videoMode.scaleFactor - 1; 1694 1695 1695 1696 // Increase/decrease the scale factor 1696 1697 if (key.keysym.sym == SDLK_EQUALS || key.keysym.sym == SDLK_PLUS || key.keysym.sym == SDLK_MINUS || … … 1716 1717 } 1717 1718 1718 1719 if (newMode >= 0) { 1719 setGraphicsMode(newMode); 1720 beginGFXTransaction(); 1721 setGraphicsMode(newMode); 1722 endGFXTransaction(); 1720 1723 #ifdef USE_OSD 1721 1724 if (_osdSurface) { 1722 1725 const char *newScalerName = 0; 1723 1726 const GraphicsMode *g = getSupportedGraphicsModes(); 1724 1727 while (g->name) { 1725 if (g->id == _ mode) {1728 if (g->id == _videoMode.mode) { 1726 1729 newScalerName = g->description; 1727 1730 break; 1728 1731 } … … 1732 1735 char buffer[128]; 1733 1736 sprintf(buffer, "Active graphics filter: %s\n%d x %d -> %d x %d", 1734 1737 newScalerName, 1735 _ screenWidth, _screenHeight,1738 _videoMode.screenWidth, _videoMode.screenHeight, 1736 1739 _hwscreen->w, _hwscreen->h 1737 1740 ); 1738 1741 displayMessageOnOSD(buffer); -
backends/platform/sdl/sdl.cpp
112 112 // Enable unicode support if possible 113 113 SDL_EnableUNICODE(1); 114 114 115 _oldVideoMode.setup = false; 116 _videoMode.setup = false; 117 115 118 _cksumValid = false; 116 119 #if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) && !defined(DISABLE_SCALERS) 117 _mode = GFX_DOUBLESIZE; 118 _scaleFactor = 2; 120 _videoMode.mode = GFX_DOUBLESIZE; 121 _videoMode.scaleFactor = 2; 122 _videoMode.aspectRatio = ConfMan.getBool("aspect_ratio"); 119 123 _scalerProc = Normal2x; 120 _adjustAspectRatio = ConfMan.getBool("aspect_ratio");121 124 #else // for small screen platforms 122 _mode = GFX_NORMAL; 123 _scaleFactor = 1; 125 _videoMode.mode = GFX_NORMAL; 126 _videoMode.scaleFactor = 1; 127 _videoMode.aspectRatio = false; 124 128 _scalerProc = Normal1x; 125 _adjustAspectRatio = false;126 129 #endif 127 130 _scalerType = 0; 128 131 _modeFlags = 0; 129 132 130 133 #if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) 131 _ fullscreen = ConfMan.getBool("fullscreen");134 _videoMode.fullscreen = ConfMan.getBool("fullscreen"); 132 135 #else 133 _ fullscreen = true;136 _videoMode.fullscreen = true; 134 137 #endif 135 138 136 139 #if !defined(MACOSX) && !defined(__SYMBIAN32__) … … 184 187 #ifdef USE_OSD 185 188 _osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0), 186 189 #endif 187 _hwscreen(0), _screen(0), _screenWidth(0), _screenHeight(0), 188 _tmpscreen(0), _overlayWidth(0), _overlayHeight(0), 190 _hwscreen(0), _screen(0), _tmpscreen(0), 189 191 _overlayVisible(false), 190 192 _overlayscreen(0), _tmpscreen2(0), 191 193 _samplesPerSec(0), … … 423 425 424 426 switch (f) { 425 427 case kFeatureFullscreenMode: 426 return _ fullscreen;428 return _videoMode.fullscreen; 427 429 case kFeatureAspectRatioCorrection: 428 return _ adjustAspectRatio;430 return _videoMode.aspectRatio; 429 431 case kFeatureAutoComputeDirtyRects: 430 432 return _modeFlags & DF_WANT_RECT_OPTIM; 431 433 default: -
backends/platform/sdl/events.cpp
77 77 78 78 // Adjust for the screen scaling 79 79 if (!_overlayVisible) { 80 event.mouse.x /= _ scaleFactor;81 event.mouse.y /= _ scaleFactor;82 if (_ adjustAspectRatio)80 event.mouse.x /= _videoMode.scaleFactor; 81 event.mouse.y /= _videoMode.scaleFactor; 82 if (_videoMode.aspectRatio) 83 83 event.mouse.y = aspect2Real(event.mouse.y); 84 84 } 85 85 } … … 196 196 if (b == Common::KBD_ALT && (ev.key.keysym.sym == SDLK_RETURN 197 197 || ev.key.keysym.sym == SDLK_KP_ENTER)) { 198 198 beginGFXTransaction(); 199 setFullscreenMode(!_fullscreen);199 setFullscreenMode(!_videoMode.fullscreen); 200 200 endGFXTransaction(); 201 201 #ifdef USE_OSD 202 if (_ fullscreen)202 if (_videoMode.fullscreen) 203 203 displayMessageOnOSD("Fullscreen mode"); 204 204 else 205 205 displayMessageOnOSD("Windowed mode"); -
backends/platform/sdl/sdl.h
85 85 virtual void initBackend(); 86 86 87 87 void beginGFXTransaction(void); 88 voidendGFXTransaction(void);88 kTransactionError endGFXTransaction(void); 89 89 90 90 // Set the size of the video bitmap. 91 91 // Typically, 320x200 … … 183 183 virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); 184 184 virtual int16 getHeight(); 185 185 virtual int16 getWidth(); 186 virtual int16 getOverlayHeight() { return _ overlayHeight; }187 virtual int16 getOverlayWidth() { return _ overlayWidth; }186 virtual int16 getOverlayHeight() { return _videoMode.overlayHeight; } 187 virtual int16 getOverlayWidth() { return _videoMode.overlayWidth; } 188 188 189 189 // Methods that convert RGB to/from colors suitable for the overlay. 190 190 virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); … … 235 235 // unseen game screen 236 236 SDL_Surface *_screen; 237 237 238 // TODO: We could get rid of the following two vars and just use _screen instead239 int _screenWidth, _screenHeight;240 241 238 // temporary screen (for scalers) 242 239 SDL_Surface *_tmpscreen; 243 240 SDL_Surface *_tmpscreen2; 244 241 245 242 // overlay 246 243 SDL_Surface *_overlayscreen; 247 int _overlayWidth, _overlayHeight;248 244 bool _overlayVisible; 249 245 250 246 // Audio … … 261 257 262 258 enum { 263 259 kTransactionNone = 0, 264 kTransaction Commit= 1,265 kTransaction Active= 2260 kTransactionActive = 1, 261 kTransactionRollback = 2 266 262 }; 267 263 268 264 struct TransactionDetails { 269 int mode;270 bool modeChanged;271 int w;272 int h;273 265 bool sizeChanged; 274 bool fs;275 bool fsChanged;276 bool ar;277 bool arChanged;278 266 bool needHotswap; 279 267 bool needUpdatescreen; 280 bool needUnload;281 bool needToggle;282 268 bool normal1xScaler; 283 269 }; 284 270 TransactionDetails _transactionDetails; 285 271 272 struct VideoState { 273 bool setup; 274 275 bool fullscreen; 276 bool aspectRatio; 277 278 int mode; 279 int scaleFactor; 280 281 int screenWidth, screenHeight; 282 int overlayWidth, overlayHeight; 283 }; 284 VideoState _videoMode, _oldVideoMode; 285 286 void setGraphicsModeIntern(); 287 286 288 /** Force full redraw on next updateScreen */ 287 289 bool _forceFull; 288 290 ScalerProc *_scalerProc; 289 291 int _scalerType; 290 int _scaleFactor;291 int _mode;292 292 int _transactionMode; 293 bool _fullscreen;294 293 295 294 bool _screenIsLocked; 296 295 Graphics::Surface _framebuffer; … … 300 299 bool _modeChanged; 301 300 int _screenChangeCount; 302 301 303 /** True if aspect ratio correction is enabled. */304 bool _adjustAspectRatio;305 306 302 enum { 307 303 NUM_DIRTY_RECT = 100, 308 304 MAX_SCALING = 3 … … 425 421 426 422 virtual void internUpdateScreen(); // overloaded by CE backend 427 423 428 virtual voidloadGFXMode(); // overloaded by CE backend424 virtual bool loadGFXMode(); // overloaded by CE backend 429 425 virtual void unloadGFXMode(); // overloaded by CE backend 430 virtual voidhotswapGFXMode(); // overloaded by CE backend426 virtual bool hotswapGFXMode(); // overloaded by CE backend 431 427 432 428 void setFullscreenMode(bool enable); 433 429 void setAspectRatioCorrection(bool enable); … … 435 431 virtual bool saveScreenshot(const char *filename); // overloaded by CE backend 436 432 437 433 int effectiveScreenHeight() const { 438 return (_ adjustAspectRatio ? real2Aspect(_screenHeight) : _screenHeight)439 * _ scaleFactor;434 return (_videoMode.aspectRatio ? real2Aspect(_videoMode.screenHeight) : _videoMode.screenHeight) 435 * _videoMode.scaleFactor; 440 436 } 441 437 442 438 void setupIcon();