aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'backends/graphics')
-rw-r--r--backends/graphics/graphics.h2
-rw-r--r--backends/graphics/null/null-graphics.h2
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp54
-rw-r--r--backends/graphics/opengl/opengl-graphics.h4
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.cpp2
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp96
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.h4
-rw-r--r--backends/graphics/wincesdl/wincesdl-graphics.cpp2
-rw-r--r--backends/graphics/wincesdl/wincesdl-graphics.h2
9 files changed, 72 insertions, 96 deletions
diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h
index 3f282df587..0d6fa30418 100644
--- a/backends/graphics/graphics.h
+++ b/backends/graphics/graphics.h
@@ -80,7 +80,7 @@ public:
virtual bool showMouse(bool visible) = 0;
virtual void warpMouse(int x, int y) = 0;
- virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) = 0;
+ virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL) = 0;
virtual void setCursorPalette(const byte *colors, uint start, uint num) = 0;
virtual void displayMessageOnOSD(const char *msg) {}
diff --git a/backends/graphics/null/null-graphics.h b/backends/graphics/null/null-graphics.h
index 2e6b24d147..2f8baae3e8 100644
--- a/backends/graphics/null/null-graphics.h
+++ b/backends/graphics/null/null-graphics.h
@@ -78,7 +78,7 @@ public:
bool showMouse(bool visible) { return !visible; }
void warpMouse(int x, int y) {}
- void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) {}
+ void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL) {}
void setCursorPalette(const byte *colors, uint start, uint num) {}
};
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index cd820ae3b2..8449048997 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -49,7 +49,7 @@ OpenGLGraphicsManager::OpenGLGraphicsManager()
_transactionMode(kTransactionNone),
_cursorNeedsRedraw(false), _cursorPaletteDisabled(true),
_cursorVisible(false), _cursorKeyColor(0),
- _cursorTargetScale(1),
+ _cursorDontScale(false),
_formatBGR(false),
_displayX(0), _displayY(0), _displayWidth(0), _displayHeight(0) {
@@ -591,7 +591,7 @@ void OpenGLGraphicsManager::warpMouse(int x, int y) {
setInternalMousePosition(scaledX, scaledY);
}
-void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
+void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) {
#ifdef USE_RGB_COLOR
if (format)
_cursorFormat = *format;
@@ -616,7 +616,7 @@ void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int
_cursorState.hotX = hotspotX;
_cursorState.hotY = hotspotY;
_cursorKeyColor = keycolor;
- _cursorTargetScale = cursorTargetScale;
+ _cursorDontScale = dontScale;
_cursorNeedsRedraw = true;
refreshCursorScale();
@@ -829,28 +829,19 @@ void OpenGLGraphicsManager::refreshCursor() {
}
void OpenGLGraphicsManager::refreshCursorScale() {
- // Calculate the scale factors of the screen. We limit ourselves to 3 at
- // most here to avoid really big (and ugly) cursors for big resolutions.
- // It might be noteworthy that 3 is the (current) target scale for the
- // modern theme and thus assures the cursor is *never* scaled.
+ // Calculate the scale factors of the screen.
// We also totally ignore the aspect of the overlay cursor, since aspect
// ratio correction only applies to the game screen.
- uint screenScaleFactorX = MIN(30000, _videoMode.hardwareWidth * 10000 / _videoMode.screenWidth);
- uint screenScaleFactorY = MIN(30000, _videoMode.hardwareHeight * 10000 / _videoMode.screenHeight);
-
- // Apply the target scale factor to the cursor.
- // It might be noteworthy we only apply any scaling to the cursor in case
- // the current scale factor is bigger than the target scale to match
- // SurfaceSdlGraphicsManager's behavior. Otherwise we would downscale the
- // GUI cursor of the modern theme for example.
- if (screenScaleFactorX > uint(_cursorTargetScale * 10000))
- screenScaleFactorX /= _cursorTargetScale;
- else
+ // TODO: It might make sense to always ignore scaling of the mouse cursor
+ // when the overlay is visible.
+ uint screenScaleFactorX = _videoMode.hardwareWidth * 10000 / _videoMode.screenWidth;
+ uint screenScaleFactorY = _videoMode.hardwareHeight * 10000 / _videoMode.screenHeight;
+
+ // Ignore scaling when the cursor should not be scaled.
+ if (_cursorDontScale) {
screenScaleFactorX = 10000;
- if (screenScaleFactorY > uint(_cursorTargetScale * 10000))
- screenScaleFactorY /= _cursorTargetScale;
- else
screenScaleFactorY = 10000;
+ }
// Apply them (without any possible) aspect ratio correction to the
// overlay.
@@ -859,16 +850,19 @@ void OpenGLGraphicsManager::refreshCursorScale() {
_cursorState.rHotX = (int16)(_cursorState.hotX * screenScaleFactorX / 10000);
_cursorState.rHotY = (int16)(_cursorState.hotY * screenScaleFactorY / 10000);
- // Make sure we properly scale the cursor according to the desired aspect.
- // It might be noteworthy that, unlike with the overlay, we do not limit
- // the scale factor here to avoid odd looks if the game uses items as
- // mouse cursor, which would otherwise suddenly be smaller.
- int width, height;
- calculateDisplaySize(width, height);
- screenScaleFactorX = (width * 10000 / _videoMode.screenWidth) / _cursorTargetScale;
- screenScaleFactorY = (height * 10000 / _videoMode.screenHeight) / _cursorTargetScale;
+ // Only apply scaling when it's desired.
+ if (_cursorDontScale) {
+ screenScaleFactorX = 10000;
+ screenScaleFactorY = 10000;
+ } else {
+ // Make sure we properly scale the cursor according to the desired aspect.
+ int width, height;
+ calculateDisplaySize(width, height);
+ screenScaleFactorX = (width * 10000 / _videoMode.screenWidth);
+ screenScaleFactorY = (height * 10000 / _videoMode.screenHeight);
+ }
- // Always scale the cursor for the game.
+ // Apply the scale cursor scaling for the game screen.
_cursorState.vW = (int16)(_cursorState.w * screenScaleFactorX / 10000);
_cursorState.vH = (int16)(_cursorState.h * screenScaleFactorY / 10000);
_cursorState.vHotX = (int16)(_cursorState.hotX * screenScaleFactorX / 10000);
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index ad8765bab1..956722c08f 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -104,7 +104,7 @@ public:
virtual bool showMouse(bool visible);
virtual void warpMouse(int x, int y);
- virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL);
+ virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL);
virtual void setCursorPalette(const byte *colors, uint start, uint num);
virtual void displayMessageOnOSD(const char *msg);
@@ -283,7 +283,7 @@ protected:
MousePos _cursorState;
bool _cursorVisible;
uint32 _cursorKeyColor;
- int _cursorTargetScale;
+ bool _cursorDontScale;
bool _cursorNeedsRedraw;
/**
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index b37d631c6d..67041ae17b 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -160,7 +160,7 @@ void OpenGLSdlGraphicsManager::detectSupportedFormats() {
_hwscreen->format->Rshift, _hwscreen->format->Gshift,
_hwscreen->format->Bshift, _hwscreen->format->Ashift);
- // Workaround to MacOSX SDL not providing an accurate Aloss value.
+ // Workaround to SDL not providing an accurate Aloss value on Mac OS X.
if (_hwscreen->format->Amask == 0)
format.aLoss = 8;
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 9631c3c07e..652c08dc45 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -63,17 +63,12 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
DECLARE_TRANSLATION_ADDITIONAL_CONTEXT("Normal (no scaling)", "lowres")
-// Table of relative scalers magnitudes
-// [definedScale - 1][scaleFactor - 1]
-static ScalerProc *scalersMagn[3][3] = {
+// Table of the cursor scalers [scaleFactor - 1]
+static ScalerProc *scalersMagn[3] = {
#ifdef USE_SCALERS
- { Normal1x, AdvMame2x, AdvMame3x },
- { Normal1x, Normal1x, Normal1o5x },
- { Normal1x, Normal1x, Normal1x }
+ Normal1x, AdvMame2x, AdvMame3x
#else // remove dependencies on other scalers
- { Normal1x, Normal1x, Normal1x },
- { Normal1x, Normal1x, Normal1x },
- { Normal1x, Normal1x, Normal1x }
+ Normal1x, Normal1x, Normal1x
#endif
};
@@ -135,7 +130,7 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
_overlayscreen(0), _tmpscreen2(0),
_scalerProc(0), _screenChangeCount(0),
_mouseVisible(false), _mouseNeedsRedraw(false), _mouseData(0), _mouseSurface(0),
- _mouseOrigSurface(0), _cursorTargetScale(1), _cursorPaletteDisabled(true),
+ _mouseOrigSurface(0), _cursorDontScale(false), _cursorPaletteDisabled(true),
_currentShakePos(0), _newShakePos(0),
_paletteDirtyStart(0), _paletteDirtyEnd(0),
_screenIsLocked(false),
@@ -458,7 +453,7 @@ void SurfaceSdlGraphicsManager::detectSupportedFormats() {
_hwscreen->format->Rshift, _hwscreen->format->Gshift,
_hwscreen->format->Bshift, _hwscreen->format->Ashift);
- // Workaround to MacOSX SDL not providing an accurate Aloss value.
+ // Workaround to SDL not providing an accurate Aloss value on Mac OS X.
if (_hwscreen->format->Amask == 0)
format.aLoss = 8;
@@ -1718,7 +1713,7 @@ void SurfaceSdlGraphicsManager::warpMouse(int x, int y) {
}
}
-void SurfaceSdlGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
+void SurfaceSdlGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) {
#ifdef USE_RGB_COLOR
if (!format)
_cursorFormat = Graphics::PixelFormat::createFormatCLUT8();
@@ -1739,7 +1734,7 @@ void SurfaceSdlGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h,
_mouseKeyColor = keycolor;
- _cursorTargetScale = cursorTargetScale;
+ _cursorDontScale = dontScale;
if (_mouseCurState.w != (int)w || _mouseCurState.h != (int)h) {
_mouseCurState.w = w;
@@ -1847,51 +1842,34 @@ void SurfaceSdlGraphicsManager::blitCursor() {
}
int rW, rH;
+ int cursorScale;
- if (_cursorTargetScale >= _videoMode.scaleFactor) {
- // The cursor target scale is greater or equal to the scale at
- // which the rest of the screen is drawn. We do not downscale
- // the cursor image, we draw it at its original size. It will
- // appear too large on screen.
-
- rW = w;
- rH = h;
- _mouseCurState.rHotX = _mouseCurState.hotX;
- _mouseCurState.rHotY = _mouseCurState.hotY;
-
- // The virtual dimensions may be larger than the original.
-
- _mouseCurState.vW = w * _cursorTargetScale / _videoMode.scaleFactor;
- _mouseCurState.vH = h * _cursorTargetScale / _videoMode.scaleFactor;
- _mouseCurState.vHotX = _mouseCurState.hotX * _cursorTargetScale /
- _videoMode.scaleFactor;
- _mouseCurState.vHotY = _mouseCurState.hotY * _cursorTargetScale /
- _videoMode.scaleFactor;
+ if (_cursorDontScale) {
+ // Don't scale the cursor at all if the user requests this behavior.
+ cursorScale = 1;
} else {
- // The cursor target scale is smaller than the scale at which
- // the rest of the screen is drawn. We scale up the cursor
- // image to make it appear correct.
+ // Scale the cursor with the game screen scale factor.
+ cursorScale = _videoMode.scaleFactor;
+ }
- rW = w * _videoMode.scaleFactor / _cursorTargetScale;
- rH = h * _videoMode.scaleFactor / _cursorTargetScale;
- _mouseCurState.rHotX = _mouseCurState.hotX * _videoMode.scaleFactor /
- _cursorTargetScale;
- _mouseCurState.rHotY = _mouseCurState.hotY * _videoMode.scaleFactor /
- _cursorTargetScale;
+ // Adapt the real hotspot according to the scale factor.
+ rW = w * cursorScale;
+ rH = h * cursorScale;
+ _mouseCurState.rHotX = _mouseCurState.hotX * cursorScale;
+ _mouseCurState.rHotY = _mouseCurState.hotY * cursorScale;
- // The virtual dimensions will be the same as the original.
+ // The virtual dimensions will be the same as the original.
- _mouseCurState.vW = w;
- _mouseCurState.vH = h;
- _mouseCurState.vHotX = _mouseCurState.hotX;
- _mouseCurState.vHotY = _mouseCurState.hotY;
- }
+ _mouseCurState.vW = w;
+ _mouseCurState.vH = h;
+ _mouseCurState.vHotX = _mouseCurState.hotX;
+ _mouseCurState.vHotY = _mouseCurState.hotY;
#ifdef USE_SCALERS
int rH1 = rH; // store original to pass to aspect-correction function later
#endif
- if (_videoMode.aspectRatioCorrection && _cursorTargetScale == 1) {
+ if (!_cursorDontScale && _videoMode.aspectRatioCorrection) {
rH = real2Aspect(rH - 1) + 1;
_mouseCurState.rHotY = real2Aspect(_mouseCurState.rHotY);
}
@@ -1922,21 +1900,25 @@ void SurfaceSdlGraphicsManager::blitCursor() {
ScalerProc *scalerProc;
- // If possible, use the same scaler for the cursor as for the rest of
- // the game. This only works well with the non-blurring scalers so we
- // actually only use the 1x, 1.5x, 2x and AdvMame scalers.
-
- if (_cursorTargetScale == 1 && (_videoMode.mode == GFX_DOUBLESIZE || _videoMode.mode == GFX_TRIPLESIZE))
- scalerProc = _scalerProc;
- else
- scalerProc = scalersMagn[_cursorTargetScale - 1][_videoMode.scaleFactor - 1];
+ // Only apply scaling, when the user allows it.
+ if (!_cursorDontScale) {
+ // If possible, use the same scaler for the cursor as for the rest of
+ // the game. This only works well with the non-blurring scalers so we
+ // actually only use the 1x, 2x and AdvMame scalers.
+ if (_videoMode.mode == GFX_DOUBLESIZE || _videoMode.mode == GFX_TRIPLESIZE)
+ scalerProc = _scalerProc;
+ else
+ scalerProc = scalersMagn[_videoMode.scaleFactor - 1];
+ } else {
+ scalerProc = Normal1x;
+ }
scalerProc((byte *)_mouseOrigSurface->pixels + _mouseOrigSurface->pitch + 2,
_mouseOrigSurface->pitch, (byte *)_mouseSurface->pixels, _mouseSurface->pitch,
_mouseCurState.w, _mouseCurState.h);
#ifdef USE_SCALERS
- if (_videoMode.aspectRatioCorrection && _cursorTargetScale == 1)
+ if (!_cursorDontScale && _videoMode.aspectRatioCorrection)
cursorStretch200To240((uint8 *)_mouseSurface->pixels, _mouseSurface->pitch, rW, rH1, 0, 0, 0);
#endif
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index f71096d43e..32fb219bcd 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -131,7 +131,7 @@ public:
virtual bool showMouse(bool visible);
virtual void warpMouse(int x, int y);
- virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL);
+ virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL);
virtual void setCursorPalette(const byte *colors, uint start, uint num);
#ifdef USE_OSD
@@ -281,7 +281,7 @@ protected:
#else
byte _mouseKeyColor;
#endif
- int _cursorTargetScale;
+ bool _cursorDontScale;
bool _cursorPaletteDisabled;
SDL_Surface *_mouseOrigSurface;
SDL_Surface *_mouseSurface;
diff --git a/backends/graphics/wincesdl/wincesdl-graphics.cpp b/backends/graphics/wincesdl/wincesdl-graphics.cpp
index 58b735ef8b..bb79813f3b 100644
--- a/backends/graphics/wincesdl/wincesdl-graphics.cpp
+++ b/backends/graphics/wincesdl/wincesdl-graphics.cpp
@@ -1128,7 +1128,7 @@ void WINCESdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int x
SDL_UnlockSurface(_screen);
}
-void WINCESdlGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
+void WINCESdlGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) {
undrawMouse();
if (w == 0 || h == 0)
diff --git a/backends/graphics/wincesdl/wincesdl-graphics.h b/backends/graphics/wincesdl/wincesdl-graphics.h
index 2e8c3313b3..7cff8a16d9 100644
--- a/backends/graphics/wincesdl/wincesdl-graphics.h
+++ b/backends/graphics/wincesdl/wincesdl-graphics.h
@@ -73,7 +73,7 @@ public:
void internDrawMouse();
void undrawMouse();
bool showMouse(bool visible);
- void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); // overloaded by CE backend
+ void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format); // overloaded by CE backend
void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h); // overloaded by CE backend (FIXME)
Graphics::Surface *lockScreen();