diff src/video/SDL_fillrect.c @ 3012:7e30c2dc7783

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.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 10 Jan 2009 18:32:24 +0000
parents ffae53de58f4
children 0267b8b1595c
line wrap: on
line diff
--- a/src/video/SDL_fillrect.c	Fri Jan 09 20:43:30 2009 +0000
+++ b/src/video/SDL_fillrect.c	Sat Jan 10 18:32:24 2009 +0000
@@ -66,7 +66,7 @@
         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 @@
     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 @@
         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 @@
     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)