[Scummvm-cvs-logs] CVS: scummvm/smush color.cpp,1.1,1.2 color.h,1.3,1.4 rect.h,1.3,1.4 scumm_renderer.cpp,1.1,1.2

Max Horn fingolfin at users.sourceforge.net
Sun Aug 25 04:13:02 CEST 2002


Update of /cvsroot/scummvm/scummvm/smush
In directory usw-pr-cvs1:/tmp/cvs-serv13510

Modified Files:
	color.cpp color.h rect.h scumm_renderer.cpp 
Log Message:
optimized color/rect classes; cleanup

Index: color.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/smush/color.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- color.cpp	24 Aug 2002 13:16:54 -0000	1.1
+++ color.cpp	25 Aug 2002 11:12:49 -0000	1.2
@@ -22,48 +22,16 @@
 #include <stdafx.h>
 #include "color.h"
 
-Color::Color() : _r(0), _g(0), _b(0) {
-}
-
-Color::Color(value_type r, value_type g, value_type b) : _r(r), _g(g), _b(b) {
-}
-
-Color::Color(const Color & c) : _r(c._r), _g(c._g), _b(c._b) {
-}
-
-Color & Color::operator=(const Color & c) {
-	_r = c._r;
-	_g = c._g;
-	_b = c._b;
-	return *this;
-}
-
-Color::~Color() {
-}
-
-Color::value_type Color::red() const { 
-	return _r; 
-}
-
-Color::value_type Color::green() const { 
-	return _g; 
-}
-
-Color::value_type Color::blue() const { 
-	return _b;
-}
+#define UPDATE_COLOR(c, inc) (((int)((c)) << 7) + (c) + (inc)) >> 7
+#define CHECK_BOUNDS(c) (((c) > 255) ? 255 : (((c) < 0) ? 0 : (c)))
 
 void Color::delta(short * ptr) {
 	// This is a very specific method for XPALs.
 	int t;
-#define UPDATE_COLOR(c, inc) (((int)((c)) << 7) + (c) + (inc)) >> 7
-#define CHECK_BOUNDS(c) (((c) > 255) ? 255 : (((c) < 0) ? 0 : (c)))
 	t = UPDATE_COLOR(_r, ptr[0]);
 	_r = CHECK_BOUNDS(t);
 	t = UPDATE_COLOR(_g, ptr[1]);
 	_g = CHECK_BOUNDS(t);
 	t = UPDATE_COLOR(_b, ptr[2]);
 	_b = CHECK_BOUNDS(t);
-#undef UPDATE_COLOR
-#undef CHECK_BOUNDS
 }

Index: color.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/smush/color.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- color.h	24 Aug 2002 23:22:00 -0000	1.3
+++ color.h	25 Aug 2002 11:12:49 -0000	1.4
@@ -36,14 +36,12 @@
 	value_type _g;	//!< The green component.
 	value_type _b;	//!< The blue component.
 public:
-	Color();
-	Color(value_type, value_type, value_type);
-	Color(const Color &);
-	Color & operator=(const Color &);
-	virtual ~Color();
-	value_type red() const;
-	value_type green() const;
-	value_type blue() const;
+	Color() : _r(0), _g(0), _b(0) {}
+	Color(value_type r, value_type g, value_type b) : _r(r), _g(g), _b(b) {}
+
+	inline value_type red() const { return _r; }
+	inline value_type green() const { return _g; }
+	inline value_type blue() const { return _b; }
 	/*!	@brief handle delta palette modification
 
 		This method is used specifically by player::handleDeltaPalette().

Index: rect.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/smush/rect.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- rect.h	24 Aug 2002 23:37:50 -0000	1.3
+++ rect.h	25 Aug 2002 11:12:49 -0000	1.4
@@ -34,19 +34,19 @@
 	int _y;	//!< The vertical part of the point
 public:
 	Point() : _x(0), _y(0) {};
-	Point(const Point & p) : _x(p.getX()), _y(p.getY()) {};
+	Point(const Point & p) : _x(p._x), _y(p._y) {};
 	explicit Point(int x, int y) : _x(x), _y(y) {};
-	Point & operator=(const Point & p) { _x = p.getX(); _y = p.getY(); return *this; };
-	bool operator==(const Point & p) const { return _x == p.getX() && _y == p.getY(); };
+	Point & operator=(const Point & p) { _x = p._x; _y = p._y; return *this; };
+	bool operator==(const Point & p) const { return _x == p._x && _y == p._y; };
 	const int & getX() const { return _x; };
 	const int & getY() const { return _y; };
 	int & getX() { return _x; };
 	int & getY() { return _y; };
-	Point operator+(const Point & p) const { return Point(_x + p.getX(), _y+p.getY()); };
-	Point operator-(const Point & p) const { return Point(_x - p.getX(), _y-p.getY()); };
-	Point & operator+=(const Point & p) { _x += p.getX(); _y += p.getY(); return *this; };
-	Point & operator-=(const Point & p) { _x -= p.getX(); _y -= p.getY(); return *this; };
-	bool isOrigin() const { return *this == Point(0, 0); };
+	Point operator+(const Point & p) const { return Point(_x + p._x, _y+p._y); };
+	Point operator-(const Point & p) const { return Point(_x - p._x, _y-p._y); };
+	Point & operator+=(const Point & p) { _x += p._x; _y += p._y; return *this; };
+	Point & operator-=(const Point & p) { _x -= p._x; _y -= p._y; return *this; };
+	bool isOrigin() const { return _x == 0 && _y == 0; };
 	void set(int x, int y) { _x = x; _y = y; }
 };
 

Index: scumm_renderer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/smush/scumm_renderer.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- scumm_renderer.cpp	24 Aug 2002 13:16:54 -0000	1.1
+++ scumm_renderer.cpp	25 Aug 2002 11:12:49 -0000	1.2
@@ -20,6 +20,7 @@
  */
 
 #include <stdafx.h>
+#include "common/util.h"
 #include "scumm_renderer.h"
 #include "channel.h"
 
@@ -246,8 +247,8 @@
 }
 
 void ScummRenderer::save(int frame) {
-	int width = min(getWidth(), _scumm->_realWidth); 
-	int height = min(getHeight(), _scumm->_realHeight);
+	int width = MIN(getWidth(), _scumm->_realWidth); 
+	int height = MIN(getHeight(), _scumm->_realHeight);
 	
 	_scumm->_system->copy_rect((const byte *)data(), getWidth(), 0, 0, width, height);
 	_scumm->_system->update_screen();





More information about the Scummvm-git-logs mailing list