60
60
61
61
62
62
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 =
65
66
"uniform mat4 uMVPMatrix;\n " +
66
67
"attribute vec4 aPosition;\n " +
67
68
"attribute vec2 aTextureCoord;\n " +
@@ -71,7 +72,7 @@ public class SDLSurfaceView extends SurfaceView implements SurfaceHolder.Callbac
71
72
" vTextureCoord = aTextureCoord;\n " +
72
73
"}\n " ;
73
74
74
- private final String mFragmentShader =
75
+ static private final String mFragmentShader =
75
76
"precision mediump float;\n " +
76
77
"varying vec2 vTextureCoord;\n " +
77
78
"uniform sampler2D sTexture;\n " +
@@ -380,9 +381,13 @@ public SDLSurfaceView(PythonActivity act, String argument) {
380
381
}
381
382
382
383
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." );
384
385
setZOrderOnTop (true );
386
+ getHolder ().setFormat (PixelFormat .TRANSPARENT );
387
+ } else {
388
+ Log .i (TAG , "Surface will NOT be transparent" );
385
389
}
390
+
386
391
}
387
392
388
393
@@ -540,7 +545,7 @@ static void ackStop() {
540
545
* not normally called or subclassed by clients of GLSurfaceView.
541
546
*/
542
547
public void surfaceCreated (SurfaceHolder holder ) {
543
- // Log.i (TAG, "surfaceCreated() is not handled :| ");
548
+ if ( DEBUG ) Log .d (TAG , "surfaceCreated()" );
544
549
synchronized (this ) {
545
550
if (!mStarted ) {
546
551
this .notifyAll ();
@@ -553,15 +558,16 @@ public void surfaceCreated(SurfaceHolder holder) {
553
558
* not normally called or subclassed by clients of GLSurfaceView.
554
559
*/
555
560
public void surfaceDestroyed (SurfaceHolder holder ) {
556
- // Log.i (TAG, "surfaceDestroyed() is not handled :| ");
561
+ if ( DEBUG ) Log .d (TAG , "surfaceDestroyed()" );
557
562
}
558
563
559
564
/**
560
565
* This method is part of the SurfaceHolder.Callback interface, and is
561
566
* not normally called or subclassed by clients of GLSurfaceView.
562
567
*/
563
568
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
+
565
571
mWidth = w ;
566
572
mHeight = h ;
567
573
@@ -609,7 +615,7 @@ public void run() {
609
615
int [] attrib_list = {EGL_CONTEXT_CLIENT_VERSION , 2 , EGL10 .EGL_NONE };
610
616
611
617
// Create an opengl es 2.0 surface
612
- Log .w (TAG , "Choose egl configuration" );
618
+ Log .i (TAG , "Choose egl configuration" );
613
619
int configToTest = 0 ;
614
620
boolean configFound = false ;
615
621
@@ -645,7 +651,7 @@ public void run() {
645
651
continue ;
646
652
}
647
653
648
- Log .w (TAG , "Create egl context" );
654
+ if ( DEBUG ) Log .d (TAG , "Create egl context" );
649
655
mEglContext = mEgl .eglCreateContext (mEglDisplay , mEglConfig , EGL10 .EGL_NO_CONTEXT , attrib_list );
650
656
if (mEglContext == null ) {
651
657
Log .w (TAG , "Unable to create egl context with this configuration, try the next one." );
@@ -669,14 +675,7 @@ public void run() {
669
675
return ;
670
676
}
671
677
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" );
680
679
waitForStart ();
681
680
682
681
nativeResize (mWidth , mHeight );
@@ -707,13 +706,6 @@ public void run() {
707
706
System .exit (0 );
708
707
}
709
708
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
-
717
709
private void waitForStart () {
718
710
719
711
int presplashId = mResourceManager .getIdentifier ("presplash" , "drawable" );
@@ -1028,7 +1020,7 @@ public boolean onTouchEvent(final MotionEvent event) {
1028
1020
1029
1021
@ Override
1030
1022
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 ));
1032
1024
if (mDelLen > 0 ){
1033
1025
mDelLen = 0 ;
1034
1026
return true ;
@@ -1042,11 +1034,11 @@ public boolean onKeyDown(int keyCode, final KeyEvent event) {
1042
1034
1043
1035
@ Override
1044
1036
public boolean onKeyUp (int keyCode , final KeyEvent event ) {
1037
+ if (DEBUG ) Log .d (TAG , String .format ("onKeyUp() keyCode=%d" , keyCode ));
1045
1038
if (mDelLen > 0 ){
1046
1039
mDelLen = 0 ;
1047
1040
return true ;
1048
1041
}
1049
- //Log.i("python", String.format("key up %d", keyCode));
1050
1042
if (mInputActivated && nativeKey (keyCode , 0 , event .getUnicodeChar ())) {
1051
1043
return true ;
1052
1044
} else {
@@ -1056,6 +1048,9 @@ public boolean onKeyUp(int keyCode, final KeyEvent event) {
1056
1048
1057
1049
@ Override
1058
1050
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 ));
1059
1054
String keys = event .getCharacters ();
1060
1055
char [] keysBuffer = new char [keys .length ()];
1061
1056
if (mDelLen > 0 ){
@@ -1087,7 +1082,7 @@ public boolean onKeyMultiple(int keyCode, int count, KeyEvent event){
1087
1082
1088
1083
@ Override
1089
1084
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 ));
1091
1086
if (mInputActivated ){
1092
1087
switch (event .getAction ()) {
1093
1088
case KeyEvent .ACTION_DOWN :
@@ -1214,7 +1209,7 @@ private void checkGlError(String op) {
1214
1209
int error ;
1215
1210
while ((error = GLES20 .glGetError ()) != GLES20 .GL_NO_ERROR ) {
1216
1211
Log .e (TAG , op + ": glError " + error );
1217
- throw new RuntimeException (op + ": glError " + error );
1212
+ // throw new RuntimeException(op + ": glError " + error);
1218
1213
}
1219
1214
}
1220
1215
private static final int FLOAT_SIZE_BYTES = 4 ;
0 commit comments