[Scummvm-cvs-logs] SF.net SVN: scummvm: [29442] scummvm/trunk/graphics
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Wed Nov 7 00:03:19 CET 2007
Revision: 29442
http://scummvm.svn.sourceforge.net/scummvm/?rev=29442&view=rev
Author: lordhoto
Date: 2007-11-06 15:03:19 -0800 (Tue, 06 Nov 2007)
Log Message:
-----------
- little bit more cleanup
- added fixme about Surface::move
Modified Paths:
--------------
scummvm/trunk/graphics/surface.cpp
scummvm/trunk/graphics/surface.h
Modified: scummvm/trunk/graphics/surface.cpp
===================================================================
--- scummvm/trunk/graphics/surface.cpp 2007-11-06 22:40:29 UTC (rev 29441)
+++ scummvm/trunk/graphics/surface.cpp 2007-11-06 23:03:19 UTC (rev 29442)
@@ -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 @@
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::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 @@
} 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 @@
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)
Modified: scummvm/trunk/graphics/surface.h
===================================================================
--- scummvm/trunk/graphics/surface.h 2007-11-06 22:40:29 UTC (rev 29441)
+++ scummvm/trunk/graphics/surface.h 2007-11-06 23:03:19 UTC (rev 29442)
@@ -66,8 +66,9 @@
void drawLine(int x0, int y0, int x1, int y1, uint32 color);
void hLine(int x, int y, int x2, uint32 color);
void vLine(int x, int y, int y2, uint32 color);
- void fillRect(const Common::Rect &r, uint32 color);
+ void fillRect(Common::Rect r, uint32 color);
void frameRect(const Common::Rect &r, uint32 color);
+ // See comment in graphics/surface.cpp about it
void move(int dx, int dy, int height);
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list