summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2014-10-02 14:32:37 +0100
committerNeil Fuller <nfuller@google.com>2014-10-02 14:32:37 +0100
commitc2a0b4482d7144e8382346ea4c22c7b89368fec0 (patch)
treef0ec3fbeee8dde1d56ad85c59d858ec093d5eb9d
parentf08384c763d2e57c05e0be4325c267d12fc516d4 (diff)
parentee665151a4c6359cbfbb9a6795aa9097c4622083 (diff)
downloadframeworks_base-c2a0b4482d7144e8382346ea4c22c7b89368fec0.zip
frameworks_base-c2a0b4482d7144e8382346ea4c22c7b89368fec0.tar.gz
frameworks_base-c2a0b4482d7144e8382346ea4c22c7b89368fec0.tar.bz2
resolved conflicts for merge of ee665151 to lmp-mr1-dev-plus-aosp
Change-Id: I2588c65b7a9fa43f968151a206924a804f0595a7
-rw-r--r--core/java/android/gesture/GestureOverlayView.java2
-rw-r--r--core/java/android/gesture/GestureStroke.java3
-rw-r--r--core/java/android/gesture/GestureUtils.java8
-rw-r--r--core/java/android/hardware/GeomagneticField.java2
-rw-r--r--core/java/android/text/BoringLayout.java5
-rw-r--r--core/java/android/util/MathUtils.java4
-rw-r--r--core/java/android/view/ScaleGestureDetector.java3
-rw-r--r--core/java/android/widget/OverScroller.java5
-rw-r--r--core/java/android/widget/Scroller.java5
-rw-r--r--core/java/android/widget/StackView.java6
-rw-r--r--core/java/android/widget/TextView.java29
-rw-r--r--core/java/com/android/internal/widget/multiwaveview/GlowPadView.java2
-rw-r--r--core/java/com/android/internal/widget/multiwaveview/PointCloud.java27
-rw-r--r--graphics/java/android/graphics/ColorMatrix.java8
-rw-r--r--graphics/java/android/graphics/PointF.java3
-rw-r--r--graphics/java/android/graphics/RectF.java5
-rw-r--r--media/mca/filterfw/java/android/filterfw/geometry/Point.java2
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/camera/CameraFunctionalTest.java1
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/camera/CameraPairwiseTest.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java3
-rw-r--r--packages/WallpaperCropper/src/com/android/wallpapercropper/CropView.java5
-rw-r--r--policy/src/com/android/internal/policy/impl/WindowOrientationListener.java7
-rw-r--r--services/accessibility/java/com/android/server/accessibility/GestureUtils.java6
-rw-r--r--services/core/java/com/android/server/TwilightCalculator.java15
-rw-r--r--test-runner/src/android/test/TouchUtils.java4
-rw-r--r--tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/CropFilter.java5
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java9
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java2
-rw-r--r--tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java132
-rw-r--r--tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java1
31 files changed, 71 insertions, 242 deletions
diff --git a/core/java/android/gesture/GestureOverlayView.java b/core/java/android/gesture/GestureOverlayView.java
index 6e3a00f..e1a2a25 100644
--- a/core/java/android/gesture/GestureOverlayView.java
+++ b/core/java/android/gesture/GestureOverlayView.java
@@ -640,7 +640,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 1d0f0fe..bed904e 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 dd221fc..416279e 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 ef05732..eb26ee5 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 6f00707..e78cf8f 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
@@ -207,7 +206,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);
}
@@ -301,7 +300,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 13a692e..36d5b50 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/view/ScaleGestureDetector.java b/core/java/android/view/ScaleGestureDetector.java
index 42a58a8..6508cca 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 7b3dd31..84b1d13 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;
@@ -181,9 +180,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 5e88a96..357c9c3 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;
@@ -425,7 +424,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;
@@ -442,7 +441,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 d2e718c..9e168b8 100644
--- a/core/java/android/widget/StackView.java
+++ b/core/java/android/widget/StackView.java
@@ -1050,10 +1050,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 a80d70a..1ba2937 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;
@@ -4790,7 +4789,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;
}
@@ -4800,10 +4799,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++) {
@@ -6491,7 +6490,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);
}
/**
@@ -6568,7 +6567,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 {
@@ -6598,7 +6597,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 {
@@ -6904,8 +6903,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;
@@ -6917,10 +6916,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) {
@@ -6995,8 +6994,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 b680fab..11ac19e 100644
--- a/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java
+++ b/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java
@@ -863,7 +863,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/PointCloud.java b/core/java/com/android/internal/widget/multiwaveview/PointCloud.java
index f299935..6f26b99 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 1242eb5..f73abcb 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;
-
import java.util.Arrays;
/**
@@ -123,9 +121,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 ee38dbb..8e4288e 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 53178b0..f5cedfa 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 8207c72c..4682a0d 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 e6f0aaf..d12ef2e 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 61b708a..8f67598 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 330333a..cf5d3a6 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;
@@ -368,7 +367,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 1e247be..d518f74 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;
@@ -378,7 +377,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 c3ef302..4405207 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 704da33..2f60d55 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;
import android.util.TimeUtils;
@@ -446,7 +445,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.
@@ -473,7 +472,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;
}
@@ -487,7 +486,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/accessibility/java/com/android/server/accessibility/GestureUtils.java b/services/accessibility/java/com/android/server/accessibility/GestureUtils.java
index b68b09f..bc76191 100644
--- a/services/accessibility/java/com/android/server/accessibility/GestureUtils.java
+++ b/services/accessibility/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/core/java/com/android/server/TwilightCalculator.java b/services/core/java/com/android/server/TwilightCalculator.java
index a5c93b5..5839b16 100644
--- a/services/core/java/com/android/server/TwilightCalculator.java
+++ b/services/core/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/test-runner/src/android/test/TouchUtils.java b/test-runner/src/android/test/TouchUtils.java
index 67a0bc2..1b854b0 100644
--- a/test-runner/src/android/test/TouchUtils.java
+++ b/test-runner/src/android/test/TouchUtils.java
@@ -564,7 +564,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);
@@ -617,7 +617,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 91fe21c..6c0f353 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 f42f48f..1105c7b 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java
@@ -661,9 +661,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);
}
@@ -918,10 +917,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.
* <p/>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 80179ee..eb29835 100644
--- a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
@@ -184,7 +184,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 8b4c60b..0000000
--- 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(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i>
- * {@code y}</i><sup>{@code 2}</sup>{@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 89cbaeb..02528c2 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
@@ -201,7 +201,6 @@ public final class CreateInfo implements ICreateInfo {
"android.text.AndroidBidi",
"android.text.StaticLayout",
"android.text.format.Time",
- "android.util.FloatMath",
"android.view.Display",
"libcore.icu.DateIntervalFormat",
"libcore.icu.ICU",