[Scummvm-git-logs] scummvm master -> 33bcc9d058e40f250c0e82686c288d6e98db53e3

dreammaster dreammaster at scummvm.org
Sat Apr 1 00:55:21 CEST 2017


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:
33bcc9d058 TITANIC: Merge CSurfaceFader and base into a single file


Commit: 33bcc9d058e40f250c0e82686c288d6e98db53e3
    https://github.com/scummvm/scummvm/commit/33bcc9d058e40f250c0e82686c288d6e98db53e3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-03-31T18:55:09-04:00

Commit Message:
TITANIC: Merge CSurfaceFader and base into a single file

Changed paths:
  R engines/titanic/star_control/surface_fader_base.cpp
  R engines/titanic/star_control/surface_fader_base.h
    engines/titanic/module.mk
    engines/titanic/star_control/surface_fader.cpp
    engines/titanic/star_control/surface_fader.h


diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index cdb3a64..3d6c66d 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -460,7 +460,6 @@ MODULE_OBJS := \
 	star_control/star_ref.o \
 	star_control/star_view.o \
 	star_control/surface_area.o \
-	star_control/surface_fader_base.o \
 	star_control/surface_fader.o \
 	support/avi_surface.o \
 	support/direct_draw.o \
diff --git a/engines/titanic/star_control/surface_fader.cpp b/engines/titanic/star_control/surface_fader.cpp
index 6948323..79129d9 100644
--- a/engines/titanic/star_control/surface_fader.cpp
+++ b/engines/titanic/star_control/surface_fader.cpp
@@ -26,6 +26,38 @@
 
 namespace Titanic {
 
+
+CSurfaceFaderBase::CSurfaceFaderBase() : _index(-1), _count(32),
+		_videoSurface(nullptr) {
+}
+
+CSurfaceFaderBase::~CSurfaceFaderBase() {
+	delete _videoSurface;
+}
+
+void CSurfaceFaderBase::reset() {
+	_index = 0;
+}
+
+bool CSurfaceFaderBase::setupSurface(CScreenManager *screenManager, CVideoSurface *srcSurface) {
+	int width = srcSurface->getWidth();
+	int height = srcSurface->getHeight();
+
+	if (_videoSurface) {
+		if (width == _videoSurface->getWidth() && _videoSurface->getHeight())
+			// Allocated surface already matches new size
+			return true;
+
+		// Different sizes, so delete old surface
+		delete _videoSurface;
+	}
+
+	_videoSurface = screenManager->createSurface(width, height);
+	return true;
+}
+
+/*------------------------------------------------------------------------*/
+
 CSurfaceFader::CSurfaceFader() : CSurfaceFaderBase() {
 	_dataP = new byte[_count];
 
@@ -38,6 +70,32 @@ CSurfaceFader::~CSurfaceFader() {
 	delete[] _dataP;
 }
 
+void CSurfaceFader::setFadeIn(bool fadeIn) {
+	_fadeIn = fadeIn;
+}
+
+CVideoSurface *CSurfaceFader::fade(CScreenManager *screenManager, CVideoSurface *srcSurface) {
+	if (_index == -1 || _index >= _count)
+		return srcSurface;
+
+	if (!_count && !setupSurface(screenManager, srcSurface))
+		return nullptr;
+
+	srcSurface->lock();
+	_videoSurface->lock();
+	CSurfaceArea srCSurfaceArea(srcSurface);
+	CSurfaceArea destSurfaceObj(_videoSurface);
+
+	// Copy the surface with fading
+	copySurface(srCSurfaceArea, destSurfaceObj);
+
+	srcSurface->unlock();
+	_videoSurface->unlock();
+
+	++_index;
+	return _videoSurface;
+}
+
 void CSurfaceFader::copySurface(CSurfaceArea &srcSurface, CSurfaceArea &destSurface) {
 	const uint16 *srcPixelP = (const uint16 *)srcSurface._pixelsPtr;
 	uint16 *destPixelP = (uint16 *)destSurface._pixelsPtr;
@@ -66,8 +124,4 @@ void CSurfaceFader::copySurface(CSurfaceArea &srcSurface, CSurfaceArea &destSurf
 	}
 }
 
-void CSurfaceFader::setFadeIn(bool fadeIn) {
-	_fadeIn = fadeIn;
-}
-
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/surface_fader.h b/engines/titanic/star_control/surface_fader.h
index 650cbbb..d861186 100644
--- a/engines/titanic/star_control/surface_fader.h
+++ b/engines/titanic/star_control/surface_fader.h
@@ -23,24 +23,63 @@
 #ifndef TITANIC_SURFACE_FADER_H
 #define TITANIC_SURFACE_FADER_H
 
-#include "titanic/star_control/surface_fader_base.h"
+#include "titanic/support/video_surface.h"
+#include "titanic/support/screen_manager.h"
+#include "titanic/star_control/surface_area.h"
 
 namespace Titanic {
 
+class CSurfaceFaderBase {
+protected:
+	/**
+	 * Sets up an internal surface to match the size of the specified one
+	 */
+	bool setupSurface(CScreenManager *screenManager, CVideoSurface *srcSurface);
+public:
+	int _index;
+	int _count;
+	CVideoSurface *_videoSurface;
+public:
+	CSurfaceFaderBase();
+	virtual ~CSurfaceFaderBase();
+
+	/**
+	 * Reset fading back to the start
+	 */
+	virtual void reset();
+
+	/**
+	 * Creates a faded version of the passed source surface, based on a percentage
+	 * visibility specified by _index of _count
+	 */
+	virtual CVideoSurface *fade(CScreenManager *screenManager, CVideoSurface *srcSurface) = 0;
+
+	/**
+	 * Returns true if a fade is in progress
+	 */
+	bool isActive() const { return _index != -1 && _index < _count; }
+};
+
 class CSurfaceFader: public CSurfaceFaderBase {
 private:
 	byte *_dataP;
 	bool _fadeIn;
-protected:
+private:
 	/**
 	 * Create a faded version of the source surface at the given dest
 	 */
-	virtual void copySurface(CSurfaceArea &srcSurface, CSurfaceArea &destSurface);
+	void copySurface(CSurfaceArea &srcSurface, CSurfaceArea &destSurface);
 public:
 	CSurfaceFader();
 	virtual ~CSurfaceFader();
 
 	/**
+	 * Creates a faded version of the passed source surface, based on a percentage
+	 * visibility specified by _index of _count
+	 */
+	virtual CVideoSurface *fade(CScreenManager *screenManager, CVideoSurface *srcSurface);
+
+	/**
 	 * Sets whether a fade in (versus a fade out) should be done
 	 */
 	void setFadeIn(bool fadeIn);
diff --git a/engines/titanic/star_control/surface_fader_base.cpp b/engines/titanic/star_control/surface_fader_base.cpp
deleted file mode 100644
index fb17fb1..0000000
--- a/engines/titanic/star_control/surface_fader_base.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/* 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/star_control/surface_fader_base.h"
-
-namespace Titanic {
-
-CSurfaceFaderBase::CSurfaceFaderBase() : _index(-1), _count(32),
-		_videoSurface(nullptr) {
-}
-
-CSurfaceFaderBase::~CSurfaceFaderBase() {
-	delete _videoSurface;
-}
-
-void CSurfaceFaderBase::reset() {
-	_index = 0;
-}
-
-bool CSurfaceFaderBase::setupSurface(CScreenManager *screenManager, CVideoSurface *srcSurface) {
-	int width = srcSurface->getWidth();
-	int height = srcSurface->getHeight();
-
-	if (_videoSurface) {
-		if (width == _videoSurface->getWidth() && _videoSurface->getHeight())
-			// Allocated surface already matches new size
-			return true;
-
-		// Different sizes, so delete old surface
-		delete _videoSurface;
-	}
-
-	_videoSurface = screenManager->createSurface(width, height);
-	return true;
-}
-
-CVideoSurface *CSurfaceFaderBase::fade(CScreenManager *screenManager, CVideoSurface *srcSurface) {
-	if (_index == -1 || _index >= _count)
-		return srcSurface;
-
-	if (!_count && !setupSurface(screenManager, srcSurface))
-		return nullptr;
-
-	srcSurface->lock();
-	_videoSurface->lock();
-	CSurfaceArea srCSurfaceArea(srcSurface);
-	CSurfaceArea destSurfaceObj(_videoSurface);
-
-	// Copy the surface with fading
-	copySurface(srCSurfaceArea, destSurfaceObj);
-
-	srcSurface->unlock();
-	_videoSurface->unlock();
-
-	++_index;
-	return _videoSurface;
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/star_control/surface_fader_base.h b/engines/titanic/star_control/surface_fader_base.h
deleted file mode 100644
index 4631835..0000000
--- a/engines/titanic/star_control/surface_fader_base.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* 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_SURFACE_FADER_BASE_H
-#define TITANIC_SURFACE_FADER_BASE_H
-
-#include "titanic/support/video_surface.h"
-#include "titanic/support/screen_manager.h"
-#include "titanic/star_control/surface_area.h"
-
-namespace Titanic {
-
-class CSurfaceFaderBase {
-private:
-	/**
-	 * Sets up an internal surface to match the size of the specified one
-	 */
-	bool setupSurface(CScreenManager *screenManager, CVideoSurface *srcSurface);
-protected:
-	/**
-	 * Create a faded version of the source surface at the given dest
-	 */
-	virtual void copySurface(CSurfaceArea &srcSurface, CSurfaceArea &destSurface) = 0;
-public:
-	int _index;
-	int _count;
-	CVideoSurface *_videoSurface;
-public:
-	CSurfaceFaderBase();
-	virtual ~CSurfaceFaderBase();
-
-	/**
-	 * Reset fading back to the start
-	 */
-	virtual void reset();
-
-	/**
-	 * Creates a faded version of the passed source surface, based on a percentage
-	 * visibility specified by _index of _count
-	 */
-	virtual CVideoSurface *fade(CScreenManager *screenManager, CVideoSurface *srcSurface);
-
-	/**
-	 * Returns true if a fade is in progress
-	 */
-	bool isActive() const { return _index != -1 && _index < _count; }
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_SURFACE_FADER_BASE_H */





More information about the Scummvm-git-logs mailing list