mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-02-16 02:20:55 +00:00
Correctly scale the surface with 4:3 aspect ratios. Merged from 6f70's PR.
This commit is contained in:
@@ -222,12 +222,22 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
{
|
||||
// Get the visible width of the activity
|
||||
double visibleWidth = getWindow().getDecorView().getWidth();
|
||||
double visibleHeight = getWindow().getDecorView().getHeight();
|
||||
|
||||
ViewGroup.LayoutParams lp = sv.getLayoutParams();
|
||||
|
||||
double vidRatio = vidHeight / vidWidth;
|
||||
double visibleRatio = visibleHeight / visibleWidth;
|
||||
|
||||
// Calculate the new size of the SurfaceView
|
||||
if (vidRatio < visibleRatio) {
|
||||
lp.width = (int) visibleWidth;
|
||||
lp.height = (int) ((vidHeight / vidWidth) * visibleWidth);
|
||||
}
|
||||
else {
|
||||
lp.width = (int) ((vidWidth / vidHeight) * visibleHeight);
|
||||
lp.height = (int) visibleHeight;
|
||||
}
|
||||
|
||||
// Apply the size change
|
||||
sv.setLayoutParams(lp);
|
||||
|
||||
Reference in New Issue
Block a user