21 #include "../SDL_internal.h" 30 int Amin, Amax, Bmin, Bmax;
77 int Amin, Amax, Bmin, Bmax;
111 result->
w = Amax - Amin;
123 result->
h = Amax - Amin;
131 int Amin, Amax, Bmin, Bmax;
176 result->
w = Amax - Amin;
188 result->
h = Amax - Amin;
213 const int clip_minx = clip->
x;
214 const int clip_miny = clip->
y;
215 const int clip_maxx = clip->
x+clip->
w-1;
216 const int clip_maxy = clip->
y+clip->
h-1;
223 for (i = 0; i <
count; ++
i) {
233 if (result ==
NULL) {
245 }
else if (x > maxx) {
250 }
else if (y > maxy) {
259 if (result ==
NULL) {
264 minx = maxx = points[0].
x;
265 miny = maxy = points[0].
y;
267 for (i = 1; i <
count; ++
i) {
273 }
else if (x > maxx) {
278 }
else if (y > maxy) {
287 result->
w = (maxx-minx)+1;
288 result->
h = (maxy-miny)+1;
294 #define CODE_BOTTOM 1 305 }
else if (y >= rect->
y + rect->
h) {
310 }
else if (x >= rect->
x + rect->
w) {
328 int outcode1, outcode2;
366 rectx2 = rect->
x + rect->
w - 1;
367 recty2 = rect->
y + rect->
h - 1;
376 if ((x1 < rectx1 && x2 < rectx1) || (x1 > rectx2 && x2 > rectx2) ||
377 (y1 < recty1 && y2 < recty1) || (y1 > recty2 && y2 > recty2)) {
385 }
else if (x1 > rectx2) {
390 }
else if (x2 > rectx2) {
400 }
else if (y1 > recty2) {
405 }
else if (y2 > recty2) {
414 while (outcode1 || outcode2) {
415 if (outcode1 & outcode2) {
422 x = x1 + ((x2 -
x1) * (y - y1)) / (y2 - y1);
425 x = x1 + ((x2 -
x1) * (y - y1)) / (y2 - y1);
428 y = y1 + ((y2 -
y1) * (x - x1)) / (x2 - x1);
431 y = y1 + ((y2 -
y1) * (x - x1)) / (x2 - x1);
439 x = x1 + ((x2 -
x1) * (y - y1)) / (y2 - y1);
442 x = x1 + ((x2 -
x1) * (y - y1)) / (y2 - y1);
448 y = y1 + ((y2 -
y1) * (x - x1)) / (x2 - x1);
454 y = y1 + ((y2 -
y1) * (x - x1)) / (x2 - x1);
473 int span_y1, span_y2;
474 int rect_y1, rect_y2;
505 for (i = 0; i < numrects; ++
i) {
506 rect_y1 = rects[
i].
y;
507 rect_y2 = rect_y1 + rects[
i].
h;
512 }
else if (rect_y1 < span_y1) {
515 if (rect_y2 > height) {
517 }
else if (rect_y2 > span_y2) {
521 if (span_y2 > span_y1) {
525 span->
h = (span_y2 - span_y1);
void SDL_UnionRect(const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result)
Calculate the union of two rectangles.
GLuint GLfloat GLfloat GLfloat x1
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei count
SDL_bool SDL_HasIntersection(const SDL_Rect *A, const SDL_Rect *B)
Determine whether two rectangles intersect.
GLfixed GLfixed GLfixed y2
The structure that defines a point.
static int ComputeOutCode(const SDL_Rect *rect, int x, int y)
#define SDL_InvalidParamError(param)
SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r)
Returns true if the rectangle has no area.
GLint GLint GLsizei width
GLfixed GLfixed GLint GLint GLfixed points
SDL_bool SDL_EnclosePoints(const SDL_Point *points, int count, const SDL_Rect *clip, SDL_Rect *result)
Calculate a minimal rectangle enclosing a set of points.
SDL_bool SDL_IntersectRect(const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result)
Calculate the intersection of two rectangles.
GLint GLint GLint GLint GLint GLint y
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)
#define SDL_assert(condition)
GLint GLint GLsizei GLsizei height
GLenum GLenum void void void * span
EGLSurface EGLint * rects
SDL_bool SDL_IntersectRectAndLine(const SDL_Rect *rect, int *X1, int *Y1, int *X2, int *Y2)
Calculate the intersection of a rectangle and line segment.
A rectangle, with the origin at the upper left.
SDL_bool SDL_GetSpanEnclosingRect(int width, int height, int numrects, const SDL_Rect *rects, SDL_Rect *span)