Merge "Remove usages of FloatMath"
This commit is contained in:
@@ -21,7 +21,6 @@ import android.content.Context;
|
|||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.FloatMath;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A PathMotion that generates a curved path along an arc on an imaginary circle containing
|
* A PathMotion that generates a curved path along an arc on an imaginary circle containing
|
||||||
@@ -257,7 +256,7 @@ public class ArcMotion extends PathMotion {
|
|||||||
}
|
}
|
||||||
if (newArcDistance2 != 0) {
|
if (newArcDistance2 != 0) {
|
||||||
float ratio2 = newArcDistance2 / arcDist2;
|
float ratio2 = newArcDistance2 / arcDist2;
|
||||||
float ratio = FloatMath.sqrt(ratio2);
|
float ratio = (float) Math.sqrt(ratio2);
|
||||||
ex = dx + (ratio * (ex - dx));
|
ex = dx + (ratio * (ex - dx));
|
||||||
ey = dy + (ratio * (ey - dy));
|
ey = dy + (ratio * (ey - dy));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
package android.transition;
|
package android.transition;
|
||||||
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.FloatMath;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -87,9 +86,9 @@ public class CircularPropagation extends VisibilityPropagation {
|
|||||||
epicenterY = Math.round(loc[1] + (sceneRoot.getHeight() / 2)
|
epicenterY = Math.round(loc[1] + (sceneRoot.getHeight() / 2)
|
||||||
+ sceneRoot.getTranslationY());
|
+ sceneRoot.getTranslationY());
|
||||||
}
|
}
|
||||||
float distance = distance(viewCenterX, viewCenterY, epicenterX, epicenterY);
|
double distance = distance(viewCenterX, viewCenterY, epicenterX, epicenterY);
|
||||||
float maxDistance = distance(0, 0, sceneRoot.getWidth(), sceneRoot.getHeight());
|
double maxDistance = distance(0, 0, sceneRoot.getWidth(), sceneRoot.getHeight());
|
||||||
float distanceFraction = distance/maxDistance;
|
double distanceFraction = distance/maxDistance;
|
||||||
|
|
||||||
long duration = transition.getDuration();
|
long duration = transition.getDuration();
|
||||||
if (duration < 0) {
|
if (duration < 0) {
|
||||||
@@ -99,9 +98,9 @@ public class CircularPropagation extends VisibilityPropagation {
|
|||||||
return Math.round(duration * directionMultiplier / mPropagationSpeed * distanceFraction);
|
return Math.round(duration * directionMultiplier / mPropagationSpeed * distanceFraction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float distance(float x1, float y1, float x2, float y2) {
|
private static double distance(float x1, float y1, float x2, float y2) {
|
||||||
float x = x2 - x1;
|
double x = x2 - x1;
|
||||||
float y = y2 - y1;
|
double y = y2 - y1;
|
||||||
return FloatMath.sqrt((x * x) + (y * y));
|
return Math.hypot(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import android.animation.TimeInterpolator;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.FloatMath;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.AccelerateInterpolator;
|
import android.view.animation.AccelerateInterpolator;
|
||||||
@@ -143,32 +142,29 @@ public class Explode extends Visibility {
|
|||||||
|
|
||||||
int centerX = bounds.centerX();
|
int centerX = bounds.centerX();
|
||||||
int centerY = bounds.centerY();
|
int centerY = bounds.centerY();
|
||||||
float xVector = centerX - focalX;
|
double xVector = centerX - focalX;
|
||||||
float yVector = centerY - focalY;
|
double yVector = centerY - focalY;
|
||||||
|
|
||||||
if (xVector == 0 && yVector == 0) {
|
if (xVector == 0 && yVector == 0) {
|
||||||
// Random direction when View is centered on focal View.
|
// Random direction when View is centered on focal View.
|
||||||
xVector = (float) (Math.random() * 2) - 1;
|
xVector = (Math.random() * 2) - 1;
|
||||||
yVector = (float) (Math.random() * 2) - 1;
|
yVector = (Math.random() * 2) - 1;
|
||||||
}
|
}
|
||||||
float vectorSize = calculateDistance(xVector, yVector);
|
double vectorSize = Math.hypot(xVector, yVector);
|
||||||
xVector /= vectorSize;
|
xVector /= vectorSize;
|
||||||
yVector /= vectorSize;
|
yVector /= vectorSize;
|
||||||
|
|
||||||
float maxDistance =
|
double maxDistance =
|
||||||
calculateMaxDistance(sceneRoot, focalX - sceneRootX, focalY - sceneRootY);
|
calculateMaxDistance(sceneRoot, focalX - sceneRootX, focalY - sceneRootY);
|
||||||
|
|
||||||
outVector[0] = Math.round(maxDistance * xVector);
|
outVector[0] = (int) Math.round(maxDistance * xVector);
|
||||||
outVector[1] = Math.round(maxDistance * yVector);
|
outVector[1] = (int) Math.round(maxDistance * yVector);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float calculateMaxDistance(View sceneRoot, int focalX, int focalY) {
|
private static double calculateMaxDistance(View sceneRoot, int focalX, int focalY) {
|
||||||
int maxX = Math.max(focalX, sceneRoot.getWidth() - focalX);
|
int maxX = Math.max(focalX, sceneRoot.getWidth() - focalX);
|
||||||
int maxY = Math.max(focalY, sceneRoot.getHeight() - focalY);
|
int maxY = Math.max(focalY, sceneRoot.getHeight() - focalY);
|
||||||
return calculateDistance(maxX, maxY);
|
return Math.hypot(maxX, maxY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float calculateDistance(float x, float y) {
|
|
||||||
return FloatMath.sqrt((x * x) + (y * y));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import android.graphics.Matrix;
|
|||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
import android.graphics.PathMeasure;
|
import android.graphics.PathMeasure;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.FloatMath;
|
|
||||||
import android.util.PathParser;
|
import android.util.PathParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,7 +118,7 @@ public class PatternPathMotion extends PathMotion {
|
|||||||
mTempMatrix.setTranslate(-startX, -startY);
|
mTempMatrix.setTranslate(-startX, -startY);
|
||||||
float dx = endX - startX;
|
float dx = endX - startX;
|
||||||
float dy = endY - startY;
|
float dy = endY - startY;
|
||||||
float distance = distance(dx, dy);
|
float distance = (float) Math.hypot(dx, dy);
|
||||||
float scale = 1 / distance;
|
float scale = 1 / distance;
|
||||||
mTempMatrix.postScale(scale, scale);
|
mTempMatrix.postScale(scale, scale);
|
||||||
double angle = Math.atan2(dy, dx);
|
double angle = Math.atan2(dy, dx);
|
||||||
@@ -130,9 +129,9 @@ public class PatternPathMotion extends PathMotion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path getPath(float startX, float startY, float endX, float endY) {
|
public Path getPath(float startX, float startY, float endX, float endY) {
|
||||||
float dx = endX - startX;
|
double dx = endX - startX;
|
||||||
float dy = endY - startY;
|
double dy = endY - startY;
|
||||||
float length = distance(dx, dy);
|
float length = (float) Math.hypot(dx, dy);
|
||||||
double angle = Math.atan2(dy, dx);
|
double angle = Math.atan2(dy, dx);
|
||||||
|
|
||||||
mTempMatrix.setScale(length, length);
|
mTempMatrix.setScale(length, length);
|
||||||
@@ -143,7 +142,4 @@ public class PatternPathMotion extends PathMotion {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float distance(float x, float y) {
|
|
||||||
return FloatMath.sqrt((x * x) + (y * y));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
package android.transition;
|
package android.transition;
|
||||||
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.FloatMath;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ public abstract class Spline {
|
|||||||
throw new IllegalArgumentException("The control points must have "
|
throw new IllegalArgumentException("The control points must have "
|
||||||
+ "monotonic Y values.");
|
+ "monotonic Y values.");
|
||||||
}
|
}
|
||||||
float h = FloatMath.hypot(a, b);
|
float h = (float) Math.hypot(a, b);
|
||||||
if (h > 9f) {
|
if (h > 9f) {
|
||||||
float t = 3f / h;
|
float t = 3f / h;
|
||||||
m[i] = t * a * d[i];
|
m[i] = t * a * d[i];
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import android.graphics.Rect;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.util.FloatMath;
|
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
import android.view.animation.DecelerateInterpolator;
|
import android.view.animation.DecelerateInterpolator;
|
||||||
import android.view.animation.Interpolator;
|
import android.view.animation.Interpolator;
|
||||||
@@ -220,8 +219,8 @@ public class EdgeEffect {
|
|||||||
if (mPullDistance == 0) {
|
if (mPullDistance == 0) {
|
||||||
mGlowScaleY = mGlowScaleYStart = 0;
|
mGlowScaleY = mGlowScaleYStart = 0;
|
||||||
} else {
|
} else {
|
||||||
final float scale = Math.max(0, 1 - 1 /
|
final float scale = (float) (Math.max(0, 1 - 1 /
|
||||||
FloatMath.sqrt(Math.abs(mPullDistance) * mBounds.height()) - 0.3f) / 0.7f;
|
Math.sqrt(Math.abs(mPullDistance) * mBounds.height()) - 0.3d) / 0.7d);
|
||||||
|
|
||||||
mGlowScaleY = mGlowScaleYStart = scale;
|
mGlowScaleY = mGlowScaleYStart = scale;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import android.opengl.EGLDisplay;
|
|||||||
import android.opengl.EGLSurface;
|
import android.opengl.EGLSurface;
|
||||||
import android.opengl.GLES20;
|
import android.opengl.GLES20;
|
||||||
import android.opengl.GLES11Ext;
|
import android.opengl.GLES11Ext;
|
||||||
import android.util.FloatMath;
|
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.DisplayInfo;
|
import android.view.DisplayInfo;
|
||||||
import android.view.Surface.OutOfResourcesException;
|
import android.view.Surface.OutOfResourcesException;
|
||||||
@@ -372,13 +371,13 @@ final class ColorFade {
|
|||||||
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
|
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
// Draw the frame.
|
// Draw the frame.
|
||||||
float one_minus_level = 1 - level;
|
double one_minus_level = 1 - level;
|
||||||
float cos = FloatMath.cos((float)Math.PI * one_minus_level);
|
double cos = Math.cos(Math.PI * one_minus_level);
|
||||||
float sign = cos < 0 ? -1 : 1;
|
double sign = cos < 0 ? -1 : 1;
|
||||||
float opacity = -FloatMath.pow(one_minus_level, 2) + 1;
|
float opacity = (float) -Math.pow(one_minus_level, 2) + 1;
|
||||||
float saturation = FloatMath.pow(level, 4);
|
float saturation = (float) Math.pow(level, 4);
|
||||||
float scale = (-FloatMath.pow(one_minus_level, 2) + 1) * 0.1f + 0.9f;
|
float scale = (float) ((-Math.pow(one_minus_level, 2) + 1) * 0.1d + 0.9d);
|
||||||
float gamma = (0.5f * sign * FloatMath.pow(cos, 2) + 0.5f) * 0.9f + 0.1f;
|
float gamma = (float) ((0.5d * sign * Math.pow(cos, 2) + 0.5d) * 0.9d + 0.1d);
|
||||||
drawFaded(opacity, 1.f / gamma, saturation, scale);
|
drawFaded(opacity, 1.f / gamma, saturation, scale);
|
||||||
if (checkGlErrors("drawFrame")) {
|
if (checkGlErrors("drawFrame")) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user