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

Side by Side Diff: ui/gfx/transform_util.h

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_GFX_TRANSFORM_UTIL_H_ 5 #ifndef UI_GFX_TRANSFORM_UTIL_H_
6 #define UI_GFX_TRANSFORM_UTIL_H_ 6 #define UI_GFX_TRANSFORM_UTIL_H_
7 7
8 #include "ui/base/ui_export.h" 8 #include "ui/base/ui_export.h"
9 #include "ui/gfx/transform.h" 9 #include "ui/gfx/transform.h"
10 10
(...skipping 28 matching lines...) Expand all
39 const DecomposedTransform& to, 39 const DecomposedTransform& to,
40 const DecomposedTransform& from, 40 const DecomposedTransform& from,
41 double progress); 41 double progress);
42 42
43 // Decomposes this transform into its translation, scale, skew, perspective, 43 // Decomposes this transform into its translation, scale, skew, perspective,
44 // and rotation components following the routines detailed in this spec: 44 // and rotation components following the routines detailed in this spec:
45 // http://www.w3.org/TR/css3-3d-transforms/. 45 // http://www.w3.org/TR/css3-3d-transforms/.
46 UI_EXPORT bool DecomposeTransform(DecomposedTransform* out, 46 UI_EXPORT bool DecomposeTransform(DecomposedTransform* out,
47 const Transform& transform); 47 const Transform& transform);
48 48
49 // Set 3rd row and 3rd colum to (0, 0, 1, 0). Note that this flattening
50 // operation is not quite the same as an orthographic projection and is
51 // technically not a linear operation.
52 //
53 // One useful interpretation of doing this operation:
54 // - For x and y values, the new transform behaves effectively like an
55 // orthographic projection was added to the matrix sequence.
56 // - For z values, the new transform overrides any effect that the transform
57 // had on z, and instead it preserves the z value for any points that are
58 // transformed.
59 // - Because of linearity of transforms, this flattened transform also
60 // preserves the effect that any subsequent (multiplied from the right)
61 // transforms would have on z values.
62 //
63 UI_EXPORT void FlattenTransformTo2d(gfx::Transform& transform);
danakj 2013/01/07 23:22:35 Why not a member of Transform?
shawnsingh 2013/01/07 23:59:53 No strong reason; I'll move it into class.
64
49 // Composes a transform from the given translation, scale, skew, prespective, 65 // Composes a transform from the given translation, scale, skew, prespective,
50 // and rotation components following the routines detailed in this spec: 66 // and rotation components following the routines detailed in this spec:
51 // http://www.w3.org/TR/css3-3d-transforms/. 67 // http://www.w3.org/TR/css3-3d-transforms/.
52 UI_EXPORT Transform ComposeTransform(const DecomposedTransform& decomp); 68 UI_EXPORT Transform ComposeTransform(const DecomposedTransform& decomp);
53 69
70 // Constructs a transform from explicit 16 matrix elements. Elements should be
71 // given in column-major order. Recommended to use this only for unit tests.
danakj 2013/01/07 23:22:35 Let's stick test-only things into test/
72 UI_EXPORT Transform CreateGfxTransform(
danakj 2013/01/07 23:22:35 The Gfx part is a bit redundant with the namespace
Ian Vollick 2013/01/08 00:41:21 How would you feel about adding some gfx::Transfor
73 double col1row1, double col1row2, double col1row3, double col1row4,
74 double col2row1, double col2row2, double col2row3, double col2row4,
75 double col3row1, double col3row2, double col3row3, double col3row4,
76 double col4row1, double col4row2, double col4row3, double col4row4);
77
78 // Constructs a transform from explicit 2d elements. All other matrix elements
79 // remain the same as the corresponding elements of an identity matrix.
80 // Recommended to use this only for unit tests.
81 UI_EXPORT Transform CreateGfxTransform(
82 double col1row1, double col1row2, double col2row1,
83 double col2row2, double x_translation, double y_translation);
84
85 // Constructs a flattened version of the given transform.
86 UI_EXPORT Transform CreateFlattenedTransform(const Transform& transform);
danakj 2013/01/07 23:22:35 Why are we breaking the pattern of always modifyin
shawnsingh 2013/01/07 23:59:53 not "breaking" so much as keeping status quo.... b
87
54 } // namespace gfx 88 } // namespace gfx
55 89
56 #endif // UI_GFX_TRANSFORM_UTIL_H_ 90 #endif // UI_GFX_TRANSFORM_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698