Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Compare Revisions
384f01b12bd26b903eb20052db2c97484a1e1d1e...066a83c9f8cf93fd35a800a6bf7f5f283a6c2312
Commits (1)
Fix SDL scaling weirdness issues.
· 066a83c9
Deucе
authored
May 15, 2021
066a83c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
8 deletions
+82
-8
src/conio/scale.c
src/conio/scale.c
+2
-2
src/conio/sdl_con.c
src/conio/sdl_con.c
+80
-6
No files found.
src/conio/scale.c
View file @
066a83c9
...
...
@@ -302,7 +302,7 @@ pointymult, pointy5, pointy3, xbr4, xbr2, xmult, ymult, csrc->h * yscale, ratio
}
// And finally, interpolate if needed
if
(
ratio
<
1
)
{
if
(
fheight
!=
csrc
->
h
)
{
interpolate_height
(
csrc
->
data
,
ctarget
->
data
,
csrc
->
w
,
csrc
->
h
,
fheight
);
ctarget
->
h
=
fheight
;
ctarget
->
w
=
csrc
->
w
;
...
...
@@ -313,7 +313,7 @@ pointymult, pointy5, pointy3, xbr4, xbr2, xmult, ymult, csrc->h * yscale, ratio
ctarget
=
ret1
;
}
if
(
ratio
>
1
)
{
if
(
fwidth
!=
csrc
->
w
)
{
interpolate_width
(
csrc
->
data
,
ctarget
->
data
,
csrc
->
w
,
csrc
->
h
,
fwidth
);
ctarget
->
h
=
csrc
->
h
;
ctarget
->
w
=
fwidth
;
...
...
src/conio/sdl_con.c
View file @
066a83c9
...
...
@@ -323,6 +323,76 @@ void sdl_flush(void)
sdl_user_func
(
SDL_USEREVENT_FLUSH
);
}
/*
* Returns true if the specified width/height can use the
* internal scaler
*
* vstat lock must be held
*/
static
bool
window_can_scale_internally
(
int
winwidth
,
int
winheight
)
{
int
idealmw
;
int
idealmh
;
int
idealh
;
int
idealw
;
// First, figure out if width or height controlls the image size.
idealmw
=
lround
((
double
)
cvstat
.
scale_numerator
/
cvstat
.
scale_denominator
*
cvstat
.
scrnwidth
);
idealmh
=
lround
((
double
)
cvstat
.
scale_denominator
/
cvstat
.
scale_numerator
*
cvstat
.
scrnheight
);
idealw
=
lround
(
winheight
*
cvstat
.
scale_numerator
/
cvstat
.
scale_denominator
*
cvstat
.
scrnwidth
/
cvstat
.
scrnheight
);
idealh
=
lround
(
winwidth
*
cvstat
.
scale_denominator
/
cvstat
.
scale_numerator
*
cvstat
.
scrnheight
/
cvstat
.
scrnwidth
);
if
(
idealw
<
winwidth
)
{
// Height controls size...
if
(
winheight
%
idealmh
==
0
)
return
true
;
}
else
{
// Width controls size...
if
(
winwidth
%
idealmw
==
0
)
return
true
;
}
return
false
;
}
static
void
internal_scaling_factors
(
int
winwidth
,
int
winheight
,
int
*
x
,
int
*
y
)
{
int
idealmh
;
int
idealmw
;
int
idealh
;
int
idealw
;
// First, figure out if width or height controlls the image size.
idealmw
=
lround
((
double
)
cvstat
.
scale_numerator
/
cvstat
.
scale_denominator
*
cvstat
.
scrnwidth
);
idealmh
=
lround
((
double
)
cvstat
.
scale_denominator
/
cvstat
.
scale_numerator
*
cvstat
.
scrnheight
);
idealw
=
lround
((
double
)
winheight
*
cvstat
.
scale_numerator
/
cvstat
.
scale_denominator
*
cvstat
.
scrnwidth
/
cvstat
.
scrnheight
);
idealh
=
lround
((
double
)
winwidth
*
cvstat
.
scale_denominator
/
cvstat
.
scale_numerator
*
cvstat
.
scrnheight
/
cvstat
.
scrnwidth
);
if
(
idealw
<
winwidth
)
{
// Height controls size...
if
(
idealh
==
winheight
)
{
idealmw
=
cvstat
.
scrnwidth
;
*
x
=
lround
((
double
)
idealw
/
idealmw
);
*
y
=
lround
((
double
)
idealh
/
idealmh
);
return
;
}
}
else
{
// Width controls size...
if
(
idealw
==
winwidth
)
{
idealmh
=
cvstat
.
scrnheight
;
*
x
=
lround
((
double
)
idealw
/
idealmw
);
*
y
=
lround
((
double
)
idealh
/
idealmh
);
return
;
}
}
*
x
=
1
;
*
y
=
1
;
}
static
int
sdl_init_mode
(
int
mode
)
{
int
oldcols
;
...
...
@@ -370,6 +440,7 @@ static int sdl_init_mode(int mode)
vstat
.
vmultiplier
=
1
;
cvstat
=
vstat
;
internal_scaling
=
window_can_scale_internally
(
vstat
.
winwidth
,
vstat
.
winheight
);
pthread_mutex_unlock
(
&
vstatlock
);
pthread_mutex_unlock
(
&
blinker_lock
);
...
...
@@ -420,6 +491,7 @@ void sdl_setwinsize_locked(int w, int h)
h
=
cvstat
.
scrnheight
;
cvstat
.
winwidth
=
vstat
.
winwidth
=
w
;
cvstat
.
winheight
=
vstat
.
winheight
=
h
;
internal_scaling
=
window_can_scale_internally
(
cvstat
.
winwidth
,
cvstat
.
winheight
);
}
void
sdl_setwinsize
(
int
w
,
int
h
)
...
...
@@ -862,6 +934,7 @@ void sdl_video_event_thread(void *data)
else
{
cvstat
.
winwidth
=
w
;
cvstat
.
winheight
=
h
;
internal_scaling
=
window_can_scale_internally
(
w
,
h
);
}
setup_surfaces_locked
();
pthread_mutex_unlock
(
&
vstatlock
);
...
...
@@ -977,13 +1050,12 @@ void sdl_video_event_thread(void *data)
pthread_mutex_lock
(
&
vstatlock
);
pthread_mutex_lock
(
&
win_mutex
);
i
f
((
ev
.
window
.
data1
%
cvstat
.
scrnwidth
)
&&
(
ev
.
window
.
data2
%
cvstat
.
scrnheight
))
{
newh
=
"2"
;
internal_scaling
=
false
;
i
nternal_scaling
=
window_can_scale_internally
(
ev
.
window
.
data1
,
ev
.
window
.
data2
);
if
(
internal_scaling
)
{
newh
=
"0"
;
}
else
{
newh
=
"0"
;
internal_scaling
=
true
;
newh
=
"2"
;
}
sdl
.
GetWindowSize
(
win
,
&
cvstat
.
winwidth
,
&
cvstat
.
winheight
);
if
(
strcmp
(
newh
,
sdl
.
GetHint
(
SDL_HINT_RENDER_SCALE_QUALITY
)))
{
...
...
@@ -1041,7 +1113,9 @@ void sdl_video_event_thread(void *data)
if
(
internal_scaling
)
{
struct
graphics_buffer
*
gb
;
gb
=
do_scale
(
list
,
cvstat
.
winwidth
/
cvstat
.
scrnwidth
,
cvstat
.
winheight
/
cvstat
.
scrnheight
,
int
xscale
,
yscale
;
internal_scaling_factors
(
cvstat
.
winwidth
,
cvstat
.
winheight
,
&
xscale
,
&
yscale
);
gb
=
do_scale
(
list
,
xscale
,
yscale
,
(
double
)
cvstat
.
scale_numerator
/
cvstat
.
scale_denominator
);
src
.
x
=
0
;
src
.
y
=
0
;
...
...