src/video/SDL_rect.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 10 Jul 2006 07:34:50 +0000
branchSDL-1.3
changeset 1735 8dd28c4ef746
child 2223 175754591a13
permissions -rw-r--r--
SDL_Rect now uses int for position and size. Added a few more rectangle functions. Added a dirty rectangle list implementation.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1735
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
    Copyright (C) 1997-2006 Sam Lantinga
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    Lesser General Public License for more details.
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free Software
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
#include "SDL_config.h"
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
#include "SDL_video.h"
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
#include "SDL_rect_c.h"
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
SDL_bool
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
SDL_HasIntersection(const SDL_Rect * A, const SDL_Rect * B)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
{
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
    int Amin, Amax, Bmin, Bmax;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
    /* Horizontal intersection */
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
    Amin = A->x;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
    Amax = Amin + A->w;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
    Bmin = B->x;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
    Bmax = Bmin + B->w;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
    if (Bmin > Amin)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
        Amin = Bmin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
    if (Bmax < Amax)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
        Amax = Bmax;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
    if (Amax <= Amin)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
        return SDL_FALSE;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
    /* Vertical intersection */
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
    Amin = A->y;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
    Amax = Amin + A->h;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
    Bmin = B->y;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
    Bmax = Bmin + B->h;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
    if (Bmin > Amin)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
        Amin = Bmin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
    if (Bmax < Amax)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
        Amax = Bmax;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
    if (Amax <= Amin)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
        return SDL_FALSE;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
    return SDL_TRUE;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
}
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
SDL_bool
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
SDL_IntersectRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
{
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
    int Amin, Amax, Bmin, Bmax;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
    /* Horizontal intersection */
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
    Amin = A->x;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
    Amax = Amin + A->w;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
    Bmin = B->x;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
    Bmax = Bmin + B->w;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
    if (Bmin > Amin)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
        Amin = Bmin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
    result->x = Amin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
    if (Bmax < Amax)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
        Amax = Bmax;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
    result->w = Amax - Amin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
    /* Vertical intersection */
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
    Amin = A->y;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
    Amax = Amin + A->h;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
    Bmin = B->y;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
    Bmax = Bmin + B->h;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
    if (Bmin > Amin)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
        Amin = Bmin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
    result->y = Amin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
    if (Bmax < Amax)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
        Amax = Bmax;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
    result->h = Amax - Amin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
    return !SDL_RectEmpty(result);
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
}
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
void
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
{
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
    int Amin, Amax, Bmin, Bmax;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
    /* Horizontal union */
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
    Amin = A->x;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
    Amax = Amin + A->w;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
    Bmin = B->x;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
    Bmax = Bmin + B->w;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
    if (Bmin < Amin)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
        Amin = Bmin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
    result->x = Amin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
    if (Bmax > Amax)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
        Amax = Bmax;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
    result->w = Amax - Amin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
    /* Vertical intersection */
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
    Amin = A->y;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
    Amax = Amin + A->h;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
    Bmin = B->y;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
    Bmax = Bmin + B->h;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
    if (Bmin < Amin)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
        Amin = Bmin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
    result->y = Amin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
    if (Bmax > Amax)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
        Amax = Bmax;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
    result->h = Amax - Amin;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
}
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
void
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
SDL_AddDirtyRect(SDL_DirtyRectList * list, const SDL_Rect * rect)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
{
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
    SDL_DirtyRect *dirty;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
    SDL_DirtyRect *check, *prev, *next;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
    if (list->free) {
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
        dirty = list->free;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
        list->free = dirty->next;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
    } else {
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
        dirty = (SDL_DirtyRect *) SDL_malloc(sizeof(*dirty));
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
        if (!dirty) {
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
            return;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
        }
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
    }
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
    dirty->rect = *rect;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
    /* FIXME: At what point is this optimization too expensive? */
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
    for (prev = NULL, check = list->list; check; check = next) {
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
        next = check->next;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
        if (SDL_HasIntersection(&dirty->rect, &check->rect)) {
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
            SDL_UnionRect(&dirty->rect, &check->rect, &dirty->rect);
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
            if (prev) {
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
                prev->next = next;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
            } else {
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
                list->list = next;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
            }
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
            check->next = list->free;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
            list->free = check;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
            --list->count;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
        } else {
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
            prev = check;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
        }
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
    }
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
    dirty->next = list->list;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
    list->list = dirty;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
    ++list->count;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
}
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
void
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
SDL_ClearDirtyRects(SDL_DirtyRectList * list)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
{
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
    while (list->list) {
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
        SDL_DirtyRect *elem = list->list;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
        list->list = elem->next;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
        elem->next = list->free;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
        list->free = elem;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
    }
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
    list->count = 0;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
}
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
void
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
SDL_FreeDirtyRects(SDL_DirtyRectList * list)
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
{
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
    while (list->list) {
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
        SDL_DirtyRect *elem = list->list;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
        list->list = elem->next;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
        SDL_free(elem);
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
    }
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
    while (list->free) {
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
        SDL_DirtyRect *elem = list->free;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
        list->free = elem->next;
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
        SDL_free(elem);
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
    }
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
}
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
8dd28c4ef746 SDL_Rect now uses int for position and size.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
/* vi: set ts=4 sw=4 expandtab: */