Skip to content
Permalink
Browse files

Implement ServoSurface::onSurfaceChanged

  • Loading branch information...
paulrouget committed Jan 30, 2019
1 parent 8646d7d commit c14665370711b708a3e06af4dbb2cfde21e2dccf
@@ -26,6 +26,7 @@
private boolean mShuttingDown;
private boolean mShutdownComplete;
private boolean mSuspended;
private Callbacks mServoCallbacks;

public Servo(
ServoOptions options,
@@ -38,10 +39,10 @@ public Servo(

mAssetMgr = activity.getResources().getAssets();

Callbacks cbs = new Callbacks(client, gfxcb);
mServoCallbacks = new Callbacks(client, gfxcb);

mRunCallback.inGLThread(() -> {
mJNI.init(activity, options, cbs);
mJNI.init(activity, options, mServoCallbacks);
});

try {
@@ -51,6 +52,10 @@ public Servo(
}
}

public void resetGfxCallbacks(GfxCallbacks gfxcb) {
mServoCallbacks.resetGfxCallbacks(gfxcb);
}

public void shutdown() {
mShuttingDown = true;
FutureTask<Void> task = new FutureTask<Void>(new Callable<Void>() {
@@ -198,14 +203,18 @@ public void suspend(boolean suspended) {

private class Callbacks implements JNIServo.Callbacks, Client {

private final GfxCallbacks mGfxCb;
private GfxCallbacks mGfxCb;
Client mClient;

Callbacks(Client client, GfxCallbacks gfxcb) {
mClient = client;
mGfxCb = gfxcb;
}

private void resetGfxCallbacks(GfxCallbacks gfxcb) {
mGfxCb = gfxcb;
}

public void wakeup() {
if (!mSuspended && !mShuttingDown) {
mRunCallback.inGLThread(() -> mJNI.performUpdates());
@@ -51,6 +51,11 @@ public ServoSurface(Surface surface, int width, int height) {
mGLThread = new GLThread();
}

public void onSurfaceChanged(Surface surface) {
mASurface = surface;
mGLThread.onSurfaceChanged();
}

public void setClient(Client client) {
mClient = client;
}
@@ -230,6 +235,13 @@ public void inUIThread(Runnable r) {
mMainLooperHandler.post(r);
}

public void onSurfaceChanged() {
Log.d(LOGTAG, "GLThread::onSurfaceChanged");
mSurface.destroy();
mSurface = new GLSurface(mASurface);
mServo.resetGfxCallbacks(mSurface);
}

public void shutdown() {
Log.d(LOGTAG, "GLThread::shutdown");
mSurface.destroy();

0 comments on commit c146653

Please sign in to comment.
You can’t perform that action at this time.