diff options
author | Chih-Chung Chang <chihchung@google.com> | 2012-02-10 17:08:58 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-10 17:08:58 -0800 |
commit | 1e33de955973996db59f08db6b843d9cd732c631 (patch) | |
tree | 8c5da11a1409d25964dd4354455c8a72fa9f8c0a | |
parent | e1e40b31bfce1885fb96edd1f92016cd73077d36 (diff) | |
download | android_packages_apps_Snap-1e33de955973996db59f08db6b843d9cd732c631.tar.gz android_packages_apps_Snap-1e33de955973996db59f08db6b843d9cd732c631.tar.bz2 android_packages_apps_Snap-1e33de955973996db59f08db6b843d9cd732c631.zip |
Revert "Use FloatMath instead of Math."
This reverts commit 6bb8b2eb8695c042798f0eb798032cd30d642a65
11 files changed, 36 insertions, 42 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java index 67aa6d77b..2192cf8ec 100644 --- a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java +++ b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java @@ -23,7 +23,6 @@ import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; import android.os.Build; -import android.util.FloatMath; import android.util.Log; import java.io.ByteArrayOutputStream; @@ -72,7 +71,7 @@ public class BitmapUtils { && minSideLength == UNCONSTRAINED) return 1; int lowerBound = (maxNumOfPixels == UNCONSTRAINED) ? 1 : - (int) FloatMath.ceil(FloatMath.sqrt((float) (w * h) / maxNumOfPixels)); + (int) Math.ceil(Math.sqrt((double) (w * h) / maxNumOfPixels)); if (minSideLength == UNCONSTRAINED) { return lowerBound; @@ -96,7 +95,7 @@ public class BitmapUtils { // Fin the min x that 1 / x <= scale public static int computeSampleSizeLarger(float scale) { - int initialSize = (int) FloatMath.floor(1f / scale); + int initialSize = (int) Math.floor(1f / scale); if (initialSize <= 1) return 1; return initialSize <= 8 @@ -107,7 +106,7 @@ public class BitmapUtils { // Find the max x that 1 / x >= scale. public static int computeSampleSize(float scale) { Utils.assertTrue(scale > 0); - int initialSize = Math.max(1, (int) FloatMath.ceil(1 / scale)); + int initialSize = Math.max(1, (int) Math.ceil(1 / scale)); return initialSize <= 8 ? Utils.nextPowerOf2(initialSize) : (initialSize + 7) / 8 * 8; @@ -117,7 +116,8 @@ public class BitmapUtils { Bitmap bitmap, int targetPixels, boolean recycle) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); - float scale = FloatMath.sqrt((float) targetPixels / (width * height)); + float scale = (float) Math.sqrt( + (double) targetPixels / (width * height)); if (scale >= 1.0f) return bitmap; return resizeBitmapByScale(bitmap, scale, recycle); } diff --git a/src/com/android/gallery3d/app/CropImage.java b/src/com/android/gallery3d/app/CropImage.java index 7e1572f0c..5ac9f0251 100644 --- a/src/com/android/gallery3d/app/CropImage.java +++ b/src/com/android/gallery3d/app/CropImage.java @@ -38,7 +38,6 @@ 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; @@ -555,7 +554,8 @@ public class CropImage extends AbstractGalleryActivity { } if (outputX * outputY > MAX_PIXEL_COUNT) { - float scale = FloatMath.sqrt((float) MAX_PIXEL_COUNT / outputX / outputY); + float scale = (float) Math.sqrt( + (double) 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 cb9299bbc..7b4495a35 100644 --- a/src/com/android/gallery3d/app/EyePosition.java +++ b/src/com/android/gallery3d/app/EyePosition.java @@ -25,7 +25,6 @@ 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; @@ -43,8 +42,8 @@ public class EyePosition { 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 = FloatMath.cos(USER_ANGEL); - private static final float USER_ANGEL_SIN = FloatMath.sin(USER_ANGEL); + 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 MAX_VIEW_RANGE = (float) 0.5; private static final int NOT_STARTED = -1; @@ -127,8 +126,8 @@ public class EyePosition { float ty = -1 + t * y; float tz = t * z; - float length = FloatMath.sqrt(tx * tx + ty * ty + tz * tz); - float glength = FloatMath.sqrt(temp); + float length = (float) Math.sqrt(tx * tx + ty * ty + tz * tz); + float glength = (float) Math.sqrt(temp); mX = Utils.clamp((x * USER_ANGEL_COS / glength + tx * USER_ANGEL_SIN / length) * mUserDistance, @@ -136,7 +135,7 @@ public class EyePosition { mY = -Utils.clamp((y * USER_ANGEL_COS / glength + ty * USER_ANGEL_SIN / length) * mUserDistance, -mLimit, mLimit); - mZ = -FloatMath.sqrt( + mZ = (float) -Math.sqrt( mUserDistance * mUserDistance - mX * mX - mY * mY); mListener.onEyePositionChanged(mX, mY, mZ); } @@ -174,7 +173,7 @@ public class EyePosition { mY = Utils.clamp((float) (mY + y * t / Math.hypot(mZ, mY)), -mLimit, mLimit) * GYROSCOPE_RESTORE_FACTOR; - mZ = -FloatMath.sqrt( + mZ = (float) -Math.sqrt( mUserDistance * mUserDistance - mX * mX - mY * mY); mListener.onEyePositionChanged(mX, mY, mZ); } diff --git a/src/com/android/gallery3d/data/LocationClustering.java b/src/com/android/gallery3d/data/LocationClustering.java index 9f3a35890..788060cf0 100644 --- a/src/com/android/gallery3d/data/LocationClustering.java +++ b/src/com/android/gallery3d/data/LocationClustering.java @@ -23,7 +23,6 @@ import com.android.gallery3d.util.GalleryUtils; import android.content.Context; import android.os.Handler; import android.os.Looper; -import android.util.FloatMath; import android.widget.Toast; import java.util.ArrayList; @@ -295,7 +294,7 @@ class LocationClustering extends Clustering { } // step 5: calculate the final score - float score = totalDistance * FloatMath.sqrt(realK); + float score = totalDistance * (float) Math.sqrt(realK); if (score < bestScore) { bestScore = score; diff --git a/src/com/android/gallery3d/photoeditor/RendererUtils.java b/src/com/android/gallery3d/photoeditor/RendererUtils.java index 3edcff5f5..b92907df0 100644 --- a/src/com/android/gallery3d/photoeditor/RendererUtils.java +++ b/src/com/android/gallery3d/photoeditor/RendererUtils.java @@ -19,7 +19,6 @@ package com.android.gallery3d.photoeditor; import android.graphics.Bitmap; import android.opengl.GLES20; import android.opengl.GLUtils; -import android.util.FloatMath; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -154,8 +153,8 @@ public class RendererUtils { public static void setRenderToRotate(RenderContext context, int srcWidth, int srcHeight, int dstWidth, int dstHeight, float degrees) { float radian = -degrees * DEGREE_TO_RADIAN; - float cosTheta = FloatMath.cos(radian); - float sinTheta = FloatMath.sin(radian); + float cosTheta = (float) Math.cos(radian); + float sinTheta = (float) Math.sin(radian); float cosWidth = cosTheta * srcWidth; float sinWidth = sinTheta * srcWidth; float cosHeight = cosTheta * srcHeight; @@ -206,8 +205,8 @@ public class RendererUtils { System.arraycopy(base, 0, vertices, 0, vertices.length); if (horizontalDegrees % 180f != 0) { float radian = (horizontalDegrees - horizontalRounds * 180) * DEGREE_TO_RADIAN; - float cosTheta = FloatMath.cos(radian); - float sinTheta = FloatMath.sin(radian); + float cosTheta = (float) Math.cos(radian); + float sinTheta = (float) Math.sin(radian); float scale = length / (length + sinTheta * base[0]); vertices[0] = cosTheta * base[0] * scale; @@ -224,8 +223,8 @@ public class RendererUtils { if (verticalDegrees % 180f != 0) { float radian = (verticalDegrees - verticalRounds * 180) * DEGREE_TO_RADIAN; - float cosTheta = FloatMath.cos(radian); - float sinTheta = FloatMath.sin(radian); + float cosTheta = (float) Math.cos(radian); + float sinTheta = (float) Math.sin(radian); float scale = length / (length + sinTheta * base[1]); vertices[0] = base[0] * scale; diff --git a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java index 0f03da844..87ff5579d 100644 --- a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java +++ b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java @@ -19,7 +19,6 @@ package com.android.gallery3d.ui; import android.graphics.Bitmap; import android.graphics.Color; import android.os.Message; -import android.util.FloatMath; import com.android.gallery3d.R; import com.android.gallery3d.app.GalleryActivity; @@ -382,8 +381,8 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { float scaley = mBoxHeight / (float) height; float scale = Math.min(scalex, scaley); - width = (int) FloatMath.floor(width * scale); - height = (int) FloatMath.floor(height * scale); + width = (int) Math.floor(width * scale); + height = (int) Math.floor(height * scale); // Now draw it int sourceType = SelectionDrawer.DATASOURCE_TYPE_NOT_CATEGORIZED; diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java index 6947d7fb9..b40d72c47 100644 --- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java +++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java @@ -18,7 +18,6 @@ package com.android.gallery3d.ui; import android.graphics.Bitmap; import android.os.Message; -import android.util.FloatMath; import com.android.gallery3d.app.GalleryActivity; import com.android.gallery3d.common.BitmapUtils; @@ -330,8 +329,8 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { float scaley = mBoxHeight / (float) height; float scale = Math.min(scalex, scaley); - width = (int) FloatMath.floor(width * scale); - height = (int) FloatMath.floor(height * scale); + width = (int) Math.floor(width * scale); + height = (int) Math.floor(height * scale); // Now draw it if (pass == 0) { diff --git a/src/com/android/gallery3d/ui/CropView.java b/src/com/android/gallery3d/ui/CropView.java index 227e67e11..71fdaab96 100644 --- a/src/com/android/gallery3d/ui/CropView.java +++ b/src/com/android/gallery3d/ui/CropView.java @@ -31,7 +31,6 @@ import android.graphics.RectF; import android.media.FaceDetector; import android.os.Handler; import android.os.Message; -import android.util.FloatMath; import android.view.MotionEvent; import android.view.animation.DecelerateInterpolator; import android.widget.Toast; @@ -757,7 +756,8 @@ public class CropView extends GLView { int rotation = mImageRotation; int width = bitmap.getWidth(); int height = bitmap.getHeight(); - float scale = FloatMath.sqrt((float) FACE_PIXEL_COUNT / (width * height)); + float scale = (float) Math.sqrt( + (double) FACE_PIXEL_COUNT / (width * height)); // faceBitmap is a correctly rotated bitmap, as viewed by a user. Bitmap faceBitmap; diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java index 68cbbee5f..b4dac973f 100644 --- a/src/com/android/gallery3d/ui/PositionController.java +++ b/src/com/android/gallery3d/ui/PositionController.java @@ -406,7 +406,7 @@ class PositionController { // force it to be in the center. // (We do for height only, not width, because the user may // want to scroll to the previous/next image.) - if (FloatMath.floor(mImageH * mToScale) <= mViewH) { + if (Math.floor(mImageH * mToScale) <= mViewH) { mToY = mImageH / 2; } @@ -582,19 +582,19 @@ class PositionController { private void calculateStableBound(float scale, float horizontalSlack) { // The number of pixels between the center of the view // and the edge when the edge is aligned. - mBoundLeft = (int) FloatMath.ceil((mViewW - horizontalSlack) / (2 * scale)); + mBoundLeft = (int) Math.ceil((mViewW - horizontalSlack) / (2 * scale)); mBoundRight = mImageW - mBoundLeft; - mBoundTop = (int) FloatMath.ceil(mViewH / (2 * scale)); + mBoundTop = (int) Math.ceil(mViewH / (2 * scale)); mBoundBottom = mImageH - mBoundTop; // If the scaled height is smaller than the view height, // force it to be in the center. - if (FloatMath.floor(mImageH * scale) <= mViewH) { + if (Math.floor(mImageH * scale) <= mViewH) { mBoundTop = mBoundBottom = mImageH / 2; } // Same for width - if (FloatMath.floor(mImageW * scale) <= mViewW) { + if (Math.floor(mImageW * scale) <= mViewW) { mBoundLeft = mBoundRight = mImageW / 2; } } diff --git a/src/com/android/gallery3d/ui/StringTexture.java b/src/com/android/gallery3d/ui/StringTexture.java index 8d47bfdac..f576c0172 100644 --- a/src/com/android/gallery3d/ui/StringTexture.java +++ b/src/com/android/gallery3d/ui/StringTexture.java @@ -69,7 +69,7 @@ class StringTexture extends CanvasTexture { private static StringTexture newInstance(String text, TextPaint paint) { FontMetricsInt metrics = paint.getFontMetricsInt(); - int width = (int) FloatMath.ceil(paint.measureText(text)); + int width = (int) Math.ceil(paint.measureText(text)); int height = metrics.bottom - metrics.top; // The texture size needs to be at least 1x1. if (width <= 0) width = 1; diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java index 05d09f5b8..980f7b208 100644 --- a/src/com/android/gallery3d/ui/TileImageView.java +++ b/src/com/android/gallery3d/ui/TileImageView.java @@ -19,7 +19,6 @@ package com.android.gallery3d.ui; import android.graphics.Bitmap; import android.graphics.Rect; import android.graphics.RectF; -import android.util.FloatMath; import com.android.gallery3d.app.GalleryContext; import com.android.gallery3d.common.Utils; @@ -294,10 +293,10 @@ public class TileImageView extends GLView { int height = (int) Math.ceil(Math.max( Math.abs(sin * w + cos * h), Math.abs(sin * w - cos * h))); - int left = (int) FloatMath.floor(cX - width / (2f * scale)); - int top = (int) FloatMath.floor(cY - height / (2f * scale)); - int right = (int) FloatMath.ceil(left + width / scale); - int bottom = (int) FloatMath.ceil(top + height / scale); + int left = (int) Math.floor(cX - width / (2f * scale)); + int top = (int) Math.floor(cY - height / (2f * scale)); + int right = (int) Math.ceil(left + width / scale); + int bottom = (int) Math.ceil(top + height / scale); // align the rectangle to tile boundary int size = TILE_SIZE << level; |