Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Fix duplicated surface changed calls with layers (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored Nov 26, 2018
1 parent 4a3d928 commit b89303c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class BrowserWidget extends UIWidget implements SessionStore.SessionChang
private BookmarksWidget mBookmarksWidget;
private float mMultiplier;
Runnable mFirstDrawCallback;
private boolean mIsInVRVideoMode;

public BrowserWidget(Context aContext, int aSessionId) {
super(aContext);
Expand Down Expand Up @@ -137,8 +138,11 @@ public void resumeCompositor() {
}

public void enableVRVideoMode(int aVideoWidth, int aVideoHeight, boolean aResetBorder) {
mWidthBackup = mWidth;
mHeightBackup = mHeight;
if (!mIsInVRVideoMode) {
mWidthBackup = mWidth;
mHeightBackup = mHeight;
mIsInVRVideoMode = true;
}
boolean borderChanged = aResetBorder && mBorderWidth > 0;
if (aVideoWidth == mWidth && aVideoHeight == mHeight && !borderChanged) {
return;
Expand All @@ -148,22 +152,22 @@ public void enableVRVideoMode(int aVideoWidth, int aVideoHeight, boolean aResetB
}
mWidgetPlacement.width = aVideoWidth + mBorderWidth * 2;
mWidgetPlacement.height = aVideoHeight + mBorderWidth * 2;
resizeSurface(aVideoWidth, aVideoHeight);
Log.e(LOGTAG, "onMetadataChange resize browser " + aVideoWidth + " " + aVideoHeight);
mWidgetManager.updateWidget(this);
}

public void disableVRVideoMode() {
if (mWidthBackup == 0 || mHeightBackup == 0) {
if (!mIsInVRVideoMode || mWidthBackup == 0 || mHeightBackup == 0) {
return;
}
mIsInVRVideoMode = false;
int border = SettingsStore.getInstance(getContext()).getLayersEnabled() ? 1 : 0;
if (mWidthBackup == mWidth && mHeightBackup == mHeight && border == mBorderWidth) {
return;
}
mBorderWidth = border;
mWidgetPlacement.width = mWidthBackup;
mWidgetPlacement.height = mHeightBackup;
resizeSurface(mWidthBackup, mWidthBackup);
mWidgetManager.updateWidget(this);
}

@Override
Expand Down Expand Up @@ -247,8 +251,8 @@ public void resizeSurface(final int aWidth, final int aHeight) {
mHeight = aHeight;
if (mTexture != null) {
mTexture.setDefaultBufferSize(aWidth, aHeight);
callSurfaceChanged();
}
callSurfaceChanged();
}

@Override
Expand Down Expand Up @@ -383,8 +387,6 @@ public void onCurrentSessionChange(GeckoSession aSession, int aId) {

mSessionId = aId;
mDisplay = aSession.acquireDisplay();
Log.d(LOGTAG, "surfaceChanged: " + aId);
callSurfaceChanged();
aSession.getTextInput().setView(this);

boolean isPrivateMode = aSession.getSettings().getBoolean(GeckoSessionSettings.USE_PRIVATE_MODE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,12 +474,12 @@ private void enterVRVideo(@VideoProjectionMenuWidget.VideoProjectionFlags int aP

this.setVisible(false);
if (mFullScreenMedia != null && mFullScreenMedia.getWidth() > 0 && mFullScreenMedia.getHeight() > 0) {
boolean resetBorder = aProjection == VideoProjectionMenuWidget.VIDEO_PROJECTION_360 ||
aProjection == VideoProjectionMenuWidget.VIDEO_PROJECTION_360_STEREO;
final boolean resetBorder = aProjection == VideoProjectionMenuWidget.VIDEO_PROJECTION_360 ||
aProjection == VideoProjectionMenuWidget.VIDEO_PROJECTION_360_STEREO;
mBrowserWidget.enableVRVideoMode(mFullScreenMedia.getWidth(), mFullScreenMedia.getHeight(), resetBorder);
// Handle video resize while in VR video playback
mFullScreenMedia.setResizeDelegate((width, height) -> {
mBrowserWidget.resizeSurface(width, height);
mBrowserWidget.enableVRVideoMode(width, height, resetBorder);
});
}
mBrowserWidget.setVisible(false);
Expand Down

0 comments on commit b89303c

Please sign in to comment.