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

Side by Side Diff: cc/math_util.h

Issue 11316043: Implement unit tests and temporary MathUtil wrappers for transform functionality (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « no previous file | cc/math_util.cc » ('j') | cc/math_util.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 CC_MATH_UTIL_H_ 5 #ifndef CC_MATH_UTIL_H_
6 #define CC_MATH_UTIL_H_ 6 #define CC_MATH_UTIL_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "cc/cc_export.h" 9 #include "cc/cc_export.h"
10 #include "ui/gfx/point_f.h" 10 #include "ui/gfx/point_f.h"
11 #include "ui/gfx/point3_f.h" 11 #include "ui/gfx/point3_f.h"
12 #include "ui/gfx/transform.h"
12 13
13 namespace WebKit { 14 namespace WebKit {
14 class WebTransformationMatrix; 15 class WebTransformationMatrix;
15 } 16 }
16 17
17 namespace gfx { 18 namespace gfx {
18 class QuadF; 19 class QuadF;
19 class Rect; 20 class Rect;
20 class RectF; 21 class RectF;
21 class Vector2dF; 22 class Vector2dF;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 static void flattenTransformTo2d(WebKit::WebTransformationMatrix&); 109 static void flattenTransformTo2d(WebKit::WebTransformationMatrix&);
109 110
110 static gfx::Vector2dF computeTransform2dScaleComponents(const WebKit::WebTra nsformationMatrix&); 111 static gfx::Vector2dF computeTransform2dScaleComponents(const WebKit::WebTra nsformationMatrix&);
111 112
112 // Returns the smallest angle between the given two vectors in degrees. Neit her vector is 113 // Returns the smallest angle between the given two vectors in degrees. Neit her vector is
113 // assumed to be normalized. 114 // assumed to be normalized.
114 static float smallestAngleBetweenVectors(gfx::Vector2dF, gfx::Vector2dF); 115 static float smallestAngleBetweenVectors(gfx::Vector2dF, gfx::Vector2dF);
115 116
116 // Projects the |source| vector onto |destination|. Neither vector is assume d to be normalized. 117 // Projects the |source| vector onto |destination|. Neither vector is assume d to be normalized.
117 static gfx::Vector2dF projectVector(gfx::Vector2dF source, gfx::Vector2dF de stination); 118 static gfx::Vector2dF projectVector(gfx::Vector2dF source, gfx::Vector2dF de stination);
119
120 // Temporary API to ease migration from WebKit::WebTransformationMatrix
121 // to gfx::Transform.
122 //
123 // TODO(shawnsingh, vollick) we should phase out as much as possible of
124 // these temporary functions, putting functionality into gfx::Transform.
125 static bool isInvertible(const gfx::Transform&);
126 static bool isBackFaceVisible(const gfx::Transform&);
127 static bool isIdentity(const gfx::Transform&);
128 static bool isIdentityOrTranslation(const gfx::Transform&);
129 static bool hasPerspective(const gfx::Transform&);
130 static void makeIdentity(gfx::Transform*);
Ian Vollick 2012/11/16 13:44:46 Would transform = gfx::Transform() suffice?
danakj 2012/11/16 16:25:15 I've seen a pattern in the existing classes to pro
131 static void rotateEulerAngles(gfx::Transform*, float eulerX, float eulerY, f loat eulerZ); // TODO: verify old webcore API was euler angles?
Ian Vollick 2012/11/16 13:44:46 These should be doubles now that gfx::Transform is
132 static void rotateAxisAngle(gfx::Transform*, float i, float j, float k, floa t degrees);
133 static gfx::Transform inverse(const gfx::Transform&);
Ian Vollick 2012/11/16 13:44:46 I think this should be pulled from the API. gfx::T
shawnsingh 2012/11/17 00:38:31 As mentioned above, I agree with this, but I would
134 static gfx::Transform to2dTransform(const gfx::Transform&);
135 static gfx::Transform toGfxTransform(const WebKit::WebTransformationMatrix&) ;
136 // Note carefully: the args here are labeled as per Webcore indexing convent ions.
137 static gfx::Transform createGfxTransform(float m11, float m12, float m13, fl oat m14,
138 float m21, float m22, float m23, fl oat m24,
139 float m31, float m32, float m33, fl oat m34,
140 float m41, float m42, float m43, fl oat m44);
Ian Vollick 2012/11/16 13:44:46 This is a bit of a matter of preference, but I pre
shawnsingh 2012/11/17 00:38:31 Same goes for this comment - this wrapper simply e
141
142 static gfx::Transform createGfxTransform(float a, float b, float c,
143 float d, float e, float f);
118 }; 144 };
119 145
146 // TODO(shawnsingh, vollick) this is a temporary home, should eventually
147 // be phased out in favor of gfx::Transform API.
148 gfx::Transform operator*(const gfx::Transform&, const gfx::Transform&);
149
120 } // namespace cc 150 } // namespace cc
121 151
122 #endif // CC_MATH_UTIL_H_ 152 #endif // CC_MATH_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | cc/math_util.cc » ('j') | cc/math_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698