summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/app
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2012-02-13 10:22:25 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-02-13 10:22:25 -0800
commit7f10c1533e087b528f58294edaba18726e350103 (patch)
tree5c21dde60bd878e243b849d2db22c9e139ce77a5 /src/com/android/gallery3d/app
parentfef6691d870711d8cdaf3ac14b24e5a7c6496b6f (diff)
parentfd91413ab46e2960803a33652025aebe3e05f2d9 (diff)
downloadandroid_packages_apps_Gallery2-7f10c1533e087b528f58294edaba18726e350103.tar.gz
android_packages_apps_Gallery2-7f10c1533e087b528f58294edaba18726e350103.tar.bz2
android_packages_apps_Gallery2-7f10c1533e087b528f58294edaba18726e350103.zip
Merge "Use FloatMath instead of Math."
Diffstat (limited to 'src/com/android/gallery3d/app')
-rw-r--r--src/com/android/gallery3d/app/CropImage.java4
-rw-r--r--src/com/android/gallery3d/app/EyePosition.java15
2 files changed, 10 insertions, 9 deletions
diff --git a/src/com/android/gallery3d/app/CropImage.java b/src/com/android/gallery3d/app/CropImage.java
index 5ac9f0251..7e1572f0c 100644
--- a/src/com/android/gallery3d/app/CropImage.java
+++ b/src/com/android/gallery3d/app/CropImage.java
@@ -38,6 +38,7 @@ import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.provider.MediaStore.Images;
+import android.util.FloatMath;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
@@ -554,8 +555,7 @@ public class CropImage extends AbstractGalleryActivity {
}
if (outputX * outputY > MAX_PIXEL_COUNT) {
- float scale = (float) Math.sqrt(
- (double) MAX_PIXEL_COUNT / outputX / outputY);
+ float scale = FloatMath.sqrt((float) MAX_PIXEL_COUNT / outputX / outputY);
Log.w(TAG, "scale down the cropped image: " + scale);
outputX = Math.round(scale * outputX);
outputY = Math.round(scale * outputY);
diff --git a/src/com/android/gallery3d/app/EyePosition.java b/src/com/android/gallery3d/app/EyePosition.java
index 7b4495a35..f9713e179 100644
--- a/src/com/android/gallery3d/app/EyePosition.java
+++ b/src/com/android/gallery3d/app/EyePosition.java
@@ -25,6 +25,7 @@ import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.SystemClock;
+import android.util.FloatMath;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
@@ -41,9 +42,9 @@ public class EyePosition {
private static final int GYROSCOPE_SETTLE_DOWN = 15;
private static final float GYROSCOPE_RESTORE_FACTOR = 0.995f;
- private static final double USER_ANGEL = Math.toRadians(10);
- private static final float USER_ANGEL_COS = (float) Math.cos(USER_ANGEL);
- private static final float USER_ANGEL_SIN = (float) Math.sin(USER_ANGEL);
+ private static final float USER_ANGEL = (float) Math.toRadians(10);
+ private static final float USER_ANGEL_COS = FloatMath.cos(USER_ANGEL);
+ private static final float USER_ANGEL_SIN = FloatMath.sin(USER_ANGEL);
private static final float MAX_VIEW_RANGE = (float) 0.5;
private static final int NOT_STARTED = -1;
@@ -126,8 +127,8 @@ public class EyePosition {
float ty = -1 + t * y;
float tz = t * z;
- float length = (float) Math.sqrt(tx * tx + ty * ty + tz * tz);
- float glength = (float) Math.sqrt(temp);
+ float length = FloatMath.sqrt(tx * tx + ty * ty + tz * tz);
+ float glength = FloatMath.sqrt(temp);
mX = Utils.clamp((x * USER_ANGEL_COS / glength
+ tx * USER_ANGEL_SIN / length) * mUserDistance,
@@ -135,7 +136,7 @@ public class EyePosition {
mY = -Utils.clamp((y * USER_ANGEL_COS / glength
+ ty * USER_ANGEL_SIN / length) * mUserDistance,
-mLimit, mLimit);
- mZ = (float) -Math.sqrt(
+ mZ = -FloatMath.sqrt(
mUserDistance * mUserDistance - mX * mX - mY * mY);
mListener.onEyePositionChanged(mX, mY, mZ);
}
@@ -173,7 +174,7 @@ public class EyePosition {
mY = Utils.clamp((float) (mY + y * t / Math.hypot(mZ, mY)),
-mLimit, mLimit) * GYROSCOPE_RESTORE_FACTOR;
- mZ = (float) -Math.sqrt(
+ mZ = -FloatMath.sqrt(
mUserDistance * mUserDistance - mX * mX - mY * mY);
mListener.onEyePositionChanged(mX, mY, mZ);
}