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

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: try to fix double/float conversion errors 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 a9e5997114f21414291c7ee2afe8394986bc3ece..10885bd3aaff9d3c345fe948a6744bb6ee93ebb4 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;
« 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