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

Side by Side Diff: cc/base/math_util.h

Issue 139233002: [#4] Pass gfx structs by const ref (gfx::PointF) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Corrected as per review comments! Created 6 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
« no previous file with comments | « no previous file | cc/base/math_util.cc » ('j') | no next file with comments »
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_BASE_MATH_UTIL_H_ 5 #ifndef CC_BASE_MATH_UTIL_H_
6 #define CC_BASE_MATH_UTIL_H_ 6 #define CC_BASE_MATH_UTIL_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // Returns an array of vertices that represent the clipped polygon. After 109 // Returns an array of vertices that represent the clipped polygon. After
110 // returning, indexes from 0 to num_vertices_in_clipped_quad are valid in the 110 // returning, indexes from 0 to num_vertices_in_clipped_quad are valid in the
111 // clipped_quad array. Note that num_vertices_in_clipped_quad may be zero, 111 // clipped_quad array. Note that num_vertices_in_clipped_quad may be zero,
112 // which means the entire quad was clipped, and none of the vertices in the 112 // which means the entire quad was clipped, and none of the vertices in the
113 // array are valid. 113 // array are valid.
114 static void MapClippedQuad(const gfx::Transform& transform, 114 static void MapClippedQuad(const gfx::Transform& transform,
115 const gfx::QuadF& src_quad, 115 const gfx::QuadF& src_quad,
116 gfx::PointF clipped_quad[8], 116 gfx::PointF clipped_quad[8],
117 int* num_vertices_in_clipped_quad); 117 int* num_vertices_in_clipped_quad);
118 118
119 static gfx::RectF ComputeEnclosingRectOfVertices(gfx::PointF vertices[], 119 static gfx::RectF ComputeEnclosingRectOfVertices(const gfx::PointF vertices[],
120 int num_vertices); 120 int num_vertices);
121 static gfx::RectF ComputeEnclosingClippedRect( 121 static gfx::RectF ComputeEnclosingClippedRect(
122 const HomogeneousCoordinate& h1, 122 const HomogeneousCoordinate& h1,
123 const HomogeneousCoordinate& h2, 123 const HomogeneousCoordinate& h2,
124 const HomogeneousCoordinate& h3, 124 const HomogeneousCoordinate& h3,
125 const HomogeneousCoordinate& h4); 125 const HomogeneousCoordinate& h4);
126 126
127 // NOTE: These functions do not do correct clipping against w = 0 plane, but 127 // NOTE: These functions do not do correct clipping against w = 0 plane, but
128 // they correctly detect the clipped condition via the boolean clipped. 128 // they correctly detect the clipped condition via the boolean clipped.
129 static gfx::QuadF MapQuad(const gfx::Transform& transform, 129 static gfx::QuadF MapQuad(const gfx::Transform& transform,
130 const gfx::QuadF& quad, 130 const gfx::QuadF& quad,
131 bool* clipped); 131 bool* clipped);
132 static gfx::PointF MapPoint(const gfx::Transform& transform, 132 static gfx::PointF MapPoint(const gfx::Transform& transform,
133 gfx::PointF point, 133 const gfx::PointF& point,
134 bool* clipped); 134 bool* clipped);
135 static gfx::Point3F MapPoint(const gfx::Transform&, 135 static gfx::Point3F MapPoint(const gfx::Transform&,
136 const gfx::Point3F&, 136 const gfx::Point3F&,
137 bool* clipped); 137 bool* clipped);
138 static gfx::QuadF ProjectQuad(const gfx::Transform& transform, 138 static gfx::QuadF ProjectQuad(const gfx::Transform& transform,
139 const gfx::QuadF& quad, 139 const gfx::QuadF& quad,
140 bool* clipped); 140 bool* clipped);
141 static gfx::PointF ProjectPoint(const gfx::Transform& transform, 141 static gfx::PointF ProjectPoint(const gfx::Transform& transform,
142 gfx::PointF point, 142 const gfx::PointF& point,
143 bool* clipped); 143 bool* clipped);
144 144
145 static gfx::Vector2dF ComputeTransform2dScaleComponents(const gfx::Transform&, 145 static gfx::Vector2dF ComputeTransform2dScaleComponents(const gfx::Transform&,
146 float fallbackValue); 146 float fallbackValue);
147 147
148 // Makes a rect that has the same relationship to input_outer_rect as 148 // Makes a rect that has the same relationship to input_outer_rect as
149 // scale_inner_rect has to scale_outer_rect. scale_inner_rect should be 149 // scale_inner_rect has to scale_outer_rect. scale_inner_rect should be
150 // contained within scale_outer_rect, and likewise the rectangle that is 150 // contained within scale_outer_rect, and likewise the rectangle that is
151 // returned will be within input_outer_rect at a similar relative, scaled 151 // returned will be within input_outer_rect at a similar relative, scaled
152 // position. 152 // position.
153 static gfx::RectF ScaleRectProportional(const gfx::RectF& input_outer_rect, 153 static gfx::RectF ScaleRectProportional(const gfx::RectF& input_outer_rect,
154 const gfx::RectF& scale_outer_rect, 154 const gfx::RectF& scale_outer_rect,
155 const gfx::RectF& scale_inner_rect); 155 const gfx::RectF& scale_inner_rect);
156 156
157 // Returns the smallest angle between the given two vectors in degrees. 157 // Returns the smallest angle between the given two vectors in degrees.
158 // Neither vector is assumed to be normalized. 158 // Neither vector is assumed to be normalized.
159 static float SmallestAngleBetweenVectors(gfx::Vector2dF v1, 159 static float SmallestAngleBetweenVectors(gfx::Vector2dF v1,
160 gfx::Vector2dF v2); 160 gfx::Vector2dF v2);
161 161
162 // Projects the |source| vector onto |destination|. Neither vector is assumed 162 // Projects the |source| vector onto |destination|. Neither vector is assumed
163 // to be normalized. 163 // to be normalized.
164 static gfx::Vector2dF ProjectVector(gfx::Vector2dF source, 164 static gfx::Vector2dF ProjectVector(gfx::Vector2dF source,
165 gfx::Vector2dF destination); 165 gfx::Vector2dF destination);
166 166
167 // Conversion to value. 167 // Conversion to value.
168 static scoped_ptr<base::Value> AsValue(gfx::Size s); 168 static scoped_ptr<base::Value> AsValue(gfx::Size s);
169 static scoped_ptr<base::Value> AsValue(gfx::SizeF s); 169 static scoped_ptr<base::Value> AsValue(gfx::SizeF s);
170 static scoped_ptr<base::Value> AsValue(const gfx::Rect& r); 170 static scoped_ptr<base::Value> AsValue(const gfx::Rect& r);
171 static bool FromValue(const base::Value*, gfx::Rect* out_rect); 171 static bool FromValue(const base::Value*, gfx::Rect* out_rect);
172 static scoped_ptr<base::Value> AsValue(gfx::PointF q); 172 static scoped_ptr<base::Value> AsValue(const gfx::PointF& q);
173 static scoped_ptr<base::Value> AsValue(const gfx::QuadF& q); 173 static scoped_ptr<base::Value> AsValue(const gfx::QuadF& q);
174 static scoped_ptr<base::Value> AsValue(const gfx::RectF& rect); 174 static scoped_ptr<base::Value> AsValue(const gfx::RectF& rect);
175 static scoped_ptr<base::Value> AsValue(const gfx::Transform& transform); 175 static scoped_ptr<base::Value> AsValue(const gfx::Transform& transform);
176 static scoped_ptr<base::Value> AsValue(const gfx::BoxF& box); 176 static scoped_ptr<base::Value> AsValue(const gfx::BoxF& box);
177 177
178 // Returns a base::Value representation of the floating point value. 178 // Returns a base::Value representation of the floating point value.
179 // If the value is inf, returns max double/float representation. 179 // If the value is inf, returns max double/float representation.
180 static scoped_ptr<base::Value> AsValueSafely(double value); 180 static scoped_ptr<base::Value> AsValueSafely(double value);
181 static scoped_ptr<base::Value> AsValueSafely(float value); 181 static scoped_ptr<base::Value> AsValueSafely(float value);
182 }; 182 };
183 183
184 } // namespace cc 184 } // namespace cc
185 185
186 #endif // CC_BASE_MATH_UTIL_H_ 186 #endif // CC_BASE_MATH_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | cc/base/math_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698