aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'graphics')
-rw-r--r--graphics/cursorman.cpp70
-rw-r--r--graphics/cursorman.h51
2 files changed, 23 insertions, 98 deletions
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