aboutsummaryrefslogtreecommitdiff
path: root/engines/hdb/gfx.cpp
diff options
context:
space:
mode:
authorNipun Garg2019-07-18 01:11:53 +0530
committerEugene Sandulenko2019-09-03 17:17:22 +0200
commite9e654d7db8c6b865c6f168f6f35663af85fce85 (patch)
tree571bb20ad35058a951bdacf574f384e345b330e2 /engines/hdb/gfx.cpp
parentadb43a79b7ee01cda7c33f48d778fc9b57358716 (diff)
downloadscummvm-rg350-e9e654d7db8c6b865c6f168f6f35663af85fce85.tar.gz
scummvm-rg350-e9e654d7db8c6b865c6f168f6f35663af85fce85.tar.bz2
scummvm-rg350-e9e654d7db8c6b865c6f168f6f35663af85fce85.zip
HDB: Convert _surface from struct to pointer
Diffstat (limited to 'engines/hdb/gfx.cpp')
-rw-r--r--engines/hdb/gfx.cpp44
1 files changed, 24 insertions, 20 deletions
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index de897074e0..942fd1d2b6 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -1032,14 +1032,16 @@ void Gfx::drawDebugInfo(Tile *_debugLogo, int fps) {
}
Picture::Picture() : _width(0), _height(0), _name("") {
- _surface.create(_width, _height, g_hdb->_format);
+ _surface = NULL;
}
Picture::~Picture() {
- _surface.free();
+ if (_surface)
+ _surface->free();
+ _surface = NULL;
}
-Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
+Graphics::ManagedSurface *Picture::load(Common::SeekableReadStream *stream) {
_width = stream->readUint32LE();
_height = stream->readUint32LE();
stream->read(_name, 64);
@@ -1047,13 +1049,14 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
debug(8, "Picture: _width: %d, _height: %d", _width, _height);
debug(8, "Picture: _name: %s", _name);
- _surface.create(_width, _height, g_hdb->_format);
+ _surface = new Graphics::ManagedSurface;
+ _surface->create(_width, _height, g_hdb->_format);
stream->readUint32LE(); // Skip Win32 Surface
uint16 *ptr;
for (int y = 0; y < _height; y++) {
- ptr = (uint16 *)_surface.getBasePtr(0, y);
+ ptr = (uint16 *)_surface->getBasePtr(0, y);
for (int x = 0; x < _width; x++) {
*ptr = TO_LE_16(stream->readUint16LE());
ptr++;
@@ -1064,9 +1067,9 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) {
}
int Picture::draw(int x, int y) {
- g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
+ g_hdb->_gfx->_globalSurface.blitFrom(*_surface, Common::Point(x, y));
- Common::Rect clip(_surface.getBounds());
+ Common::Rect clip(_surface->getBounds());
clip.moveTo(x, y);
clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
if (!clip.isEmpty()) {
@@ -1077,9 +1080,9 @@ int Picture::draw(int x, int y) {
}
int Picture::drawMasked(int x, int y, int alpha) {
- g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
+ g_hdb->_gfx->_globalSurface.transBlitFrom(*_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
- Common::Rect clip(_surface.getBounds());
+ Common::Rect clip(_surface->getBounds());
clip.moveTo(x, y);
clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
if (!clip.isEmpty()) {
@@ -1089,25 +1092,26 @@ int Picture::drawMasked(int x, int y, int alpha) {
return 0;
}
-Tile::Tile() : _flags(0), _name("") {
- _surface.create(32, 32, g_hdb->_format);
-}
+Tile::Tile() : _flags(0), _name(""), _surface(NULL) {}
Tile::~Tile() {
- _surface.free();
+ if (_surface)
+ _surface->free();
+ _surface = NULL;
}
-Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
+Graphics::ManagedSurface *Tile::load(Common::SeekableReadStream *stream) {
_flags = stream->readUint32LE();
stream->read(_name, 64);
- _surface.create(32, 32, g_hdb->_format);
+ _surface = new Graphics::ManagedSurface;
+ _surface->create(32, 32, g_hdb->_format);
stream->readUint32LE(); // Skip Win32 Surface
uint16 *ptr;
for (uint y = 0; y < 32; y++) {
- ptr = (uint16 *)_surface.getBasePtr(0, y);
+ ptr = (uint16 *)_surface->getBasePtr(0, y);
for (uint x = 0; x < 32; x++) {
*ptr = TO_LE_16(stream->readUint16LE());
ptr++;
@@ -1118,9 +1122,9 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) {
}
int Tile::draw(int x, int y) {
- g_hdb->_gfx->_globalSurface.blitFrom(_surface, Common::Point(x, y));
+ g_hdb->_gfx->_globalSurface.blitFrom(*_surface, Common::Point(x, y));
- Common::Rect clip(_surface.getBounds());
+ Common::Rect clip(_surface->getBounds());
clip.moveTo(x, y);
clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
if (!clip.isEmpty()) {
@@ -1131,9 +1135,9 @@ int Tile::draw(int x, int y) {
}
int Tile::drawMasked(int x, int y, int alpha) {
- g_hdb->_gfx->_globalSurface.transBlitFrom(_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
+ g_hdb->_gfx->_globalSurface.transBlitFrom(*_surface, Common::Point(x, y), 0xf81f, false, 0, alpha & 0xff);
- Common::Rect clip(_surface.getBounds());
+ Common::Rect clip(_surface->getBounds());
clip.moveTo(x, y);
clip.clip(g_hdb->_gfx->_globalSurface.getBounds());
if (!clip.isEmpty()) {