mirror of
https://github.com/scummvm/scummvm.git
synced 2024-05-29 01:07:44 -04:00
COMMON: Rename memset2/4/8 to memset16/32/64
This commit is contained in:
parent
ae8c6242bf
commit
953772ba99
|
@ -24,7 +24,7 @@
|
|||
|
||||
namespace Common {
|
||||
|
||||
void memset8(uint64 *dst, uint64 val, size_t count) {
|
||||
void memset64(uint64 *dst, uint64 val, size_t count) {
|
||||
if (!count)
|
||||
return;
|
||||
|
||||
|
@ -44,26 +44,26 @@ void memset8(uint64 *dst, uint64 val, size_t count) {
|
|||
}
|
||||
}
|
||||
|
||||
void memset4(uint32 *dst, uint32 val, size_t count) {
|
||||
void memset32(uint32 *dst, uint32 val, size_t count) {
|
||||
if (!IS_ALIGNED(dst, 8) && count) {
|
||||
*dst++ = val;
|
||||
count -= 1;
|
||||
}
|
||||
|
||||
memset8((uint64 *)dst, val | ((uint64)val << 32), count >> 1);
|
||||
memset64((uint64 *)dst, val | ((uint64)val << 32), count >> 1);
|
||||
|
||||
if (count & 1) {
|
||||
dst[count & ~1] = val;
|
||||
}
|
||||
}
|
||||
|
||||
void memset2(uint16 *dst, uint16 val, size_t count) {
|
||||
void memset16(uint16 *dst, uint16 val, size_t count) {
|
||||
if (!IS_ALIGNED(dst, 4) && count) {
|
||||
*dst++ = val;
|
||||
count -= 1;
|
||||
}
|
||||
|
||||
memset4((uint32 *)dst, val | ((uint32)val << 16), count >> 1);
|
||||
memset32((uint32 *)dst, val | ((uint32)val << 16), count >> 1);
|
||||
|
||||
if (count & 1) {
|
||||
dst[count & ~1] = val;
|
||||
|
|
|
@ -46,9 +46,9 @@ namespace Common {
|
|||
*
|
||||
* Note that pointers passed to these functions must be aligned correctly.
|
||||
*/
|
||||
void memset2(uint16 *dst, uint16 val, size_t count);
|
||||
void memset4(uint32 *dst, uint32 val, size_t count);
|
||||
void memset8(uint64 *dst, uint64 val, size_t count);
|
||||
void memset16(uint16 *dst, uint16 val, size_t count);
|
||||
void memset32(uint32 *dst, uint32 val, size_t count);
|
||||
void memset64(uint64 *dst, uint64 val, size_t count);
|
||||
|
||||
/**
|
||||
* Copies data from the range [first, last) to [dst, dst + (last - first)).
|
||||
|
|
|
@ -438,9 +438,9 @@ void colorFill(PixelType *first, PixelType *last, PixelType color) {
|
|||
if (sizeof(PixelType) == 1)
|
||||
memset((uint8 *)first, color, count);
|
||||
else if (sizeof(PixelType) == 2)
|
||||
Common::memset2((uint16 *)first, color, count);
|
||||
Common::memset16((uint16 *)first, color, count);
|
||||
else
|
||||
Common::memset4((uint32 *)first, color, count);
|
||||
Common::memset32((uint32 *)first, color, count);
|
||||
}
|
||||
|
||||
template<typename PixelType>
|
||||
|
@ -470,9 +470,9 @@ void colorFillClip(PixelType *first, PixelType *last, PixelType color, int realX
|
|||
if (sizeof(PixelType) == 1)
|
||||
memset((uint8 *)first, color, count);
|
||||
else if (sizeof(PixelType) == 2)
|
||||
Common::memset2((uint16 *)first, color, count);
|
||||
Common::memset16((uint16 *)first, color, count);
|
||||
else
|
||||
Common::memset4((uint32 *)first, color, count);
|
||||
Common::memset32((uint32 *)first, color, count);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -225,10 +225,10 @@ void Surface::hLine(int x, int y, int x2, uint32 color) {
|
|||
memset(ptr, (byte)color, x2 - x + 1);
|
||||
} else if (format.bytesPerPixel == 2) {
|
||||
uint16 *ptr = (uint16 *)getBasePtr(x, y);
|
||||
Common::memset2(ptr, (uint16)color, x2 - x + 1);
|
||||
Common::memset16(ptr, (uint16)color, x2 - x + 1);
|
||||
} else if (format.bytesPerPixel == 4) {
|
||||
uint32 *ptr = (uint32 *)getBasePtr(x, y);
|
||||
Common::memset4(ptr, (uint32)color, x2 - x + 1);
|
||||
Common::memset32(ptr, (uint32)color, x2 - x + 1);
|
||||
} else {
|
||||
error("Surface::hLine: bytesPerPixel must be 1, 2, or 4");
|
||||
}
|
||||
|
@ -303,12 +303,12 @@ void Surface::fillRect(Common::Rect r, uint32 color) {
|
|||
} else {
|
||||
if (format.bytesPerPixel == 2) {
|
||||
while (height--) {
|
||||
Common::memset2((uint16 *)ptr, (uint16)color, width);
|
||||
Common::memset16((uint16 *)ptr, (uint16)color, width);
|
||||
ptr += pitch;
|
||||
}
|
||||
} else {
|
||||
while (height--) {
|
||||
Common::memset4((uint32 *)ptr, (uint32)color, width);
|
||||
Common::memset32((uint32 *)ptr, (uint32)color, width);
|
||||
ptr += pitch;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ void FrameBuffer::clear(int clearZ, int z, int clearColor, int r, int g, int b,
|
|||
memset(_zbuf, zc[0], sizeof(uint) * _pbufWidth * _pbufHeight);
|
||||
} else {
|
||||
// Cannot use memset, use a variant working on integers (possibly slower)
|
||||
Common::memset4((uint32 *)_zbuf, z, _pbufWidth * _pbufHeight);
|
||||
Common::memset32((uint32 *)_zbuf, z, _pbufWidth * _pbufHeight);
|
||||
}
|
||||
}
|
||||
if (clearColor) {
|
||||
|
@ -105,10 +105,10 @@ void FrameBuffer::clear(int clearZ, int z, int clearColor, int r, int g, int b,
|
|||
// Cannot use memset, use a variant working on shorts/ints (possibly slower)
|
||||
switch(_pbufBpp) {
|
||||
case 2:
|
||||
Common::memset2((uint16 *)pp, color, _pbufWidth * _pbufHeight);
|
||||
Common::memset16((uint16 *)pp, color, _pbufWidth * _pbufHeight);
|
||||
break;
|
||||
case 4:
|
||||
Common::memset4((uint32 *)pp, color, _pbufWidth * _pbufHeight);
|
||||
Common::memset32((uint32 *)pp, color, _pbufWidth * _pbufHeight);
|
||||
break;
|
||||
default:
|
||||
error("Unsupported pixel size %i", _pbufBpp);
|
||||
|
@ -137,7 +137,7 @@ void FrameBuffer::clearRegion(int x, int y, int w, int h, bool clearZ, int z,
|
|||
} else {
|
||||
// Cannot use memset, use a variant working on integers (possibly slower)
|
||||
while (height--) {
|
||||
Common::memset4((uint32 *)zbuf, z, w);
|
||||
Common::memset32((uint32 *)zbuf, z, w);
|
||||
zbuf += _pbufWidth;
|
||||
}
|
||||
}
|
||||
|
@ -160,10 +160,10 @@ void FrameBuffer::clearRegion(int x, int y, int w, int h, bool clearZ, int z,
|
|||
while (height--) {
|
||||
switch(_pbufBpp) {
|
||||
case 2:
|
||||
Common::memset2((uint16 *)pp, color, w);
|
||||
Common::memset16((uint16 *)pp, color, w);
|
||||
break;
|
||||
case 4:
|
||||
Common::memset4((uint32 *)pp, color, w);
|
||||
Common::memset32((uint32 *)pp, color, w);
|
||||
break;
|
||||
default:
|
||||
error("Unsupported pixel size %i", _pbufBpp);
|
||||
|
|
|
@ -4,59 +4,59 @@
|
|||
|
||||
class MemoryTestSuite : public CxxTest::TestSuite {
|
||||
public:
|
||||
void test_memset2() {
|
||||
void test_memset16() {
|
||||
uint16 expected[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
const uint16 step1[8] = { 0, 1, 1, 1, 1, 1, 1, 0 };
|
||||
const uint16 step2[8] = { 0, 1, 2, 2, 2, 2, 1, 0 };
|
||||
const uint16 step3[8] = { 0, 1, 2, 3, 3, 2, 1, 0 };
|
||||
|
||||
Common::memset2(expected + 1, 1, 6);
|
||||
Common::memset16(expected + 1, 1, 6);
|
||||
|
||||
TS_ASSERT_EQUALS(memcmp(expected, step1, sizeof(expected)), 0);
|
||||
|
||||
Common::memset2(expected + 2, 2, 4);
|
||||
Common::memset16(expected + 2, 2, 4);
|
||||
|
||||
TS_ASSERT_EQUALS(memcmp(expected, step2, sizeof(expected)), 0);
|
||||
|
||||
Common::memset2(expected + 3, 3, 2);
|
||||
Common::memset16(expected + 3, 3, 2);
|
||||
|
||||
TS_ASSERT_EQUALS(memcmp(expected, step3, sizeof(expected)), 0);
|
||||
}
|
||||
|
||||
void test_memset4() {
|
||||
void test_memset32() {
|
||||
uint32 expected[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
const uint32 step1[8] = { 0, 1, 1, 1, 1, 1, 1, 0 };
|
||||
const uint32 step2[8] = { 0, 1, 2, 2, 2, 2, 1, 0 };
|
||||
const uint32 step3[8] = { 0, 1, 2, 3, 3, 2, 1, 0 };
|
||||
|
||||
Common::memset4(expected + 1, 1, 6);
|
||||
Common::memset32(expected + 1, 1, 6);
|
||||
|
||||
TS_ASSERT_EQUALS(memcmp(expected, step1, sizeof(expected)), 0);
|
||||
|
||||
Common::memset4(expected + 2, 2, 4);
|
||||
Common::memset32(expected + 2, 2, 4);
|
||||
|
||||
TS_ASSERT_EQUALS(memcmp(expected, step2, sizeof(expected)), 0);
|
||||
|
||||
Common::memset4(expected + 3, 3, 2);
|
||||
Common::memset32(expected + 3, 3, 2);
|
||||
|
||||
TS_ASSERT_EQUALS(memcmp(expected, step3, sizeof(expected)), 0);
|
||||
}
|
||||
|
||||
void test_memset8() {
|
||||
void test_memset64() {
|
||||
uint64 expected[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
const uint64 step1[8] = { 0, 1, 1, 1, 1, 1, 1, 0 };
|
||||
const uint64 step2[8] = { 0, 1, 2, 2, 2, 2, 1, 0 };
|
||||
const uint64 step3[8] = { 0, 1, 2, 3, 3, 2, 1, 0 };
|
||||
|
||||
Common::memset8(expected + 1, 1, 6);
|
||||
Common::memset64(expected + 1, 1, 6);
|
||||
|
||||
TS_ASSERT_EQUALS(memcmp(expected, step1, sizeof(expected)), 0);
|
||||
|
||||
Common::memset8(expected + 2, 2, 4);
|
||||
Common::memset64(expected + 2, 2, 4);
|
||||
|
||||
TS_ASSERT_EQUALS(memcmp(expected, step2, sizeof(expected)), 0);
|
||||
|
||||
Common::memset8(expected + 3, 3, 2);
|
||||
Common::memset64(expected + 3, 3, 2);
|
||||
|
||||
TS_ASSERT_EQUALS(memcmp(expected, step3, sizeof(expected)), 0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue