- little bit more cleanup

- added fixme about Surface::move

svn-id: r29442
This commit is contained in:
Johannes Schickel 2007-11-06 23:03:19 +00:00
parent 3592690b78
commit 616c8357b4
2 changed files with 15 additions and 11 deletions

View file

@ -22,6 +22,7 @@
* $Id$
*/
#include "common/algorithm.h"
#include "common/util.h"
#include "graphics/primitives.h"
#include "graphics/surface.h"
@ -78,15 +79,15 @@ void Surface::hLine(int x, int y, int x2, uint32 color) {
if (x2 >= w)
x2 = w - 1;
if (x2 < x)
return;
if (bytesPerPixel == 1) {
byte *ptr = (byte *)getBasePtr(x, y);
if (x2 >= x)
memset(ptr, (byte)color, x2-x+1);
memset(ptr, (byte)color, x2-x+1);
} else if (bytesPerPixel == 2) {
uint16 *ptr = (uint16 *)getBasePtr(x, y);
while (x++ <= x2) {
*ptr++ = (uint16)color;
}
Common::set_to(ptr, ptr + (x2-x+1), (uint16)color);
} else {
error("Surface::hLine: bytesPerPixel must be 1 or 2");
}
@ -122,8 +123,7 @@ void Surface::vLine(int x, int y, int y2, uint32 color) {
}
}
void Surface::fillRect(const Common::Rect &rOld, uint32 color) {
Common::Rect r(rOld);
void Surface::fillRect(Common::Rect r, uint32 color) {
r.clip(w, h);
if (!r.isValidRect())
@ -142,9 +142,7 @@ void Surface::fillRect(const Common::Rect &rOld, uint32 color) {
} else if (bytesPerPixel == 2) {
uint16 *ptr = (uint16 *)getBasePtr(r.left, r.top);
while (height--) {
for (i = 0; i < width; i++) {
ptr[i] = (uint16)color;
}
Common::set_to(ptr, ptr + width, (uint16)color);
ptr += pitch/2;
}
} else {
@ -159,6 +157,11 @@ void Surface::frameRect(const Common::Rect &r, uint32 color) {
vLine(r.right-1, r.top, r.bottom-1, color);
}
// FIXME: LordHoto asks why is this in Surface, since this
// just supports 8bpp surfaces. Looks like someone wants
// to subclass Surface to add this or it should be extended
// to support 16bpp (or marked as just working for 8bpp
// surfaces).
void Surface::move(int dx, int dy, int height) {
// Short circuit check - do we have to do anything anyway?
if ((dx == 0 && dy == 0) || height <= 0)