optimized color/rect classes; cleanup

svn-id: r4844
This commit is contained in:
Max Horn 2002-08-25 11:12:49 +00:00
parent 2355db8017
commit 1cbd00bd64
4 changed files with 19 additions and 52 deletions

View file

@ -22,48 +22,16 @@
#include <stdafx.h> #include <stdafx.h>
#include "color.h" #include "color.h"
Color::Color() : _r(0), _g(0), _b(0) { #define UPDATE_COLOR(c, inc) (((int)((c)) << 7) + (c) + (inc)) >> 7
} #define CHECK_BOUNDS(c) (((c) > 255) ? 255 : (((c) < 0) ? 0 : (c)))
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;
}
void Color::delta(short * ptr) { void Color::delta(short * ptr) {
// This is a very specific method for XPALs. // This is a very specific method for XPALs.
int t; 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]); t = UPDATE_COLOR(_r, ptr[0]);
_r = CHECK_BOUNDS(t); _r = CHECK_BOUNDS(t);
t = UPDATE_COLOR(_g, ptr[1]); t = UPDATE_COLOR(_g, ptr[1]);
_g = CHECK_BOUNDS(t); _g = CHECK_BOUNDS(t);
t = UPDATE_COLOR(_b, ptr[2]); t = UPDATE_COLOR(_b, ptr[2]);
_b = CHECK_BOUNDS(t); _b = CHECK_BOUNDS(t);
#undef UPDATE_COLOR
#undef CHECK_BOUNDS
} }

View file

@ -36,14 +36,12 @@ private:
value_type _g; //!< The green component. value_type _g; //!< The green component.
value_type _b; //!< The blue component. value_type _b; //!< The blue component.
public: public:
Color(); Color() : _r(0), _g(0), _b(0) {}
Color(value_type, value_type, value_type); Color(value_type r, value_type g, value_type b) : _r(r), _g(g), _b(b) {}
Color(const Color &);
Color & operator=(const Color &); inline value_type red() const { return _r; }
virtual ~Color(); inline value_type green() const { return _g; }
value_type red() const; inline value_type blue() const { return _b; }
value_type green() const;
value_type blue() const;
/*! @brief handle delta palette modification /*! @brief handle delta palette modification
This method is used specifically by player::handleDeltaPalette(). This method is used specifically by player::handleDeltaPalette().

View file

@ -34,19 +34,19 @@ private:
int _y; //!< The vertical part of the point int _y; //!< The vertical part of the point
public: public:
Point() : _x(0), _y(0) {}; 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) {}; explicit Point(int x, int y) : _x(x), _y(y) {};
Point & operator=(const Point & p) { _x = p.getX(); _y = p.getY(); return *this; }; Point & operator=(const Point & p) { _x = p._x; _y = p._y; return *this; };
bool operator==(const Point & p) const { return _x == p.getX() && _y == p.getY(); }; bool operator==(const Point & p) const { return _x == p._x && _y == p._y; };
const int & getX() const { return _x; }; const int & getX() const { return _x; };
const int & getY() const { return _y; }; const int & getY() const { return _y; };
int & getX() { return _x; }; int & getX() { return _x; };
int & getY() { return _y; }; 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._x, _y+p._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._x, _y-p._y); };
Point & operator+=(const Point & p) { _x += p.getX(); _y += p.getY(); return *this; }; Point & operator+=(const Point & p) { _x += p._x; _y += p._y; return *this; };
Point & operator-=(const Point & p) { _x -= p.getX(); _y -= p.getY(); return *this; }; Point & operator-=(const Point & p) { _x -= p._x; _y -= p._y; return *this; };
bool isOrigin() const { return *this == Point(0, 0); }; bool isOrigin() const { return _x == 0 && _y == 0; };
void set(int x, int y) { _x = x; _y = y; } void set(int x, int y) { _x = x; _y = y; }
}; };

View file

@ -20,6 +20,7 @@
*/ */
#include <stdafx.h> #include <stdafx.h>
#include "common/util.h"
#include "scumm_renderer.h" #include "scumm_renderer.h"
#include "channel.h" #include "channel.h"
@ -246,8 +247,8 @@ bool ScummRenderer::setPalette(const Palette & pal) {
} }
void ScummRenderer::save(int frame) { void ScummRenderer::save(int frame) {
int width = min(getWidth(), _scumm->_realWidth); int width = MIN(getWidth(), _scumm->_realWidth);
int height = min(getHeight(), _scumm->_realHeight); int height = MIN(getHeight(), _scumm->_realHeight);
_scumm->_system->copy_rect((const byte *)data(), getWidth(), 0, 0, width, height); _scumm->_system->copy_rect((const byte *)data(), getWidth(), 0, 0, width, height);
_scumm->_system->update_screen(); _scumm->_system->update_screen();