src/video/SDL_fillrect.c
author Gabriel Jacobo <gabomdq@gmail.com>
Wed, 21 Aug 2013 10:13:12 -0300
changeset 7680 6ab959ebea26
parent 7679 b1fe132bc6a4
child 7682 f182a912606a
permissions -rw-r--r--
More fixes for -Wdeclaration-after-statement
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
     2
  Simple DirectMedia Layer
6885
700f1b25f77f Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
     7
  arising from the use of this software.
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
    11
  freely, subject to the following restrictions:
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5297
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
#include "SDL_config.h"
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
#include "SDL_video.h"
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
#include "SDL_blit.h"
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#ifdef __SSE__
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
/* *INDENT-OFF* */
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
#ifdef _MSC_VER
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
#define SSE_BEGIN \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
    __m128 c128; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
    c128.m128_u32[0] = color; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
    c128.m128_u32[1] = color; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
    c128.m128_u32[2] = color; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
    c128.m128_u32[3] = color;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
#else
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
#define SSE_BEGIN \
7679
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
    39
    __m128 c128; \
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
    DECLARE_ALIGNED(Uint32, cccc[4], 16); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
    cccc[0] = color; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
    cccc[1] = color; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
    cccc[2] = color; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
    cccc[3] = color; \
7679
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
    45
    c128 = *(__m128 *)cccc;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
#endif
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
#define SSE_WORK \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
    for (i = n / 64; i--;) { \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
        _mm_stream_ps((float *)(p+0), c128); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
        _mm_stream_ps((float *)(p+16), c128); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
        _mm_stream_ps((float *)(p+32), c128); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
        _mm_stream_ps((float *)(p+48), c128); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
        p += 64; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
    }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
#define SSE_END
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
#define DEFINE_SSE_FILLRECT(bpp, type) \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
static void \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
{ \
7679
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
    63
    int i, n; \
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
    64
    Uint8 *p = NULL; \
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
    65
 \
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
    SSE_BEGIN; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
 \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
    while (h--) { \
7679
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
    69
        n = w * bpp; \
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
    70
        p = pixels; \
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
 \
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
    72
        if (n > 63) { \
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
            int adjust = 16 - ((uintptr_t)p & 15); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
            if (adjust < 16) { \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
                n -= adjust; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
                adjust /= bpp; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
                while (adjust--) { \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
                    *((type *)p) = (type)color; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
                    p += bpp; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
                } \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
            } \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
            SSE_WORK; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
        } \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
        if (n & 63) { \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
            int remainder = (n & 63); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
            remainder /= bpp; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
            while (remainder--) { \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
                *((type *)p) = (type)color; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
                p += bpp; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
            } \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
        } \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
        pixels += pitch; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
    } \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
 \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
    SSE_END; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
}
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
    98
static void
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
    99
SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   100
{
7679
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   101
    int i, n;
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   102
    Uint8 *p = NULL;
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   103
    
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   104
    SSE_BEGIN;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   105
    while (h--) {
7679
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   106
        n = w;
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   107
        p = pixels;
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   108
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   109
        if (n > 63) {
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   110
            int adjust = 16 - ((uintptr_t)p & 15);
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   111
            if (adjust) {
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   112
                n -= adjust;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   113
                SDL_memset(p, color, adjust);
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   114
                p += adjust;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   115
            }
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   116
            SSE_WORK;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   117
        }
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   118
        if (n & 63) {
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   119
            int remainder = (n & 63);
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   120
            SDL_memset(p, color, remainder);
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   121
            p += remainder;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   122
        }
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   123
        pixels += pitch;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   124
    }
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   125
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   126
    SSE_END;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   127
}
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   128
/* DEFINE_SSE_FILLRECT(1, Uint8) */
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
DEFINE_SSE_FILLRECT(2, Uint16)
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
DEFINE_SSE_FILLRECT(4, Uint32)
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
/* *INDENT-ON* */
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
#endif /* __SSE__ */
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
#ifdef __MMX__
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
/* *INDENT-OFF* */
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
#define MMX_BEGIN \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
    __m64 c64 = _mm_set_pi32(color, color)
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
#define MMX_WORK \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
    for (i = n / 64; i--;) { \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
        _mm_stream_pi((__m64 *)(p+0), c64); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
        _mm_stream_pi((__m64 *)(p+8), c64); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
        _mm_stream_pi((__m64 *)(p+16), c64); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
        _mm_stream_pi((__m64 *)(p+24), c64); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
        _mm_stream_pi((__m64 *)(p+32), c64); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
        _mm_stream_pi((__m64 *)(p+40), c64); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
        _mm_stream_pi((__m64 *)(p+48), c64); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
        _mm_stream_pi((__m64 *)(p+56), c64); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
        p += 64; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
    }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
