summaryrefslogtreecommitdiffstats
path: root/ui/gfx/transform.h
diff options
context:
space:
mode:
authorshawnsingh@chromium.org <shawnsingh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-15 07:49:40 +0000
committershawnsingh@chromium.org <shawnsingh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-15 07:49:40 +0000
commit78634b0c0110540942123e08138341c09b308734 (patch)
tree4836a18c9c85f19e8695940157569672a254bd21 /ui/gfx/transform.h
parentbe9764cd5e2d38ce276f428dd23658862bf888e2 (diff)
downloadchromium_src-78634b0c0110540942123e08138341c09b308734.zip
chromium_src-78634b0c0110540942123e08138341c09b308734.tar.gz
chromium_src-78634b0c0110540942123e08138341c09b308734.tar.bz2
Migrate more functions from MathUtil to gfx::Transform
This patch (1) removes rotateEulerAngles entirely (2) migrates some util functions from MathUtil to transform_util, and (3) moves all the MathUtil unit tests that actually belonged in ui/gfx/. BUG=159972 Review URL: https://chromiumcodereview.appspot.com/11774005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176832 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/transform.h')
-rw-r--r--ui/gfx/transform.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/ui/gfx/transform.h b/ui/gfx/transform.h
index a9e5997..10885bd 100644
--- a/ui/gfx/transform.h
+++ b/ui/gfx/transform.h
@@ -37,6 +37,18 @@ class UI_EXPORT Transform {
// Initialize with the concatenation of lhs * rhs.
Transform(const Transform& lhs, const Transform& rhs)
: matrix_(lhs.matrix_, rhs.matrix_) {}
+ // Constructs a transform from explicit 16 matrix elements. Elements
+ // should be given in row-major order.
+ Transform(double col1row1, double col2row1, double col3row1, double col4row1,
+ double col1row2, double col2row2, double col3row2, double col4row2,
+ double col1row3, double col2row3, double col3row3, double col4row3,
+ double col1row4, double col2row4, double col3row4, double col4row4);
+ // Constructs a transform from explicit 2d elements. All other matrix
+ // elements remain the same as the corresponding elements of an identity
+ // matrix.
+ Transform(double col1row1, double col2row1,
+ double col1row2, double col2row2,
+ double x_translation, double y_translation);
~Transform() {}
bool operator==(const Transform& rhs) const { return matrix_ == rhs.matrix_; }
@@ -129,6 +141,22 @@ class UI_EXPORT Transform {
// Transposes this transform in place.
void Transpose();
+ // Set 3rd row and 3rd colum to (0, 0, 1, 0). Note that this flattening
+ // operation is not quite the same as an orthographic projection and is
+ // technically not a linear operation.
+ //
+ // One useful interpretation of doing this operation:
+ // - For x and y values, the new transform behaves effectively like an
+ // orthographic projection was added to the matrix sequence.
+ // - For z values, the new transform overrides any effect that the transform
+ // had on z, and instead it preserves the z value for any points that are
+ // transformed.
+ // - Because of linearity of transforms, this flattened transform also
+ // preserves the effect that any subsequent (multiplied from the right)
+ // transforms would have on z values.
+ //
+ void FlattenTo2d();
+
// Applies the transformation on the point. Returns true if the point is
// transformed successfully.
void TransformPoint(Point3F& point) const;