зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1564846 - Do better at managing secondary windows in TestRunnerActivity r=kats
Differential Revision: https://phabricator.services.mozilla.com/D37570 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
9e0db48791
Коммит
4945d746d5
|
@ -41,7 +41,35 @@ public class TestRunnerActivity extends Activity {
|
|||
private GeckoView mView;
|
||||
private boolean mKillProcessOnDestroy;
|
||||
|
||||
private HashMap<GeckoSession, GeckoDisplay> mDisplays = new HashMap<>();
|
||||
private HashMap<GeckoSession, Display> mDisplays = new HashMap<>();
|
||||
|
||||
private static class Display {
|
||||
public final SurfaceTexture texture;
|
||||
public final Surface surface;
|
||||
|
||||
private final int width;
|
||||
private final int height;
|
||||
private GeckoDisplay sessionDisplay;
|
||||
|
||||
public Display(final int width, final int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
texture = new SurfaceTexture(0);
|
||||
texture.setDefaultBufferSize(width, height);
|
||||
surface = new Surface(texture);
|
||||
}
|
||||
|
||||
public void attach(final GeckoSession session) {
|
||||
sessionDisplay = session.acquireDisplay();
|
||||
sessionDisplay.surfaceChanged(surface, width, height);
|
||||
}
|
||||
|
||||
public void release(final GeckoSession session) {
|
||||
sessionDisplay.surfaceDestroyed();
|
||||
session.releaseDisplay(sessionDisplay);
|
||||
}
|
||||
}
|
||||
|
||||
private HashSet<GeckoSession> mOwnedSessions = new HashSet<>();
|
||||
|
||||
private GeckoSession.PermissionDelegate mPermissionDelegate = new GeckoSession.PermissionDelegate() {
|
||||
|
@ -158,11 +186,9 @@ public class TestRunnerActivity extends Activity {
|
|||
private GeckoSession createBackgroundSession(final GeckoSessionSettings settings) {
|
||||
final GeckoSession session = createSession(settings);
|
||||
|
||||
final SurfaceTexture texture = new SurfaceTexture(0);
|
||||
final Surface surface = new Surface(texture);
|
||||
final Display display = new Display(mView.getWidth(), mView.getHeight());
|
||||
display.attach(session);
|
||||
|
||||
final GeckoDisplay display = session.acquireDisplay();
|
||||
display.surfaceChanged(surface, mView.getWidth(), mView.getHeight());
|
||||
mDisplays.put(session, display);
|
||||
|
||||
return session;
|
||||
|
@ -170,10 +196,8 @@ public class TestRunnerActivity extends Activity {
|
|||
|
||||
private void closeSession(GeckoSession session) {
|
||||
if (mDisplays.containsKey(session)) {
|
||||
final GeckoDisplay display = mDisplays.remove(session);
|
||||
display.surfaceDestroyed();
|
||||
|
||||
session.releaseDisplay(display);
|
||||
final Display display = mDisplays.remove(session);
|
||||
display.release(session);
|
||||
}
|
||||
mOwnedSessions.remove(session);
|
||||
session.close();
|
||||
|
|
Загрузка…
Ссылка в новой задаче