#define MMX_END \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
    _mm_empty()
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
#define DEFINE_MMX_FILLRECT(bpp, type) \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
static void \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
{ \
7679
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   161
    int i, n; \
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   162
    Uint8 *p = NULL; \
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   163
 \
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
    MMX_BEGIN; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
 \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
    while (h--) { \
7679
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   167
        n = w * bpp; \
b1fe132bc6a4 Fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7678
diff changeset
   168
        p = pixels; \
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
 \
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   170
        if (n > 63) { \
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
            int adjust = 8 - ((uintptr_t)p & 7); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
            if (adjust < 8) { \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
                n -= adjust; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
                adjust /= bpp; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
                while (adjust--) { \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
                    *((type *)p) = (type)color; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
                    p += bpp; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
                } \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
            } \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
            MMX_WORK; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
        } \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
        if (n & 63) { \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
            int remainder = (n & 63); \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
            remainder /= bpp; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
            while (remainder--) { \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
                *((type *)p) = (type)color; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
                p += bpp; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
            } \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
        } \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
        pixels += pitch; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
    } \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
 \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
    MMX_END; \
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
}
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   196
static void
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   197
SDL_FillRect1MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   198
{
7680
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   199
    int i, n;
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   200
    Uint8 *p = NULL;
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   201
    
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   202
    MMX_BEGIN;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   203
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   204
    while (h--) {
7680
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   205
        n = w;
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   206
        p = pixels;
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   207
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   208
        if (n > 63) {
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   209
            int adjust = 8 - ((uintptr_t)p & 7);
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   210
            if (adjust) {
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   211
                n -= adjust;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   212
                SDL_memset(p, color, adjust);
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   213
                p += adjust;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   214
            }
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   215
            MMX_WORK;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   216
        }
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   217
        if (n & 63) {
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   218
            int remainder = (n & 63);
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   219
            SDL_memset(p, color, remainder);
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   220
            p += remainder;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   221
        }
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   222
        pixels += pitch;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   223
    }
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   224
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   225
    MMX_END;
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2913
diff changeset
   226
}
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   227
/* DEFINE_MMX_FILLRECT(1, Uint8) */
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   228
DEFINE_MMX_FILLRECT(2, Uint16)
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
DEFINE_MMX_FILLRECT(4, Uint32)
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   230
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   231
/* *INDENT-ON* */
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   232
#endif /* __MMX__ */
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   233
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   234
static void
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   235
SDL_FillRect1(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   236
{
7680
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   237
    int n;
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   238
    Uint8 *p = NULL;
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   239
    
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   240
    while (h--) {
7680
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   241
        n = w;
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   242
        p = pixels;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
        if (n > 3) {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   245
            switch ((uintptr_t) p & 3) {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   246
            case 1:
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   247
                *p++ = (Uint8) color;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
                --n;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
            case 2:
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
                *p++ = (Uint8) color;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
                --n;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
            case 3:
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
                *p++ = (Uint8) color;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
                --n;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
            }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
            SDL_memset4(p, color, (n >> 2));
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
        }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   258
        if (n & 3) {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   259
            p += (n & ~3);
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   260
            switch (n & 3) {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   261
            case 3:
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   262
                *p++ = (Uint8) color;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   263
            case 2:
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
                *p++ = (Uint8) color;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   265
            case 1:
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   266
                *p++ = (Uint8) color;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
            }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   268
        }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   269
        pixels += pitch;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
    }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   271
}
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   272
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   273
static void
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   274
SDL_FillRect2(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
{
7680
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   276
    int n;
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   277
    Uint8 *p = NULL;
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   278
    
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   279
    while (h--) {
7680
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   280
        n = w;
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   281
        p = (Uint16 *) pixels;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   282
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   283
        if (n > 1) {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   284
            if ((uintptr_t) p & 2) {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   285
                *p++ = (Uint16) color;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   286
                --n;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   287
            }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   288
            SDL_memset4(p, color, (n >> 1));
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   289
        }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   290
        if (n & 1) {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   291
            p[n - 1] = (Uint16) color;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   292
        }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   293
        pixels += pitch;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   294
    }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   295
}
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   296
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   297
static void
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   298
SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   299
{
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   300
    Uint8 r = (Uint8) ((color >> 16) & 0xFF);
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   301
    Uint8 g = (Uint8) ((color >> 8) & 0xFF);
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   302
    Uint8 b = (Uint8) (color & 0xFF);
7680
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   303
    int n;
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   304
    Uint8 *p = NULL;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   305
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   306
    while (h--) {
7680
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   307
        n = w;
6ab959ebea26 More fixes for -Wdeclaration-after-statement
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7679
diff changeset
   308
        p = pixels;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   309
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   310
        while (n--) {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   311
            *p++ = r;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   312
            *p++ = g;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   313
            *p++ = b;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   314
        }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   315
        pixels += pitch;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   316
    }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   317
}
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   318
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   319
static void
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   320
SDL_FillRect4(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   321
{
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   322
    while (h--) {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   323
        SDL_memset4(pixels, color, w);
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   324
        pixels += pitch;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   325
    }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   326
}
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   327
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   328
/* 
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   329
 * This function performs a fast fill of the given rectangle with 'color'
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   330
 */
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   331
int
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   332
SDL_FillRect(SDL_Surface * dst, const SDL_Rect * rect, Uint32 color)
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   333
{
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   334
    SDL_Rect clipped;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   335
    Uint8 *pixels;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   336
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   337
    if (!dst) {
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   338
        return SDL_SetError("Passed NULL destination surface");
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   339
    }
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   340
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   341
    /* This function doesn't work on surfaces < 8 bpp */
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   342
    if (dst->format->BitsPerPixel < 8) {
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   343
        return SDL_SetError("SDL_FillRect(): Unsupported surface format");
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   344
    }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   345
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   346
    /* If 'rect' == NULL, then fill the whole surface */
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   347
    if (rect) {
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   348
        /* Perform clipping */
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   349
        if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) {
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   350
            return 0;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   351
        }
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   352
        rect = &clipped;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   353
    } else {
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   354
        rect = &dst->clip_rect;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   355
    }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   356
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   357
    /* Perform software fill */
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   358
    if (!dst->pixels) {
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   359
        return SDL_SetError("SDL_FillRect(): You must lock the surface");
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   360
    }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   361
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   362
    pixels = (Uint8 *) dst->pixels + rect->y * dst->pitch +
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   363
                                     rect->x * dst->format->BytesPerPixel;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   364
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   365
    switch (dst->format->BytesPerPixel) {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   366
    case 1:
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   367
        {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   368
            color |= (color << 8);
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   369
            color |= (color << 16);
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   370
#ifdef __SSE__
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   371
            if (SDL_HasSSE()) {
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   372
                SDL_FillRect1SSE(pixels, dst->pitch, color, rect->w, rect->h);
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   373
                break;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   374
            }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   375
#endif
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   376
#ifdef __MMX__
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   377
            if (SDL_HasMMX()) {
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   378
                SDL_FillRect1MMX(pixels, dst->pitch, color, rect->w, rect->h);
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   379
                break;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   380
            }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   381
#endif
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   382
            SDL_FillRect1(pixels, dst->pitch, color, rect->w, rect->h);
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   383
            break;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   384
        }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   385
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   386
    case 2:
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   387
        {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   388
            color |= (color << 16);
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   389
#ifdef __SSE__
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   390
            if (SDL_HasSSE()) {
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   391
                SDL_FillRect2SSE(pixels, dst->pitch, color, rect->w, rect->h);
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   392
                break;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   393
            }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   394
#endif
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   395
#ifdef __MMX__
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   396
            if (SDL_HasMMX()) {
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   397
                SDL_FillRect2MMX(pixels, dst->pitch, color, rect->w, rect->h);
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   398
                break;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   399
            }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   400
#endif
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   401
            SDL_FillRect2(pixels, dst->pitch, color, rect->w, rect->h);
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   402
            break;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   403
        }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   404
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   405
    case 3:
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   406
        /* 24-bit RGB is a slow path, at least for now. */
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   407
        {
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   408
            SDL_FillRect3(pixels, dst->pitch, color, rect->w, rect->h);
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   409
            break;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   410
        }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   411
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   412
    case 4:
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   413
        {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   414
#ifdef __SSE__
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   415
            if (SDL_HasSSE()) {
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   416
                SDL_FillRect4SSE(pixels, dst->pitch, color, rect->w, rect->h);
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   417
                break;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   418
            }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   419
#endif
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   420
#ifdef __MMX__
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   421
            if (SDL_HasMMX()) {
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   422
                SDL_FillRect4MMX(pixels, dst->pitch, color, rect->w, rect->h);
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   423
                break;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   424
            }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   425
#endif
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   426
            SDL_FillRect4(pixels, dst->pitch, color, rect->w, rect->h);
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   427
            break;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   428
        }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   429
    }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   430
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   431
    /* We're done! */
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   432
    return 0;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   433
}
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   434
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   435
int
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   436
SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   437
              Uint32 color)
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   438
{
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   439
    int i;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   440
    int status = 0;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   441
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   442
    if (!rects) {
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   443
        return SDL_SetError("SDL_FillRects() passed NULL rects");
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   444
    }
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   445
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   446
    for (i = 0; i < count; ++i) {
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   447
        status += SDL_FillRect(dst, &rects[i], color);
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   448
    }
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3012
diff changeset
   449
    return status;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   450
}
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   451
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   452
/* vi: set ts=4 sw=4 expandtab: */