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
32d70d6f
Commit
32d70d6f
authored
Feb 14, 2011
by
Ken Rogoway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Software scaling support. Not very fast, but it seems to work.
parent
20b4d9f7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
1 deletion
+62
-1
SDL_surface.h
include/SDL_surface.h
+11
-0
SDL_render_sw.c
src/render/software/SDL_render_sw.c
+6
-1
SDL_surface.c
src/video/SDL_surface.c
+45
-0
No files found.
include/SDL_surface.h
View file @
32d70d6f
...
...
@@ -464,6 +464,17 @@ extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
SDL_Surface
*
dst
,
const
SDL_Rect
*
dstrect
);
/**
* \brief Perform a fast, low quality, stretch blit between two surfaces of the
* different pixel formats.
*
* \note This function calls SDL_SoftStretch or SDL_LowerBlit.
*/
extern
DECLSPEC
int
SDLCALL
SDL_BlitScaled
(
SDL_Surface
*
src
,
const
SDL_Rect
*
srcrect
,
SDL_Surface
*
dst
,
const
SDL_Rect
*
dstrect
);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
...
...
src/render/software/SDL_render_sw.c
View file @
32d70d6f
...
...
@@ -364,7 +364,12 @@ SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
if
(
!
surface
)
{
return
-
1
;
}
return
SDL_BlitSurface
(
src
,
srcrect
,
surface
,
&
final_rect
);
if
(
srcrect
->
w
==
final_rect
.
w
&&
srcrect
->
h
==
final_rect
.
h
)
{
return
SDL_BlitSurface
(
src
,
srcrect
,
surface
,
&
final_rect
);
}
else
{
return
SDL_BlitScaled
(
src
,
srcrect
,
surface
,
&
final_rect
);
}
}
static
int
...
...
src/video/SDL_surface.c
View file @
32d70d6f
...
...
@@ -639,6 +639,51 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect,
return
0
;
}
/*
* Scale and blit a surface
*/
int
SDL_BlitScaled
(
SDL_Surface
*
src
,
const
SDL_Rect
*
srcrect
,
SDL_Surface
*
dst
,
const
SDL_Rect
*
dstrect
)
{
/* Save off the original dst width, height */
int
dstW
=
dstrect
->
w
;
int
dstH
=
dstrect
->
h
;
SDL_Rect
final_dst
=
*
dstrect
;
SDL_Rect
final_src
=
*
srcrect
;
/* Clip the dst surface to the dstrect */
SDL_SetClipRect
(
dst
,
&
final_dst
);
/* If the dest was clipped to a zero sized rect then exit */
if
(
dst
->
clip_rect
.
w
<=
0
||
dst
->
clip_rect
.
h
<=
0
)
{
return
-
1
;
}
/* Did the dst width change? */
if
(
dstW
!=
dst
->
clip_rect
.
w
)
{
/* scale the src width appropriately */
final_src
.
w
=
final_src
.
w
*
dst
->
clip_rect
.
w
/
dstW
;
}
/* Did the dst height change? */
if
(
dstH
!=
dst
->
clip_rect
.
h
)
{
/* scale the src width appropriately */
final_src
.
h
=
final_src
.
h
*
dst
->
clip_rect
.
h
/
dstH
;
}
/* Clip the src surface to the srcrect */
SDL_SetClipRect
(
src
,
&
final_src
);
src
->
map
->
info
.
flags
|=
SDL_COPY_NEAREST
;
if
(
src
->
format
->
format
==
dst
->
format
->
format
&&
!
SDL_ISPIXELFORMAT_INDEXED
(
src
->
format
->
format
)
)
{
return
SDL_SoftStretch
(
src
,
&
final_src
,
dst
,
&
final_dst
);
}
else
{
return
SDL_LowerBlit
(
src
,
&
final_src
,
dst
,
&
final_dst
);
}
}
/*
* Lock a surface to directly access the pixels
*/
...
...
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