UiBench: Fix camera distance for GlTextureView
Change-Id: Ieab2080c8b0a4baa3e844a2a616cdc9f4d4e8101
diff --git a/tests/UiBench/src/com/android/test/uibench/GlTextureViewActivity.java b/tests/UiBench/src/com/android/test/uibench/GlTextureViewActivity.java
index a12742d..36d703c 100644
--- a/tests/UiBench/src/com/android/test/uibench/GlTextureViewActivity.java
+++ b/tests/UiBench/src/com/android/test/uibench/GlTextureViewActivity.java
@@ -21,6 +21,7 @@
import android.graphics.SurfaceTexture;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.TextureView;
@@ -49,7 +50,9 @@
mRenderThread = new ImageFlipRenderThread(getResources(), surface);
mRenderThread.start();
- mTextureView.setCameraDistance(5000);
+ DisplayMetrics metrics = mTextureView.getContext().getResources().getDisplayMetrics();
+ int distance = Math.max(mTextureView.getWidth(), mTextureView.getHeight());
+ mTextureView.setCameraDistance(distance * metrics.density);
ObjectAnimator animator = ObjectAnimator.ofFloat(mTextureView, "rotationY", 0.0f, 360.0f);
animator.setRepeatMode(ObjectAnimator.REVERSE);