Bug 1489569 - 1. Avoid unnecessary setActive calls; r=droeh a=cpeterson
To avoid unnecessary setActive calls, only call it when we have a
display and when the display acquires or releases a surface. In other
cases, we can delay the setActive call until later.
Differential Revision:
https://phabricator.services.mozilla.com/D5328
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
@@ -106,18 +106,18 @@ public class GeckoView extends FrameLayo
}
// Tell display there is already a surface.
onGlobalLayout();
if (GeckoView.this.mSurfaceView != null) {
final SurfaceHolder holder = GeckoView.this.mSurfaceView.getHolder();
final Rect frame = holder.getSurfaceFrame();
mDisplay.surfaceChanged(holder.getSurface(), frame.right, frame.bottom);
+ GeckoView.this.setActive(true);
}
- GeckoView.this.setActive(true);
}
public GeckoDisplay release() {
if (mValid) {
mDisplay.surfaceDestroyed();
GeckoView.this.setActive(false);
}
@@ -130,27 +130,29 @@ public class GeckoView extends FrameLayo
public void surfaceCreated(final SurfaceHolder holder) {
}
@Override // SurfaceHolder.Callback
public void surfaceChanged(final SurfaceHolder holder, final int format,
final int width, final int height) {
if (mDisplay != null) {
mDisplay.surfaceChanged(holder.getSurface(), width, height);
+ if (!mValid) {
+ GeckoView.this.setActive(true);
+ }
}
- GeckoView.this.setActive(true);
mValid = true;
}
@Override // SurfaceHolder.Callback
public void surfaceDestroyed(final SurfaceHolder holder) {
if (mDisplay != null) {
mDisplay.surfaceDestroyed();
+ GeckoView.this.setActive(false);
}
- GeckoView.this.setActive(false);
mValid = false;
}
public void onGlobalLayout() {
if (mDisplay == null) {
return;
}
if (GeckoView.this.mSurfaceView != null) {