From 33253a4baa6279f81a73425b49dfb6abe5f5416e Mon Sep 17 00:00:00 2001 From: Neil Fuller Date: Wed, 1 Oct 2014 11:55:10 +0100 Subject: [PATCH] Switch from FloatMath -> Math and Math.hypot where possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The motivation is an API change: FloatMath is going to be deprecated and/or removed. Performance is not the goal of this change. That said... Math is faster than FloatMath with AOT compilation. While making the change, occurances of: {Float}Math.sqrt(x * x + y * y) and {Float}Math.sqrt({Float}Math.pow(x, 2) + {Float}Math.pow(y, 2)) have been replaced with: {(float)} Math.hypot(x, y) Right now there is no runtime intrinsic for hypot so is not faster in all cases for AOT compilation: Math.sqrt(x * x + y * y) is faster than Math.hypot(x, y) with AOT, but all other combinations of FloatMath, use of pow() etc. are slower than hypot(). hypot() has the advantage of being self documenting and could be optimized in future. None of the behavior differences around NaN and rounding appear to be important for the cases looked at: they all assume results and arguments are in range and usually the results are cast to float. Different implementations measured on hammerhead / L: AOT compiled: [FloatMath.hypot(x, y)] benchmark=Hypot_FloatMathHypot} 633.85 ns; σ=0.32 ns @ 3 trials [FloatMath.sqrt(x*x + y*y)] benchmark=Hypot_FloatMathSqrtMult} 684.17 ns; σ=4.83 ns @ 3 trials [FloatMath.sqrt(FloatMath.pow(x, 2) + FloatMath.pow(y, 2))] benchmark=Hypot_FloatMathSqrtPow} 1270.65 ns; σ=12.20 ns @ 6 trials [(float) Math.hypot(x, y)] benchmark=Hypot_MathHypot} 96.80 ns; σ=0.05 ns @ 3 trials [(float) Math.sqrt(x*x + y*y)] benchmark=Hypot_MathSqrtMult} 23.97 ns; σ=0.01 ns @ 3 trials [(float) Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))] benchmark=Hypot_MathSqrtPow} 156.19 ns; σ=0.12 ns @ 3 trials Interpreter: benchmark=Hypot_FloatMathHypot} 1180.54 ns; σ=5.13 ns @ 3 trials benchmark=Hypot_FloatMathSqrtMult} 1121.05 ns; σ=3.80 ns @ 3 trials benchmark=Hypot_FloatMathSqrtPow} 3327.14 ns; σ=7.33 ns @ 3 trials benchmark=Hypot_MathHypot} 856.57 ns; σ=1.41 ns @ 3 trials benchmark=Hypot_MathSqrtMult} 1028.92 ns; σ=9.11 ns @ 3 trials benchmark=Hypot_MathSqrtPow} 2539.47 ns; σ=24.44 ns @ 3 trials Bug: https://code.google.com/p/android/issues/detail?id=36199 Change-Id: I06c91f682095e627cb547d60d936ef87941be692 --- .../android/gesture/GestureOverlayView.java | 2 +- core/java/android/gesture/GestureStroke.java | 3 +- core/java/android/gesture/GestureUtils.java | 8 +- .../android/hardware/GeomagneticField.java | 2 +- core/java/android/text/BoringLayout.java | 5 +- core/java/android/util/MathUtils.java | 4 +- core/java/android/util/Spline.java | 2 +- .../android/view/ScaleGestureDetector.java | 3 +- core/java/android/widget/OverScroller.java | 5 +- core/java/android/widget/Scroller.java | 5 +- core/java/android/widget/StackView.java | 6 +- core/java/android/widget/TextView.java | 29 ++-- .../widget/multiwaveview/GlowPadView.java | 2 +- .../widget/multiwaveview/MultiWaveView.java | 2 +- .../widget/multiwaveview/PointCloud.java | 27 ++-- .../java/android/graphics/ColorMatrix.java | 8 +- graphics/java/android/graphics/PointF.java | 3 +- graphics/java/android/graphics/RectF.java | 5 +- .../java/android/filterfw/geometry/Point.java | 2 +- .../camera/CameraFunctionalTest.java | 1 - .../functional/camera/CameraPairwiseTest.java | 1 - .../recent/RecentsHorizontalScrollView.java | 3 +- .../recent/RecentsVerticalScrollView.java | 3 +- .../android/wallpapercropper/CropView.java | 5 +- .../impl/WindowOrientationListener.java | 7 +- .../android/server/TwilightCalculator.java | 15 +- .../server/accessibility/GestureUtils.java | 6 +- .../server/power/DisplayPowerController.java | 5 +- .../android/server/power/ElectronBeam.java | 3 +- .../server/wm/WindowManagerService.java | 3 +- test-runner/src/android/test/TouchUtils.java | 4 +- .../androidx/media/filterfw/CropFilter.java | 5 +- .../src/android/graphics/Matrix_Delegate.java | 9 +- .../graphics/RadialGradient_Delegate.java | 2 +- .../src/android/util/FloatMath_Delegate.java | 132 ------------------ .../tools/layoutlib/create/CreateInfo.java | 1 - 36 files changed, 77 insertions(+), 251 deletions(-) delete mode 100644 tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java diff --git a/core/java/android/gesture/GestureOverlayView.java b/core/java/android/gesture/GestureOverlayView.java index 2d47f289b38ef..e0bb6e0e61419 100644 --- a/core/java/android/gesture/GestureOverlayView.java +++ b/core/java/android/gesture/GestureOverlayView.java @@ -635,7 +635,7 @@ public class GestureOverlayView extends FrameLayout { mStrokeBuffer.add(new GesturePoint(x, y, event.getEventTime())); if (mHandleGestureActions && !mIsGesturing) { - mTotalLength += (float) Math.sqrt(dx * dx + dy * dy); + mTotalLength += (float) Math.hypot(dx, dy); if (mTotalLength > mGestureStrokeLengthThreshold) { final OrientedBoundingBox box = diff --git a/core/java/android/gesture/GestureStroke.java b/core/java/android/gesture/GestureStroke.java index 1d0f0fec2a917..bed904ef49d24 100644 --- a/core/java/android/gesture/GestureStroke.java +++ b/core/java/android/gesture/GestureStroke.java @@ -69,8 +69,7 @@ public class GestureStroke { bx.bottom = p.y; len = 0; } else { - len += Math.sqrt(Math.pow(p.x - tmpPoints[(i - 1) * 2], 2) - + Math.pow(p.y - tmpPoints[(i -1 ) * 2 + 1], 2)); + len += Math.hypot(p.x - tmpPoints[(i - 1) * 2], p.y - tmpPoints[(i -1 ) * 2 + 1]); bx.union(p.x, p.y); } index++; diff --git a/core/java/android/gesture/GestureUtils.java b/core/java/android/gesture/GestureUtils.java index dd221fc7bbe8c..416279e6e5eb7 100644 --- a/core/java/android/gesture/GestureUtils.java +++ b/core/java/android/gesture/GestureUtils.java @@ -293,7 +293,7 @@ public final class GestureUtils { } float deltaX = currentPointX - lstPointX; float deltaY = currentPointY - lstPointY; - float distance = (float) Math.sqrt(deltaX * deltaX + deltaY * deltaY); + float distance = (float) Math.hypot(deltaX, deltaY); if (distanceSoFar + distance >= increment) { float ratio = (increment - distanceSoFar) / distance; float nx = lstPointX + ratio * deltaX; @@ -379,7 +379,7 @@ public final class GestureUtils { for (int i = 0; i < count; i += 2) { float dx = points[i + 2] - points[i]; float dy = points[i + 3] - points[i + 1]; - sum += Math.sqrt(dx * dx + dy * dy); + sum += Math.hypot(dx, dy); } return sum; } @@ -388,13 +388,13 @@ public final class GestureUtils { float totalLen = computeTotalLength(points); float dx = points[2] - points[0]; float dy = points[3] - points[1]; - return (float) Math.sqrt(dx * dx + dy * dy) / totalLen; + return (float) Math.hypot(dx, dy) / totalLen; } static float computeStraightness(float[] points, float totalLen) { float dx = points[2] - points[0]; float dy = points[3] - points[1]; - return (float) Math.sqrt(dx * dx + dy * dy) / totalLen; + return (float) Math.hypot(dx, dy) / totalLen; } /** diff --git a/core/java/android/hardware/GeomagneticField.java b/core/java/android/hardware/GeomagneticField.java index 036982592d5c6..f1341a053ae80 100644 --- a/core/java/android/hardware/GeomagneticField.java +++ b/core/java/android/hardware/GeomagneticField.java @@ -281,7 +281,7 @@ public class GeomagneticField { * @return Horizontal component of the field strength in nonoteslas. */ public float getHorizontalStrength() { - return (float) Math.sqrt(mX * mX + mY * mY); + return (float) Math.hypot(mX, mY); } /** diff --git a/core/java/android/text/BoringLayout.java b/core/java/android/text/BoringLayout.java index 77cd71efc3c3d..52e6a2ce24db8 100644 --- a/core/java/android/text/BoringLayout.java +++ b/core/java/android/text/BoringLayout.java @@ -20,7 +20,6 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Path; import android.text.style.ParagraphStyle; -import android.util.FloatMath; /** * A BoringLayout is a very simple Layout implementation for text that @@ -211,7 +210,7 @@ public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback TextLine line = TextLine.obtain(); line.set(paint, source, 0, source.length(), Layout.DIR_LEFT_TO_RIGHT, Layout.DIRS_ALL_LEFT_TO_RIGHT, false, null); - mMax = (int) FloatMath.ceil(line.metrics(null)); + mMax = (int) Math.ceil(line.metrics(null)); TextLine.recycle(line); } @@ -305,7 +304,7 @@ public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback TextLine line = TextLine.obtain(); line.set(paint, text, 0, length, Layout.DIR_LEFT_TO_RIGHT, Layout.DIRS_ALL_LEFT_TO_RIGHT, false, null); - fm.width = (int) FloatMath.ceil(line.metrics(fm)); + fm.width = (int) Math.ceil(line.metrics(fm)); TextLine.recycle(line); return fm; diff --git a/core/java/android/util/MathUtils.java b/core/java/android/util/MathUtils.java index 13a692ea18c95..36d5b505d4de5 100644 --- a/core/java/android/util/MathUtils.java +++ b/core/java/android/util/MathUtils.java @@ -94,7 +94,7 @@ public final class MathUtils { public static float dist(float x1, float y1, float x2, float y2) { final float x = (x2 - x1); final float y = (y2 - y1); - return (float) Math.sqrt(x * x + y * y); + return (float) Math.hypot(x, y); } public static float dist(float x1, float y1, float z1, float x2, float y2, float z2) { @@ -105,7 +105,7 @@ public final class MathUtils { } public static float mag(float a, float b) { - return (float) Math.sqrt(a * a + b * b); + return (float) Math.hypot(a, b); } public static float mag(float a, float b, float c) { diff --git a/core/java/android/util/Spline.java b/core/java/android/util/Spline.java index ed027eb18166e..60d1e7c216e8e 100644 --- a/core/java/android/util/Spline.java +++ b/core/java/android/util/Spline.java @@ -88,7 +88,7 @@ public final class Spline { throw new IllegalArgumentException("The control points must have " + "monotonic Y values."); } - float h = FloatMath.hypot(a, b); + float h = (float) Math.hypot(a, b); if (h > 9f) { float t = 3f / h; m[i] = t * a * d[i]; diff --git a/core/java/android/view/ScaleGestureDetector.java b/core/java/android/view/ScaleGestureDetector.java index 42a58a8efc222..6508cca7cc3f7 100644 --- a/core/java/android/view/ScaleGestureDetector.java +++ b/core/java/android/view/ScaleGestureDetector.java @@ -21,7 +21,6 @@ import android.content.res.Resources; import android.os.Build; import android.os.Handler; import android.os.SystemClock; -import android.util.FloatMath; /** * Detects scaling transformation gestures using the supplied {@link MotionEvent}s. @@ -394,7 +393,7 @@ public class ScaleGestureDetector { if (inDoubleTapMode()) { span = spanY; } else { - span = FloatMath.sqrt(spanX * spanX + spanY * spanY); + span = (float) Math.hypot(spanX, spanY); } // Dispatch begin/end events as needed. diff --git a/core/java/android/widget/OverScroller.java b/core/java/android/widget/OverScroller.java index f2181991b4c45..0d692eb04c671 100644 --- a/core/java/android/widget/OverScroller.java +++ b/core/java/android/widget/OverScroller.java @@ -18,7 +18,6 @@ package android.widget; 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; @@ -173,9 +172,7 @@ public class OverScroller { * @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); } /** diff --git a/core/java/android/widget/Scroller.java b/core/java/android/widget/Scroller.java index 3bfd39d80baa2..760e05c5c2872 100644 --- a/core/java/android/widget/Scroller.java +++ b/core/java/android/widget/Scroller.java @@ -19,7 +19,6 @@ package android.widget; import android.content.Context; import android.hardware.SensorManager; import android.os.Build; -import android.util.FloatMath; import android.view.ViewConfiguration; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; @@ -436,7 +435,7 @@ public class Scroller { float dx = (float) (mFinalX - mStartX); float dy = (float) (mFinalY - mStartY); - float hyp = FloatMath.sqrt(dx * dx + dy * dy); + float hyp = (float) Math.hypot(dx, dy); float ndx = dx / hyp; float ndy = dy / hyp; @@ -453,7 +452,7 @@ public class Scroller { mMode = FLING_MODE; mFinished = false; - float velocity = FloatMath.sqrt(velocityX * velocityX + velocityY * velocityY); + float velocity = (float) Math.hypot(velocityX, velocityY); mVelocity = velocity; mDuration = getSplineFlingDuration(velocity); diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java index 68536604bf676..7df0a31e54489 100644 --- a/core/java/android/widget/StackView.java +++ b/core/java/android/widget/StackView.java @@ -1043,10 +1043,8 @@ public class StackView extends AdapterViewAnimator { if (mView != null) { final LayoutParams viewLp = (LayoutParams) mView.getLayoutParams(); - float d = (float) Math.sqrt(Math.pow(viewLp.horizontalOffset, 2) + - Math.pow(viewLp.verticalOffset, 2)); - float maxd = (float) Math.sqrt(Math.pow(mSlideAmount, 2) + - Math.pow(0.4f * mSlideAmount, 2)); + float d = (float) Math.hypot(viewLp.horizontalOffset, viewLp.verticalOffset); + float maxd = (float) Math.hypot(mSlideAmount, 0.4f * mSlideAmount); if (velocity == 0) { return (invert ? (1 - d / maxd) : d / maxd) * DEFAULT_ANIMATION_DURATION; diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 5ece0160b841c..3f26dd39def7a 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -92,7 +92,6 @@ import android.text.style.URLSpan; import android.text.style.UpdateAppearance; import android.text.util.Linkify; import android.util.AttributeSet; -import android.util.FloatMath; import android.util.Log; import android.util.TypedValue; import android.view.AccessibilityIterators.TextSegmentIterator; @@ -4556,7 +4555,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * make sure the entire cursor gets invalidated instead of * sometimes missing half a pixel. */ - float thick = FloatMath.ceil(mTextPaint.getStrokeWidth()); + float thick = (float) Math.ceil(mTextPaint.getStrokeWidth()); if (thick < 1.0f) { thick = 1.0f; } @@ -4566,10 +4565,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // mHighlightPath is guaranteed to be non null at that point. mHighlightPath.computeBounds(TEMP_RECTF, false); - invalidate((int) FloatMath.floor(horizontalPadding + TEMP_RECTF.left - thick), - (int) FloatMath.floor(verticalPadding + TEMP_RECTF.top - thick), - (int) FloatMath.ceil(horizontalPadding + TEMP_RECTF.right + thick), - (int) FloatMath.ceil(verticalPadding + TEMP_RECTF.bottom + thick)); + invalidate((int) Math.floor(horizontalPadding + TEMP_RECTF.left - thick), + (int) Math.floor(verticalPadding + TEMP_RECTF.top - thick), + (int) Math.ceil(horizontalPadding + TEMP_RECTF.right + thick), + (int) Math.ceil(verticalPadding + TEMP_RECTF.bottom + thick)); } } else { for (int i = 0; i < mEditor.mCursorCount; i++) { @@ -6236,7 +6235,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener max = Math.max(max, layout.getLineWidth(i)); } - return (int) FloatMath.ceil(max); + return (int) Math.ceil(max); } /** @@ -6313,7 +6312,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (boring == null || boring == UNKNOWN_BORING) { if (des < 0) { - des = (int) FloatMath.ceil(Layout.getDesiredWidth(mTransformed, mTextPaint)); + des = (int) Math.ceil(Layout.getDesiredWidth(mTransformed, mTextPaint)); } width = des; } else { @@ -6343,7 +6342,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (hintBoring == null || hintBoring == UNKNOWN_BORING) { if (hintDes < 0) { - hintDes = (int) FloatMath.ceil(Layout.getDesiredWidth(mHint, mTextPaint)); + hintDes = (int) Math.ceil(Layout.getDesiredWidth(mHint, mTextPaint)); } hintWidth = hintDes; } else { @@ -6649,8 +6648,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * keep leading edge in view. */ - int left = (int) FloatMath.floor(layout.getLineLeft(line)); - int right = (int) FloatMath.ceil(layout.getLineRight(line)); + int left = (int) Math.floor(layout.getLineLeft(line)); + int right = (int) Math.ceil(layout.getLineRight(line)); if (right - left < hspace) { scrollx = (right + left) / 2 - hspace / 2; @@ -6662,10 +6661,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } } else if (a == Layout.Alignment.ALIGN_RIGHT) { - int right = (int) FloatMath.ceil(layout.getLineRight(line)); + int right = (int) Math.ceil(layout.getLineRight(line)); scrollx = right - hspace; } else { // a == Layout.Alignment.ALIGN_LEFT (will also be the default) - scrollx = (int) FloatMath.floor(layout.getLineLeft(line)); + scrollx = (int) Math.floor(layout.getLineLeft(line)); } if (ht < vspace) { @@ -6740,8 +6739,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener final int top = layout.getLineTop(line); final int bottom = layout.getLineTop(line + 1); - int left = (int) FloatMath.floor(layout.getLineLeft(line)); - int right = (int) FloatMath.ceil(layout.getLineRight(line)); + int left = (int) Math.floor(layout.getLineLeft(line)); + int right = (int) Math.ceil(layout.getLineRight(line)); int ht = layout.getHeight(); int hspace = mRight - mLeft - getCompoundPaddingLeft() - getCompoundPaddingRight(); diff --git a/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java b/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java index cd1ccd3bb9eb4..bc058b635550f 100644 --- a/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java +++ b/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java @@ -857,7 +857,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/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java b/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java index e22d1e8d43ba6..0a3d509cc675d 100644 --- a/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java +++ b/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java @@ -832,7 +832,7 @@ public class MultiWaveView 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/core/java/com/android/internal/widget/multiwaveview/PointCloud.java b/core/java/com/android/internal/widget/multiwaveview/PointCloud.java index f2999354cada9..6f26b99c09833 100644 --- a/core/java/com/android/internal/widget/multiwaveview/PointCloud.java +++ b/core/java/com/android/internal/widget/multiwaveview/PointCloud.java @@ -22,7 +22,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; public class PointCloud { @@ -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,32 +166,24 @@ 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)); + float cosf = (float) Math.cos(PI * 0.25f * glowDistance / glowManager.radius); + glowAlpha = glowManager.alpha * Math.max(0.0f, (float) Math.pow(cosf, 10.0f)); } // Compute contribution from Wave - float radius = hypot(point.x, point.y); + float radius = (float) Math.hypot(point.x, point.y); float waveAlpha = 0.0f; if (radius < waveManager.radius * 2) { float distanceToWaveRing = (radius - waveManager.radius); - float cosf = FloatMath.cos(PI * 0.5f * distanceToWaveRing / waveManager.radius); - waveAlpha = waveManager.alpha * max(0.0f, (float) Math.pow(cosf, 6.0f)); + float cosf = (float) Math.cos(PI * 0.5f * distanceToWaveRing / waveManager.radius); + waveAlpha = waveManager.alpha * Math.max(0.0f, (float) Math.pow(cosf, 6.0f)); } - return (int) (max(glowAlpha, waveAlpha) * 255); + return (int) (Math.max(glowAlpha, waveAlpha) * 255); } private float interp(float min, float max, float f) { diff --git a/graphics/java/android/graphics/ColorMatrix.java b/graphics/java/android/graphics/ColorMatrix.java index e3596c80808d5..0bfd07bebe9c8 100644 --- a/graphics/java/android/graphics/ColorMatrix.java +++ b/graphics/java/android/graphics/ColorMatrix.java @@ -16,8 +16,6 @@ package android.graphics; -import android.util.FloatMath; - /** * 4x5 matrix for transforming the color+alpha components of a Bitmap. * The matrix is stored in a single array, and its treated as follows: @@ -118,9 +116,9 @@ public class ColorMatrix { */ public void setRotate(int axis, float degrees) { reset(); - float radians = degrees * (float)Math.PI / 180; - float cosine = FloatMath.cos(radians); - float sine = FloatMath.sin(radians); + double radians = degrees * Math.PI / 180d; + float cosine = (float) Math.cos(radians); + float sine = (float) Math.sin(radians); switch (axis) { // Rotation around the red color case 0: diff --git a/graphics/java/android/graphics/PointF.java b/graphics/java/android/graphics/PointF.java index ee38dbb27d34d..8e4288e35c42a 100644 --- a/graphics/java/android/graphics/PointF.java +++ b/graphics/java/android/graphics/PointF.java @@ -18,7 +18,6 @@ package android.graphics; import android.os.Parcel; import android.os.Parcelable; -import android.util.FloatMath; /** @@ -109,7 +108,7 @@ public class PointF implements Parcelable { * Returns the euclidian distance from (0,0) to (x,y) */ public static float length(float x, float y) { - return FloatMath.sqrt(x * x + y * y); + return (float) Math.hypot(x, y); } /** diff --git a/graphics/java/android/graphics/RectF.java b/graphics/java/android/graphics/RectF.java index 53178b05e3d7b..f5cedfa260838 100644 --- a/graphics/java/android/graphics/RectF.java +++ b/graphics/java/android/graphics/RectF.java @@ -20,7 +20,6 @@ import java.io.PrintWriter; import android.os.Parcel; import android.os.Parcelable; -import android.util.FloatMath; import com.android.internal.util.FastMath; /** @@ -450,8 +449,8 @@ public class RectF implements Parcelable { * floor of top and left, and the ceiling of right and bottom. */ public void roundOut(Rect dst) { - dst.set((int) FloatMath.floor(left), (int) FloatMath.floor(top), - (int) FloatMath.ceil(right), (int) FloatMath.ceil(bottom)); + dst.set((int) Math.floor(left), (int) Math.floor(top), + (int) Math.ceil(right), (int) Math.ceil(bottom)); } /** diff --git a/media/mca/filterfw/java/android/filterfw/geometry/Point.java b/media/mca/filterfw/java/android/filterfw/geometry/Point.java index 8207c72c42555..4682a0db85fdf 100644 --- a/media/mca/filterfw/java/android/filterfw/geometry/Point.java +++ b/media/mca/filterfw/java/android/filterfw/geometry/Point.java @@ -70,7 +70,7 @@ public class Point { } public float length() { - return (float)Math.sqrt(x*x + y*y); + return (float)Math.hypot(x, y); } public float distanceTo(Point p) { diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/camera/CameraFunctionalTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/camera/CameraFunctionalTest.java index e6f0aaf77f1a9..d12ef2e77c4a8 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/camera/CameraFunctionalTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/camera/CameraFunctionalTest.java @@ -37,7 +37,6 @@ import android.os.Handler; import android.os.Looper; import android.test.ActivityInstrumentationTestCase2; import android.test.suitebuilder.annotation.LargeTest; -import android.util.FloatMath; import android.util.Log; import android.view.SurfaceHolder; import com.android.mediaframeworktest.CameraStressTestRunner; diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/camera/CameraPairwiseTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/camera/CameraPairwiseTest.java index 61b708a46f555..8f675983bec21 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/camera/CameraPairwiseTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/camera/CameraPairwiseTest.java @@ -24,7 +24,6 @@ import android.os.Handler; import android.os.Looper; import android.test.ActivityInstrumentationTestCase2; import android.test.suitebuilder.annotation.LargeTest; -import android.util.FloatMath; import android.util.Log; import android.view.SurfaceHolder; diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java index be42bc0c9b325..a56d5e7db7018 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java @@ -23,7 +23,6 @@ import android.database.DataSetObserver; import android.graphics.Canvas; import android.util.AttributeSet; import android.util.DisplayMetrics; -import android.util.FloatMath; import android.util.Log; import android.view.MotionEvent; import android.view.View; @@ -351,7 +350,7 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView View child = mAdapter.createView(mLinearLayout); child.measure(childWidthMeasureSpec, childheightMeasureSpec); mNumItemsInOneScreenful = - (int) FloatMath.ceil(dm.widthPixels / (float) child.getMeasuredWidth()); + (int) Math.ceil(dm.widthPixels / (double) child.getMeasuredWidth()); addToRecycledViews(child); for (int i = 0; i < mNumItemsInOneScreenful - 1; i++) { diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java index 6dddc392be8bf..569c418a89122 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java @@ -23,7 +23,6 @@ import android.database.DataSetObserver; import android.graphics.Canvas; import android.util.AttributeSet; import android.util.DisplayMetrics; -import android.util.FloatMath; import android.util.Log; import android.view.MotionEvent; import android.view.View; @@ -361,7 +360,7 @@ public class RecentsVerticalScrollView extends ScrollView View child = mAdapter.createView(mLinearLayout); child.measure(childWidthMeasureSpec, childheightMeasureSpec); mNumItemsInOneScreenful = - (int) FloatMath.ceil(dm.heightPixels / (float) child.getMeasuredHeight()); + (int) Math.ceil(dm.heightPixels / (double) child.getMeasuredHeight()); addToRecycledViews(child); for (int i = 0; i < mNumItemsInOneScreenful - 1; i++) { diff --git a/packages/WallpaperCropper/src/com/android/wallpapercropper/CropView.java b/packages/WallpaperCropper/src/com/android/wallpapercropper/CropView.java index c3ef3024f4840..4405207274387 100644 --- a/packages/WallpaperCropper/src/com/android/wallpapercropper/CropView.java +++ b/packages/WallpaperCropper/src/com/android/wallpapercropper/CropView.java @@ -21,7 +21,6 @@ import android.graphics.Matrix; import android.graphics.Point; import android.graphics.RectF; import android.util.AttributeSet; -import android.util.FloatMath; import android.view.MotionEvent; import android.view.ScaleGestureDetector; import android.view.ScaleGestureDetector.OnScaleGestureListener; @@ -300,12 +299,12 @@ public class CropView extends TiledImageView implements OnScaleGestureListener { adjustment[0] = (edges.right - getWidth()) / scale; } if (edges.top > 0) { - adjustment[1] = FloatMath.ceil(edges.top / scale); + adjustment[1] = (float) Math.ceil(edges.top / scale); } else if (edges.bottom < getHeight()) { adjustment[1] = (edges.bottom - getHeight()) / scale; } for (int dim = 0; dim <= 1; dim++) { - if (coef[dim] > 0) adjustment[dim] = FloatMath.ceil(adjustment[dim]); + if (coef[dim] > 0) adjustment[dim] = (float) Math.ceil(adjustment[dim]); } mInverseRotateMatrix.mapPoints(adjustment); diff --git a/policy/src/com/android/internal/policy/impl/WindowOrientationListener.java b/policy/src/com/android/internal/policy/impl/WindowOrientationListener.java index 0c77556830af3..d92759266ebfb 100644 --- a/policy/src/com/android/internal/policy/impl/WindowOrientationListener.java +++ b/policy/src/com/android/internal/policy/impl/WindowOrientationListener.java @@ -23,7 +23,6 @@ import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Handler; import android.os.SystemProperties; -import android.util.FloatMath; import android.util.Log; import android.util.Slog; @@ -401,7 +400,7 @@ public abstract class WindowOrientationListener { if (LOG) { Slog.v(TAG, "Raw acceleration vector: " + "x=" + x + ", y=" + y + ", z=" + z - + ", magnitude=" + FloatMath.sqrt(x * x + y * y + z * z)); + + ", magnitude=" + Math.sqrt(x * x + y * y + z * z)); } // Apply a low-pass filter to the acceleration up vector in cartesian space. @@ -428,7 +427,7 @@ public abstract class WindowOrientationListener { if (LOG) { Slog.v(TAG, "Filtered acceleration vector: " + "x=" + x + ", y=" + y + ", z=" + z - + ", magnitude=" + FloatMath.sqrt(x * x + y * y + z * z)); + + ", magnitude=" + Math.sqrt(x * x + y * y + z * z)); } skipSample = false; } @@ -442,7 +441,7 @@ public abstract class WindowOrientationListener { boolean isSwinging = false; if (!skipSample) { // Calculate the magnitude of the acceleration vector. - final float magnitude = FloatMath.sqrt(x * x + y * y + z * z); + final float magnitude = (float) Math.sqrt(x * x + y * y + z * z); if (magnitude < NEAR_ZERO_MAGNITUDE) { if (LOG) { Slog.v(TAG, "Ignoring sensor data, magnitude too close to zero."); diff --git a/services/java/com/android/server/TwilightCalculator.java b/services/java/com/android/server/TwilightCalculator.java index a5c93b5173d47..5839b1674d637 100644 --- a/services/java/com/android/server/TwilightCalculator.java +++ b/services/java/com/android/server/TwilightCalculator.java @@ -17,7 +17,6 @@ package com.android.server; import android.text.format.DateUtils; -import android.util.FloatMath; /** @hide */ public class TwilightCalculator { @@ -75,24 +74,24 @@ public class TwilightCalculator { final float meanAnomaly = 6.240059968f + daysSince2000 * 0.01720197f; // true anomaly - final float trueAnomaly = meanAnomaly + C1 * FloatMath.sin(meanAnomaly) + C2 - * FloatMath.sin(2 * meanAnomaly) + C3 * FloatMath.sin(3 * meanAnomaly); + final double trueAnomaly = meanAnomaly + C1 * Math.sin(meanAnomaly) + C2 + * Math.sin(2 * meanAnomaly) + C3 * Math.sin(3 * meanAnomaly); // ecliptic longitude - final float solarLng = trueAnomaly + 1.796593063f + (float) Math.PI; + final double solarLng = trueAnomaly + 1.796593063d + Math.PI; // solar transit in days since 2000 final double arcLongitude = -longitude / 360; float n = Math.round(daysSince2000 - J0 - arcLongitude); - double solarTransitJ2000 = n + J0 + arcLongitude + 0.0053f * FloatMath.sin(meanAnomaly) - + -0.0069f * FloatMath.sin(2 * solarLng); + double solarTransitJ2000 = n + J0 + arcLongitude + 0.0053d * Math.sin(meanAnomaly) + + -0.0069d * Math.sin(2 * solarLng); // declination of sun - double solarDec = Math.asin(FloatMath.sin(solarLng) * FloatMath.sin(OBLIQUITY)); + double solarDec = Math.asin(Math.sin(solarLng) * Math.sin(OBLIQUITY)); final double latRad = latiude * DEGREES_TO_RADIANS; - double cosHourAngle = (FloatMath.sin(ALTIDUTE_CORRECTION_CIVIL_TWILIGHT) - Math.sin(latRad) + double cosHourAngle = (Math.sin(ALTIDUTE_CORRECTION_CIVIL_TWILIGHT) - Math.sin(latRad) * Math.sin(solarDec)) / (Math.cos(latRad) * Math.cos(solarDec)); // The day or night never ends for the given date and location, if this value is out of // range. diff --git a/services/java/com/android/server/accessibility/GestureUtils.java b/services/java/com/android/server/accessibility/GestureUtils.java index b68b09f8d0a07..bc761914caf21 100644 --- a/services/java/com/android/server/accessibility/GestureUtils.java +++ b/services/java/com/android/server/accessibility/GestureUtils.java @@ -69,8 +69,7 @@ final class GestureUtils { return true; } - final float firstMagnitude = - (float) Math.sqrt(firstDeltaX * firstDeltaX + firstDeltaY * firstDeltaY); + final float firstMagnitude = (float) Math.hypot(firstDeltaX, firstDeltaY); final float firstXNormalized = (firstMagnitude > 0) ? firstDeltaX / firstMagnitude : firstDeltaX; final float firstYNormalized = @@ -83,8 +82,7 @@ final class GestureUtils { return true; } - final float secondMagnitude = - (float) Math.sqrt(secondDeltaX * secondDeltaX + secondDeltaY * secondDeltaY); + final float secondMagnitude = (float) Math.hypot(secondDeltaX, secondDeltaY); final float secondXNormalized = (secondMagnitude > 0) ? secondDeltaX / secondMagnitude : secondDeltaX; final float secondYNormalized = diff --git a/services/java/com/android/server/power/DisplayPowerController.java b/services/java/com/android/server/power/DisplayPowerController.java index 30bc9226da24f..389880a63d1f7 100644 --- a/services/java/com/android/server/power/DisplayPowerController.java +++ b/services/java/com/android/server/power/DisplayPowerController.java @@ -35,7 +35,6 @@ import android.os.Message; import android.os.PowerManager; import android.os.SystemClock; import android.text.format.DateUtils; -import android.util.FloatMath; import android.util.Slog; import android.util.Spline; import android.util.TimeUtils; @@ -1092,7 +1091,7 @@ final class DisplayPowerController { if (USE_SCREEN_AUTO_BRIGHTNESS_ADJUSTMENT && mPowerRequest.screenAutoBrightnessAdjustment != 0.0f) { - final float adjGamma = FloatMath.pow(SCREEN_AUTO_BRIGHTNESS_ADJUSTMENT_MAX_GAMMA, + final float adjGamma = (float) Math.pow(SCREEN_AUTO_BRIGHTNESS_ADJUSTMENT_MAX_GAMMA, Math.min(1.0f, Math.max(-1.0f, -mPowerRequest.screenAutoBrightnessAdjustment))); gamma *= adjGamma; @@ -1119,7 +1118,7 @@ final class DisplayPowerController { if (gamma != 1.0f) { final float in = value; - value = FloatMath.pow(value, gamma); + value = (float) Math.pow(value, gamma); if (DEBUG) { Slog.d(TAG, "updateAutoBrightness: gamma=" + gamma + ", in=" + in + ", out=" + value); diff --git a/services/java/com/android/server/power/ElectronBeam.java b/services/java/com/android/server/power/ElectronBeam.java index 729bd1669e831..b9b892c823317 100644 --- a/services/java/com/android/server/power/ElectronBeam.java +++ b/services/java/com/android/server/power/ElectronBeam.java @@ -31,7 +31,6 @@ import android.opengl.EGLSurface; import android.opengl.GLES10; import android.opengl.GLES11Ext; import android.os.Looper; -import android.util.FloatMath; import android.util.Slog; import android.view.Display; import android.view.DisplayInfo; @@ -636,7 +635,7 @@ final class ElectronBeam { } private static float sigmoid(float x, float s) { - return 1.0f / (1.0f + FloatMath.exp(-x * s)); + return 1.0f / (1.0f + (float) Math.exp(-x * s)); } private static FloatBuffer createNativeFloatBuffer(int size) { diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 096921d13eba0..eaa237ae5a616 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -91,7 +91,6 @@ import android.os.WorkSource; import android.provider.Settings; import android.util.DisplayMetrics; import android.util.EventLog; -import android.util.FloatMath; import android.util.Log; import android.util.SparseArray; import android.util.Pair; @@ -5724,7 +5723,7 @@ public class WindowManagerService extends IWindowManager.Stub Matrix matrix = new Matrix(); ScreenRotationAnimation.createRotationMatrix(rot, dw, dh, matrix); // TODO: Test for RTL vs. LTR and use frame.right-width instead of -frame.left - matrix.postTranslate(-FloatMath.ceil(frame.left), -FloatMath.ceil(frame.top)); + matrix.postTranslate((float) -Math.ceil(frame.left), (float) -Math.ceil(frame.top)); Canvas canvas = new Canvas(bm); canvas.drawColor(0xFF000000); canvas.drawBitmap(rawss, matrix, null); diff --git a/test-runner/src/android/test/TouchUtils.java b/test-runner/src/android/test/TouchUtils.java index acbde0bd2e574..0fbffcd52bf91 100644 --- a/test-runner/src/android/test/TouchUtils.java +++ b/test-runner/src/android/test/TouchUtils.java @@ -576,7 +576,7 @@ public class TouchUtils { final int fromX = xy[0]; final int fromY = xy[1]; - int distance = (int) Math.sqrt(deltaX * deltaX + deltaY * deltaY); + int distance = (int) Math.hypot(deltaX, deltaY); drag(test, fromX, fromX + deltaX, fromY, fromY + deltaY, distance); @@ -629,7 +629,7 @@ public class TouchUtils { int deltaX = fromX - toX; int deltaY = fromY - toY; - int distance = (int)Math.sqrt(deltaX * deltaX + deltaY * deltaY); + int distance = (int)Math.hypot(deltaX, deltaY); drag(test, fromX, toX, fromY, toY, distance); return distance; diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/CropFilter.java b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/CropFilter.java index 91fe21c57d307..6c0f353f8e5eb 100644 --- a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/CropFilter.java +++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/CropFilter.java @@ -20,7 +20,6 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; -import android.util.FloatMath; import androidx.media.filterfw.Filter; import androidx.media.filterfw.FrameImage2D; @@ -90,8 +89,8 @@ public class CropFilter extends Filter { // Pull input frame FrameImage2D inputImage = getConnectedInputPort("image").pullFrame().asFrameImage2D(); int[] inDims = inputImage.getDimensions(); - int[] croppedDims = { (int)FloatMath.ceil(mCropRect.xEdge().length() * inDims[0]), - (int)FloatMath.ceil(mCropRect.yEdge().length() * inDims[1]) }; + int[] croppedDims = { (int)Math.ceil(mCropRect.xEdge().length() * inDims[0]), + (int)Math.ceil(mCropRect.yEdge().length() * inDims[1]) }; int[] outDims = { getOutputWidth(croppedDims[0], croppedDims[1]), getOutputHeight(croppedDims[0], croppedDims[1]) }; FrameImage2D outputImage = outPort.fetchAvailableFrame(outDims).asFrameImage2D(); diff --git a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java index ebfe9bc3ab2c9..e9b5211b36322 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java @@ -716,9 +716,8 @@ public final class Matrix_Delegate { float[] src = new float[] { radius, 0.f, 0.f, radius }; d.mapVectors(src, 0, src, 0, 2); - float l1 = getPointLength(src, 0); - float l2 = getPointLength(src, 2); - + float l1 = (float) Math.hypot(src[0], src[1]); + float l2 = (float) Math.hypot(src[2], src[3]); return (float) Math.sqrt(l1 * l2); } @@ -973,10 +972,6 @@ public final class Matrix_Delegate { } } - private static float getPointLength(float[] src, int index) { - return (float) Math.sqrt(src[index] * src[index] + src[index + 1] * src[index + 1]); - } - /** * multiply two matrices and store them in a 3rd. *

