aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/sdl/graphics.cpp4
-rw-r--r--backends/platform/sdl/sdl.h2
-rw-r--r--common/system.h3
-rw-r--r--engines/scumm/cursor.cpp9
-rw-r--r--graphics/cursorman.cpp70
-rw-r--r--graphics/cursorman.h51
-rw-r--r--gui/GuiManager.cpp14
-rw-r--r--gui/ThemeEngine.cpp9
8 files changed, 36 insertions, 126 deletions
diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp
index b5ec9b9db8..d7cabd00cc 100644
--- a/backends/platform/sdl/graphics.cpp
+++ b/backends/platform/sdl/graphics.cpp
@@ -1378,8 +1378,10 @@ void OSystem_SDL::warpMouse(int x, int y) {
}
}
-void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale) {
+void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, Graphics::PixelFormat format) {
#ifdef ENABLE_RGB_COLOR
+ if (format.bytesPerPixel <= _screenFormat.bytesPerPixel)
+ _cursorFormat = format;
keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1;
#else
keycolor &= 0xFF;
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index db855094cb..7aeebf9264 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -135,7 +135,7 @@ public:
virtual void warpMouse(int x, int y); // overloaded by CE backend (FIXME)
// Set the bitmap that's used when drawing the cursor.
- virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME)
+ virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, Graphics::PixelFormat format); // overloaded by CE backend (FIXME)
#ifdef ENABLE_RGB_COLOR
virtual void setCursorFormat(Graphics::PixelFormat format);
#endif
diff --git a/common/system.h b/common/system.h
index 1f91fc900d..fad9cf378a 100644
--- a/common/system.h
+++ b/common/system.h
@@ -714,8 +714,9 @@ public:
* @param hotspotY vertical offset from the top side to the hotspot
* @param keycolor transparency color index
* @param cursorTargetScale scale factor which cursor is designed for
+ * @param format pixel format which cursor graphic uses
*/
- virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int cursorTargetScale = 1) = 0;
+ virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int cursorTargetScale = 1, Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8()) = 0;
#ifdef ENABLE_RGB_COLOR
virtual void setCursorFormat(Graphics::PixelFormat format) = 0;
#endif
diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp
index 5c695e58a5..190c337c63 100644
--- a/engines/scumm/cursor.cpp
+++ b/engines/scumm/cursor.cpp
@@ -113,12 +113,17 @@ void ScummEngine_v6::setCursorTransparency(int a) {
void ScummEngine::updateCursor() {
int transColor = (_game.heversion >= 80) ? 5 : 255;
#ifdef ENABLE_RGB_COLOR
- CursorMan.replaceCursorFormat(_system->getScreenFormat());
-#endif
+ CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height,
+ _cursor.hotspotX, _cursor.hotspotY,
+ (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor),
+ (_game.heversion == 70 ? 2 : 1),
+ _system->getScreenFormat());
+#else
CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height,
_cursor.hotspotX, _cursor.hotspotY,
(_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor),
(_game.heversion == 70 ? 2 : 1));
+#endif
}
void ScummEngine_v6::grabCursor(int x, int y, int w, int h) {
diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp
index 865c7515f0..76ebb9b455 100644
--- a/graphics/cursorman.cpp
+++ b/graphics/cursorman.cpp
@@ -57,14 +57,14 @@ bool CursorManager::showMouse(bool visible) {
return g_system->showMouse(visible);
}
-void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale) {
- Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale);
+void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, Graphics::PixelFormat format) {
+ Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale, format);
cur->_visible = isVisible();
_cursorStack.push(cur);
if (buf) {
- g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale);
+ g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, format);
}
}
@@ -77,7 +77,7 @@ void CursorManager::popCursor() {
if (!_cursorStack.empty()) {
cur = _cursorStack.top();
- g_system->setMouseCursor(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale);
+ g_system->setMouseCursor(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale, cur->_format);
}
g_system->showMouse(isVisible());
@@ -97,27 +97,20 @@ void CursorManager::popAllCursors() {
}
}
-#ifdef ENABLE_RGB_COLOR
- while (!_cursorFormatStack.empty()) {
- PixelFormat *form = _cursorFormatStack.pop();
- delete form;
- }
-#endif
-
g_system->showMouse(isVisible());
}
-void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale) {
+void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, Graphics::PixelFormat format) {
if (_cursorStack.empty()) {
- pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale);
+ pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale, format);
return;
}
Cursor *cur = _cursorStack.top();
#ifdef ENABLE_RGB_COLOR
- uint size = w * h * g_system->getScreenFormat().bytesPerPixel;
+ uint size = w * h * format.bytesPerPixel;
#else
uint size = w * h;
#endif
@@ -137,8 +130,11 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX,
cur->_hotspotY = hotspotY;
cur->_keycolor = keycolor;
cur->_targetScale = targetScale;
+#ifdef ENABLE_RGB_COLOR
+ cur->_format = format;
+#endif
- g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale);
+ g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, format);
}
void CursorManager::disableCursorPalette(bool disable) {
@@ -220,48 +216,4 @@ void CursorManager::replaceCursorPalette(const byte *colors, uint start, uint nu
}
}
-#ifdef ENABLE_RGB_COLOR
-void CursorManager::pushCursorFormat(PixelFormat format) {
-// if (!g_system->hasFeature(OSystem::kFeatureCursorHasPalette))
-// return;
- PixelFormat *form = new PixelFormat(format);
-
- _cursorFormatStack.push(form);
- g_system->setCursorFormat(format);
-}
-
-void CursorManager::popCursorFormat() {
-
- if (_cursorFormatStack.empty())
- return;
-
- PixelFormat *form = _cursorFormatStack.pop();
- delete form;
-
- if (_cursorFormatStack.empty()) {
- g_system->setCursorFormat(g_system->getScreenFormat());
- return;
- }
-
- form = _cursorFormatStack.top();
- disableCursorPalette(form->bytesPerPixel != 1);
-
- g_system->setCursorFormat(*form);
-}
-
-void CursorManager::replaceCursorFormat(PixelFormat format) {
-// if (!g_system->hasFeature(OSystem::kFeatureCursorHasPalette))
-// return;
-
- if (_cursorFormatStack.empty()) {
- pushCursorFormat(format);
- return;
- }
-
- PixelFormat *form = _cursorFormatStack.top();
-
- g_system->setCursorFormat(*form);
-}
-#endif
-
} // End of namespace Graphics
diff --git a/graphics/cursorman.h b/graphics/cursorman.h
index b28145d932..1ac711caec 100644
--- a/graphics/cursorman.h
+++ b/graphics/cursorman.h
@@ -28,8 +28,8 @@
#include "common/scummsys.h"
#include "common/stack.h"
#include "common/singleton.h"
-#ifdef ENABLE_RGB_COLOR
#include "graphics/pixelformat.h"
+#ifdef ENABLE_RGB_COLOR
#include "common/system.h"
#endif
@@ -55,12 +55,13 @@ public:
* @param hotspotY the hotspot Y coordinate
* @param keycolor the index for the transparent color
* @param targetScale the scale for which the cursor is designed
+ * @param format the pixel format which the cursor graphic uses
*
* @note It is ok for the buffer to be a NULL pointer. It is sometimes
* useful to push a "dummy" cursor and modify it later. The
* cursor will be added to the stack, but not to the backend.
*/
- void pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1);
+ void pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8());
/**
* Pop a cursor from the stack, and restore the previous one to the
@@ -80,8 +81,9 @@ public:
* @param hotspotY the hotspot Y coordinate
* @param keycolor the index for the transparent color
* @param targetScale the scale for which the cursor is designed
+ * @param format the pixel format which the cursor graphic uses
*/
- void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1);
+ void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8());
/**
* Pop all of the cursors and cursor palettes from their respective stacks.
@@ -134,31 +136,6 @@ public:
*/
void replaceCursorPalette(const byte *colors, uint start, uint num);
-#ifdef ENABLE_RGB_COLOR
- /**
- * Push a new cursor pixel format onto the stack, and set it in the backend.
- *
- * @param format the new format data, in a Graphics::PixelFormat
- */
- void pushCursorFormat(PixelFormat format);
-
- /**
- * Pop a cursor pixel format from the stack, and restore the previous one to
- * the backend. If there is no previous format, the screen format is
- * used instead.
- */
- void popCursorFormat();
-
- /**
- * Replace the current cursor pixel format on the stack. If the stack is
- * empty, the format is pushed instead. It's a slightly more optimized
- * way of popping the old format before pushing the new one.
- *
- * @param format the new format data, in a Graphics::PixelFormat
- */
- void replaceCursorFormat(PixelFormat format);
-#endif
-
private:
friend class Common::Singleton<SingletonBaseType>;
CursorManager();
@@ -171,18 +148,17 @@ private:
int _hotspotX;
int _hotspotY;
uint32 _keycolor;
-
+#ifdef ENABLE_RGB_COLOR
+ Graphics::PixelFormat _format;
+#endif
byte _targetScale;
-
uint _size;
- Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, uint8 bitDepth = 8) {
+ Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8()) {
#ifdef ENABLE_RGB_COLOR
- { //limit the lifespan of the format value to minimize impact on memory usage
- Graphics::PixelFormat f = g_system->getScreenFormat();
- _size = w * h * f.bytesPerPixel;
- _keycolor = keycolor & ((1 << (f.bytesPerPixel << 3)) - 1);
- }
+ _size = w * h * format.bytesPerPixel;
+ _keycolor = keycolor & ((1 << (format.bytesPerPixel << 3)) - 1);
+ _format = format;
#else
_size = w * h;
_keycolor = keycolor & 0xFF;
@@ -231,9 +207,6 @@ private:
};
Common::Stack<Cursor *> _cursorStack;
Common::Stack<Palette *> _cursorPaletteStack;
-#ifdef ENABLE_RGB_COLOR
- Common::Stack<Graphics::PixelFormat *> _cursorFormatStack;
-#endif
};
} // End of namespace Graphics
diff --git a/gui/GuiManager.cpp b/gui/GuiManager.cpp
index 8e161f3e60..cf8b7b2d9d 100644
--- a/gui/GuiManager.cpp
+++ b/gui/GuiManager.cpp
@@ -135,9 +135,6 @@ bool GuiManager::loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx)
delete _theme;
if (_useStdCursor) {
-#ifdef ENABLE_RGB_COLOR
- CursorMan.popCursorFormat();
-#endif
CursorMan.popCursorPalette();
CursorMan.popCursor();
}
@@ -385,9 +382,6 @@ void GuiManager::saveState() {
void GuiManager::restoreState() {
if (_useStdCursor) {
-#ifdef ENABLE_RGB_COLOR
- CursorMan.popCursorFormat();
-#endif
CursorMan.popCursor();
CursorMan.popCursorPalette();
}
@@ -430,14 +424,6 @@ void GuiManager::setupCursor() {
87, 87, 87, 0
};
-#ifdef ENABLE_RGB_COLOR
- Graphics::PixelFormat format;
- format.bytesPerPixel = 1;
- format.rLoss = format.gLoss = format.bLoss = format.aLoss = 8;
- format.rShift = format.gShift = format.bShift = format.aShift = 0;
-
- CursorMan.pushCursorFormat(format);
-#endif
CursorMan.pushCursorPalette(palette, 0, 4);
CursorMan.pushCursor(NULL, 0, 0, 0, 0);
CursorMan.showMouse(true);
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 70b295b989..6041fb8858 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -434,9 +434,6 @@ void ThemeEngine::refresh() {
_system->showOverlay();
if (_useCursor) {
-#ifdef ENABLE_RGB_COLOR
- CursorMan.replaceCursorFormat(_cursorFormat);
-#endif
CursorMan.replaceCursorPalette(_cursorPal, 0, _cursorPalSize);
CursorMan.replaceCursor(_cursor, _cursorWidth, _cursorHeight, _cursorHotspotX, _cursorHotspotY, 255, _cursorTargetScale);
}
@@ -448,9 +445,6 @@ void ThemeEngine::enable() {
return;
if (_useCursor) {
-#ifdef ENABLE_RGB_COLOR
- CursorMan.pushCursorFormat(_cursorFormat);
-#endif
CursorMan.pushCursorPalette(_cursorPal, 0, _cursorPalSize);
CursorMan.pushCursor(_cursor, _cursorWidth, _cursorHeight, _cursorHotspotX, _cursorHotspotY, 255, _cursorTargetScale);
CursorMan.showMouse(true);
@@ -468,9 +462,6 @@ void ThemeEngine::disable() {
_system->hideOverlay();
if (_useCursor) {
-#ifdef ENABLE_RGB_COLOR
- CursorMan.popCursorFormat();
-#endif
CursorMan.popCursorPalette();
CursorMan.popCursor();
}