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

Side by Side Diff: ui/gfx/geometry/quad_f.h

Issue 998023002: Revert of Splitting of layers for correct intersections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « cc/trees/occlusion_tracker_unittest.cc ('k') | ui/gfx/skia_util.h » ('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 (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_GEOMETRY_QUAD_F_H_ 5 #ifndef UI_GFX_GEOMETRY_QUAD_F_H_
6 #define UI_GFX_GEOMETRY_QUAD_F_H_ 6 #define UI_GFX_GEOMETRY_QUAD_F_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <cmath> 9 #include <cmath>
10 #include <iosfwd> 10 #include <iosfwd>
11 #include <string> 11 #include <string>
12 12
13 #include "base/logging.h"
14 #include "ui/gfx/geometry/point_f.h" 13 #include "ui/gfx/geometry/point_f.h"
15 #include "ui/gfx/geometry/rect_f.h" 14 #include "ui/gfx/geometry/rect_f.h"
16 #include "ui/gfx/gfx_export.h" 15 #include "ui/gfx/gfx_export.h"
17 16
18 namespace gfx { 17 namespace gfx {
19 18
20 // A Quad is defined by four corners, allowing it to have edges that are not 19 // A Quad is defined by four corners, allowing it to have edges that are not
21 // axis-aligned, unlike a Rect. 20 // axis-aligned, unlike a Rect.
22 class GFX_EXPORT QuadF { 21 class GFX_EXPORT QuadF {
23 public: 22 public:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // the quad may lie on the right/bottom edge of the resulting rectangle, 60 // the quad may lie on the right/bottom edge of the resulting rectangle,
62 // rather than being strictly inside it. 61 // rather than being strictly inside it.
63 RectF BoundingBox() const { 62 RectF BoundingBox() const {
64 float rl = std::min(std::min(p1_.x(), p2_.x()), std::min(p3_.x(), p4_.x())); 63 float rl = std::min(std::min(p1_.x(), p2_.x()), std::min(p3_.x(), p4_.x()));
65 float rr = std::max(std::max(p1_.x(), p2_.x()), std::max(p3_.x(), p4_.x())); 64 float rr = std::max(std::max(p1_.x(), p2_.x()), std::max(p3_.x(), p4_.x()));
66 float rt = std::min(std::min(p1_.y(), p2_.y()), std::min(p3_.y(), p4_.y())); 65 float rt = std::min(std::min(p1_.y(), p2_.y()), std::min(p3_.y(), p4_.y()));
67 float rb = std::max(std::max(p1_.y(), p2_.y()), std::max(p3_.y(), p4_.y())); 66 float rb = std::max(std::max(p1_.y(), p2_.y()), std::max(p3_.y(), p4_.y()));
68 return RectF(rl, rt, rr - rl, rb - rt); 67 return RectF(rl, rt, rr - rl, rb - rt);
69 } 68 }
70 69
71 // Realigns the corners in the quad by rotating them n corners to the right.
72 void Realign(size_t times) {
73 DCHECK_LE(times, 4u);
74 for (size_t i = 0; i < times; ++i) {
75 PointF temp = p1_;
76 p1_ = p2_;
77 p2_ = p3_;
78 p3_ = p4_;
79 p4_ = temp;
80 }
81 }
82
83 // Add a vector to the quad, offseting each point in the quad by the vector. 70 // Add a vector to the quad, offseting each point in the quad by the vector.
84 void operator+=(const Vector2dF& rhs); 71 void operator+=(const Vector2dF& rhs);
85 // Subtract a vector from the quad, offseting each point in the quad by the 72 // Subtract a vector from the quad, offseting each point in the quad by the
86 // inverse of the vector. 73 // inverse of the vector.
87 void operator-=(const Vector2dF& rhs); 74 void operator-=(const Vector2dF& rhs);
88 75
89 // Scale each point in the quad by the |scale| factor. 76 // Scale each point in the quad by the |scale| factor.
90 void Scale(float scale) { Scale(scale, scale); } 77 void Scale(float scale) { Scale(scale, scale); }
91 78
92 // Scale each point in the quad by the scale factors along each axis. 79 // Scale each point in the quad by the scale factors along each axis.
(...skipping 26 matching lines...) Expand all
119 GFX_EXPORT QuadF operator-(const QuadF& lhs, const Vector2dF& rhs); 106 GFX_EXPORT QuadF operator-(const QuadF& lhs, const Vector2dF& rhs);
120 107
121 // This is declared here for use in gtest-based unit tests but is defined in 108 // This is declared here for use in gtest-based unit tests but is defined in
122 // the gfx_test_support target. Depend on that to use this in your unit test. 109 // the gfx_test_support target. Depend on that to use this in your unit test.
123 // This should not be used in production code - call ToString() instead. 110 // This should not be used in production code - call ToString() instead.
124 void PrintTo(const QuadF& quad, ::std::ostream* os); 111 void PrintTo(const QuadF& quad, ::std::ostream* os);
125 112
126 } // namespace gfx 113 } // namespace gfx
127 114
128 #endif // UI_GFX_GEOMETRY_QUAD_F_H_ 115 #endif // UI_GFX_GEOMETRY_QUAD_F_H_
OLDNEW
« no previous file with comments | « cc/trees/occlusion_tracker_unittest.cc ('k') | ui/gfx/skia_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698