diff options
| author | Norbert Lange | 2009-08-24 17:51:47 +0000 |
|---|---|---|
| committer | Norbert Lange | 2009-08-24 17:51:47 +0000 |
| commit | 917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5 (patch) | |
| tree | e652563203a00f8acecfaafbf93c64dbfbd13f25 /graphics | |
| parent | 5f87d5090cfcb34cda3c1f5d430e0865344d7366 (diff) | |
| parent | dd7868acc2512c9761d892e67a4837f4dc38bdc0 (diff) | |
| download | scummvm-rg350-917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5.tar.gz scummvm-rg350-917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5.tar.bz2 scummvm-rg350-917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5.zip | |
Merge with trunk
svn-id: r43701
Diffstat (limited to 'graphics')
| -rw-r--r-- | graphics/cursorman.cpp | 29 | ||||
| -rw-r--r-- | graphics/cursorman.h | 36 | ||||
| -rw-r--r-- | graphics/module.mk | 2 | ||||
| -rw-r--r-- | graphics/pixelformat.h | 39 | ||||
| -rw-r--r-- | graphics/scaler.cpp | 9 | ||||
| -rw-r--r-- | graphics/sjis.cpp | 5 | ||||
| -rw-r--r-- | graphics/video/coktelvideo/coktelvideo.cpp | 15 |
7 files changed, 109 insertions, 26 deletions
diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 2e71b548bc..0834760861 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, byte 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, const 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()); @@ -100,15 +100,24 @@ 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, const Graphics::PixelFormat *format) { -void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) { 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 USE_RGB_COLOR + uint size; + if (!format) + size = w * h; + else + size = w * h * format->bytesPerPixel; +#else uint size = w * h; +#endif if (cur->_size < size) { delete[] cur->_data; @@ -125,8 +134,14 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, cur->_hotspotY = hotspotY; cur->_keycolor = keycolor; cur->_targetScale = targetScale; +#ifdef USE_RGB_COLOR + if (format) + cur->_format = *format; + else + cur->_format = Graphics::PixelFormat::createFormatCLUT8(); +#endif - g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale); + g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, format); } bool CursorManager::supportsCursorPalettes() { diff --git a/graphics/cursorman.h b/graphics/cursorman.h index f019e37b04..f5b60d76b9 100644 --- a/graphics/cursorman.h +++ b/graphics/cursorman.h @@ -28,6 +28,10 @@ #include "common/scummsys.h" #include "common/stack.h" #include "common/singleton.h" +#include "graphics/pixelformat.h" +#ifdef USE_RGB_COLOR +#include "common/system.h" +#endif namespace Graphics { @@ -59,18 +63,19 @@ public: * safely freed afterwards. * * @param buf the new cursor data - * @param w the width - * @param h the height + * @param w the width + * @param h the height * @param hotspotX the hotspot X coordinate * @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 a pointer to the pixel format which the cursor graphic uses, + * CLUT8 will be used if this is NULL or not specified. * @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, byte keycolor = 255, int targetScale = 1); + void pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, const Graphics::PixelFormat *format = NULL); /** * Pop a cursor from the stack, and restore the previous one to the @@ -90,8 +95,10 @@ 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 a pointer to the pixel format which the cursor graphic uses, + * CLUT8 will be used if this is NULL or not specified. */ - void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int targetScale = 1); + void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, const Graphics::PixelFormat *format = NULL); /** * Pop all of the cursors and cursor palettes from their respective stacks. @@ -166,13 +173,24 @@ private: uint _height; int _hotspotX; int _hotspotY; - byte _keycolor; + uint32 _keycolor; + Graphics::PixelFormat _format; byte _targetScale; uint _size; - - Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int targetScale = 1) { + Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, const Graphics::PixelFormat *format = NULL) { +#ifdef USE_RGB_COLOR + if (!format) + _format = Graphics::PixelFormat::createFormatCLUT8(); + else + _format = *format; + _size = w * h * _format.bytesPerPixel; + _keycolor &= ((1 << (_format.bytesPerPixel << 3)) - 1); +#else + _format = Graphics::PixelFormat::createFormatCLUT8(); _size = w * h; + _keycolor &= 0xFF; +#endif _data = new byte[_size]; if (data && _data) memcpy(_data, data, _size); @@ -180,7 +198,6 @@ private: _height = h; _hotspotX = hotspotX; _hotspotY = hotspotY; - _keycolor = keycolor; _targetScale = targetScale; } @@ -216,7 +233,6 @@ private: delete[] _data; } }; - Common::Stack<Cursor *> _cursorStack; Common::Stack<Palette *> _cursorPaletteStack; }; diff --git a/graphics/module.mk b/graphics/module.mk index 46ed564e1e..ed14051243 100644 --- a/graphics/module.mk +++ b/graphics/module.mk @@ -1,6 +1,7 @@ MODULE := graphics MODULE_OBJS := \ + conversion.o \ cursorman.o \ dither.o \ font.o \ @@ -11,6 +12,7 @@ MODULE_OBJS := \ fonts/scummfont.o \ iff.o \ imagedec.o \ + jpeg.o \ primitives.o \ scaler.o \ scaler/thumbnail_intern.o \ diff --git a/graphics/pixelformat.h b/graphics/pixelformat.h index f59650e5cc..b94ef41412 100644 --- a/graphics/pixelformat.h +++ b/graphics/pixelformat.h @@ -27,6 +27,7 @@ #define GRAPHICS_PIXELFORMAT_H #include "common/scummsys.h" +#include "common/list.h" namespace Graphics { @@ -50,6 +51,24 @@ struct PixelFormat { byte rLoss, gLoss, bLoss, aLoss; /**< Precision loss of each color component. */ byte rShift, gShift, bShift, aShift; /**< Binary left shift of each color component in the pixel value. */ + inline PixelFormat() { + bytesPerPixel = + rLoss = gLoss = bLoss = aLoss = + rShift = gShift = bShift = aShift = 0; + } + + inline PixelFormat(byte BytesPerPixel, + byte RBits, byte GBits, byte BBits, byte ABits, + byte RShift, byte GShift, byte BShift, byte AShift) { + bytesPerPixel = BytesPerPixel; + rLoss = 8 - RBits, gLoss = 8 - GBits, bLoss = 8 - BBits, aLoss = 8 - ABits; + rShift = RShift, gShift = GShift, bShift = BShift, aShift = AShift; + } + + static inline PixelFormat createFormatCLUT8() { + return PixelFormat(1, 0, 0, 0, 0, 0, 0, 0, 0); + } + inline bool operator==(const PixelFormat &fmt) const { // TODO: If aLoss==8, then the value of aShift is irrelevant, and should be ignored. return 0 == memcmp(this, &fmt, sizeof(PixelFormat)); @@ -129,6 +148,26 @@ struct PixelFormat { } }; +/** + * Determines the first matching format between two lists. + * + * @param backend The higher priority list, meant to be a list of formats supported by the backend + * @param frontend The lower priority list, meant to be a list of formats supported by the engine + * @return The first item on the backend list that also occurs on the frontend list + * or PixelFormat::createFormatCLUT8() if no matching formats were found. + */ +inline PixelFormat findCompatibleFormat(Common::List<PixelFormat> backend, Common::List<PixelFormat> frontend) { +#ifdef USE_RGB_COLOR + for (Common::List<PixelFormat>::iterator i = backend.begin(); i != backend.end(); ++i) { + for (Common::List<PixelFormat>::iterator j = frontend.begin(); j != frontend.end(); ++j) { + if (*i == *j) + return *i; + } + } +#endif + return PixelFormat::createFormatCLUT8(); +} + } // end of namespace Graphics #endif diff --git a/graphics/scaler.cpp b/graphics/scaler.cpp index a3aaaa121d..8c677cc083 100644 --- a/graphics/scaler.cpp +++ b/graphics/scaler.cpp @@ -30,18 +30,17 @@ int gBitFormat = 565; -static const Graphics::PixelFormat gPixelFormat555 = { +static const Graphics::PixelFormat gPixelFormat555( 2, 3, 3, 3, 8, 10, 5, 0, 0 - }; + ); -static const Graphics::PixelFormat gPixelFormat565 = { +static const Graphics::PixelFormat gPixelFormat565( 2, 3, 2, 3, 8, 11, 5, 0, 0 - }; - + ); #ifndef DISABLE_HQ_SCALERS diff --git a/graphics/sjis.cpp b/graphics/sjis.cpp index 405d8622c2..9f5def8f10 100644 --- a/graphics/sjis.cpp +++ b/graphics/sjis.cpp @@ -280,6 +280,11 @@ const uint16 *FontSjisSVM::getCharData(uint16 c) const { if (index >= 0x3F) --index; + // Another check if the passed character was an + // correctly encoded SJIS character. + if (index < 0 || index >= 0xBC || base < 0) + return 0; + return _fontData + (base * 0xBC + index) * 16; } diff --git a/graphics/video/coktelvideo/coktelvideo.cpp b/graphics/video/coktelvideo/coktelvideo.cpp index 39aeca07bd..b69315cbae 100644 --- a/graphics/video/coktelvideo/coktelvideo.cpp +++ b/graphics/video/coktelvideo/coktelvideo.cpp @@ -362,6 +362,10 @@ void Imd::setDoubleMode(bool doubleMode) { } void Imd::enableSound(Audio::Mixer &mixer) { + // Sanity check + if (mixer.getOutputRate() == 0) + return; + // Only possible on the first frame if (_curFrame > 0) return; @@ -387,7 +391,7 @@ void Imd::disableSound() { } bool Imd::isSoundPlaying() const { - if (_audioStream && _mixer->isSoundHandleActive(_audioHandle)) + if (_audioStream && _mixer && _mixer->isSoundHandleActive(_audioHandle)) return true; return false; @@ -1706,9 +1710,12 @@ CoktelVideo::State Vmd::processFrame(uint16 frame) { } if (startSound && _soundEnabled) { - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_audioHandle, _audioStream); - _skipFrames = 0; - _soundStage = 2; + if (_hasSound && _audioStream) { + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_audioHandle, _audioStream); + _skipFrames = 0; + _soundStage = 2; + } else + _soundStage = 0; } if ((_curFrame == (_framesCount - 1)) && (_soundStage == 2)) { |
