Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Ryan Pavlik
Monado
Commits
28eb856c
Commit
28eb856c
authored
Mar 16, 2021
by
Ryan Pavlik
Browse files
wip watching for surface lost and surface lifecycle
parent
11d35a15
Pipeline
#733031
failed with stages
in 3 minutes and 7 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/xrt/compositor/main/comp_window_android.c
View file @
28eb856c
...
...
@@ -43,6 +43,8 @@ struct comp_window_android
struct
comp_target_swapchain
base
;
struct
android_custom_surface
*
custom_surface
;
uint32_t
swapchain_width
;
uint32_t
swapchain_height
;
};
...
...
@@ -125,13 +127,42 @@ comp_window_android_create_surface(struct comp_window_android *cwa,
return
VK_SUCCESS
;
}
// static bool
// on_receive_surface(struct comp_window_android *cwa)
// {
// struct comp_window_android *cwa = (struct comp_window_android *)ct;
// VkResult ret;
// struct ANativeWindow *window = NULL;
// if (android_globals_get_activity() != NULL) {
// /* In process: Creating surface from activity */
// window = _create_android_window(cwa);
// } else {
// /* Out of process: Getting cached surface */
// window = (struct ANativeWindow *)android_globals_get_window();
// }
// if (window == NULL) {
// COMP_ERROR(cwa->base.base.c, "could not get ANativeWindow");
// return false;
// }
// ret = comp_window_android_create_surface(cwa, window, &cwa->base.surface.handle);
// if (ret != VK_SUCCESS) {
// COMP_ERROR(ct->c, "Failed to create surface '%s'!", vk_result_string(ret));
// return false;
// }
// return true;
// }
static
bool
comp_window_android_init_swapchain
(
struct
comp_target
*
ct
,
uint32_t
width
,
uint32_t
height
)
{
struct
comp_window_android
*
cwa
=
(
struct
comp_window_android
*
)
ct
;
VkResult
ret
;
cwa
->
swapchain_width
=
width
;
cwa
->
swapchain_height
=
height
;
struct
ANativeWindow
*
window
=
NULL
;
if
(
android_globals_get_activity
()
!=
NULL
)
{
...
...
src/xrt/ipc/android/src/main/aidl/org/freedesktop/monado/ipc/IMonado.aidl
View file @
28eb856c
...
...
@@ -32,4 +32,9 @@ interface IMonado {
*
Asking
service
whether
it
has
the
capbility
to
draw
over
other
apps
or
not
.
*/
boolean
canDrawOverOtherApps
();
/*
!
*
Indicate
that
the
surface
provided
is
no
longer
available
.
*/
void
surfaceLost
();
}
src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/Client.java
View file @
28eb856c
...
...
@@ -27,6 +27,7 @@ import android.view.WindowManager;
import
androidx.annotation.Keep
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.NonNull
;
import
org.freedesktop.monado.auxiliary.MonadoView
;
import
org.freedesktop.monado.auxiliary.NativeCounterpart
;
...
...
@@ -41,7 +42,7 @@ import java.util.concurrent.Executors;
* This class will get loaded into the OpenXR client application by our native code.
*/
@Keep
public
class
Client
implements
ServiceConnection
{
public
class
Client
implements
ServiceConnection
,
SurfaceHolder
.
Callback
{
private
static
final
String
TAG
=
"monado-ipc-client"
;
/**
* Used to block until binder is ready.
...
...
@@ -326,6 +327,50 @@ public class Client implements ServiceConnection {
//! @todo tell C/C++ that the world is crumbling, then close the fd here.
}
/**
* This is called immediately after the surface is first created.
* Implementations of this should start up whatever rendering code
* they desire. Note that only one thread can ever draw into
* a {@link Surface}, so you should not draw into the Surface here
* if your normal rendering will be in another thread.
*
* @param holder The SurfaceHolder whose surface is being created.
*/
@Override
public
void
surfaceCreated
(
@NonNull
SurfaceHolder
holder
)
{
}
/**
* This is called immediately after any structural changes (format or
* size) have been made to the surface. You should at this point update
* the imagery in the surface. This method is always called at least
* once, after {@link #surfaceCreated}.
*
* @param holder The SurfaceHolder whose surface has changed.
* @param format The new {@link PixelFormat} of the surface.
* @param width The new width of the surface.
* @param height The new height of the surface.
*/
@Override
public
void
surfaceChanged
(
@NonNull
SurfaceHolder
holder
,
int
format
,
int
width
,
int
height
)
{
}
/**
* This is called immediately before a surface is being destroyed. After
* returning from this call, you should no longer try to access this
* surface. If you have a rendering thread that directly accesses
* the surface, you must ensure that thread is no longer touching the
* Surface before returning from this function.
*
* @param holder The SurfaceHolder whose surface is being destroyed.
*/
@Override
public
void
surfaceDestroyed
(
@NonNull
SurfaceHolder
holder
)
{
}
/*
* @todo do we need to watch for a disconnect here?
* https://stackoverflow.com/questions/18078914/notify-an-android-service-when-a-bound-client-disconnects
...
...
src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/MonadoImpl.java
View file @
28eb856c
...
...
@@ -11,6 +11,7 @@
package
org.freedesktop.monado.ipc
;
import
android.os.ParcelFileDescriptor
;
import
android.os.RemoteException
;
import
android.util.Log
;
import
android.view.Surface
;
import
android.view.SurfaceHolder
;
...
...
@@ -91,6 +92,11 @@ public class MonadoImpl extends IMonado.Stub {
nativeStartServer
();
}
@Override
public
void
surfaceLost
()
throws
RemoteException
{
}
@Override
public
boolean
createSurface
(
int
displayId
,
boolean
focusable
)
{
Log
.
i
(
TAG
,
"createSurface"
);
...
...
@@ -127,6 +133,12 @@ public class MonadoImpl extends IMonado.Stub {
@SuppressWarnings
(
"JavaJniMissingFunction"
)
private
native
void
nativeAppSurface
(
@NonNull
Surface
surface
);
/**
* Native handling of a lost surface.
*/
@SuppressWarnings
(
"JavaJniMissingFunction"
)
private
native
void
nativeAppSurfaceLost
();
/**
* Native handling of receiving an FD for a new client: the FD should be used to start up the
* rest of the native IPC code on that socket.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment