Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: ui/gfx/transform.h

Issue 11774005: Migrate more functions from MathUtil to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed reviewers feedback Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/video_layer_impl.cc ('k') | ui/gfx/transform.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/transform.h
diff --git a/ui/gfx/transform.h b/ui/gfx/transform.h
index 95de30fa3f4c0d3275c19cd61c3e4663f232c38f..5154097988402f0550eee4e0291158d02a993d08 100644
--- a/ui/gfx/transform.h
+++ b/ui/gfx/transform.h
@@ -39,6 +39,19 @@ class UI_EXPORT Transform {
: matrix_(lhs.matrix_, rhs.matrix_) {}
~Transform() {}
+ // Constructs a transform from explicit 16 matrix elements. Elements should be
+ // given in column-major order.
+ Transform(double col1row1, double col1row2, double col1row3, double col1row4,
+ double col2row1, double col2row2, double col2row3, double col2row4,
+ double col3row1, double col3row2, double col3row3, double col3row4,
+ double col4row1, double col4row2, double col4row3, double col4row4);
Ian Vollick 2013/01/08 23:52:54 I'm sorry to start on this again, but can we pleas
danakj 2013/01/09 14:33:46 +1 OOO for a bit today, will review this later.
+
+ // 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 col1row2, double col2row1,
+ double col2row2, double x_translation, double y_translation);
+
bool operator==(const Transform& rhs) const { return matrix_ == rhs.matrix_; }
bool operator!=(const Transform& rhs) const { return matrix_ != rhs.matrix_; }
@@ -120,6 +133,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;
« no previous file with comments | « cc/video_layer_impl.cc ('k') | ui/gfx/transform.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698