diff options
-rw-r--r-- | engines/titanic/direct_draw.h | 5 | ||||
-rw-r--r-- | engines/titanic/image_decoders.cpp | 45 | ||||
-rw-r--r-- | engines/titanic/image_decoders.h | 81 | ||||
-rw-r--r-- | engines/titanic/module.mk | 1 | ||||
-rw-r--r-- | engines/titanic/screen_manager.cpp | 5 | ||||
-rw-r--r-- | engines/titanic/screen_manager.h | 12 | ||||
-rw-r--r-- | engines/titanic/video_surface.cpp | 36 | ||||
-rw-r--r-- | engines/titanic/video_surface.h | 23 |
8 files changed, 202 insertions, 6 deletions
diff --git a/engines/titanic/direct_draw.h b/engines/titanic/direct_draw.h index 71210f1b28..4bd723bcd3 100644 --- a/engines/titanic/direct_draw.h +++ b/engines/titanic/direct_draw.h @@ -43,6 +43,11 @@ struct DDSurfaceDesc { class DirectDrawSurface : public Graphics::Surface { public: /** + * Return the size of the surface in ytes + */ + int getSize() const { return pitch * h; } + + /** * Lock the surface for access */ void *lock(const Common::Rect *bounds, int flags); diff --git a/engines/titanic/image_decoders.cpp b/engines/titanic/image_decoders.cpp new file mode 100644 index 0000000000..896155d7b8 --- /dev/null +++ b/engines/titanic/image_decoders.cpp @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/image_decoders.h" + +namespace Titanic { + +CJPEGDecode::CJPEGDecode(const CString &name): _file(name), + _width(0), _height(0) { +} + +void CJPEGDecode::decode(OSVideoSurface &surface) { + +} + +/*------------------------------------------------------------------------*/ + + +CTargaDecode::CTargaDecode(const CString &name) : _file(name), + _width(0), _height(0) { +} + +void CTargaDecode::decode(OSVideoSurface &surface) { +} + +} // End of namespace Titanic diff --git a/engines/titanic/image_decoders.h b/engines/titanic/image_decoders.h new file mode 100644 index 0000000000..258595846c --- /dev/null +++ b/engines/titanic/image_decoders.h @@ -0,0 +1,81 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_IMAGE_DECODERS_H +#define TITANIC_IMAGE_DECODERS_H + +#include "titanic/string.h" +#include "titanic/simple_file.h" +#include "titanic/video_surface.h" + +namespace Titanic { + +class CJPEGDecode { +private: + StdCWadFile _file; + int _width, _height; +public: + CJPEGDecode(const CString &name); + + /** + * Return the width of the JPEG + */ + int getWidth() const { return _width; } + + /** + * Return the height of the JPEG + */ + int getHeight() const { return _height; } + + /** + * Decode the image onto the passed surface + */ + void decode(OSVideoSurface &surface); +}; + +class CTargaDecode { +private: + StdCWadFile _file; + int _width, _height; +public: + CTargaDecode(const CString &name); + + /** + * Return the width of the JPEG + */ + int getWidth() const { return _width; } + + /** + * Return the height of the JPEG + */ + int getHeight() const { return _height; } + + /** + * Decode the image onto the passed surface + */ + void decode(OSVideoSurface &surface); + +}; + +} // End of namespace Titanic + +#endif /* TITANIC_IMAGE_DECODERS_H */ diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index 664dc0a3e5..ec55392833 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -10,6 +10,7 @@ MODULE_OBJS := \ game_state.o \ game_view.o \ image.o \ + image_decoders.o \ input_handler.o \ input_translator.o \ main_game_window.o \ diff --git a/engines/titanic/screen_manager.cpp b/engines/titanic/screen_manager.cpp index f64468e90b..9c88dc6de9 100644 --- a/engines/titanic/screen_manager.cpp +++ b/engines/titanic/screen_manager.cpp @@ -130,7 +130,10 @@ void OSScreenManager::clearSurface(int surfaceNum, Common::Rect *bounds) { _directDrawManager._backSurfaces[surfaceNum]->fill(bounds, 0); } -void OSScreenManager::proc21() {} +void OSScreenManager::resizeSurface(CVideoSurface *surface, int width, int height) { + DirectDrawSurface *ddSurface = _directDrawManager.createSurface(width, height, 0); + surface->setSurface(this, ddSurface); +} CVideoSurface *OSScreenManager::createSurface(int w, int h) { DirectDrawSurface *ddSurface = _directDrawManager.createSurface(w, h, 0); diff --git a/engines/titanic/screen_manager.h b/engines/titanic/screen_manager.h index 075e36cadf..caaefc87a6 100644 --- a/engines/titanic/screen_manager.h +++ b/engines/titanic/screen_manager.h @@ -105,7 +105,10 @@ public: */ virtual void clearSurface(int surfaceNum, Common::Rect *_bounds) = 0; - virtual void proc21() = 0; + /** + * Resize the passed surface + */ + virtual void resizeSurface(CVideoSurface *surface, int width, int height) = 0; /** * Creates a surface of a given size @@ -167,8 +170,11 @@ public: * Clear a portion of the screen surface */ virtual void clearSurface(int surfaceNum, Common::Rect *bounds); - - virtual void proc21(); + + /** + * Resize the passed surface + */ + virtual void resizeSurface(CVideoSurface *surface, int width, int height); /** * Creates a surface of a given size diff --git a/engines/titanic/video_surface.cpp b/engines/titanic/video_surface.cpp index 44b91c0ed0..4f79cd8189 100644 --- a/engines/titanic/video_surface.cpp +++ b/engines/titanic/video_surface.cpp @@ -21,6 +21,7 @@ */ #include "titanic/video_surface.h" +#include "titanic/image_decoders.h" #include "titanic/screen_manager.h" namespace Titanic { @@ -29,11 +30,19 @@ int CVideoSurface::_videoSurfaceCounter = 0; CVideoSurface::CVideoSurface(CScreenManager *screenManager) : _screenManager(screenManager), _pixels(nullptr), - _field34(0), _pendingLoad(false), _field3C(0), _field40(0), + _field34(nullptr), _pendingLoad(false), _field3C(0), _field40(0), _field44(4), _field48(0), _field50(1) { _videoSurfaceNum = _videoSurfaceCounter++; } + +CVideoSurface::~CVideoSurface() { + if (_ddSurface) + _videoSurfaceCounter -= freeSurface(); + --_videoSurfaceCounter; +} + + void CVideoSurface::setSurface(CScreenManager *screenManager, DirectDrawSurface *surface) { _screenManager = screenManager; _ddSurface = surface; @@ -72,6 +81,10 @@ void OSVideoSurface::loadTarga() { } void OSVideoSurface::loadJPEG() { + CString filename = _resourceKey.exists(); + CJPEGDecode decoder(filename); + + warning("TODO"); } @@ -114,6 +127,14 @@ int OSVideoSurface::getPitch() const { return _ddSurface->pitch; } +void OSVideoSurface::resize(int width, int height) { + freeSurface(); + + _screenManager->resizeSurface(this, width, height); + if (_ddSurface) + _videoSurfaceCounter += _ddSurface->getSize(); +} + bool OSVideoSurface::load() { if (!_resourceKey.scanForFile()) return false; @@ -155,4 +176,17 @@ bool OSVideoSurface::loadIfReady() { } } +int OSVideoSurface::freeSurface() { + if (!_ddSurface) + return 0; + int surfaceSize = _ddSurface->getSize(); + + delete _field34; + _field34 = nullptr; + delete _ddSurface; + _ddSurface = nullptr; + + return surfaceSize; +} + } // End of namespace Titanic diff --git a/engines/titanic/video_surface.h b/engines/titanic/video_surface.h index d03e322d03..cd1fc2e786 100644 --- a/engines/titanic/video_surface.h +++ b/engines/titanic/video_surface.h @@ -42,7 +42,7 @@ protected: CResourceKey _resourceKey; DirectDrawSurface *_ddSurface; uint16 *_pixels; - int _field34; + void *_field34; bool _pendingLoad; int _field3C; int _field40; @@ -53,6 +53,7 @@ protected: int _lockCount; public: CVideoSurface(CScreenManager *screenManager); + virtual ~CVideoSurface(); /** * Set the underlying surface for this video surface @@ -110,6 +111,11 @@ public: virtual int getPitch() const = 0; /** + * Reiszes the surface + */ + virtual void resize(int width, int height) = 0; + + /** * Loads the surface data based on the currently set resource key */ virtual bool load() = 0; @@ -118,6 +124,11 @@ public: * Loads the surface's resource if there's one pending */ virtual bool loadIfReady() = 0; + + /** + * Frees the underlying surface + */ + virtual int freeSurface() { return 0; } }; class OSVideoSurface : public CVideoSurface { @@ -176,6 +187,11 @@ public: virtual int getPitch() const; /** + * Reiszes the surface + */ + virtual void resize(int width, int height); + + /** * Loads the surface data based on the currently set resource key */ virtual bool load(); @@ -184,6 +200,11 @@ public: * Loads the surface's resource if there's one pending */ virtual bool loadIfReady(); + + /** + * Frees the underlying surface + */ + virtual int freeSurface(); }; } // End of namespace Titanic |