Auto merge of #22785 - paulrouget:surfaceChange, r=avadacatavra

Implement ServoSurface::onSurfaceChanged

Fix #21860

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22785)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-01-30 04:27:30 -05:00 committed by GitHub
commit 756bd2173a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View file

@ -26,6 +26,7 @@ public class Servo {
private boolean mShuttingDown;
private boolean mShutdownComplete;
private boolean mSuspended;
private Callbacks mServoCallbacks;
public Servo(
ServoOptions options,
@ -38,10 +39,10 @@ public class 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 class Servo {
}
}
public void resetGfxCallbacks(GfxCallbacks gfxcb) {
mServoCallbacks.resetGfxCallbacks(gfxcb);
}
public void shutdown() {
mShuttingDown = true;
FutureTask<Void> task = new FutureTask<Void>(new Callable<Void>() {
@ -198,7 +203,7 @@ public class Servo {
private class Callbacks implements JNIServo.Callbacks, Client {
private final GfxCallbacks mGfxCb;
private GfxCallbacks mGfxCb;
Client mClient;
Callbacks(Client client, GfxCallbacks gfxcb) {
@ -206,6 +211,10 @@ public class Servo {
mGfxCb = gfxcb;
}
private void resetGfxCallbacks(GfxCallbacks gfxcb) {
mGfxCb = gfxcb;
}
public void wakeup() {
if (!mSuspended && !mShuttingDown) {
mRunCallback.inGLThread(() -> mJNI.performUpdates());

View file

@ -51,6 +51,11 @@ public class ServoSurface {
mGLThread = new GLThread();
}
public void onSurfaceChanged(Surface surface) {
mASurface = surface;
mGLThread.onSurfaceChanged();
}
public void setClient(Client client) {
mClient = client;
}
@ -230,6 +235,13 @@ public class ServoSurface {
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();