SDL  2.0
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 468 of file SDL_rect.c.

470 {
471  int i;
472  int span_y1, span_y2;
473  int rect_y1, rect_y2;
474 
475  if (width < 1) {
476  SDL_InvalidParamError("width");
477  return SDL_FALSE;
478  }
479 
480  if (height < 1) {
481  SDL_InvalidParamError("height");
482  return SDL_FALSE;
483  }
484 
485  if (!rects) {
486  SDL_InvalidParamError("rects");
487  return SDL_FALSE;
488  }
489 
490  if (!span) {
491  SDL_InvalidParamError("span");
492  return SDL_FALSE;
493  }
494 
495  if (numrects < 1) {
496  SDL_InvalidParamError("numrects");
497  return SDL_FALSE;
498  }
499 
500  /* Initialize to empty rect */
501  span_y1 = height;
502  span_y2 = 0;
503 
504  for (i = 0; i < numrects; ++i) {
505  rect_y1 = rects[i].y;
506  rect_y2 = rect_y1 + rects[i].h;
507 
508  /* Clip out of bounds rectangles, and expand span rect */
509  if (rect_y1 < 0) {
510  span_y1 = 0;
511  } else if (rect_y1 < span_y1) {
512  span_y1 = rect_y1;
513  }
514  if (rect_y2 > height) {
515  span_y2 = height;
516  } else if (rect_y2 > span_y2) {
517  span_y2 = rect_y2;
518  }
519  }
520  if (span_y2 > span_y1) {
521  span->x = 0;
522  span->y = span_y1;
523  span->w = width;
524  span->h = (span_y2 - span_y1);
525  return SDL_TRUE;
526  }
527  return SDL_FALSE;
528 }
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:90
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
GLenum GLenum void void void * span
@ SDL_TRUE
Definition: SDL_stdinc.h:170
@ SDL_FALSE
Definition: SDL_stdinc.h:169
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
EGLSurface EGLint * rects
Definition: eglext.h:282

References i, SDL_FALSE, SDL_InvalidParamError, and SDL_TRUE.

Referenced by SDL_UpdateWindowTexture().