summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorzachh <zachh@google.com>2017-08-11 17:28:47 -0700
committerEric Erfanian <erfanian@google.com>2017-08-14 08:31:18 -0700
commitb0c760ee35a5d1b361a39c91b633136c82938240 (patch)
tree7137a85d41c33b882c4fcbc0d74b79b14e06a60f /java
parent86d76510112dbd1349b3ab6797febebd179a725b (diff)
Improvements to preview scaling on IMS video calls.
This is a partial rollback of previous attempts to fix preview scaling in cl/161444534 and cl/157891853. The scaling issue was partially due to issues beneath the application, see b/63518188. By rolling back the previous attempts, this CL improves preview scaling across all devices and OS's (assuming O builds after Aug 3). There are still some very slight and intermittent scaling issues which we believe to be caused by the system but this CL is strictly a huge improvement. See b/63518188 for details. Bug: 63518188 Test: manual PiperOrigin-RevId: 165045984 Change-Id: I8e53870077e2ae86b10cd934f9f3b4508eb60ac3
Diffstat (limited to 'java')
-rw-r--r--java/com/android/incallui/video/impl/VideoCallFragment.java55
-rw-r--r--java/com/android/incallui/videosurface/impl/VideoSurfaceTextureImpl.java3
2 files changed, 31 insertions, 27 deletions
diff --git a/java/com/android/incallui/video/impl/VideoCallFragment.java b/java/com/android/incallui/video/impl/VideoCallFragment.java
index 84e01bd31..b0beb77c1 100644
--- a/java/com/android/incallui/video/impl/VideoCallFragment.java
+++ b/java/com/android/incallui/video/impl/VideoCallFragment.java
@@ -21,7 +21,6 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
-import android.graphics.Matrix;
import android.graphics.Outline;
import android.graphics.Point;
import android.graphics.drawable.Animatable;
@@ -284,7 +283,7 @@ public class VideoCallFragment extends Fragment
int oldRight,
int oldBottom) {
LogUtil.i("VideoCallFragment.onLayoutChange", "previewTextureView layout changed");
- fixPreviewRotation();
+ updatePreviewVideoScaling();
updatePreviewOffView();
}
});
@@ -689,11 +688,13 @@ public class VideoCallFragment extends Fragment
@Override
public void onLocalVideoDimensionsChanged() {
LogUtil.i("VideoCallFragment.onLocalVideoDimensionsChanged", null);
+ updatePreviewVideoScaling();
}
@Override
public void onLocalVideoOrientationChanged() {
LogUtil.i("VideoCallFragment.onLocalVideoOrientationChanged", null);
+ updatePreviewVideoScaling();
}
/** Called when the remote video's dimensions change. */
@@ -961,15 +962,31 @@ public class VideoCallFragment extends Fragment
// Do nothing
}
- private void fixPreviewRotation() {
- int rotationDegrees = getRotationDegrees();
- if (rotationDegrees == 90 || rotationDegrees == 270) {
- int viewWidth = previewTextureView.getWidth();
- int viewHeight = previewTextureView.getHeight();
- Matrix transform = new Matrix();
- // Multiplying by -1 prevents the image from being upside down in landscape mode.
- transform.postRotate(rotationDegrees * -1.0f, viewWidth / 2.0f, viewHeight / 2.0f);
- previewTextureView.setTransform(transform);
+ private void updatePreviewVideoScaling() {
+ if (previewTextureView.getWidth() == 0 || previewTextureView.getHeight() == 0) {
+ LogUtil.i("VideoCallFragment.updatePreviewVideoScaling", "view layout hasn't finished yet");
+ return;
+ }
+ VideoSurfaceTexture localVideoSurfaceTexture =
+ videoCallScreenDelegate.getLocalVideoSurfaceTexture();
+ Point cameraDimensions = localVideoSurfaceTexture.getSurfaceDimensions();
+ if (cameraDimensions == null) {
+ LogUtil.i(
+ "VideoCallFragment.updatePreviewVideoScaling", "camera dimensions haven't been set");
+ return;
+ }
+ if (isLandscape()) {
+ VideoSurfaceBindings.scaleVideoAndFillView(
+ previewTextureView,
+ cameraDimensions.x,
+ cameraDimensions.y,
+ videoCallScreenDelegate.getDeviceOrientation());
+ } else {
+ VideoSurfaceBindings.scaleVideoAndFillView(
+ previewTextureView,
+ cameraDimensions.y,
+ cameraDimensions.x,
+ videoCallScreenDelegate.getDeviceOrientation());
}
}
@@ -1006,22 +1023,6 @@ public class VideoCallFragment extends Fragment
return rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270;
}
- private int getRotationDegrees() {
- int rotation = getActivity().getWindowManager().getDefaultDisplay().getRotation();
- switch (rotation) {
- case Surface.ROTATION_0:
- return 0;
- case Surface.ROTATION_90:
- return 90;
- case Surface.ROTATION_180:
- return 180;
- case Surface.ROTATION_270:
- return 270;
- default:
- throw Assert.createAssertionFailException("unsupported rotation: " + rotation);
- }
- }
-
private void enterGreenScreenMode() {
LogUtil.i("VideoCallFragment.enterGreenScreenMode", null);
RelativeLayout.LayoutParams params =
diff --git a/java/com/android/incallui/videosurface/impl/VideoSurfaceTextureImpl.java b/java/com/android/incallui/videosurface/impl/VideoSurfaceTextureImpl.java
index 1af7dff4f..8cac40229 100644
--- a/java/com/android/incallui/videosurface/impl/VideoSurfaceTextureImpl.java
+++ b/java/com/android/incallui/videosurface/impl/VideoSurfaceTextureImpl.java
@@ -67,6 +67,9 @@ public class VideoSurfaceTextureImpl implements VideoSurfaceTexture {
"VideoSurfaceTextureImpl.setSurfaceDimensions",
"surfaceDimensions: " + surfaceDimensions + " " + toString());
this.surfaceDimensions = surfaceDimensions;
+ if (surfaceDimensions != null && savedSurfaceTexture != null) {
+ savedSurfaceTexture.setDefaultBufferSize(surfaceDimensions.x, surfaceDimensions.y);
+ }
}
@Override