From 6adbd0c41e79b5a21f0430e060347d4978e9ce78 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Thu, 11 Jun 2009 05:56:00 +0000 Subject: Renamed Graphics::ColorFormat to Graphics::ColorMode, streamlined enum by removing order section and temporarily removing kFormatARGB1555 Converted cursor code to make use of _screenFormat, instead of a parameter passed directly to it by the engine. Adjusted scumm engine to account for these changes. This should probably have been two separate commits, but the changes concern the same files... svn-id: r41443 --- graphics/cursorman.cpp | 56 +++++++++++--------------------------------------- 1 file changed, 12 insertions(+), 44 deletions(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 00932e55b0..850b0044dc 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -57,33 +57,18 @@ bool CursorManager::showMouse(bool visible) { return g_system->showMouse(visible); } -void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) { #ifdef ENABLE_16BIT - pushCursorReal(buf,w,h,hotspotX,hotspotY,keycolor,targetScale,8); -} -void CursorManager::pushCursorReal(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, uint8 bitDepth) { - uint32 colmask = 0xFF; - uint8 byteDepth = bitDepth >> 3; - for (int i = byteDepth; i > 1; i--) { - colmask <<= 8; - colmask |= 0xFF; - } - keycolor &= colmask; - - Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale, bitDepth); +void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale) { #else - 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, byte keycolor, int targetScale) { #endif + Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale); cur->_visible = isVisible(); _cursorStack.push(cur); if (buf) { -#ifdef ENABLE_16BIT - g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, bitDepth); -#else g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale); -#endif } } @@ -96,11 +81,7 @@ void CursorManager::popCursor() { if (!_cursorStack.empty()) { cur = _cursorStack.top(); -#ifdef ENABLE_16BIT - g_system->setMouseCursor(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale, cur->_bitDepth); -#else g_system->setMouseCursor(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale); -#endif } g_system->showMouse(isVisible()); @@ -123,34 +104,25 @@ void CursorManager::popAllCursors() { g_system->showMouse(isVisible()); } -void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) { #ifdef ENABLE_16BIT - replaceCursorReal(buf,w,h,hotspotX,hotspotY,keycolor,targetScale); -} - -void CursorManager::replaceCursorReal(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, uint8 bitDepth) { - uint32 colmask = 0xFF; - uint8 byteDepth = bitDepth >> 3; - for (int i = byteDepth; i > 1; i--) { - colmask <<= 8; - colmask |= 0xFF; - } - keycolor &= colmask; - +void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale) { +#else +void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) { #endif + if (_cursorStack.empty()) { -#ifdef ENABLE_16BIT - pushCursorReal(buf, w, h, hotspotX, hotspotY, keycolor, targetScale, bitDepth); -#else pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale); -#endif return; } Cursor *cur = _cursorStack.top(); #ifdef ENABLE_16BIT - uint size = w * h * (bitDepth >> 3); + uint size; + { //limit the lifespan of the format variable to minimize memory impact + Graphics::PixelFormat f = g_system->getScreenFormat(); + size = w * h * (f.bytesPerPixel); + } #else uint size = w * h; #endif @@ -171,11 +143,7 @@ void CursorManager::replaceCursorReal(const byte *buf, uint w, uint h, int hotsp cur->_keycolor = keycolor; cur->_targetScale = targetScale; -#ifdef ENABLE_16BIT - g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, bitDepth); -#else g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale); -#endif } void CursorManager::disableCursorPalette(bool disable) { -- cgit v1.2.3