From 7a42f8afc6cc6a18ef0b555145a5c3d5150dc860 Mon Sep 17 00:00:00 2001 From: Neil Fuller Date: Thu, 2 Oct 2014 16:34:24 +0100 Subject: Remove dependencies on FloatMath See frameworks/base commit 33253a4baa6279f81a73425b49dfb6abe5f5416e for details. Bug: https://code.google.com/p/android/issues/detail?id=36199 Change-Id: I62da9522f98b293d3c594627f7816d68f79d5bad --- .../deskclock/widget/multiwaveview/GlowPadView.java | 2 +- .../deskclock/widget/multiwaveview/PointCloud.java | 21 ++++++++------------- .../deskclock/widget/sgv/OverScrollerSGV.java | 5 +---- 3 files changed, 10 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/com/android/deskclock/widget/multiwaveview/GlowPadView.java b/src/com/android/deskclock/widget/multiwaveview/GlowPadView.java index 30c77ba3c..d8e29d8e7 100644 --- a/src/com/android/deskclock/widget/multiwaveview/GlowPadView.java +++ b/src/com/android/deskclock/widget/multiwaveview/GlowPadView.java @@ -845,7 +845,7 @@ public class GlowPadView extends View { // tx and ty are relative to wave center float tx = eventX - mWaveCenterX; float ty = eventY - mWaveCenterY; - float touchRadius = (float) Math.sqrt(dist2(tx, ty)); + float touchRadius = (float) Math.hypot(tx, ty); final float scale = touchRadius > mOuterRadius ? mOuterRadius / touchRadius : 1.0f; float limitX = tx * scale; float limitY = ty * scale; diff --git a/src/com/android/deskclock/widget/multiwaveview/PointCloud.java b/src/com/android/deskclock/widget/multiwaveview/PointCloud.java index 8154ff7a9..685716975 100644 --- a/src/com/android/deskclock/widget/multiwaveview/PointCloud.java +++ b/src/com/android/deskclock/widget/multiwaveview/PointCloud.java @@ -20,7 +20,6 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.drawable.Drawable; -import android.util.FloatMath; import android.util.Log; import java.util.ArrayList; @@ -151,8 +150,8 @@ public class PointCloud { float eta = PI/2.0f; float dEta = 2.0f * PI / pointsInBand; for (int i = 0; i < pointsInBand; i++) { - float x = r * FloatMath.cos(eta); - float y = r * FloatMath.sin(eta); + float x = r * (float) Math.cos(eta); + float y = r * (float) Math.sin(eta); eta += dEta; mPointCloud.add(new Point(x, y, r)); } @@ -167,31 +166,27 @@ public class PointCloud { return mScale; } - private static float hypot(float x, float y) { - return FloatMath.sqrt(x*x + y*y); - } - private static float max(float a, float b) { return a > b ? a : b; } public int getAlphaForPoint(Point point) { // Contribution from positional glow - float glowDistance = hypot(glowManager.x - point.x, glowManager.y - point.y); + float glowDistance = (float) Math.hypot(glowManager.x - point.x, glowManager.y - point.y); float glowAlpha = 0.0f; if (glowDistance < glowManager.radius) { - float cosf = FloatMath.cos(PI * 0.25f * glowDistance / glowManager.radius); - glowAlpha = glowManager.alpha * max(0.0f, (float) Math.pow(cosf, 10.0f)); + double cos = Math.cos(Math.PI * 0.25d * glowDistance / glowManager.radius); + glowAlpha = glowManager.alpha * (float) Math.max(0.0d, Math.pow(cos, 10.0d)); } // Compute contribution from Wave - float radius = hypot(point.x, point.y); + float radius = (float) Math.hypot(point.x, point.y); float distanceToWaveRing = (radius - waveManager.radius); float waveAlpha = 0.0f; if (distanceToWaveRing < waveManager.width * 0.5f && distanceToWaveRing < 0.0f) { - float cosf = FloatMath.cos(PI * 0.25f * distanceToWaveRing / waveManager.width); - waveAlpha = waveManager.alpha * max(0.0f, (float) Math.pow(cosf, 20.0f)); + double cos = Math.cos(Math.PI * 0.25d * distanceToWaveRing / waveManager.width); + waveAlpha = waveManager.alpha * (float) Math.max(0.0d, Math.pow(cos, 20.0d)); } return (int) (max(glowAlpha, waveAlpha) * 255); diff --git a/src/com/android/deskclock/widget/sgv/OverScrollerSGV.java b/src/com/android/deskclock/widget/sgv/OverScrollerSGV.java index a5ce155b9..636a90e9d 100644 --- a/src/com/android/deskclock/widget/sgv/OverScrollerSGV.java +++ b/src/com/android/deskclock/widget/sgv/OverScrollerSGV.java @@ -18,7 +18,6 @@ package com.android.deskclock.widget.sgv; import android.content.Context; import android.hardware.SensorManager; -import android.util.FloatMath; import android.util.Log; import android.view.ViewConfiguration; import android.view.animation.AnimationUtils; @@ -177,9 +176,7 @@ public class OverScrollerSGV { * @return The original velocity less the deceleration, norm of the X and Y velocity vector. */ public float getCurrVelocity() { - float squaredNorm = mScrollerX.mCurrVelocity * mScrollerX.mCurrVelocity; - squaredNorm += mScrollerY.mCurrVelocity * mScrollerY.mCurrVelocity; - return FloatMath.sqrt(squaredNorm); + return (float) Math.hypot(mScrollerX.mCurrVelocity, mScrollerY.mCurrVelocity); } /** -- cgit v1.2.3