am 0c1faf43: Merge "Switch from FloatMath -> Math and Math.hypot where possible"

* commit '0c1faf43aecadc37b78c4ad6cb669eb351d21385':
  Switch from FloatMath -> Math and Math.hypot where possible
This commit is contained in:
Neil Fuller
2014-10-02 10:18:29 +00:00
committed by Android Git Automerger
36 changed files with 77 additions and 251 deletions

View File

@@ -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.

View File

@@ -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 =

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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);