Skip to content

Commit 9bce70f

Browse files
committed
Merge branch 'j-santander-master' into old_toolchain
2 parents 9b4d6a7 + 3b2397d commit 9bce70f

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

src/src/org/renpy/android/SDLSurfaceView.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,37 @@ private void waitForStart() {
812812
GLES20.glViewport(0, 0, mWidth, mHeight);
813813

814814
if (bitmap != null) {
815-
float mx = ((float)mWidth / bitmap.getWidth()) / 2.0f;
816-
float my = ((float)mHeight / bitmap.getHeight()) / 2.0f;
815+
String fit = (String) ai.metaData.get("presplash-fit");
816+
817+
Log.i("python","presplash-fit is "+fit);
818+
// WARNING: The presplash-fit api is unstable and may be changed
819+
820+
int bitmapWidth = bitmap.getWidth();
821+
int bitmapHeight = bitmap.getHeight();
822+
823+
float mx;
824+
float my;
825+
826+
if (fit != null && fit.equals("fit")) {
827+
float bitmapMultiplier = (float) Math.sqrt(2f * mWidth * mHeight / bitmapWidth / bitmapHeight);
828+
mx = (float) mWidth / bitmapWidth / bitmapMultiplier;
829+
my = (float) mHeight / bitmapHeight / bitmapMultiplier;
830+
} else if (fit != null && fit.equals("width")) {
831+
float bitmapMultiplier = ((float) mWidth) / bitmapWidth;
832+
mx = (float) mWidth / bitmapWidth / 2.0f /bitmapMultiplier;
833+
my = (float) mHeight / bitmapHeight / 2.0f /bitmapMultiplier;
834+
} else if (fit != null && fit.equals("height")) {
835+
float bitmapMultiplier = ((float) mHeight) / bitmapHeight;
836+
mx = (float) mWidth / bitmapWidth / 2.0f / bitmapMultiplier;
837+
my = (float) mHeight / bitmapHeight / 2.0f / bitmapMultiplier;
838+
} else {
839+
// default
840+
mx = ((float) mWidth / bitmapWidth) / 2.0f;
841+
my = ((float) mHeight / bitmapWidth) / 2.0f;
842+
}
843+
844+
Log.i("python", String.format("presplash (fit=%s) mx=%f,my=%f", fit,mx, my));
845+
817846
Matrix.orthoM(mProjMatrix, 0, -mx, mx, my, -my, 0, 10);
818847
int value = bitmap.getPixel(0, 0);
819848
Color color = new Color();

0 commit comments

Comments
 (0)