Skip to content

Commit 335adb9

Browse files
committed
rename transluent to transparent, correctly set the setZOrderOnTop before the view is attached to the Window, only if the view is transparent.
fix a issue with lost buffer / loading screen, now loading should always be displayed.
1 parent 55dbc25 commit 335adb9

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

docs/source/usage.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ component.
140140

141141
* - Token
142142
- Description
143-
* - `surface.transluent`
144-
- If set to 1, the created surface will be transluent (can be used
143+
* - `surface.transparent`
144+
- If set to 1, the created surface will be transparent (can be used
145145
to add background Android widget in the background, or use accelerated
146146
widgets)
147147
* - `surface.depth`
@@ -150,3 +150,7 @@ component.
150150
support the depth you want.
151151
* - `surface.stencil`
152152
- Size of the stencil component, default to 8.
153+
* - `android.background_color`
154+
- Color (32bits RGBA color), used for the background window. Usually, the
155+
background is covered by the OpenGL Background, unless
156+
`surface.transparent` is set.

src/src/org/renpy/android/PythonActivity.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ protected void onCreate(Bundle savedInstanceState) {
144144

145145
Hardware.view = mView;
146146
setContentView(mView);
147+
148+
// Force the background window color if asked
149+
if ( this.mInfo.metaData.containsKey("android.background_color") ) {
150+
getWindow().getDecorView().setBackgroundColor(
151+
this.mInfo.metaData.getInt("android.background_color"));
152+
}
147153
}
148154

149155
/**

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

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,11 @@ public SDLSurfaceView(PythonActivity act, String argument) {
372372
}
373373
} catch (PackageManager.NameNotFoundException e) {
374374
}
375+
376+
if ( ai.metaData.getInt("surface.transparent") != 0 ) {
377+
Log.d(TAG, "Surface will be transparent, so put on the top.");
378+
setZOrderOnTop(true);
379+
}
375380
}
376381

377382

@@ -530,6 +535,11 @@ static void ackStop() {
530535
*/
531536
public void surfaceCreated(SurfaceHolder holder) {
532537
//Log.i(TAG, "surfaceCreated() is not handled :|");
538+
synchronized (this) {
539+
if (!mStarted) {
540+
this.notifyAll();
541+
}
542+
}
533543
}
534544

535545
/**
@@ -545,7 +555,7 @@ public void surfaceDestroyed(SurfaceHolder holder) {
545555
* not normally called or subclassed by clients of GLSurfaceView.
546556
*/
547557
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
548-
//Log.i(TAG, "surfaceChanged() :|");
558+
//Log.i(TAG, String.format("surfaceChanged() fmt=%d size=%dx%d", format, w, h));
549559
mWidth = w;
550560
mHeight = h;
551561

@@ -653,14 +663,14 @@ public void run() {
653663
return;
654664
}
655665

656-
if ( ai.metaData.getInt("surface.transluent") != 0 ) {
657-
Log.i(TAG, "Surface will be transluent");
658-
getHolder().setFormat(PixelFormat.TRANSLUCENT);
666+
if ( ai.metaData.getInt("surface.transparent") != 0 ) {
667+
Log.i(TAG, "Surface will be transparent");
668+
getHolder().setFormat(PixelFormat.TRANSPARENT);
659669
} else {
660-
Log.i(TAG, "Surface will NOT be transluent");
670+
Log.i(TAG, "Surface will NOT be transparent");
661671
}
662672

663-
Log.w(TAG, "Done");
673+
//Log.d(TAG, "Done");
664674
waitForStart();
665675

666676
nativeResize(mWidth, mHeight);
@@ -815,9 +825,15 @@ private void waitForStart() {
815825
Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mMVPMatrix, 0);
816826

817827
GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
818-
GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 6);
819-
checkGlError("glDrawArrays");
820-
swapBuffers();
828+
829+
// Ensure that, even with double buffer, or if we lost one buffer (like
830+
// BufferQueue has been abandoned!), it will work.
831+
for ( int i = 0; i < 2; i++ ) {
832+
GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
833+
GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 6);
834+
checkGlError("glDrawArrays");
835+
swapBuffers();
836+
}
821837

822838
// Wait to be notified it's okay to start Python.
823839
synchronized (this) {
@@ -830,7 +846,6 @@ private void waitForStart() {
830846
try {
831847
this.wait(250);
832848
} catch (InterruptedException e) {
833-
continue;
834849
}
835850
}
836851
}

0 commit comments

Comments
 (0)