diff options
Diffstat (limited to 'src')
14 files changed, 29 insertions, 40 deletions
diff --git a/src/com/android/gallery3d/app/EyePosition.java b/src/com/android/gallery3d/app/EyePosition.java index d99d97b0e..4248f49b8 100644 --- a/src/com/android/gallery3d/app/EyePosition.java +++ b/src/com/android/gallery3d/app/EyePosition.java @@ -22,7 +22,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; @@ -44,9 +43,9 @@ public class EyePosition { private static final float GYROSCOPE_RESTORE_FACTOR = 0.995f; 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 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 = 0.5f; private static final int NOT_STARTED = -1; private static final float USER_DISTANCE_METER = 0.3f; @@ -128,8 +127,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, @@ -137,7 +136,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); } @@ -175,7 +174,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/DecodeUtils.java b/src/com/android/gallery3d/data/DecodeUtils.java index 825c4bbea..7e10191b7 100644 --- a/src/com/android/gallery3d/data/DecodeUtils.java +++ b/src/com/android/gallery3d/data/DecodeUtils.java @@ -24,7 +24,6 @@ import android.graphics.BitmapFactory; import android.graphics.BitmapFactory.Options; import android.graphics.BitmapRegionDecoder; import android.os.Build; -import android.util.FloatMath; import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.BitmapUtils; @@ -137,7 +136,7 @@ public class DecodeUtils { final int MAX_PIXEL_COUNT = 640000; // 400 x 1600 if ((w / options.inSampleSize) * (h / options.inSampleSize) > MAX_PIXEL_COUNT) { options.inSampleSize = BitmapUtils.computeSampleSize( - FloatMath.sqrt((float) MAX_PIXEL_COUNT / (w * h))); + (float) Math.sqrt((double) MAX_PIXEL_COUNT / (w * h))); } } else { // For screen nail, we only want to keep the longer side >= targetSize. diff --git a/src/com/android/gallery3d/data/LocationClustering.java b/src/com/android/gallery3d/data/LocationClustering.java index 540322a33..90ac41c65 100644 --- a/src/com/android/gallery3d/data/LocationClustering.java +++ b/src/com/android/gallery3d/data/LocationClustering.java @@ -19,7 +19,6 @@ package com.android.gallery3d.data; import android.content.Context; import android.os.Handler; import android.os.Looper; -import android.util.FloatMath; import android.widget.Toast; import com.android.gallery3d.R; @@ -298,7 +297,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/filtershow/filters/saturation.rs b/src/com/android/gallery3d/filtershow/filters/saturation.rs index 5210e34a3..5b216406d 100644 --- a/src/com/android/gallery3d/filtershow/filters/saturation.rs +++ b/src/com/android/gallery3d/filtershow/filters/saturation.rs @@ -149,7 +149,6 @@ uchar4 __attribute__((kernel)) selectiveAdjust(const uchar4 in, uint32_t x, uint32_t y) { float4 pixel = rsUnpackColor8888(in); - float4 wsum = pixel; int hue = rgb2hue(in); float t = satLut[hue]; @@ -158,4 +157,4 @@ uchar4 __attribute__((kernel)) selectiveAdjust(const uchar4 in, uint32_t x, pixel.a = 1.0f; return rsPackColorTo8888(clamp(pixel, 0.f, 1.0f)); -}
\ No newline at end of file +} diff --git a/src/com/android/gallery3d/filtershow/filters/vignette.rs b/src/com/android/gallery3d/filtershow/filters/vignette.rs index 709b220e4..7ab466348 100644 --- a/src/com/android/gallery3d/filtershow/filters/vignette.rs +++ b/src/com/android/gallery3d/filtershow/filters/vignette.rs @@ -38,8 +38,6 @@ static const float Bf = 0.114f; void setupVignetteParams() { - int k = 0; - scalex = 1.f / radiusx; scaley = 1.f / radiusy; @@ -75,4 +73,4 @@ uchar4 __attribute__((kernel)) vignette(const uchar4 in, uint32_t x, uint32_t y wsum.a = 1.0f; uchar4 out = rsPackColorTo8888(clamp(wsum, 0.f, 1.0f)); return out; -}
\ No newline at end of file +} diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java index dada7dcb2..614b6485d 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java +++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java @@ -151,7 +151,7 @@ public final class GeometryMathUtils { } public static float[] normalize(float[] a) { - float length = (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]); + float length = (float) Math.hypot(a[0], a[1]); float[] b = { a[0] / length, a[1] / length }; @@ -160,7 +160,7 @@ public final class GeometryMathUtils { // A onto B public static float scalarProjection(float[] a, float[] b) { - float length = (float) Math.sqrt(b[0] * b[0] + b[1] * b[1]); + float length = (float) Math.hypot(b[0], b[1]); return dotProduct(a, b) / length; } @@ -175,7 +175,7 @@ public final class GeometryMathUtils { float[] p = { point2[0] - point1[0], point2[1] - point1[1] }; - float length = (float) Math.sqrt(p[0] * p[0] + p[1] * p[1]); + float length = (float) Math.hypot(p[0], p[1]); p[0] = p[0] / length; p[1] = p[1] / length; return p; @@ -198,7 +198,7 @@ public final class GeometryMathUtils { } public static float vectorLength(float[] a) { - return (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]); + return (float) Math.hypot(a[0], a[1]); } public static float scale(float oldWidth, float oldHeight, float newWidth, float newHeight) { diff --git a/src/com/android/gallery3d/filtershow/imageshow/GradControl.java b/src/com/android/gallery3d/filtershow/imageshow/GradControl.java index 964da99e9..29870154b 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/GradControl.java +++ b/src/com/android/gallery3d/filtershow/imageshow/GradControl.java @@ -110,7 +110,7 @@ public class GradControl { for (int i = 0; i < handlex.length; i++) { float dx = handlex[i] - x; float dy = handley[i] - y; - float dist = (float) Math.sqrt(dx * dx + dy * dy); + float dist = (float) Math.hypot(dx, dy); } return -1; @@ -236,7 +236,7 @@ public class GradControl { float cy = (p1y + p2y) / 2; float dx = p1x - p2x; float dy = p1y - p2y; - float len = (float) Math.sqrt(dx * dx + dy * dy); + float len = (float) Math.hypot(dx, dy); dx *= 2048 / len; dy *= 2048 / len; diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java b/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java index 0d20322d6..3fb75c6df 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java @@ -223,12 +223,11 @@ public class ImageCurves extends ImageShow { Spline spline = getSpline(mCurrentCurveIndex); float px = spline.getPoint(0).x; float py = spline.getPoint(0).y; - double delta = Math.sqrt((px - x) * (px - x) + (py - y) * (py - y)); + double delta = Math.hypot(px - x, py - y); for (int i = 1; i < spline.getNbPoints(); i++) { px = spline.getPoint(i).x; py = spline.getPoint(i).y; - double currentDelta = Math.sqrt((px - x) * (px - x) + (py - y) - * (py - y)); + double currentDelta = Math.hypot(px - x, py - y); if (currentDelta < delta) { delta = currentDelta; pick = i; diff --git a/src/com/android/gallery3d/filtershow/tools/SaveImage.java b/src/com/android/gallery3d/filtershow/tools/SaveImage.java index 8997ef540..e07dd2ce8 100644 --- a/src/com/android/gallery3d/filtershow/tools/SaveImage.java +++ b/src/com/android/gallery3d/filtershow/tools/SaveImage.java @@ -49,8 +49,8 @@ import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.sql.Date; import java.text.SimpleDateFormat; +import java.util.Date; import java.util.TimeZone; /** diff --git a/src/com/android/gallery3d/glrenderer/StringTexture.java b/src/com/android/gallery3d/glrenderer/StringTexture.java index 56ca29753..c18d91b47 100644 --- a/src/com/android/gallery3d/glrenderer/StringTexture.java +++ b/src/com/android/gallery3d/glrenderer/StringTexture.java @@ -23,7 +23,6 @@ import android.graphics.Paint.FontMetricsInt; import android.graphics.Typeface; import android.text.TextPaint; import android.text.TextUtils; -import android.util.FloatMath; // StringTexture is a texture shows the content of a specified String. // @@ -72,7 +71,7 @@ public 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/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java index 1fff4ea3e..265a53fc7 100755 --- a/src/com/android/gallery3d/ui/PhotoView.java +++ b/src/com/android/gallery3d/ui/PhotoView.java @@ -24,7 +24,6 @@ import android.graphics.Matrix; import android.graphics.Rect; import android.os.Build; import android.os.Message; -import android.util.FloatMath; import android.view.MotionEvent; import android.view.View.MeasureSpec; import android.view.animation.AccelerateInterpolator; @@ -1103,7 +1102,7 @@ public class PhotoView extends GLView { delta = delta > 0 ? maxScrollDistance : -maxScrollDistance; } else { delta = maxScrollDistance * - FloatMath.sin((delta / size) * (float) (Math.PI / 2)); + (float) Math.sin((delta / size) * (Math.PI / 2)); } return (int) (delta + 0.5f); } diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java index 3185c7598..1103ed80a 100644 --- a/src/com/android/gallery3d/ui/TileImageView.java +++ b/src/com/android/gallery3d/ui/TileImageView.java @@ -23,7 +23,6 @@ import android.graphics.Rect; import android.graphics.RectF; import android.support.v4.util.LongSparseArray; import android.util.DisplayMetrics; -import android.util.FloatMath; import android.view.WindowManager; import com.android.gallery3d.app.GalleryContext; @@ -313,10 +312,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 = sTileSize << level; diff --git a/src/com/android/gallery3d/util/MotionEventHelper.java b/src/com/android/gallery3d/util/MotionEventHelper.java index 715f7fa69..dc01cd98c 100644 --- a/src/com/android/gallery3d/util/MotionEventHelper.java +++ b/src/com/android/gallery3d/util/MotionEventHelper.java @@ -17,7 +17,6 @@ package com.android.gallery3d.util; import android.annotation.TargetApi; import android.graphics.Matrix; -import android.util.FloatMath; import android.view.MotionEvent; import android.view.MotionEvent.PointerCoords; @@ -104,8 +103,8 @@ public final class MotionEventHelper { // angle from vertical. Coordinate system: down is increasing Y, right is // increasing X. float[] v = new float[2]; - v[0] = FloatMath.sin(angleRadians); - v[1] = -FloatMath.cos(angleRadians); + v[0] = (float) Math.sin(angleRadians); + v[1] = (float) -Math.cos(angleRadians); m.mapVectors(v); // Derive the transformed vector's clockwise angle from vertical. diff --git a/src/com/android/gallery3d/util/SaveVideoFileUtils.java b/src/com/android/gallery3d/util/SaveVideoFileUtils.java index 10c41de90..bef75bac4 100644 --- a/src/com/android/gallery3d/util/SaveVideoFileUtils.java +++ b/src/com/android/gallery3d/util/SaveVideoFileUtils.java @@ -28,8 +28,8 @@ import android.provider.MediaStore.Video.VideoColumns; import com.android.gallery3d.filtershow.tools.SaveImage.ContentResolverQueryCallback; import java.io.File; -import java.sql.Date; import java.text.SimpleDateFormat; +import java.util.Date; public class SaveVideoFileUtils { // This function can decide which folder to save the video file, and generate |