Ticket #8534: cursor-fixes.diff
File cursor-fixes.diff, 4.1 KB (added by , 18 years ago) |
---|
-
backends/sdl/graphics.cpp
858 858 return true; 859 859 } 860 860 861 void OSystem_SDL::addDirtyRect(int x, int y, int w, int h , bool mouseRect) {861 void OSystem_SDL::addDirtyRect(int x, int y, int w, int h) { 862 862 if (_forceFull) 863 863 return; 864 864 … … 867 867 return; 868 868 } 869 869 870 SDL_Rect *r = &_dirtyRectList[_numDirtyRects++];871 872 if (mouseRect) {873 r->x = x;874 r->y = y;875 r->w = w;876 r->h = h;877 return;878 }879 880 870 int height, width; 881 871 882 872 if (!_overlayVisible) { … … 921 911 } 922 912 #endif 923 913 924 r->x = x; 925 r->y = y; 926 r->w = w; 927 r->h = h; 914 if (w > 0 && h > 0) { 915 SDL_Rect *r = &_dirtyRectList[_numDirtyRects++]; 916 917 r->x = x; 918 r->y = y; 919 r->w = w; 920 r->h = h; 921 } 928 922 } 929 923 930 924 … … 1450 1444 1451 1445 void OSystem_SDL::undrawMouse() { 1452 1446 const int x = _mouseBackup.x; 1453 const int y = (_adjustAspectRatio && !_overlayVisible) ? aspect2Real(_mouseBackup.y) :_mouseBackup.y;1447 const int y = _mouseBackup.y; 1454 1448 1455 1449 // When we switch bigger overlay off mouse jumps. Argh! 1456 1450 // This is intended to prevent undrawing offscreen mouse … … 1468 1462 return; 1469 1463 } 1470 1464 1471 SDL_Rect src,dst;1465 SDL_Rect dst; 1472 1466 bool useCursorScaling; 1473 1467 int scale; 1474 1468 int width, height; … … 1483 1477 height = _overlayHeight; 1484 1478 } 1485 1479 1486 useCursorScaling = ( _scaleFactor> _cursorTargetScale);1480 useCursorScaling = (scale > _cursorTargetScale); 1487 1481 1488 1482 if (useCursorScaling) { 1489 dst.x = _mouseCurState.x - _mouseHotspotX * scale/ _cursorTargetScale;1490 dst.y = _mouseCurState.y - _mouseHotspotY * scale/ _cursorTargetScale;1483 dst.x = _mouseCurState.x - _mouseHotspotX / _cursorTargetScale; 1484 dst.y = _mouseCurState.y - _mouseHotspotY / _cursorTargetScale; 1491 1485 } else { 1492 1486 dst.x = _mouseCurState.x - _mouseHotspotX; 1493 1487 dst.y = _mouseCurState.y - _mouseHotspotY; 1494 1488 } 1495 1489 1496 dst.w = _mouseCurState.hW; 1497 dst.h = _mouseCurState.hH; 1498 src.x = src.y = 0; 1490 dst.w = _mouseCurState.w; 1491 dst.h = _mouseCurState.h; 1499 1492 1500 // clip the mouse rect, and adjust the src pointer accordingly 1501 int dx, dy; 1502 1503 if (dst.x < 0) { 1504 dx = useCursorScaling ? dst.x * scale / _cursorTargetScale : dst.x; 1505 dst.w += dx; 1506 src.x -= dx; 1507 dst.x = 0; 1508 } 1509 if (dst.y < 0) { 1510 dy = useCursorScaling ? dst.y * scale / _cursorTargetScale : dst.y; 1511 dst.h += dy; 1512 src.y -= dy; 1513 dst.y = 0; 1514 } 1493 // Note that addDirtyRect() will perform any necessary clipping 1515 1494 1516 // Quick check to see if anything has to be drawn at all1517 if (dst.w <= 0 || dst.h <= 0)1518 return;1519 1520 src.w = dst.w;1521 src.h = dst.h;1522 1523 if (_adjustAspectRatio && !_overlayVisible)1524 dst.y = real2Aspect(dst.y);1525 1526 1495 _mouseBackup.x = dst.x; 1527 1496 _mouseBackup.y = dst.y; 1528 1497 _mouseBackup.w = dst.w; 1529 1498 _mouseBackup.h = dst.h; 1499 1500 addDirtyRect(_mouseBackup.x, _mouseBackup.y, _mouseBackup.w, _mouseBackup.h); 1501 1502 // We draw the pre-scaled cursor image, so now we need to adjust for 1503 // scaling, shake position and aspect ratio correction manually. 1504 1505 if (!_overlayVisible) { 1506 dst.y += _currentShakePos; 1507 } 1508 1509 if (_adjustAspectRatio && !_overlayVisible) 1510 dst.y = real2Aspect(dst.y); 1530 1511 1531 1512 dst.x *= scale; 1532 1513 dst.y *= scale; 1514 dst.w = _mouseCurState.hW; 1515 dst.h = _mouseCurState.hH; 1533 1516 1534 if (SDL_BlitSurface(_mouseSurface, &src, _hwscreen, &dst) != 0) 1517 // Note that SDL_BlitSurface() will perform any clipping necessary 1518 1519 if (SDL_BlitSurface(_mouseSurface, NULL, _hwscreen, &dst) != 0) 1535 1520 error("SDL_BlitSurface failed: %s", SDL_GetError()); 1536 1537 addDirtyRect(dst.x, dst.y, dst.w, dst.h, true);1538 1521 } 1539 1522 1540 1523 #pragma mark - -
backends/sdl/sdl-common.h
336 336 void addDirtyRgnAuto(const byte *buf); 337 337 void makeChecksums(const byte *buf); 338 338 339 virtual void addDirtyRect(int x, int y, int w, int h , bool mouseRect = false); // overloaded by CE backend339 virtual void addDirtyRect(int x, int y, int w, int h); // overloaded by CE backend 340 340 341 341 virtual void drawMouse(); // overloaded by CE backend 342 342 virtual void undrawMouse(); // overloaded by CE backend (FIXME)