[Scummvm-cvs-logs] CVS: scummvm/smush palette.h,1.3,1.4 rect.h,1.4,1.5

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


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

Modified Files:
	palette.h rect.h 
Log Message:
more optimizations

Index: palette.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/smush/palette.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- palette.h	24 Aug 2002 23:37:50 -0000	1.3
+++ palette.h	25 Aug 2002 11:38:14 -0000	1.4
@@ -34,12 +34,24 @@
 private:
 	Color _colors[256];
 public:
-	Palette();
-	Palette(unsigned char *);
-	Palette(const Palette &);
-	const Color & operator[](int) const;
-	Color & operator[](int);
-	Palette & operator=(const Palette &);
+	Palette() {}
+	Palette(unsigned char *ptr)
+	{
+		for(int i = 0; i < 256; i++) {
+			_colors[i] = Color(ptr[3 * i + 0], ptr[3 * i + 1], ptr[3 * i + 2]);
+		}
+	
+	}
+	const Color & operator[](int a) const
+	{
+		assert(a >= 0 && a < 256);
+		return _colors[a];
+	}
+	Color & operator[](int a)
+	{
+		assert(a >= 0 && a < 256);
+		return _colors[a];
+	}
 };
 
 #endif

Index: rect.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/smush/rect.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- rect.h	25 Aug 2002 11:12:49 -0000	1.4
+++ rect.h	25 Aug 2002 11:38:14 -0000	1.5
@@ -29,6 +29,7 @@
 	This small class is an helper for position and size values.
 */
 class Point {
+	friend class Rect;
 private:
 	int _x;	//!< The horizontal part of the point
 	int _y;	//!< The vertical part of the point
@@ -59,24 +60,17 @@
 private:
 	Point _topLeft;		//!< The point at the top left of the rectangle
 	Point _bottomRight;	//!< The point at the bottom right of the rectangle
-protected:
-	void check();
 public:
-	Rect();
-	Rect(int x, int y);
-	explicit Rect(const Point & size);
-	Rect(int x1, int y1, int x2, int y2);
-	Rect(const Point & topleft, const Point & bottomright);
-	Rect(const Rect & r);
-	Rect & operator=(const Rect & r);
-	bool operator==(const Rect & r) const;
+	Rect() : _topLeft(0, 0), _bottomRight(0,0) {}
+	Rect(int x, int y) : _topLeft(0, 0), _bottomRight(x, y) {}
+	Rect(int x1, int y1, int x2, int y2) : _topLeft(x1, y1), _bottomRight(x2, y2) {}
 	Point size() const { return (_bottomRight - _topLeft); };
-	int width() const { return size().getX(); }
-	int height() const { return size().getY(); }
-	int left() const { return _topLeft.getX(); }
-	int right() const { return _bottomRight.getX(); }
-	int top() const { return _topLeft.getY(); }
-	int bottom() const { return _bottomRight.getY(); }
+	int width() const { return size()._x; }
+	int height() const { return size()._y; }
+	int left() const { return _topLeft._x; }
+	int right() const { return _bottomRight._x; }
+	int top() const { return _topLeft._y; }
+	int bottom() const { return _bottomRight._y; }
 	const Point & topLeft() const { return _topLeft; }
 	const Point & bottomRight() const { return _bottomRight; }
 
@@ -87,14 +81,22 @@
 		
 		@return true if the given position is inside the rectangle, false otherwise
 	*/
-	bool isInside(int x, int y) const;
+	bool isInside(int x, int y) const
+	{
+		return (_topLeft._x <= x) && (_bottomRight._x > x) && (_topLeft._y <= y) && (_bottomRight._y > y);
+	}
 	/*!	@brief check if given point is inside the rectangle
 		
 		@param p the point to check
 		
 		@return true if the given point is inside the rectangle, false otherwise
 	*/
-	bool isInside(const Point & p) const;
+	bool isInside(const Point & p) const
+	{
+		return (_topLeft._x <= p._x) && (_bottomRight._x > p._x) && (_topLeft._y <= p._y) && (_bottomRight._y > p._y);
+	}
+
+
 	bool clip(Rect & r) const;
 };
 





More information about the Scummvm-git-logs mailing list