Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
1694584d
Commit
1694584d
authored
Sep 18, 2011
by
Andreas Schiffler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add special cases for empty rectangles in SDL_Rect functions
parent
6c747303
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
1 deletion
+39
-1
SDL_rect.c
src/video/SDL_rect.c
+39
-1
No files found.
src/video/SDL_rect.c
View file @
1694584d
...
@@ -33,6 +33,11 @@ SDL_HasIntersection(const SDL_Rect * A, const SDL_Rect * B)
...
@@ -33,6 +33,11 @@ SDL_HasIntersection(const SDL_Rect * A, const SDL_Rect * B)
return
SDL_FALSE
;
return
SDL_FALSE
;
}
}
/* Special cases for empty rects */
if
(
SDL_RectEmpty
(
A
)
||
SDL_RectEmpty
(
B
))
{
return
SDL_FALSE
;
}
/* Horizontal intersection */
/* Horizontal intersection */
Amin
=
A
->
x
;
Amin
=
A
->
x
;
Amax
=
Amin
+
A
->
w
;
Amax
=
Amin
+
A
->
w
;
...
@@ -70,6 +75,11 @@ SDL_IntersectRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
...
@@ -70,6 +75,11 @@ SDL_IntersectRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
return
SDL_FALSE
;
return
SDL_FALSE
;
}
}
/* Special cases for empty rects */
if
(
SDL_RectEmpty
(
A
)
||
SDL_RectEmpty
(
B
))
{
return
SDL_FALSE
;
}
/* Horizontal intersection */
/* Horizontal intersection */
Amin
=
A
->
x
;
Amin
=
A
->
x
;
Amax
=
Amin
+
A
->
w
;
Amax
=
Amin
+
A
->
w
;
...
@@ -106,6 +116,24 @@ SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
...
@@ -106,6 +116,24 @@ SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
return
;
return
;
}
}
/* Special cases for empty Rects */
if
(
SDL_RectEmpty
(
A
))
{
if
(
SDL_RectEmpty
(
B
))
{
/* A and B empty */
return
;
}
else
{
/* A empty, B not empty */
*
result
=
*
B
;
return
;
}
}
else
{
if
(
SDL_RectEmpty
(
B
))
{
/* A not empty, B empty */
*
result
=
*
A
;
return
;
}
}
/* Horizontal union */
/* Horizontal union */
Amin
=
A
->
x
;
Amin
=
A
->
x
;
Amax
=
Amin
+
A
->
w
;
Amax
=
Amin
+
A
->
w
;
...
@@ -118,7 +146,7 @@ SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
...
@@ -118,7 +146,7 @@ SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
Amax
=
Bmax
;
Amax
=
Bmax
;
result
->
w
=
Amax
-
Amin
;
result
->
w
=
Amax
-
Amin
;
/* Vertical
intersect
ion */
/* Vertical
un
ion */
Amin
=
A
->
y
;
Amin
=
A
->
y
;
Amax
=
Amin
+
A
->
h
;
Amax
=
Amin
+
A
->
h
;
Bmin
=
B
->
y
;
Bmin
=
B
->
y
;
...
@@ -152,6 +180,11 @@ SDL_EnclosePoints(const SDL_Point * points, int count, const SDL_Rect * clip,
...
@@ -152,6 +180,11 @@ SDL_EnclosePoints(const SDL_Point * points, int count, const SDL_Rect * clip,
}
}
if
(
clip
)
{
if
(
clip
)
{
/* Special case for empty rectangle */
if
(
SDL_RectEmpty
(
clip
))
{
return
SDL_FALSE
;
}
SDL_bool
added
=
SDL_FALSE
;
SDL_bool
added
=
SDL_FALSE
;
int
clip_minx
=
clip
->
x
;
int
clip_minx
=
clip
->
x
;
int
clip_miny
=
clip
->
y
;
int
clip_miny
=
clip
->
y
;
...
@@ -269,6 +302,11 @@ SDL_IntersectRectAndLine(const SDL_Rect * rect, int *X1, int *Y1, int *X2,
...
@@ -269,6 +302,11 @@ SDL_IntersectRectAndLine(const SDL_Rect * rect, int *X1, int *Y1, int *X2,
return
SDL_FALSE
;
return
SDL_FALSE
;
}
}
/* Special case for empty rect */
if
(
SDL_RectEmpty
(
rect
))
{
return
SDL_FALSE
;
}
x1
=
*
X1
;
x1
=
*
X1
;
y1
=
*
Y1
;
y1
=
*
Y1
;
x2
=
*
X2
;
x2
=
*
X2
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment