Chromium Code Reviews| Index: ui/gfx/geometry/quad_f.cc |
| diff --git a/ui/gfx/geometry/quad_f.cc b/ui/gfx/geometry/quad_f.cc |
| index dbc50458b3fa1e04aedfdee3c51d5ae00351b46a..a384ea06dcc53e9c76be8e54ebbb7525a00360de 100644 |
| --- a/ui/gfx/geometry/quad_f.cc |
| +++ b/ui/gfx/geometry/quad_f.cc |
| @@ -45,17 +45,16 @@ bool QuadF::IsCounterClockwise() const { |
| // pointing downards. |
| // Reference: http://mathworld.wolfram.com/PolygonArea.html |
| + float tmp1 = p2_.y() - p4_.y(); |
|
danakj
2014/08/11 14:18:49
how about naming this p24 or something more descri
kui.zheng
2014/08/12 04:20:55
Done.
|
| + float tmp2 = p3_.y() - p1_.y(); |
|
danakj
2014/08/11 14:18:49
ditto
kui.zheng
2014/08/12 04:20:55
Done.
|
| + |
| // Up-cast to double so this cannot overflow. |
| - double determinant1 = static_cast<double>(p1_.x()) * p2_.y() |
| - - static_cast<double>(p2_.x()) * p1_.y(); |
| - double determinant2 = static_cast<double>(p2_.x()) * p3_.y() |
| - - static_cast<double>(p3_.x()) * p2_.y(); |
| - double determinant3 = static_cast<double>(p3_.x()) * p4_.y() |
| - - static_cast<double>(p4_.x()) * p3_.y(); |
| - double determinant4 = static_cast<double>(p4_.x()) * p1_.y() |
| - - static_cast<double>(p1_.x()) * p4_.y(); |
| - |
| - return determinant1 + determinant2 + determinant3 + determinant4 < 0; |
| + double determinant1 = static_cast<double>(p1_.x()) * tmp1; |
|
Ian Vollick
2014/08/11 14:39:09
If I'm understanding things, determinant1 here is
kui.zheng
2014/08/12 04:20:55
Right, This patch just refactoring the computation
|
| + double determinant2 = static_cast<double>(p2_.x()) * tmp2; |
| + double determinant3 = static_cast<double>(p3_.x()) * tmp1; |
| + double determinant4 = static_cast<double>(p4_.x()) * tmp2; |
| + |
| + return determinant1 + determinant2 < determinant3 + determinant4; |
| } |
| static inline bool PointIsInTriangle(const PointF& point, |