summaryrefslogtreecommitdiff
path: root/tests/HwAccelerationTest
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2016-04-29 14:49:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-04-29 14:49:21 +0000
commit6d42b5c6e399a10799d2bba3f7113dd198cbcae6 (patch)
treed003e4cc33b4114b5bc8ff7b0c7a3118cf8a2431 /tests/HwAccelerationTest
parenta1c06675dd2a83ce445f27b46cddab80f8c743e6 (diff)
parent2f69d6d4fdd4994912e5515016421625d1e1c4ec (diff)
Merge "Support transform'd GraphicBuffers" into nyc-dev
Diffstat (limited to 'tests/HwAccelerationTest')
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapSurfaceViewActivity.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapSurfaceViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapSurfaceViewActivity.java
index f658b7c05e66..6fe2cb472a97 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapSurfaceViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapSurfaceViewActivity.java
@@ -23,6 +23,7 @@ import android.os.Bundle;
import android.os.Environment;
import android.view.Gravity;
import android.view.PixelCopy;
+import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
@@ -87,9 +88,42 @@ public class GetBitmapSurfaceViewActivity extends Activity implements SurfaceHol
android.util.Log.e("TextureView", "Cannot set preview texture target!", t);
}
+ setCameraDisplayOrientation(this, 0, mCamera);
mCamera.startPreview();
}
+ public static void setCameraDisplayOrientation(Activity activity,
+ int cameraId, android.hardware.Camera camera) {
+ android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
+ android.hardware.Camera.getCameraInfo(cameraId, info);
+ int rotation = activity.getWindowManager().getDefaultDisplay()
+ .getRotation();
+ int degrees = 0;
+ switch (rotation) {
+ case Surface.ROTATION_0:
+ degrees = 0;
+ break;
+ case Surface.ROTATION_90:
+ degrees = 90;
+ break;
+ case Surface.ROTATION_180:
+ degrees = 180;
+ break;
+ case Surface.ROTATION_270:
+ degrees = 270;
+ break;
+ }
+
+ int result;
+ if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
+ result = (info.orientation + degrees) % 360;
+ result = (360 - result) % 360; // compensate the mirror
+ } else { // back-facing
+ result = (info.orientation - degrees + 360) % 360;
+ }
+ camera.setDisplayOrientation(result);
+ }
+
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}