Skip to content

Commit 937f873

Browse files
committed
call setFormat in the constructor, to avoid the surfaceview creation twice on the start. it is enough to resolve the issues seen on the Gabriel Nexus 7 2013 gen/Android 4.3
1 parent b09db57 commit 937f873

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

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

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@
6060

6161

6262
public class SDLSurfaceView extends SurfaceView implements SurfaceHolder.Callback, Runnable {
63-
private static String TAG = "SDLSurface";
64-
private final String mVertexShader =
63+
static private final String TAG = "SDLSurface";
64+
static private final boolean DEBUG = false;
65+
static private final String mVertexShader =
6566
"uniform mat4 uMVPMatrix;\n" +
6667
"attribute vec4 aPosition;\n" +
6768
"attribute vec2 aTextureCoord;\n" +
@@ -71,7 +72,7 @@ public class SDLSurfaceView extends SurfaceView implements SurfaceHolder.Callbac
7172
" vTextureCoord = aTextureCoord;\n" +
7273
"}\n";
7374

74-
private final String mFragmentShader =
75+
static private final String mFragmentShader =
7576
"precision mediump float;\n" +
7677
"varying vec2 vTextureCoord;\n" +
7778
"uniform sampler2D sTexture;\n" +
@@ -380,9 +381,13 @@ public SDLSurfaceView(PythonActivity act, String argument) {
380381
}
381382

382383
if ( ai.metaData.getInt("surface.transparent") != 0 ) {
383-
Log.d(TAG, "Surface will be transparent, so put on the top.");
384+
Log.d(TAG, "Surface will be transparent.");
384385
setZOrderOnTop(true);
386+
getHolder().setFormat(PixelFormat.TRANSPARENT);
387+
} else {
388+
Log.i(TAG, "Surface will NOT be transparent");
385389
}
390+
386391
}
387392

388393

@@ -540,7 +545,7 @@ static void ackStop() {
540545
* not normally called or subclassed by clients of GLSurfaceView.
541546
*/
542547
public void surfaceCreated(SurfaceHolder holder) {
543-
//Log.i(TAG, "surfaceCreated() is not handled :|");
548+
if (DEBUG) Log.d(TAG, "surfaceCreated()");
544549
synchronized (this) {
545550
if (!mStarted) {
546551
this.notifyAll();
@@ -553,15 +558,16 @@ public void surfaceCreated(SurfaceHolder holder) {
553558
* not normally called or subclassed by clients of GLSurfaceView.
554559
*/
555560
public void surfaceDestroyed(SurfaceHolder holder) {
556-
//Log.i(TAG, "surfaceDestroyed() is not handled :|");
561+
if (DEBUG) Log.d(TAG, "surfaceDestroyed()");
557562
}
558563

559564
/**
560565
* This method is part of the SurfaceHolder.Callback interface, and is
561566
* not normally called or subclassed by clients of GLSurfaceView.
562567
*/
563568
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
564-
//Log.i(TAG, String.format("surfaceChanged() fmt=%d size=%dx%d", format, w, h));
569+
if (DEBUG) Log.i(TAG, String.format("surfaceChanged() fmt=%d size=%dx%d", format, w, h));
570+
565571
mWidth = w;
566572
mHeight = h;
567573

@@ -609,7 +615,7 @@ public void run() {
609615
int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
610616

611617
// Create an opengl es 2.0 surface
612-
Log.w(TAG, "Choose egl configuration");
618+
Log.i(TAG, "Choose egl configuration");
613619
int configToTest = 0;
614620
boolean configFound = false;
615621

@@ -645,7 +651,7 @@ public void run() {
645651
continue;
646652
}
647653

648-
Log.w(TAG, "Create egl context");
654+
if (DEBUG) Log.d(TAG, "Create egl context");
649655
mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
650656
if (mEglContext == null) {
651657
Log.w(TAG, "Unable to create egl context with this configuration, try the next one.");
@@ -669,14 +675,7 @@ public void run() {
669675
return;
670676
}
671677

672-
if ( ai.metaData.getInt("surface.transparent") != 0 ) {
673-
Log.i(TAG, "Surface will be transparent");
674-
getHolder().setFormat(PixelFormat.TRANSPARENT);
675-
} else {
676-
Log.i(TAG, "Surface will NOT be transparent");
677-
}
678-
679-
//Log.d(TAG, "Done");
678+
if (DEBUG) Log.d(TAG, "Done egl");
680679
waitForStart();
681680

682681
nativeResize(mWidth, mHeight);
@@ -707,13 +706,6 @@ public void run() {
707706
System.exit(0);
708707
}
709708

710-
private void glCheck(GL10 gl) {
711-
int gle = gl.glGetError();
712-
if (gle != gl.GL_NO_ERROR) {
713-
throw new RuntimeException("GL Error: " + gle);
714-
}
715-
}
716-
717709
private void waitForStart() {
718710

719711
int presplashId = mResourceManager.getIdentifier("presplash", "drawable");
@@ -1028,7 +1020,7 @@ public boolean onTouchEvent(final MotionEvent event) {
10281020

10291021
@Override
10301022
public boolean onKeyDown(int keyCode, final KeyEvent event) {
1031-
//Log.i("python", String.format("key down %d", keyCode));
1023+
if (DEBUG) Log.d(TAG, String.format("onKeyDown() keyCode=%d", keyCode));
10321024
if (mDelLen > 0){
10331025
mDelLen = 0;
10341026
return true;
@@ -1042,11 +1034,11 @@ public boolean onKeyDown(int keyCode, final KeyEvent event) {
10421034

10431035
@Override
10441036
public boolean onKeyUp(int keyCode, final KeyEvent event) {
1037+
if (DEBUG) Log.d(TAG, String.format("onKeyUp() keyCode=%d", keyCode));
10451038
if (mDelLen > 0){
10461039
mDelLen = 0;
10471040
return true;
10481041
}
1049-
//Log.i("python", String.format("key up %d", keyCode));
10501042
if (mInputActivated && nativeKey(keyCode, 0, event.getUnicodeChar())) {
10511043
return true;
10521044
} else {
@@ -1056,6 +1048,9 @@ public boolean onKeyUp(int keyCode, final KeyEvent event) {
10561048

10571049
@Override
10581050
public boolean onKeyMultiple(int keyCode, int count, KeyEvent event){
1051+
if (DEBUG)
1052+
Log.d(TAG, String.format(
1053+
"onKeyMultiple() keyCode=%d count=%d", keyCode, count));
10591054
String keys = event.getCharacters();
10601055
char[] keysBuffer = new char[keys.length()];
10611056
if (mDelLen > 0){
@@ -1087,7 +1082,7 @@ public boolean onKeyMultiple(int keyCode, int count, KeyEvent event){
10871082

10881083
@Override
10891084
public boolean onKeyPreIme(int keyCode, final KeyEvent event){
1090-
//Log.i("python", String.format("key pre ime %d", keyCode));
1085+
if (DEBUG) Log.d(TAG, String.format("onKeyPreIme() keyCode=%d", keyCode));
10911086
if (mInputActivated){
10921087
switch (event.getAction()) {
10931088
case KeyEvent.ACTION_DOWN:
@@ -1214,7 +1209,7 @@ private void checkGlError(String op) {
12141209
int error;
12151210
while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) {
12161211
Log.e(TAG, op + ": glError " + error);
1217-
throw new RuntimeException(op + ": glError " + error);
1212+
//throw new RuntimeException(op + ": glError " + error);
12181213
}
12191214
}
12201215
private static final int FLOAT_SIZE_BYTES = 4;

0 commit comments

Comments
 (0)