This in effect does dest = a*b diff --git a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java index 4f16dcf081fd2..b640ece579811 100644 --- a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java @@ -198,7 +198,7 @@ public class RadialGradient_Delegate extends Gradient_Delegate { float _x = pt2[0]; float _y = pt2[1]; - float distance = (float) Math.sqrt(_x * _x + _y * _y); + float distance = (float) Math.hypot(_x, _y); data[index++] = getGradientColor(distance / mRadius); } diff --git a/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java b/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java deleted file mode 100644 index 8b4c60b5fead3..0000000000000 --- a/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.util; - -import com.android.layoutlib.bridge.impl.DelegateManager; -import com.android.tools.layoutlib.annotations.LayoutlibDelegate; - -/** - * Delegate implementing the native methods of android.util.FloatMath - * - * Through the layoutlib_create tool, the original native methods of FloatMath have been replaced - * by calls to methods of the same name in this delegate class. - * - * Because it's a stateless class to start with, there's no need to keep a {@link DelegateManager} - * around to map int to instance of the delegate. - * - */ -/*package*/ final class FloatMath_Delegate { - - /** Prevents instantiation. */ - private FloatMath_Delegate() {} - - /** - * Returns the float conversion of the most positive (i.e. closest to - * positive infinity) integer value which is less than the argument. - * - * @param value to be converted - * @return the floor of value - */ - @LayoutlibDelegate - /*package*/ static float floor(float value) { - return (float)Math.floor(value); - } - - /** - * Returns the float conversion of the most negative (i.e. closest to - * negative infinity) integer value which is greater than the argument. - * - * @param value to be converted - * @return the ceiling of value - */ - @LayoutlibDelegate - /*package*/ static float ceil(float value) { - return (float)Math.ceil(value); - } - - /** - * Returns the closest float approximation of the sine of the argument. - * - * @param angle to compute the cosine of, in radians - * @return the sine of angle - */ - @LayoutlibDelegate - /*package*/ static float sin(float angle) { - return (float)Math.sin(angle); - } - - /** - * Returns the closest float approximation of the cosine of the argument. - * - * @param angle to compute the cosine of, in radians - * @return the cosine of angle - */ - @LayoutlibDelegate - /*package*/ static float cos(float angle) { - return (float)Math.cos(angle); - } - - /** - * Returns the closest float approximation of the square root of the - * argument. - * - * @param value to compute sqrt of - * @return the square root of value - */ - @LayoutlibDelegate - /*package*/ static float sqrt(float value) { - return (float)Math.sqrt(value); - } - - /** - * Returns the closest float approximation of the raising "e" to the power - * of the argument. - * - * @param value to compute the exponential of - * @return the exponential of value - */ - @LayoutlibDelegate - /*package*/ static float exp(float value) { - return (float)Math.exp(value); - } - - /** - * Returns the closest float approximation of the result of raising {@code - * x} to the power of {@code y}. - * - * @param x the base of the operation. - * @param y the exponent of the operation. - * @return {@code x} to the power of {@code y}. - */ - @LayoutlibDelegate - /*package*/ static float pow(float x, float y) { - return (float)Math.pow(x, y); - } - - /** - * Returns {@code sqrt(}{@code x}{@code 2}{@code +} - * {@code y}{@code 2}{@code )}. - * - * @param x a float number - * @param y a float number - * @return the hypotenuse - */ - @LayoutlibDelegate - /*package*/ static float hypot(float x, float y) { - return (float)Math.sqrt(x*x + y*y); - } -} diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java index 79aa642b7024c..29a57064bc688 100644 --- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java +++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java @@ -188,7 +188,6 @@ public final class CreateInfo implements ICreateInfo { "android.os.SystemClock", "android.text.AndroidBidi", "android.text.format.Time", - "android.util.FloatMath", "android.view.Display", "libcore.icu.DateIntervalFormat", "libcore.icu.ICU",