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

Issue 11369043: ui: Create the gfx::QuadF class. (Closed)

Created:
8 years, 1 month ago by danakj
Modified:
8 years, 1 month ago
CC:
chromium-reviews, cc-bugs_chromium.org
Visibility:
Public.

Description

ui: Create the gfx::QuadF class. This class is composed of four points representing its corners. It does not have to be axis-aligned, unlike a rectangle. The class supports the following operations: IsRectilinear() - True if the quad is an axis-aligned rectangle. IsCounterClockwise() - True if the points of the quad are in counter-clockwise order. Contains(Point) - True if Point is inside the quad or on its boundary. BoundingBox() - A Rectangle whose edges are defined by the four points of the quad. Scale() - Scales each point on the quad by the given scale factors. operator+/- - Moves each point in the quad by the given offset. The operations on this class are inspired by, but not copied from, the FloatQuad class in WebCore. I've written my own implementation to match those in WebCore for each of them, with exception of IsRectilinear() as I also wrote the current method in WebCore. Tests: ui_unittests:QuadTest.Construction ui_unittests:QuadTest.AddingVectors ui_unittests:QuadTest.IsRectilinear ui_unittests:QuadTest.IsCounterClockwise ui_unittests:QuadTest.BoundingBox ui_unittests:QuadTest.ContainsPoint ui_unittests:QuadTest.Scale BUG=147395 R=sky,pkasting Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=165689

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Patch Set 4 : #

Patch Set 5 : #

Patch Set 6 : Use f suffix for floats #

Total comments: 9

Patch Set 7 : nits #

