| OLD | NEW | 
|---|
| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 93 | 93 | 
| 94   // Background: Existing transform code does not do the right thing in | 94   // Background: Existing transform code does not do the right thing in | 
| 95   // MapRect / MapQuad / ProjectQuad when there is a perspective projection that | 95   // MapRect / MapQuad / ProjectQuad when there is a perspective projection that | 
| 96   // causes one of the transformed vertices to go to w < 0. In those cases, it | 96   // causes one of the transformed vertices to go to w < 0. In those cases, it | 
| 97   // is necessary to perform clipping in homogeneous coordinates, after applying | 97   // is necessary to perform clipping in homogeneous coordinates, after applying | 
| 98   // the transform, before dividing-by-w to convert to cartesian coordinates. | 98   // the transform, before dividing-by-w to convert to cartesian coordinates. | 
| 99   // | 99   // | 
| 100   // These functions return the axis-aligned rect that encloses the correctly | 100   // These functions return the axis-aligned rect that encloses the correctly | 
| 101   // clipped, transformed polygon. | 101   // clipped, transformed polygon. | 
| 102   static gfx::Rect MapClippedRect(const gfx::Transform& transform, | 102   static gfx::Rect MapClippedRect(const gfx::Transform& transform, | 
| 103                                   gfx::Rect rect); | 103                                   const gfx::Rect& rect); | 
| 104   static gfx::RectF MapClippedRect(const gfx::Transform& transform, | 104   static gfx::RectF MapClippedRect(const gfx::Transform& transform, | 
| 105                                    const gfx::RectF& rect); | 105                                    const gfx::RectF& rect); | 
| 106   static gfx::RectF ProjectClippedRect(const gfx::Transform& transform, | 106   static gfx::RectF ProjectClippedRect(const gfx::Transform& transform, | 
| 107                                        const gfx::RectF& rect); | 107                                        const gfx::RectF& rect); | 
| 108 | 108 | 
| 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. | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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(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(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_ | 
| OLD | NEW | 
|---|