Ticket #8792: float-scaler.patch
File float-scaler.patch, 5.5 KB (added by , 17 years ago) |
---|
-
backends/platform/sdl/graphics.cpp
30 30 #include "graphics/scaler.h" 31 31 #include "graphics/surface.h" 32 32 33 #ifndef DISABLE_FLOAT_SCALER 34 #include "common/config-manager.h" 35 #include "common/singleton.h" 36 extern float gScale; // from scaler.cpp 37 #endif 38 33 39 static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { 34 40 {"1x", "Normal (no scaling)", GFX_NORMAL}, 35 41 {"2x", "2x", GFX_DOUBLESIZE}, … … 45 51 #endif 46 52 {"tv2x", "TV2x", GFX_TV2X}, 47 53 {"dotmatrix", "DotMatrix", GFX_DOTMATRIX}, 54 {"user", "User defined float scaling", GFX_FLOAT}, 48 55 {0, 0, 0} 49 56 }; 50 57 … … 70 77 { GFX_NORMAL, GFX_SUPER2XSAI, -1, -1 }, 71 78 { GFX_NORMAL, GFX_SUPEREAGLE, -1, -1 }, 72 79 { GFX_NORMAL, GFX_TV2X, -1, -1 }, 73 { GFX_NORMAL, GFX_DOTMATRIX, -1, -1 } 80 { GFX_NORMAL, GFX_DOTMATRIX, -1, -1 }, 81 { GFX_NORMAL, GFX_FLOAT, -1, -1 } 74 82 }; 75 83 76 84 #ifndef DISABLE_SCALERS … … 147 155 bool OSystem_SDL::setGraphicsMode(int mode) { 148 156 Common::StackLock lock(_graphicsMutex); 149 157 150 int newScaleFactor = 1;158 scale_t newScaleFactor = 1; 151 159 ScalerProc *newScalerProc; 160 #ifndef DISABLE_FLOAT_SCALER 161 float f; 162 Common::String s; 163 #endif 152 164 153 165 switch(mode) { 154 166 case GFX_NORMAL: … … 203 215 newScaleFactor = 2; 204 216 newScalerProc = DotMatrix; 205 217 break; 218 #ifndef DISABLE_FLOAT_SCALER 219 case GFX_FLOAT: 220 s = Common::Singleton<Common::ConfigManager>::instance().get("gfx_scale"); 221 f = atof(s.c_str()); 222 if (f > 0.0f && f <= 3.0f) { 223 newScaleFactor = f; 224 gScale = f; 225 } else { 226 newScaleFactor = 1.0f; 227 gScale = 1.0f; 228 } 229 newScalerProc = UserScaler; 230 break; 231 #endif // DISABLE_FLOAT_SCALER 206 232 #endif // DISABLE_SCALERS 207 233 208 234 default: … … 1446 1472 // the game. This only works well with the non-blurring scalers so we 1447 1473 // actually only use the 1x, 1.5x, 2x and AdvMame scalers. 1448 1474 1449 if (_cursorTargetScale == 1 && (_mode == GFX_DOUBLESIZE || _mode == GFX_TRIPLESIZE)) 1475 if (_cursorTargetScale == 1 && (_mode == GFX_DOUBLESIZE || _mode == GFX_TRIPLESIZE) || 1476 _mode == GFX_FLOAT) 1450 1477 scalerProc = _scalerProc; 1451 1478 else 1452 scalerProc = scalersMagn[ _cursorTargetScale - 1][_scaleFactor - 1];1479 scalerProc = scalersMagn[(int)_cursorTargetScale - 1][(int)_scaleFactor - 1]; 1453 1480 1454 1481 scalerProc((byte *)_mouseOrigSurface->pixels + _mouseOrigSurface->pitch + 2, 1455 1482 _mouseOrigSurface->pitch, (byte *)_mouseSurface->pixels, _mouseSurface->pitch, … … 1514 1541 } 1515 1542 1516 1543 SDL_Rect dst; 1517 int scale;1544 scale_t scale; 1518 1545 int width, height; 1519 1546 int hotX, hotY; 1520 1547 -
backends/platform/sdl/sdl.h
64 64 GFX_HQ2X = 8, 65 65 GFX_HQ3X = 9, 66 66 GFX_TV2X = 10, 67 GFX_DOTMATRIX = 11 67 GFX_DOTMATRIX = 11, 68 GFX_FLOAT = 12, 68 69 }; 69 70 70 71 … … 270 271 bool _forceFull; 271 272 ScalerProc *_scalerProc; 272 273 int _scalerType; 273 int _scaleFactor;274 scale_t _scaleFactor; 274 275 int _mode; 275 276 int _transactionMode; 276 277 bool _fullscreen; … … 339 340 SDL_Rect _mouseBackup; 340 341 MousePos _mouseCurState; 341 342 byte _mouseKeyColor; 342 int _cursorTargetScale;343 scale_t _cursorTargetScale; 343 344 bool _cursorPaletteDisabled; 344 345 SDL_Surface *_mouseOrigSurface; 345 346 SDL_Surface *_mouseSurface; -
common/scummsys.h
441 441 typedef unsigned short uint16; 442 442 typedef signed short int16; 443 443 444 #ifndef DISABLE_FLOAT_SCALER 445 typedef float scale_t; 446 #else 447 typedef int scale_t; 448 #endif 449 444 450 #ifdef SCUMMVM_USE_LONG_INT 445 451 typedef unsigned long uint32; 446 452 typedef signed long int32; -
graphics/scaler.cpp
320 320 } 321 321 } 322 322 323 #ifndef DISABLE_FLOAT_SCALER 324 325 float gScale; 326 void UserScaler(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, 327 int width, int height) { 328 329 float scale = gScale; 330 if (scale <= 0.0f || scale > 3.0f) 331 scale = 1.0f; 332 333 for (int y = 0; y < height; y++) { 334 for (int x = 0; x < width; x++) { 335 int xMin, yMin; 336 uint16 pixel = *((uint16 *)(srcPtr + srcPitch * y) + x); 337 // calculate the point where this pixel would be on a scalar coordinate system 338 xMin = x * scale; 339 yMin = y * scale; 340 341 #define DESTOF(a, b, c) do { *(uint16 *)((dstPtr + (dstPitch * (b)) + (a)*2)) = pixel; } while (0) 342 DESTOF(xMin, yMin, pixel); 343 if (scale > 1.0) { 344 DESTOF(xMin + 1, yMin, pixel); 345 DESTOF(xMin, yMin + 1, pixel); 346 DESTOF(xMin + 1, yMin + 1, pixel); 347 if (scale > 2.0 && x < width - 1 && y < height - 1) { 348 DESTOF(xMin + 2, yMin, pixel); 349 DESTOF(xMin + 2, yMin + 1, pixel); 350 DESTOF(xMin + 2, yMin + 2, pixel); 351 DESTOF(xMin + 1, yMin + 2, pixel); 352 DESTOF(xMin, yMin + 2, pixel); 353 } 354 } 355 } 356 } 357 } 358 #endif // DISABLE_FLOAT_SCALER 359 323 360 #endif -
graphics/scaler.h
48 48 DECLARE_SCALER(Normal1o5x); 49 49 DECLARE_SCALER(TV2x); 50 50 DECLARE_SCALER(DotMatrix); 51 DECLARE_SCALER(UserScaler); 51 52 52 53 #ifndef DISABLE_HQ_SCALERS 53 54 DECLARE_SCALER(HQ2x);