SDL_rect_c.h File Reference
`#include "../SDL_internal.h"`
Include dependency graph for SDL_rect_c.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Functions

SDL_bool | SDL_GetSpanEnclosingRect (int width, int height, int numrects, const SDL_Rect *rects, SDL_Rect *span)

## Function Documentation

## SDL_GetSpanEnclosingRect()

SDL_bool SDL_GetSpanEnclosingRect | ( | int | width,
|  | int | height,
|  | int | numrects,
|  | const SDL_Rect * | rects,
|  | SDL_Rect * | span
| ) |  |

Definition at line 469 of file SDL_rect.c.

References SDL_Rect::h, i, SDL_FALSE, SDL_InvalidParamError, SDL_TRUE, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_UpdateWindowTexture().

{
int i;
int span_y1, span_y2;
int rect_y1, rect_y2;
if (width < 1) {
SDL_InvalidParamError("width");
return SDL_FALSE;
}
if (height < 1) {
SDL_InvalidParamError("height");
return SDL_FALSE;
}
if (!rects) {
SDL_InvalidParamError("rects");
return SDL_FALSE;
}
if (!span) {
SDL_InvalidParamError("span");
return SDL_FALSE;
}
if (numrects < 1) {
SDL_InvalidParamError("numrects");
return SDL_FALSE;
}
/* Initialize to empty rect */
span_y1 = height;
span_y2 = 0;
for (i = 0; i < numrects; ++i) {
rect_y1 = rects[i].y;
rect_y2 = rect_y1 + rects[i].h;
/* Clip out of bounds rectangles, and expand span rect */
if (rect_y1 < 0) {
span_y1 = 0;
} else if (rect_y1 < span_y1) {
span_y1 = rect_y1;
}
if (rect_y2 > height) {
span_y2 = height;
} else if (rect_y2 > span_y2) {
span_y2 = rect_y2;
}
}
if (span_y2 > span_y1) {
span->x = 0;
span->y = span_y1;
span->w = width;
span->h = (span_y2 - span_y1);
return SDL_TRUE;
}
return SDL_FALSE;
}
SDL_TRUE
Definition: SDL_stdinc.h:142
SDL_FALSE
Definition: SDL_stdinc.h:141
SDL_InvalidParamError
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
SDL_Rect::x
int x
Definition: SDL_rect.h:66
SDL_Rect::w
int w
Definition: SDL_rect.h:67
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
height
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
SDL_Rect::h
int h
Definition: SDL_rect.h:67
SDL_Rect::y
int y
Definition: SDL_rect.h:66