Moved AffineTransform multiplication methods into Transforms so that
performance sensitive callers can make use of them.
This commit is contained in:
@@ -201,7 +201,7 @@ public class AffineTransform extends AbstractTransform
|
||||
@Override // from Transform
|
||||
public Transform rotate (float angle) {
|
||||
float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle);
|
||||
return multiply(cosa, -sina, sina, cosa, 0, 0, this, this);
|
||||
return Transforms.multiply(cosa, -sina, sina, cosa, 0, 0, this, this);
|
||||
}
|
||||
|
||||
@Override // from Transform
|
||||
@@ -237,10 +237,10 @@ public class AffineTransform extends AbstractTransform
|
||||
return other.preConcatenate(this);
|
||||
}
|
||||
if (other instanceof AffineTransform) {
|
||||
return multiply(this, (AffineTransform)other, new AffineTransform());
|
||||
return Transforms.multiply(this, (AffineTransform)other, new AffineTransform());
|
||||
} else {
|
||||
AffineTransform oaff = new AffineTransform(other);
|
||||
return multiply(this, oaff, oaff);
|
||||
return Transforms.multiply(this, oaff, oaff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,10 +250,10 @@ public class AffineTransform extends AbstractTransform
|
||||
return other.concatenate(this);
|
||||
}
|
||||
if (other instanceof AffineTransform) {
|
||||
return multiply((AffineTransform)other, this, new AffineTransform());
|
||||
return Transforms.multiply((AffineTransform)other, this, new AffineTransform());
|
||||
} else {
|
||||
AffineTransform oaff = new AffineTransform(other);
|
||||
return multiply(oaff, this, oaff);
|
||||
return Transforms.multiply(oaff, this, oaff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,37 +331,4 @@ public class AffineTransform extends AbstractTransform
|
||||
this(other.getScaleX(), other.getScaleY(), other.getRotation(),
|
||||
other.getTx(), other.getTy());
|
||||
}
|
||||
|
||||
protected static AffineTransform multiply (
|
||||
AffineTransform a, AffineTransform b, AffineTransform into) {
|
||||
return multiply(a.m00, a.m01, a.m10, a.m11, a.tx, a.ty,
|
||||
b.m00, b.m01, b.m10, b.m11, b.tx, b.ty, into);
|
||||
}
|
||||
|
||||
protected static AffineTransform multiply (
|
||||
AffineTransform a, float m00, float m01, float m10, float m11, float tx, float ty,
|
||||
AffineTransform into) {
|
||||
return multiply(a.m00, a.m01, a.m10, a.m11, a.tx, a.ty,
|
||||
m00, m01, m10, m11, tx, ty, into);
|
||||
}
|
||||
|
||||
protected static AffineTransform multiply (
|
||||
float m00, float m01, float m10, float m11, float tx, float ty,
|
||||
AffineTransform b, AffineTransform into) {
|
||||
return multiply(m00, m01, m10, m11, tx, ty,
|
||||
b.m00, b.m01, b.m10, b.m11, b.tx, b.ty, into);
|
||||
}
|
||||
|
||||
protected static AffineTransform multiply (
|
||||
float am00, float am01, float am10, float am11, float atx, float aty,
|
||||
float bm00, float bm01, float bm10, float bm11, float btx, float bty,
|
||||
AffineTransform into) {
|
||||
into.m00 = am00 * bm00 + am01 * bm10;
|
||||
into.m01 = am00 * bm01 + am01 * bm11;
|
||||
into.m10 = am10 * bm00 + am11 * bm10;
|
||||
into.m11 = am10 * bm01 + am11 * bm11;
|
||||
into.tx = am00 * btx + am01 * bty + atx;
|
||||
into.ty = am10 * btx + am11 * bty + aty;
|
||||
return into;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,56 @@ public class Transforms
|
||||
dst.append(path, false);
|
||||
return dst;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiplies the supplied two affine transforms, storing the result in {@code into}. {@code
|
||||
* into} may refer to the same instance as {@code a} or {@code b}.
|
||||
* @return {@code into} for chaining.
|
||||
*/
|
||||
public static AffineTransform multiply (
|
||||
AffineTransform a, AffineTransform b, AffineTransform into) {
|
||||
return multiply(a.m00, a.m01, a.m10, a.m11, a.tx, a.ty,
|
||||
b.m00, b.m01, b.m10, b.m11, b.tx, b.ty, into);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiplies the supplied two affine transforms, storing the result in {@code into}. {@code
|
||||
* into} may refer to the same instance as {@code a}.
|
||||
* @return {@code into} for chaining.
|
||||
*/
|
||||
public static AffineTransform multiply (
|
||||
AffineTransform a, float m00, float m01, float m10, float m11, float tx, float ty,
|
||||
AffineTransform into) {
|
||||
return multiply(a.m00, a.m01, a.m10, a.m11, a.tx, a.ty,
|
||||
m00, m01, m10, m11, tx, ty, into);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiplies the supplied two affine transforms, storing the result in {@code into}. {@code
|
||||
* into} may refer to the same instance as {@code b}.
|
||||
* @return {@code into} for chaining.
|
||||
*/
|
||||
public static AffineTransform multiply (
|
||||
float m00, float m01, float m10, float m11, float tx, float ty,
|
||||
AffineTransform b, AffineTransform into) {
|
||||
return multiply(m00, m01, m10, m11, tx, ty,
|
||||
b.m00, b.m01, b.m10, b.m11, b.tx, b.ty, into);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiplies the supplied two affine transforms, storing the result in {@code into}.
|
||||
* @return {@code into} for chaining.
|
||||
*/
|
||||
public static AffineTransform multiply (
|
||||
float am00, float am01, float am10, float am11, float atx, float aty,
|
||||
float bm00, float bm01, float bm10, float bm11, float btx, float bty,
|
||||
AffineTransform into) {
|
||||
into.m00 = am00 * bm00 + am01 * bm10;
|
||||
into.m01 = am00 * bm01 + am01 * bm11;
|
||||
into.m10 = am10 * bm00 + am11 * bm10;
|
||||
into.m11 = am10 * bm01 + am11 * bm11;
|
||||
into.tx = am00 * btx + am01 * bty + atx;
|
||||
into.ty = am10 * btx + am11 * bty + aty;
|
||||
return into;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user