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

Unified Diff: ui/gfx/transform_util.cc

Issue 11774005: Migrate more functions from MathUtil to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
Index: ui/gfx/transform_util.cc
diff --git a/ui/gfx/transform_util.cc b/ui/gfx/transform_util.cc
index c8ef5736d3e4b51103ff0c73a4d1f82496a74ef2..268aa3862c733525a7de4a4433a0cf036da8bfc3 100644
--- a/ui/gfx/transform_util.cc
+++ b/ui/gfx/transform_util.cc
@@ -315,4 +315,74 @@ Transform ComposeTransform(const DecomposedTransform& decomp) {
return to_return;
}
+Transform CreateGfxTransform(
+ 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)
+{
+ Transform result(Transform::kSkipInitialization);
+ SkMatrix44& matrix = result.matrix();
+
+ // Initialize column 1
+ matrix.setDouble(0, 0, col1row1);
+ matrix.setDouble(1, 0, col1row2);
+ matrix.setDouble(2, 0, col1row3);
+ matrix.setDouble(3, 0, col1row4);
+
+ // Initialize column 2
+ matrix.setDouble(0, 1, col2row1);
+ matrix.setDouble(1, 1, col2row2);
+ matrix.setDouble(2, 1, col2row3);
+ matrix.setDouble(3, 1, col2row4);
+
+ // Initialize column 3
+ matrix.setDouble(0, 2, col3row1);
+ matrix.setDouble(1, 2, col3row2);
+ matrix.setDouble(2, 2, col3row3);
+ matrix.setDouble(3, 2, col3row4);
+
+ // Initialize column 4
+ matrix.setDouble(0, 3, col4row1);
+ matrix.setDouble(1, 3, col4row2);
+ matrix.setDouble(2, 3, col4row3);
+ matrix.setDouble(3, 3, col4row4);
+
+ return result;
+}
+
+Transform CreateGfxTransform(
+ double col1row1, double col1row2, double col2row1,
+ double col2row2, double x_translation, double y_translation)
+{
+ gfx::Transform result;
+ SkMatrix44& matrix = result.matrix();
+ matrix.setDouble(0, 0, col1row1);
+ matrix.setDouble(1, 0, col1row2);
+ matrix.setDouble(0, 1, col2row1);
+ matrix.setDouble(1, 1, col2row2);
+ matrix.setDouble(0, 3, x_translation);
+ matrix.setDouble(1, 3, y_translation);
+
+ return result;
+}
+
+void FlattenTransformTo2d(Transform& transform) {
+ // Set both the 3rd row and 3rd column to (0, 0, 1, 0).
+ transform.matrix().setDouble(2, 0, 0);
+ transform.matrix().setDouble(2, 1, 0);
+ transform.matrix().setDouble(0, 2, 0);
+ transform.matrix().setDouble(1, 2, 0);
+ transform.matrix().setDouble(2, 2, 1);
+ transform.matrix().setDouble(3, 2, 0);
+ transform.matrix().setDouble(2, 3, 0);
+}
+
+// Constructs a flattened version of the given transform.
+Transform CreateFlattenedTransform(const Transform& transform) {
+ Transform result = transform;
+ FlattenTransformTo2d(result);
+ return result;
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698