[Scummvm-cvs-logs] SF.net SVN: scummvm:[41825] scummvm/branches/gsoc2009-16bit
upthorn at users.sourceforge.net
upthorn at users.sourceforge.net
Wed Jun 24 08:44:30 CEST 2009
Revision: 41825
http://scummvm.svn.sourceforge.net/scummvm/?rev=41825&view=rev
Author: upthorn
Date: 2009-06-24 06:44:30 +0000 (Wed, 24 Jun 2009)
Log Message:
-----------
made the cursor's pixel format a member of the cursor object, merged ____CursorFormat functions into equivalent ____Cursor functions.
Modified Paths:
--------------
scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp
scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h
scummvm/branches/gsoc2009-16bit/common/system.h
scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp
scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp
scummvm/branches/gsoc2009-16bit/graphics/cursorman.h
scummvm/branches/gsoc2009-16bit/gui/GuiManager.cpp
scummvm/branches/gsoc2009-16bit/gui/ThemeEngine.cpp
Modified: scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp 2009-06-24 00:36:49 UTC (rev 41824)
+++ scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp 2009-06-24 06:44:30 UTC (rev 41825)
@@ -1378,8 +1378,10 @@
}
}
-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;
Modified: scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h 2009-06-24 00:36:49 UTC (rev 41824)
+++ scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h 2009-06-24 06:44:30 UTC (rev 41825)
@@ -135,7 +135,7 @@
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
Modified: scummvm/branches/gsoc2009-16bit/common/system.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/common/system.h 2009-06-24 00:36:49 UTC (rev 41824)
+++ scummvm/branches/gsoc2009-16bit/common/system.h 2009-06-24 06:44:30 UTC (rev 41825)
@@ -714,8 +714,9 @@
* @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
Modified: scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp 2009-06-24 00:36:49 UTC (rev 41824)
+++ scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp 2009-06-24 06:44:30 UTC (rev 41825)
@@ -113,12 +113,17 @@
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) {
Modified: scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp 2009-06-24 00:36:49 UTC (rev 41824)
+++ scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp 2009-06-24 06:44:30 UTC (rev 41825)
@@ -57,14 +57,14 @@
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 @@
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 @@
}
}
-#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 @@
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 @@
}
}
-#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
Modified: scummvm/branches/gsoc2009-16bit/graphics/cursorman.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/cursorman.h 2009-06-24 00:36:49 UTC (rev 41824)
+++ scummvm/branches/gsoc2009-16bit/graphics/cursorman.h 2009-06-24 06:44:30 UTC (rev 41825)
@@ -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 @@
* @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 @@
* @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 @@
*/
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 @@
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 @@
};
Common::Stack<Cursor *> _cursorStack;
Common::Stack<Palette *> _cursorPaletteStack;
-#ifdef ENABLE_RGB_COLOR
- Common::Stack<Graphics::PixelFormat *> _cursorFormatStack;
-#endif
};
} // End of namespace Graphics
Modified: scummvm/branches/gsoc2009-16bit/gui/GuiManager.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/gui/GuiManager.cpp 2009-06-24 00:36:49 UTC (rev 41824)
+++ scummvm/branches/gsoc2009-16bit/gui/GuiManager.cpp 2009-06-24 06:44:30 UTC (rev 41825)
@@ -135,9 +135,6 @@
delete _theme;
if (_useStdCursor) {
-#ifdef ENABLE_RGB_COLOR
- CursorMan.popCursorFormat();
-#endif
CursorMan.popCursorPalette();
CursorMan.popCursor();
}
@@ -385,9 +382,6 @@
void GuiManager::restoreState() {
if (_useStdCursor) {
-#ifdef ENABLE_RGB_COLOR
- CursorMan.popCursorFormat();
-#endif
CursorMan.popCursor();
CursorMan.popCursorPalette();
}
@@ -430,14 +424,6 @@
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);
Modified: scummvm/branches/gsoc2009-16bit/gui/ThemeEngine.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/gui/ThemeEngine.cpp 2009-06-24 00:36:49 UTC (rev 41824)
+++ scummvm/branches/gsoc2009-16bit/gui/ThemeEngine.cpp 2009-06-24 06:44:30 UTC (rev 41825)
@@ -434,9 +434,6 @@
_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 @@
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 @@
_system->hideOverlay();
if (_useCursor) {
-#ifdef ENABLE_RGB_COLOR
- CursorMan.popCursorFormat();
-#endif
CursorMan.popCursorPalette();
CursorMan.popCursor();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list