mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
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:
commit
756bd2173a
2 changed files with 24 additions and 3 deletions
|
@ -26,6 +26,7 @@ public class Servo {
|
||||||
private boolean mShuttingDown;
|
private boolean mShuttingDown;
|
||||||
private boolean mShutdownComplete;
|
private boolean mShutdownComplete;
|
||||||
private boolean mSuspended;
|
private boolean mSuspended;
|
||||||
|
private Callbacks mServoCallbacks;
|
||||||
|
|
||||||
public Servo(
|
public Servo(
|
||||||
ServoOptions options,
|
ServoOptions options,
|
||||||
|
@ -38,10 +39,10 @@ public class Servo {
|
||||||
|
|
||||||
mAssetMgr = activity.getResources().getAssets();
|
mAssetMgr = activity.getResources().getAssets();
|
||||||
|
|
||||||
Callbacks cbs = new Callbacks(client, gfxcb);
|
mServoCallbacks = new Callbacks(client, gfxcb);
|
||||||
|
|
||||||
mRunCallback.inGLThread(() -> {
|
mRunCallback.inGLThread(() -> {
|
||||||
mJNI.init(activity, options, cbs);
|
mJNI.init(activity, options, mServoCallbacks);
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -51,6 +52,10 @@ public class Servo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetGfxCallbacks(GfxCallbacks gfxcb) {
|
||||||
|
mServoCallbacks.resetGfxCallbacks(gfxcb);
|
||||||
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
mShuttingDown = true;
|
mShuttingDown = true;
|
||||||
FutureTask<Void> task = new FutureTask<Void>(new Callable<Void>() {
|
FutureTask<Void> task = new FutureTask<Void>(new Callable<Void>() {
|
||||||
|
@ -198,7 +203,7 @@ public class Servo {
|
||||||
|
|
||||||
private class Callbacks implements JNIServo.Callbacks, Client {
|
private class Callbacks implements JNIServo.Callbacks, Client {
|
||||||
|
|
||||||
private final GfxCallbacks mGfxCb;
|
private GfxCallbacks mGfxCb;
|
||||||
Client mClient;
|
Client mClient;
|
||||||
|
|
||||||
Callbacks(Client client, GfxCallbacks gfxcb) {
|
Callbacks(Client client, GfxCallbacks gfxcb) {
|
||||||
|
@ -206,6 +211,10 @@ public class Servo {
|
||||||
mGfxCb = gfxcb;
|
mGfxCb = gfxcb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resetGfxCallbacks(GfxCallbacks gfxcb) {
|
||||||
|
mGfxCb = gfxcb;
|
||||||
|
}
|
||||||
|
|
||||||
public void wakeup() {
|
public void wakeup() {
|
||||||
if (!mSuspended && !mShuttingDown) {
|
if (!mSuspended && !mShuttingDown) {
|
||||||
mRunCallback.inGLThread(() -> mJNI.performUpdates());
|
mRunCallback.inGLThread(() -> mJNI.performUpdates());
|
||||||
|
|
|
@ -51,6 +51,11 @@ public class ServoSurface {
|
||||||
mGLThread = new GLThread();
|
mGLThread = new GLThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onSurfaceChanged(Surface surface) {
|
||||||
|
mASurface = surface;
|
||||||
|
mGLThread.onSurfaceChanged();
|
||||||
|
}
|
||||||
|
|
||||||
public void setClient(Client client) {
|
public void setClient(Client client) {
|
||||||
mClient = client;
|
mClient = client;
|
||||||
}
|
}
|
||||||
|
@ -230,6 +235,13 @@ public class ServoSurface {
|
||||||
mMainLooperHandler.post(r);
|
mMainLooperHandler.post(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onSurfaceChanged() {
|
||||||
|
Log.d(LOGTAG, "GLThread::onSurfaceChanged");
|
||||||
|
mSurface.destroy();
|
||||||
|
mSurface = new GLSurface(mASurface);
|
||||||
|
mServo.resetGfxCallbacks(mSurface);
|
||||||
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
Log.d(LOGTAG, "GLThread::shutdown");
|
Log.d(LOGTAG, "GLThread::shutdown");
|
||||||
mSurface.destroy();
|
mSurface.destroy();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue