diff options
author | Chih-Chung Chang <chihchung@google.com> | 2012-02-11 07:19:47 +0800 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2012-02-11 07:20:05 +0800 |
commit | e1e40b31bfce1885fb96edd1f92016cd73077d36 (patch) | |
tree | 5df2e2c294f0f7c65ea75452d44d564780bf38e9 /src/com/android/gallery3d/ui | |
parent | feef78c1ecf63c88e052698040e809f25ffef0c4 (diff) | |
download | android_packages_apps_Snap-e1e40b31bfce1885fb96edd1f92016cd73077d36.tar.gz android_packages_apps_Snap-e1e40b31bfce1885fb96edd1f92016cd73077d36.tar.bz2 android_packages_apps_Snap-e1e40b31bfce1885fb96edd1f92016cd73077d36.zip |
Use FloatMath instead of Math.
Change-Id: I26eb6a554f72c13ba2801ce35ef0cf2a1466a97b
Diffstat (limited to 'src/com/android/gallery3d/ui')
6 files changed, 19 insertions, 16 deletions
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java index 87ff5579d..0f03da844 100644 --- a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java +++ b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java @@ -19,6 +19,7 @@ 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; @@ -381,8 +382,8 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { float scaley = mBoxHeight / (float) height; float scale = Math.min(scalex, scaley); - width = (int) Math.floor(width * scale); - height = (int) Math.floor(height * scale); + width = (int) FloatMath.floor(width * scale); + height = (int) FloatMath.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 b40d72c47..6947d7fb9 100644 --- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java +++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java @@ -18,6 +18,7 @@ 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; @@ -329,8 +330,8 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { float scaley = mBoxHeight / (float) height; float scale = Math.min(scalex, scaley); - width = (int) Math.floor(width * scale); - height = (int) Math.floor(height * scale); + width = (int) FloatMath.floor(width * scale); + height = (int) FloatMath.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 71fdaab96..227e67e11 100644 --- a/src/com/android/gallery3d/ui/CropView.java +++ b/src/com/android/gallery3d/ui/CropView.java @@ -31,6 +31,7 @@ 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; @@ -756,8 +757,7 @@ public class CropView extends GLView { int rotation = mImageRotation; int width = bitmap.getWidth(); int height = bitmap.getHeight(); - float scale = (float) Math.sqrt( - (double) FACE_PIXEL_COUNT / (width * height)); + float scale = FloatMath.sqrt((float) 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 b4dac973f..68cbbee5f 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 (Math.floor(mImageH * mToScale) <= mViewH) { + if (FloatMath.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) Math.ceil((mViewW - horizontalSlack) / (2 * scale)); + mBoundLeft = (int) FloatMath.ceil((mViewW - horizontalSlack) / (2 * scale)); mBoundRight = mImageW - mBoundLeft; - mBoundTop = (int) Math.ceil(mViewH / (2 * scale)); + mBoundTop = (int) FloatMath.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 (Math.floor(mImageH * scale) <= mViewH) { + if (FloatMath.floor(mImageH * scale) <= mViewH) { mBoundTop = mBoundBottom = mImageH / 2; } // Same for width - if (Math.floor(mImageW * scale) <= mViewW) { + if (FloatMath.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 f576c0172..8d47bfdac 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) Math.ceil(paint.measureText(text)); + int width = (int) FloatMath.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 980f7b208..05d09f5b8 100644 --- a/src/com/android/gallery3d/ui/TileImageView.java +++ b/src/com/android/gallery3d/ui/TileImageView.java @@ -19,6 +19,7 @@ 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; @@ -293,10 +294,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) 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); + 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); // align the rectangle to tile boundary int size = TILE_SIZE << level; |