From f8361b5c53b96faddb56024bb932ce46b7005dbf Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 5 Jun 2009 06:41:04 +0000 Subject: Converted cursor code to use 16-bit. svn-id: r41191 --- graphics/cursorman.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index fe5f653b94..f303749572 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -108,7 +108,11 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, } Cursor *cur = _cursorStack.top(); +#ifdef ENABLE_16BIT + uint size = w * h * 2; +#else uint size = w * h; +#endif if (cur->_size < size) { delete[] cur->_data; -- cgit v1.2.3 From 9789ba7f28d2c0a093adda01435306f28e91fede Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 5 Jun 2009 08:09:37 +0000 Subject: Corrected backend to be able to accept a 16-bit mouseKeyColor without overflow svn-id: r41194 --- graphics/cursorman.cpp | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index f303749572..84578a3911 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -100,6 +100,37 @@ void CursorManager::popAllCursors() { g_system->showMouse(isVisible()); } +#ifdef ENABLE_16BIT +//HACK Made a separate method to avoid massive linker errors on every engine +void CursorManager::replaceCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor, int targetScale) { + if (_cursorStack.empty()) { + pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale); + return; + } + + Cursor *cur = _cursorStack.top(); + + uint size = w * h * 2; + + if (cur->_size < size) { + delete[] cur->_data; + cur->_data = new byte[size]; + cur->_size = size; + } + + if (buf && cur->_data) + memcpy(cur->_data, buf, size); + + cur->_width = w; + cur->_height = h; + cur->_hotspotX = hotspotX; + cur->_hotspotY = hotspotY; + cur->_keycolor = keycolor; + cur->_targetScale = targetScale; + + g_system->setMouseCursor16(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale); +} +#endif void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) { if (_cursorStack.empty()) { @@ -108,11 +139,8 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, } Cursor *cur = _cursorStack.top(); -#ifdef ENABLE_16BIT - uint size = w * h * 2; -#else + uint size = w * h; -#endif if (cur->_size < size) { delete[] cur->_data; -- cgit v1.2.3 From d65bbe1d7a5efbcf04831dbb68a45ca833db1ae1 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 5 Jun 2009 23:59:40 +0000 Subject: Fixes ScummEngine_v70he::setDefaultCursor to work in 16-bit, using a temporary hack. svn-id: r41204 --- graphics/cursorman.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 84578a3911..5fe58314b3 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -56,6 +56,33 @@ bool CursorManager::showMouse(bool visible) { // Should work, even if there's just a dummy cursor on the stack. return g_system->showMouse(visible); } +#ifdef ENABLE_16BIT +void CursorManager::pushCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor, int targetScale) { + Cursor16 *cur = new Cursor16(buf, w, h, hotspotX, hotspotY, keycolor, targetScale); + + cur->_visible = isVisible(); + _cursor16Stack.push(cur); + + if (buf) { + g_system->setMouseCursor16(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale); + } +} + +void CursorManager::popCursor16() { + if (_cursor16Stack.empty()) + return; + + Cursor16 *cur = _cursor16Stack.pop(); + delete cur; + + if (!_cursorStack.empty()) { + cur = _cursor16Stack.top(); + g_system->setMouseCursor16(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale); + } + + g_system->showMouse(isVisible()); +} +#endif void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) { Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale); @@ -104,7 +131,7 @@ void CursorManager::popAllCursors() { //HACK Made a separate method to avoid massive linker errors on every engine void CursorManager::replaceCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor, int targetScale) { if (_cursorStack.empty()) { - pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale); + pushCursor16(buf, w, h, hotspotX, hotspotY, keycolor, targetScale); return; } -- cgit v1.2.3 From 56e5920bba753820c457c078237a8c06241302ed Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 6 Jun 2009 01:16:04 +0000 Subject: Corrected cursor display errors introduced by revision 41204, reimplemented 16-bit cursor support in a less hacky, but still temporary way. svn-id: r41209 --- graphics/cursorman.cpp | 96 ++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 53 deletions(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 5fe58314b3..00932e55b0 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -56,42 +56,34 @@ bool CursorManager::showMouse(bool visible) { // Should work, even if there's just a dummy cursor on the stack. return g_system->showMouse(visible); } -#ifdef ENABLE_16BIT -void CursorManager::pushCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor, int targetScale) { - Cursor16 *cur = new Cursor16(buf, w, h, hotspotX, hotspotY, keycolor, targetScale); - - cur->_visible = isVisible(); - _cursor16Stack.push(cur); - if (buf) { - g_system->setMouseCursor16(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale); - } +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::popCursor16() { - if (_cursor16Stack.empty()) - return; - - Cursor16 *cur = _cursor16Stack.pop(); - delete cur; - - if (!_cursorStack.empty()) { - cur = _cursor16Stack.top(); - g_system->setMouseCursor16(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale); +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; - g_system->showMouse(isVisible()); -} -#endif - -void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) { + Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale, bitDepth); +#else Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale); +#endif 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 } } @@ -104,7 +96,11 @@ 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()); @@ -127,47 +123,37 @@ 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 -//HACK Made a separate method to avoid massive linker errors on every engine -void CursorManager::replaceCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor, int targetScale) { - if (_cursorStack.empty()) { - pushCursor16(buf, w, h, hotspotX, hotspotY, keycolor, targetScale); - return; - } - - Cursor *cur = _cursorStack.top(); - - uint size = w * h * 2; + replaceCursorReal(buf,w,h,hotspotX,hotspotY,keycolor,targetScale); +} - if (cur->_size < size) { - delete[] cur->_data; - cur->_data = new byte[size]; - cur->_size = size; +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; - if (buf && cur->_data) - memcpy(cur->_data, buf, size); - - cur->_width = w; - cur->_height = h; - cur->_hotspotX = hotspotX; - cur->_hotspotY = hotspotY; - cur->_keycolor = keycolor; - cur->_targetScale = targetScale; - - g_system->setMouseCursor16(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale); -} #endif - -void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) { 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); +#else uint size = w * h; +#endif if (cur->_size < size) { delete[] cur->_data; @@ -185,7 +171,11 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, 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 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 From 350dc4290fd5dd8f28af9e63713b48ef2c131f09 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 13 Jun 2009 10:24:52 +0000 Subject: Fixed cursor code to keep track of cursor formats so that ThemeEngine and/or GuiManager cursors will render properly over the game (on spacebar hit, for instance) svn-id: r41491 --- graphics/cursorman.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 850b0044dc..e5a86b6bd8 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -101,6 +101,13 @@ void CursorManager::popAllCursors() { } } +#ifdef ENABLE_16BIT + while (!_cursorFormatStack.empty()) { + PixelFormat *form = _cursorFormatStack.pop(); + delete form; + } +#endif + g_system->showMouse(isVisible()); } @@ -118,8 +125,8 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, Cursor *cur = _cursorStack.top(); #ifdef ENABLE_16BIT - uint size; - { //limit the lifespan of the format variable to minimize memory impact + uint size; + { //limit the lifespan of the format variable to minimize memory impact Graphics::PixelFormat f = g_system->getScreenFormat(); size = w * h * (f.bytesPerPixel); } @@ -225,4 +232,48 @@ void CursorManager::replaceCursorPalette(const byte *colors, uint start, uint nu } } +#ifdef ENABLE_16BIT +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 -- cgit v1.2.3 From fb96e826f27b071d6696731f43cb5fa0d8760205 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 16 Jun 2009 05:33:11 +0000 Subject: Simplified cursor related 16-bit code. svn-id: r41577 --- graphics/cursorman.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index e5a86b6bd8..6446216867 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -57,11 +57,7 @@ bool CursorManager::showMouse(bool visible) { return g_system->showMouse(visible); } -#ifdef ENABLE_16BIT void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale) { -#else -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(); @@ -111,11 +107,7 @@ void CursorManager::popAllCursors() { g_system->showMouse(isVisible()); } -#ifdef ENABLE_16BIT 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()) { pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale); @@ -125,11 +117,7 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, Cursor *cur = _cursorStack.top(); #ifdef ENABLE_16BIT - uint size; - { //limit the lifespan of the format variable to minimize memory impact - Graphics::PixelFormat f = g_system->getScreenFormat(); - size = w * h * (f.bytesPerPixel); - } + uint size = w * h * g_system->getScreenFormat().bytesPerPixel; #else uint size = w * h; #endif -- cgit v1.2.3 From f7dd1c15ed38418a0371032966144eb6c2e004cb Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 20 Jun 2009 05:23:09 +0000 Subject: renamed ENABLE_16BIT define to more accurate ENABLE_RGB_COLOR svn-id: r41696 --- graphics/cursorman.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 6446216867..865c7515f0 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -97,7 +97,7 @@ void CursorManager::popAllCursors() { } } -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR while (!_cursorFormatStack.empty()) { PixelFormat *form = _cursorFormatStack.pop(); delete form; @@ -116,7 +116,7 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, Cursor *cur = _cursorStack.top(); -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR uint size = w * h * g_system->getScreenFormat().bytesPerPixel; #else uint size = w * h; @@ -220,7 +220,7 @@ void CursorManager::replaceCursorPalette(const byte *colors, uint start, uint nu } } -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR void CursorManager::pushCursorFormat(PixelFormat format) { // if (!g_system->hasFeature(OSystem::kFeatureCursorHasPalette)) // return; -- cgit v1.2.3 From 865129a5630017f05d08e778ba1ef430c23cd55a Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Wed, 24 Jun 2009 06:44:30 +0000 Subject: made the cursor's pixel format a member of the cursor object, merged ____CursorFormat functions into equivalent ____Cursor functions. svn-id: r41825 --- graphics/cursorman.cpp | 70 ++++++++------------------------------------------ 1 file changed, 11 insertions(+), 59 deletions(-) (limited to 'graphics/cursorman.cpp') 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 -- cgit v1.2.3 From 2859c9130462e66df705d534f9a70d1430628be7 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 26 Jun 2009 08:50:11 +0000 Subject: Changed cursor manager functions to take *Graphics::PixelFormat with default parameter of NULL (and initialize NULL pointers with CLUT8), rather than taking a Graphics::PixelFormat with default parameter of Graphics::PixelFormat::createFormatCLUT8() svn-id: r41900 --- graphics/cursorman.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 76ebb9b455..574950a09b 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, Graphics::PixelFormat format) { +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, format); + g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, *format); } } @@ -100,7 +100,7 @@ void CursorManager::popAllCursors() { g_system->showMouse(isVisible()); } -void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, Graphics::PixelFormat format) { +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, format); @@ -110,7 +110,10 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, Cursor *cur = _cursorStack.top(); #ifdef ENABLE_RGB_COLOR - uint size = w * h * format.bytesPerPixel; + if (!format) + format = new Graphics::PixelFormat(1,8,8,8,8,0,0,0,0); + + uint size = w * h * format->bytesPerPixel; #else uint size = w * h; #endif @@ -131,10 +134,10 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, cur->_keycolor = keycolor; cur->_targetScale = targetScale; #ifdef ENABLE_RGB_COLOR - cur->_format = format; + cur->_format = *format; #endif - g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, format); + g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, *format); } void CursorManager::disableCursorPalette(bool disable) { -- cgit v1.2.3 From 27e50db5d7cdbed498d6a61b1ee1ad5405ce33a2 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 26 Jun 2009 10:37:00 +0000 Subject: Converted OSystem::SetMouseCursor to take pointer to PixelFormat, instead of full PixelFormat. Removed OSystem::setCursorFormat (since I forgot to do so several commits ago) svn-id: r41901 --- graphics/cursorman.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 574950a09b..bf6de44fbf 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -64,7 +64,7 @@ void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, in _cursorStack.push(cur); if (buf) { - g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, *format); + 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, cur->_format); + g_system->setMouseCursor(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale, &(cur->_format)); } g_system->showMouse(isVisible()); @@ -137,7 +137,7 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, cur->_format = *format; #endif - g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, *format); + g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, format); } void CursorManager::disableCursorPalette(bool disable) { -- cgit v1.2.3 From 9e1916bcad3cc33a870bdbff5bd01b39e523492d Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 30 Jun 2009 07:30:57 +0000 Subject: renamed kTransactionPixelFormatNotSupported to kTransactionFormatNotSupported, retyped all Graphics::PixelFormat * parameters to const Graphics::PixelFormat *, (hopefully) repaired all memory leaks on screen and cursor format changes, provided OSystem::getScreenFormat and OSystem::getSupportedFormats methods for when ENABLE_RGB_COLOR is not set, completely forgot the "commit early, commit often" mantra. svn-id: r41972 --- graphics/cursorman.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index bf6de44fbf..b35bbe73ae 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -57,7 +57,7 @@ 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, Graphics::PixelFormat *format) { +void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, const Graphics::PixelFormat *format) { Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale, format); cur->_visible = isVisible(); @@ -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, &(cur->_format)); + g_system->setMouseCursor(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale, cur->_format); } g_system->showMouse(isVisible()); @@ -100,7 +100,7 @@ void CursorManager::popAllCursors() { g_system->showMouse(isVisible()); } -void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, Graphics::PixelFormat *format) { +void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, const Graphics::PixelFormat *format) { if (_cursorStack.empty()) { pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale, format); @@ -110,10 +110,10 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, Cursor *cur = _cursorStack.top(); #ifdef ENABLE_RGB_COLOR + uint size; if (!format) - format = new Graphics::PixelFormat(1,8,8,8,8,0,0,0,0); - - uint size = w * h * format->bytesPerPixel; + size = w * h; + else size = w * h * format->bytesPerPixel; #else uint size = w * h; #endif @@ -134,7 +134,7 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, cur->_keycolor = keycolor; cur->_targetScale = targetScale; #ifdef ENABLE_RGB_COLOR - cur->_format = *format; + cur->_format = format; #endif g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, format); -- cgit v1.2.3 From 5e9285e8fa8eb2f0b01abc6caf93dc926f41d795 Mon Sep 17 00:00:00 2001 From: Jordi Vilalta Prat Date: Tue, 30 Jun 2009 08:25:08 +0000 Subject: Fixed a few formatting bits svn-id: r41973 --- graphics/cursorman.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index b35bbe73ae..08a0b3bb88 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -113,7 +113,8 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, uint size; if (!format) size = w * h; - else size = w * h * format->bytesPerPixel; + else + size = w * h * format->bytesPerPixel; #else uint size = w * h; #endif -- cgit v1.2.3 From 6ef485f44896ad778d355bc1201f2f143cc9e770 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 4 Jul 2009 04:13:10 +0000 Subject: Fixed cursor corruption in non-8bit graphics games when switching back from overlay. svn-id: r42084 --- graphics/cursorman.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 08a0b3bb88..9559b59d4a 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -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, cur->_format); + g_system->setMouseCursor(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale, &cur->_format); } g_system->showMouse(isVisible()); @@ -135,7 +135,10 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, cur->_keycolor = keycolor; cur->_targetScale = targetScale; #ifdef ENABLE_RGB_COLOR - cur->_format = format; + if (format) + cur->_format = *format; + else + cur->_format = Graphics::PixelFormat::createFormatCLUT8(); #endif g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, format); -- cgit v1.2.3 From 2c5d11b67b35f93b2292c1ca56d0c9fc89608921 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 7 Jul 2009 07:50:40 +0000 Subject: Removed PixelFormat convenience constructors at behest of Max and Eugene. svn-id: r42207 --- graphics/cursorman.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index b77aac37cf..3dd7c1d023 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -138,7 +138,7 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, if (format) cur->_format = *format; else - cur->_format = Graphics::PixelFormat::createFormatCLUT8(); + cur->_format = Graphics::PixelFormat(1, 8, 8, 8, 8, 0, 0, 0, 0); #endif g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, format); -- cgit v1.2.3 From 828ed66555b99363fed62b4cbb83c36de68c3024 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Wed, 8 Jul 2009 16:07:58 +0000 Subject: Reinstated static inline Graphics::PixelFormat::createFormatCLUT8(), which I am told was not supposed to be removed with the others. svn-id: r42268 --- graphics/cursorman.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics/cursorman.cpp') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 3dd7c1d023..b77aac37cf 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -138,7 +138,7 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, if (format) cur->_format = *format; else - cur->_format = Graphics::PixelFormat(1, 8, 8, 8, 8, 0, 0, 0, 0); + cur->_format = Graphics::PixelFormat::createFormatCLUT8(); #endif g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, format); -- cgit v1.2.3