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
svn-id: r39542
This commit is contained in:
parent
428b0ec800
commit
e59b4587b7
2 changed files with 14 additions and 2 deletions
|
@ -793,7 +793,7 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int
|
||||||
assert(h > 0 && y + h <= _videoMode.screenHeight);
|
assert(h > 0 && y + h <= _videoMode.screenHeight);
|
||||||
assert(w > 0 && x + w <= _videoMode.screenWidth);
|
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) {
|
w == _videoMode.screenWidth && h == _videoMode.screenHeight && _modeFlags & DF_WANT_RECT_OPTIM) {
|
||||||
/* Special, optimized case for full screen updates.
|
/* Special, optimized case for full screen updates.
|
||||||
* It tries to determine what areas were actually changed,
|
* It tries to determine what areas were actually changed,
|
||||||
|
@ -997,7 +997,7 @@ void OSystem_SDL::makeChecksums(const byte *buf) {
|
||||||
|
|
||||||
void OSystem_SDL::addDirtyRgnAuto(const byte *buf) {
|
void OSystem_SDL::addDirtyRgnAuto(const byte *buf) {
|
||||||
assert(buf);
|
assert(buf);
|
||||||
assert(((long)buf & 3) == 0);
|
assert(IS_ALIGNED(buf, 4));
|
||||||
|
|
||||||
/* generate a table of the checksums */
|
/* generate a table of the checksums */
|
||||||
makeChecksums(buf);
|
makeChecksums(buf);
|
||||||
|
|
|
@ -28,6 +28,15 @@
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "common/str.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
|
#ifdef MIN
|
||||||
#undef MIN
|
#undef MIN
|
||||||
#endif
|
#endif
|
||||||
|
@ -47,6 +56,9 @@ template<typename T> inline T CLIP (T v, T amin, T amax)
|
||||||
*/
|
*/
|
||||||
template<typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }
|
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])))
|
#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue