aboutsummaryrefslogtreecommitdiff
path: root/engines/tsage
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-26 23:01:34 -0400
committerPaul Gilbert2016-05-26 23:01:34 -0400
commit559b9744bfc6e7c84f75641bafc531f9ab30cdc8 (patch)
tree45a88953d0477aeae4a8ac47b4a1ad935df40e3b /engines/tsage
parent4d933a15f65809afa330622339a200f15cb19eeb (diff)
downloadscummvm-rg350-559b9744bfc6e7c84f75641bafc531f9ab30cdc8.tar.gz
scummvm-rg350-559b9744bfc6e7c84f75641bafc531f9ab30cdc8.tar.bz2
scummvm-rg350-559b9744bfc6e7c84f75641bafc531f9ab30cdc8.zip
TSAGE: Refactor GfxSurface and Screen to not use virtual inheritance
Diffstat (limited to 'engines/tsage')
-rw-r--r--engines/tsage/graphics.cpp6
-rw-r--r--engines/tsage/graphics.h14
-rw-r--r--engines/tsage/screen.cpp7
-rw-r--r--engines/tsage/screen.h11
4 files changed, 31 insertions, 7 deletions
diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp
index 58fa5b8094..7b7b41f0aa 100644
--- a/engines/tsage/graphics.cpp
+++ b/engines/tsage/graphics.cpp
@@ -229,14 +229,16 @@ void Rect::synchronize(Serializer &s) {
/*--------------------------------------------------------------------------*/
-GfxSurface::GfxSurface() : Graphics::ManagedSurface(), _bounds(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) {
+GfxSurface::GfxSurface() : Graphics::Screen(0, 0), _bounds(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) {
+ free(); // Free the 0x0 surface allocated by Graphics::Screen
_disableUpdates = false;
_lockSurfaceCtr = 0;
_transColor = -1;
_flags = 0;
}
-GfxSurface::GfxSurface(const GfxSurface &s): Graphics::ManagedSurface() {
+GfxSurface::GfxSurface(const GfxSurface &s): Graphics::Screen(0, 0) {
+ free(); // Free the 0x0 surface allocated by Graphics::Screen
_lockSurfaceCtr = 0;
operator=(s);
diff --git a/engines/tsage/graphics.h b/engines/tsage/graphics.h
index 3b395b7625..51636c4119 100644
--- a/engines/tsage/graphics.h
+++ b/engines/tsage/graphics.h
@@ -28,7 +28,7 @@
#include "common/list.h"
#include "common/rect.h"
#include "common/system.h"
-#include "graphics/managed_surface.h"
+#include "graphics/screen.h"
namespace TsAGE {
@@ -73,13 +73,23 @@ public:
enum FrameFlag { FRAME_FLIP_CENTROID_X = 4, FRAME_FLIP_CENTROID_Y = 8 };
-class GfxSurface: virtual public Graphics::ManagedSurface {
+/**
+ * Surface class. This derivces from Graphics::Screen because it has
+ * logic we'll need for our own Screen class that derives from this one
+ */
+ class GfxSurface: public Graphics::Screen {
private:
int _lockSurfaceCtr;
Graphics::ManagedSurface _rawSurface;
bool _disableUpdates;
Rect _bounds;
+ protected:
+ /**
+ * Override the addDirtyRect from Graphics::Screen, since for standard
+ * surfaces we don't need dirty rects to be tracked
+ */
+ virtual void addDirtyRect(const Common::Rect &r) {}
public:
Common::Point _centroid;
int _transColor;
diff --git a/engines/tsage/screen.cpp b/engines/tsage/screen.cpp
index f11c384797..eaf2067c32 100644
--- a/engines/tsage/screen.cpp
+++ b/engines/tsage/screen.cpp
@@ -25,10 +25,15 @@
namespace TsAGE {
-Screen::Screen(): GfxSurface(), Graphics::Screen() {
+Screen::Screen(): GfxSurface() {
create(SCREEN_WIDTH, SCREEN_HEIGHT);
}
+Screen::~Screen() {
+ // Delete the screen's surface
+ free();
+}
+
void Screen::update() {
// When dialogs are active, the screen surface may be remapped to
// sub-sections of the screen. But for drawing we'll need to temporarily
diff --git a/engines/tsage/screen.h b/engines/tsage/screen.h
index bf5057e4d6..c5cfee754a 100644
--- a/engines/tsage/screen.h
+++ b/engines/tsage/screen.h
@@ -36,7 +36,14 @@ namespace TsAGE {
#define SCREEN_CENTER_Y 100
#define UI_INTERFACE_Y 168
-class Screen : virtual public Graphics::Screen, virtual public GfxSurface {
+class Screen : public GfxSurface {
+ /**
+ * Override the addDirtyRect from GfxSurface, since for our screen
+ * class we need to reintroduce the standard Graphics::Screen implementation
+ */
+ virtual void addDirtyRect(const Common::Rect &r) {
+ Graphics::Screen::addDirtyRect(r);
+ }
public:
/**
* Constructor
@@ -46,7 +53,7 @@ public:
/**
* Destructor
*/
- virtual ~Screen() {}
+ virtual ~Screen();
/**
* Update the screen