[Scummvm-cvs-logs] SF.net SVN: scummvm:[39542] scummvm/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Thu Mar 19 22:43:27 CET 2009
Revision: 39542
http://scummvm.svn.sourceforge.net/scummvm/?rev=39542&view=rev
Author: fingolfin
Date: 2009-03-19 21:43:27 +0000 (Thu, 19 Mar 2009)
Log Message:
-----------
COMMON: Added a new IS_ALIGNED macro (for now using size_t, we can change it if this turns out to be not portable enough. Also added a doxygen comment to the ARRAYSIZE macro
Modified Paths:
--------------
scummvm/trunk/backends/platform/sdl/graphics.cpp
scummvm/trunk/common/util.h
Modified: scummvm/trunk/backends/platform/sdl/graphics.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/graphics.cpp 2009-03-19 21:42:50 UTC (rev 39541)
+++ scummvm/trunk/backends/platform/sdl/graphics.cpp 2009-03-19 21:43:27 UTC (rev 39542)
@@ -793,7 +793,7 @@
assert(h > 0 && y + h <= _videoMode.screenHeight);
assert(w > 0 && x + w <= _videoMode.screenWidth);
- if (((long)src & 3) == 0 && pitch == _videoMode.screenWidth && x == 0 && y == 0 &&
+ if (IS_ALIGNED(src, 4) && pitch == _videoMode.screenWidth && x == 0 && y == 0 &&
w == _videoMode.screenWidth && h == _videoMode.screenHeight && _modeFlags & DF_WANT_RECT_OPTIM) {
/* Special, optimized case for full screen updates.
* It tries to determine what areas were actually changed,
@@ -997,7 +997,7 @@
void OSystem_SDL::addDirtyRgnAuto(const byte *buf) {
assert(buf);
- assert(((long)buf & 3) == 0);
+ assert(IS_ALIGNED(buf, 4));
/* generate a table of the checksums */
makeChecksums(buf);
Modified: scummvm/trunk/common/util.h
===================================================================
--- scummvm/trunk/common/util.h 2009-03-19 21:42:50 UTC (rev 39541)
+++ scummvm/trunk/common/util.h 2009-03-19 21:43:27 UTC (rev 39542)
@@ -28,6 +28,15 @@
#include "common/scummsys.h"
#include "common/str.h"
+
+/**
+ * Check whether a given pointer is aligned correctly.
+ * Note that 'alignment' must be a power of two!
+ */
+#define IS_ALIGNED(value, alignment) \
+ ((((size_t)value) & ((alignment) - 1)) == 0)
+
+
#ifdef MIN
#undef MIN
#endif
@@ -47,6 +56,9 @@
*/
template<typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }
+/**
+ * Macro which determines the number of entries in a fixed size array.
+ */
#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
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