summaryrefslogtreecommitdiff
path: root/src/video/SDL_fillrect.c
diff options
context:
space:
mode:
authorSam Lantinga <slouken@libsdl.org>2009-01-10 18:32:24 +0000
committerSam Lantinga <slouken@libsdl.org>2009-01-10 18:32:24 +0000
commit840977a3f2df5e112ee90d21ea591564e554faf3 (patch)
treeaf1f29c624d19e2bd72170a99dd026e431dba2ec /src/video/SDL_fillrect.c
parent8b072d9defa2505538efcddf9e3803571856c7f5 (diff)
downloadsdl-840977a3f2df5e112ee90d21ea591564e554faf3.tar.gz
Fixed Visual C++ release build for Visual C++ 2005
* Some math functions become intrinsic in release mode, so we need to convert all the math functions into SDL math functions, like we did with the stdlib functions. * Constant initializers of 8-bit values become calls to memset() in release mode, but memset() itself is an intrinsic when explicitly called. So we'll just explicitly call memset() in those cases.
Diffstat (limited to 'src/video/SDL_fillrect.c')
-rw-r--r--src/video/SDL_fillrect.c64
1 files changed, 60 insertions, 4 deletions
diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c
index 3ced3e7fe..f86e675f1 100644
--- a/src/video/SDL_fillrect.c
+++ b/src/video/SDL_fillrect.c
@@ -66,7 +66,7 @@ SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
int i, n = w * bpp; \
Uint8 *p = pixels; \
\
- if (n > 15) { \
+ if (n > 63) { \
int adjust = 16 - ((uintptr_t)p & 15); \
if (adjust < 16) { \
n -= adjust; \
@@ -92,7 +92,35 @@ SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
SSE_END; \
}
-DEFINE_SSE_FILLRECT(1, Uint8)
+static void
+SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
+{
+ SSE_BEGIN;
+
+ while (h--) {
+ int i, n = w;
+ Uint8 *p = pixels;
+
+ if (n > 63) {
+ int adjust = 16 - ((uintptr_t)p & 15);
+ if (adjust) {
+ n -= adjust;
+ SDL_memset(p, color, adjust);
+ p += adjust;
+ }
+ SSE_WORK;
+ }
+ if (n & 63) {
+ int remainder = (n & 63);
+ SDL_memset(p, color, remainder);
+ p += remainder;
+ }
+ pixels += pitch;
+ }
+
+ SSE_END;
+}
+/*DEFINE_SSE_FILLRECT(1, Uint8)*/
DEFINE_SSE_FILLRECT(2, Uint16)
DEFINE_SSE_FILLRECT(4, Uint32)
@@ -131,7 +159,7 @@ SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
int i, n = w * bpp; \
Uint8 *p = pixels; \
\
- if (n > 7) { \
+ if (n > 63) { \
int adjust = 8 - ((uintptr_t)p & 7); \
if (adjust < 8) { \
n -= adjust; \
@@ -157,7 +185,35 @@ SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
MMX_END; \
}
-DEFINE_MMX_FILLRECT(1, Uint8)
+static void
+SDL_FillRect1MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
+{
+ MMX_BEGIN;
+
+ while (h--) {
+ int i, n = w;
+ Uint8 *p = pixels;
+
+ if (n > 63) {
+ int adjust = 8 - ((uintptr_t)p & 7);
+ if (adjust) {
+ n -= adjust;
+ SDL_memset(p, color, adjust);
+ p += adjust;
+ }
+ MMX_WORK;
+ }
+ if (n & 63) {
+ int remainder = (n & 63);
+ SDL_memset(p, color, remainder);
+ p += remainder;
+ }
+ pixels += pitch;
+ }
+
+ MMX_END;
+}
+/*DEFINE_MMX_FILLRECT(1, Uint8)*/
DEFINE_MMX_FILLRECT(2, Uint16)
DEFINE_MMX_FILLRECT(4, Uint32)