Total comments: 15
Unified diffs Side-by-side diffs Delta from patch set Stats (+587 lines, -0 lines) Patch
M WATCHLISTS View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
A ui/gfx/quad_f.h View 1 2 3 4 5 6 1 chunk +94 lines, -0 lines 1 comment Download
A ui/gfx/quad_f.cc View 1 2 3 4 5 6 1 chunk +151 lines, -0 lines 10 comments Download
A ui/gfx/quad_unittest.cc View 1 2 3 4 1 chunk +322 lines, -0 lines 0 comments Download
M ui/gfx/vector2d_f.h View 1 chunk +6 lines, -0 lines 4 comments Download
M ui/gfx/vector2d_f.cc View 1 chunk +10 lines, -0 lines 0 comments Download
M ui/ui.gyp View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
M ui/ui_unittests.gypi View 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
danakj
8 years, 1 month ago (2012-11-02 04:43:08 UTC) #1
danakj
Context: I made use of this for https://codereview.chromium.org/11364044/
8 years, 1 month ago (2012-11-02 04:55:08 UTC) #2
sky
Just nits, LGTM https://codereview.chromium.org/11369043/diff/4012/ui/gfx/quad_f.cc File ui/gfx/quad_f.cc (right): https://codereview.chromium.org/11369043/diff/4012/ui/gfx/quad_f.cc#newcode60 ui/gfx/quad_f.cc:60: { { on previous line. https://codereview.chromium.org/11369043/diff/4012/ui/gfx/quad_f.cc#newcode67 ...
8 years, 1 month ago (2012-11-02 15:49:43 UTC) #3
tfarina
https://codereview.chromium.org/11369043/diff/4012/ui/gfx/quad_f.h File ui/gfx/quad_f.h (right): https://codereview.chromium.org/11369043/diff/4012/ui/gfx/quad_f.h#newcode33 ui/gfx/quad_f.h:33: PointF p1() const { return p1_; } On 2012/11/02 ...
8 years, 1 month ago (2012-11-02 15:53:30 UTC) #4
danakj
Thanks :) https://codereview.chromium.org/11369043/diff/4012/ui/gfx/quad_f.cc File ui/gfx/quad_f.cc (right): https://codereview.chromium.org/11369043/diff/4012/ui/gfx/quad_f.cc#newcode60 ui/gfx/quad_f.cc:60: { On 2012/11/02 15:49:43, sky wrote: > ...
8 years, 1 month ago (2012-11-02 15:54:59 UTC) #5
tfarina
https://codereview.chromium.org/11369043/diff/13002/ui/gfx/quad_f.h File ui/gfx/quad_f.h (right): https://codereview.chromium.org/11369043/diff/13002/ui/gfx/quad_f.h#newcode78 ui/gfx/quad_f.h:78: lhs.p1() == rhs.p1() && lhs.p2() == rhs.p2() && nit: ...
8 years, 1 month ago (2012-11-02 15:59:10 UTC) #6
Peter Kasting
When you give multiple reviewers, always list what you want each to look at. Given ...
8 years, 1 month ago (2012-11-02 17:54:34 UTC) #7
danakj
On 2012/11/02 17:54:34, Peter Kasting wrote: > When you give multiple reviewers, always list what ...
8 years, 1 month ago (2012-11-02 17:58:19 UTC) #8
Peter Kasting
https://codereview.chromium.org/11369043/diff/13002/ui/gfx/quad_f.cc File ui/gfx/quad_f.cc (right): https://codereview.chromium.org/11369043/diff/13002/ui/gfx/quad_f.cc#newcode28 ui/gfx/quad_f.cc:28: : p1_(rect.x(), rect.y()), Nit: could be rect.origin() (2 places) ...
8 years, 1 month ago (2012-11-02 18:09:37 UTC) #9
danakj
https://codereview.chromium.org/11369043/diff/13002/ui/gfx/quad_f.cc File ui/gfx/quad_f.cc (right): https://codereview.chromium.org/11369043/diff/13002/ui/gfx/quad_f.cc#newcode28 ui/gfx/quad_f.cc:28: : p1_(rect.x(), rect.y()), On 2012/11/02 18:09:37, Peter Kasting wrote: ...
8 years, 1 month ago (2012-11-02 18:34:10 UTC) #10
danakj
https://codereview.chromium.org/11369043/diff/13002/ui/gfx/quad_f.cc File ui/gfx/quad_f.cc (right): https://codereview.chromium.org/11369043/diff/13002/ui/gfx/quad_f.cc#newcode60 ui/gfx/quad_f.cc:60: return std::abs(a - b) < std::numeric_limits<float>::epsilon(); On 2012/11/02 18:34:10, ...
8 years, 1 month ago (2012-11-02 18:38:42 UTC) #11
Peter Kasting
https://codereview.chromium.org/11369043/diff/13002/ui/gfx/vector2d_f.h File ui/gfx/vector2d_f.h (right): https://codereview.chromium.org/11369043/diff/13002/ui/gfx/vector2d_f.h#newcode80 ui/gfx/vector2d_f.h:80: UI_EXPORT double CrossProduct(const Vector2dF& lhs, const Vector2dF& rhs); On ...
8 years, 1 month ago (2012-11-02 20:41:46 UTC) #12
danakj
https://codereview.chromium.org/11369043/diff/13002/ui/gfx/vector2d_f.h File ui/gfx/vector2d_f.h (right): https://codereview.chromium.org/11369043/diff/13002/ui/gfx/vector2d_f.h#newcode80 ui/gfx/vector2d_f.h:80: UI_EXPORT double CrossProduct(const Vector2dF& lhs, const Vector2dF& rhs); On ...
8 years, 1 month ago (2012-11-02 20:44:00 UTC) #13
Peter Kasting
8 years, 1 month ago (2012-11-02 20:44:54 UTC) #14
On 2012/11/02 20:44:00, danakj wrote:
> https://codereview.chromium.org/11369043/diff/13002/ui/gfx/vector2d_f.h
> File ui/gfx/vector2d_f.h (right):
> 
>
https://codereview.chromium.org/11369043/diff/13002/ui/gfx/vector2d_f.h#newco...
> ui/gfx/vector2d_f.h:80: UI_EXPORT double CrossProduct(const Vector2dF& lhs,
> const Vector2dF& rhs);
> On 2012/11/02 20:41:46, Peter Kasting wrote:
> > On 2012/11/02 18:34:10, danakj wrote:
> > > On 2012/11/02 18:09:37, Peter Kasting wrote:
> > > > Isn't the cross product a vector?
> > > 
> > > http://mathworld.wolfram.com/CrossProduct.html
> > > 
> > > See: "In two dimensions, the analog of the cross product..."
> > 
> > Maybe we should name the 2d "cross product" "Determinant"?  That might be
> > clearer, since a 2d "cross product" is just surprising.
> 
> Well, determinant is only an operation on matrices. If you search for two
> dimension cross product you find a few references to this. In particular, in
the
> description of the Graham Scan algorithm, you also find it. It's a bit of a
toss
> up, but I do like this one a bit more for these reasons.

Yeah, on reflection I agree, leave it.

Powered by Google App Engine
This is Rietveld 408576698