Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android ZOrder for transparent surfaceView #460

Merged
merged 9 commits into from
Sep 28, 2022

Conversation

CedricGuillemet
Copy link
Contributor

@CedricGuillemet CedricGuillemet commented Sep 13, 2022

As discussed offline, add a new androidView property and remove isTopMost

@CedricGuillemet CedricGuillemet changed the title overlay property Android ZOrder for transparent surfaceView Sep 13, 2022
@bghgary
Copy link
Contributor

bghgary commented Sep 13, 2022

I couldn't find any more info on this. What is the difference between these two functions in practice?

https://developer.android.com/reference/kotlin/android/view/SurfaceView#setzordermediaoverlay

Control whether the surface view's surface is placed on top of another regular surface view in the window (but still behind the window itself). This is typically used to place overlays on top of an underlying media surface view.

https://developer.android.com/reference/kotlin/android/view/SurfaceView#setzorderontop

Control whether the surface view's surface is placed on top of its window. Normally it is placed behind the window, to allow it to (for the most part) appear to composite with the views in the hierarchy. By setting this, you cause it to be placed above the window. This means that none of the contents of the window this SurfaceView is in will be visible on top of its surface.

@CedricGuillemet
Copy link
Contributor Author

I couldn't find any more info on this. What is the difference between these two functions in practice?

setzorderontop will make the surfaceView on top of everything that's under (surfaceView, textureView,... anything), independently of view hierarchy.
setzordermediaoverlay will composite the surfaceView on top of other surfaceViews

@ryantrem
Copy link
Member

setZOrderMediaOverlay says "the surface view's surface is placed on top of another regular surface view in the window (but still behind the window itself)". Doesn't that mean it is not top most (i.e. it is still behind the window itself and therefore behind all the normal UI)?

…va/com/babylonreactnative/EngineView.java

Co-authored-by: Ryan Tremblay <[email protected]>
@CedricGuillemet
Copy link
Contributor Author

setZOrderMediaOverlay says "the surface view's surface is placed on top of another regular surface view in the window (but still behind the window itself)". Doesn't that mean it is not top most (i.e. it is still behind the window itself and therefore behind all the normal UI)?

Yes, it's not topmost on Android anymore (as it's still on iOS). It's topMost on other surfaceViews. It's platform specific behaviors. I don't see any obvious name for that. Or even if just a name change is enough.

@bghgary
Copy link
Contributor

bghgary commented Sep 13, 2022

It seems like this flag is no longer consistent across platforms with this change. That seems bad. I wonder if it makes sense to expose the underlying platform view and the application can do whatever it wants with it?

@CedricGuillemet
Copy link
Contributor Author

It seems like this flag is no longer consistent across platforms with this change. That seems bad. I wonder if it makes sense to expose the underlying platform view and the application can do whatever it wants with it?

Do you mean exposing a MTKView or a surfaceView to JS? Or asking user to add a bridge between the native view and JS?

@bghgary
Copy link
Contributor

bghgary commented Sep 14, 2022

Do you mean exposing a MTKView or a surfaceView to JS? Or asking user to add a bridge between the native view and JS?

I'm not sure. Is there already an existing JS visible interface for talking to the native view? I'm guessing no.

@ryantrem
Copy link
Member

What I've seen in other RN components is having props that are platform specific and documented as such. In this specific case, what is the behavior you are trying to achieve? It seems like maybe there is a SurfaceView, and then the BRN EngineView is supposed to go on top of that, but then UI is supposed to go on top of everything? Although that's not the behavior we'd have on iOS, right? So yea, maybe if you can explain a little more scenario that will help with figuring out a reasonable set of props across platforms.

@CedricGuillemet
Copy link
Contributor Author

The scenario is quite simple actually: when isTransparent is true for the EngineView, there is nothing to do on iOS or Windows except.
On Android, there are 3 modes: textureView, surfaceView with zTop, surfaceView with with mediaOverlay.
So, we can removed isTopMost and have an Android enum property 'androidTransparencyMode. Or keep isTopMost` and add another property that will interfer.
Is it too late to remove isTopMost?

@bghgary
Copy link
Contributor

bghgary commented Sep 26, 2022

It would be good if @ryantrem can review as well before I sign off.

Copy link
Contributor

@bghgary bghgary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good from my perspective.

@CedricGuillemet CedricGuillemet merged commit 7121c42 into BabylonJS:master Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants