aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction
diff options
context:
space:
mode:
authorNicola Mettifogo2007-08-12 08:47:45 +0000
committerNicola Mettifogo2007-08-12 08:47:45 +0000
commit8444ad7f4890e3192e0ac1dccf01c53297144b1f (patch)
treebcd2b561c5a03fcc1130c38638f7f3399c0a1338 /engines/parallaction
parentfdee6a6e873f75a7274df1ef77a58e14042c374d (diff)
downloadscummvm-rg350-8444ad7f4890e3192e0ac1dccf01c53297144b1f.tar.gz
scummvm-rg350-8444ad7f4890e3192e0ac1dccf01c53297144b1f.tar.bz2
scummvm-rg350-8444ad7f4890e3192e0ac1dccf01c53297144b1f.zip
Even better large background support. Now internal buffers aren't reallocated if not background size stays the same across location switches.
svn-id: r28540
Diffstat (limited to 'engines/parallaction')
-rw-r--r--engines/parallaction/graphics.cpp62
-rw-r--r--engines/parallaction/graphics.h7
2 files changed, 49 insertions, 20 deletions
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index 023df8015a..cad25b578d 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -693,15 +693,11 @@ void Gfx::restoreBackground(const Common::Rect& r) {
}
+
void Gfx::setBackground(Graphics::Surface *surface) {
_buffers[kBit2] = surface;
- _backgroundWidth = surface->w;
- _backgroundHeight = surface->h;
-
- _buffers[kBitFront]->create(surface->w, surface->h, 1);
- _buffers[kBitBack]->create(surface->w, surface->h, 1);
-
+ initBuffers(surface->w, surface->h);
copyScreen(kBit2, kBitBack);
}
@@ -781,17 +777,11 @@ Gfx::Gfx(Parallaction* vm) :
g_system->initSize(_vm->_screenWidth, _vm->_screenHeight);
g_system->endGFXTransaction();
- _backgroundWidth = _vm->_screenWidth;
- _backgroundHeight = _vm->_screenHeight;
-
- _buffers[kBitFront] = new Graphics::Surface;
- _buffers[kBitFront]->create(_vm->_screenWidth, _vm->_screenHeight, 1);
- _buffers[kBitBack] = new Graphics::Surface;
- _buffers[kBitBack]->create(_vm->_screenWidth, _vm->_screenHeight, 1);
_buffers[kBit2] = 0;
-
_depthMask = 0;
+ initBuffers(_vm->_screenWidth, _vm->_screenHeight);
+
setPalette(_palette);
_screenX = 0;
@@ -810,13 +800,49 @@ Gfx::Gfx(Parallaction* vm) :
Gfx::~Gfx() {
- _buffers[kBitFront]->free();
- delete _buffers[kBitFront];
- _buffers[kBitBack]->free();
- delete _buffers[kBitBack];
+ freeBuffers();
return;
}
+void Gfx::initBuffers(int w, int h) {
+
+ _backgroundWidth = w;
+ _backgroundHeight = h;
+
+ if (!_buffers[kBitFront]) {
+ _buffers[kBitFront] = new Graphics::Surface;
+ }
+
+ if (!_buffers[kBitBack]) {
+ _buffers[kBitBack] = new Graphics::Surface;
+ }
+
+ if (_buffers[kBitFront]->w != w || _buffers[kBitFront]->h != h) {
+ _buffers[kBitFront]->create(w, h, 1);
+ }
+
+ if (_buffers[kBitBack]->w != w || _buffers[kBitBack]->h != h) {
+ _buffers[kBitBack]->create(w, h, 1);
+ }
+
+}
+
+void Gfx::freeBuffers() {
+
+ if (_buffers[kBitFront]) {
+ _buffers[kBitFront]->free();
+ delete _buffers[kBitFront];
+ }
+
+ if (_buffers[kBitBack]) {
+ _buffers[kBitBack]->free();
+ delete _buffers[kBitBack];
+ }
+
+ _buffers[kBitFront] = 0;
+ _buffers[kBitBack] = 0;
+}
+
} // namespace Parallaction
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index e130067b17..e64ea81403 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -241,8 +241,8 @@ public:
PaletteFxRange _palettefx[6];
Palette _palette;
- uint _backgroundWidth;
- uint _backgroundHeight;
+ int _backgroundWidth;
+ int _backgroundHeight;
uint _screenX; // scrolling position
uint _screenY;
@@ -255,6 +255,9 @@ protected:
bool _halfbrite;
protected:
+ void initBuffers(int w, int h);
+ void freeBuffers();
+
void copyRect(uint width, uint height, byte *dst, uint dstPitch, byte *src, uint srcPitch);
void flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer, byte transparentColor);
void blit(const Common::Rect& r, uint16 z, byte *data, Gfx::Buffers buffer);