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 "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
}

View file

@ -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().

View file

@ -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; }
};

View file

@ -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();