aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2002-08-25 11:12:49 +0000
committerMax Horn2002-08-25 11:12:49 +0000
commit1cbd00bd64d48c156ca46e204309c67aef6842cb (patch)
treea8ae7f6c7f56733a615ee3bc351f66726a0312bb /scumm
parent2355db8017f30a13312aa531fd6e431784514e96 (diff)
downloadscummvm-rg350-1cbd00bd64d48c156ca46e204309c67aef6842cb.tar.gz
scummvm-rg350-1cbd00bd64d48c156ca46e204309c67aef6842cb.tar.bz2
scummvm-rg350-1cbd00bd64d48c156ca46e204309c67aef6842cb.zip
optimized color/rect classes; cleanup
svn-id: r4844
Diffstat (limited to 'scumm')
-rw-r--r--scumm/smush/color.cpp36
-rw-r--r--scumm/smush/color.h14
-rw-r--r--scumm/smush/rect.h16
-rw-r--r--scumm/smush/scumm_renderer.cpp5
4 files changed, 19 insertions, 52 deletions
diff --git a/scumm/smush/color.cpp b/scumm/smush/color.cpp
index e88785ccbd..54a06df3e1 100644
--- a/scumm/smush/color.cpp
+++ b/scumm/smush/color.cpp
@@ -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
}
diff --git a/scumm/smush/color.h b/scumm/smush/color.h
index d2ee53271a..e0afefaf01 100644
--- a/scumm/smush/color.h
+++ b/scumm/smush/color.h
@@ -36,14 +36,12 @@ private:
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().
diff --git a/scumm/smush/rect.h b/scumm/smush/rect.h
index d74395ebd3..1a7801ce65 100644
--- a/scumm/smush/rect.h
+++ b/scumm/smush/rect.h
@@ -34,19 +34,19 @@ private:
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; }
};
diff --git a/scumm/smush/scumm_renderer.cpp b/scumm/smush/scumm_renderer.cpp
index bfce102ae5..3e357091c2 100644
--- a/scumm/smush/scumm_renderer.cpp
+++ b/scumm/smush/scumm_renderer.cpp
@@ -20,6 +20,7 @@
*/
#include <stdafx.h>
+#include "common/util.h"
#include "scumm_renderer.h"
#include "channel.h"
@@ -246,8 +247,8 @@ bool ScummRenderer::setPalette(const Palette & pal) {
}
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();