[Scummvm-cvs-logs] scummvm master -> 559b9744bfc6e7c84f75641bafc531f9ab30cdc8

dreammaster dreammaster at scummvm.org
Fri May 27 05:01:57 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
559b9744bf TSAGE: Refactor GfxSurface and Screen to not use virtual inheritance


Commit: 559b9744bfc6e7c84f75641bafc531f9ab30cdc8
    https://github.com/scummvm/scummvm/commit/559b9744bfc6e7c84f75641bafc531f9ab30cdc8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-05-26T23:01:34-04:00

Commit Message:
TSAGE: Refactor GfxSurface and Screen to not use virtual inheritance

Changed paths:
    engines/tsage/graphics.cpp
    engines/tsage/graphics.h
    engines/tsage/screen.cpp
    engines/tsage/screen.h



diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp
index 58fa5b8..7b7b41f 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 3b395b7..51636c4 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 f11c384..eaf2067 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 bf5057e..c5cfee7 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






More information about the Scummvm-git-logs mailing list