summaryrefslogtreecommitdiffstats
path: root/ui/gfx/point_f.h
Commit message (Collapse)AuthorAgeFilesLines
* Inline hot ctor/dtors for struct-like gfx:: geometry typesjamesr@chromium.org2012-11-301-3/+3
| | | | | | | | | | | | | | | | This inlines the ctors and (empty) dtors for gfx::PointF, SizeF and RectF. On a ToT chromium mac release build, inlining these is a 8.5% speedup on cc_perftests. Based on profiling data from instruments inlining QuadF would be a speedup as well, but the chromium-style plugin thinks it's too complex (even though the dtor has no code). BUG= NOTRY=true (yoda style) Review URL: https://chromiumcodereview.appspot.com/11428076 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170378 0039d316-1c4b-4281-b951-d872f2087c98
* ui: Prefer +/- operators to apply offsets.danakj@chromium.org2012-11-101-1/+1
| | | | | | | | | | | | | | | | | Adds +/- operators to gfx::Rect that are applied to its origin Point. Removes gfx::Point method a.OffsetFrom(b) in favor of (b - a). Begin use +/- instead of Offset() in ui/gfx/ and cc/ New tests: ui_unittests:RectTest.Offset R=pkasting,enne BUG=158416 Review URL: https://codereview.chromium.org/11293194 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167012 0039d316-1c4b-4281-b951-d872f2087c98
* ui: Make gfx::Point::Scale() mutate the class, similar to gfx::Rect.danakj@chromium.org2012-11-091-4/+10
| | | | | | | | | | | | | | We add gfx::ScalePoint() as a non-mutating version of the Scale method. Tests: ui_unittests:PointTest.Scale R=sky BUG=160158 Review URL: https://codereview.chromium.org/11369144 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166979 0039d316-1c4b-4281-b951-d872f2087c98
* ui: Remove gfx::Point Add() and Subtract() which were non-mutating member ↵danakj@chromium.org2012-11-091-2/+6
| | | | | | | | | | | | | | | | methods. Replace use of these with operator +, +=, -, -=. Covered by existing unit tests. R=sky BUG=158416,160158 Review URL: https://chromiumcodereview.appspot.com/11362173 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166933 0039d316-1c4b-4281-b951-d872f2087c98
* Add Vector2d classes that represent offsets, instead of using Point.danakj@chromium.org2012-10-311-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously Point served two purposes, to be a position in 2d space, and also an offset from the origin. This introduces a Vector2d class to represent an offset, allowing typesafety checks for geometric operations. The following are now the case: Point +/- Vector = Point - A point plus/minus an offset gives you a point at a position offset by the vector. Vector +/- Vector = Vector - Two offsets can be added together to make a new offset. Point - Point = Vector - Subtracting one point from another gives you the offset between the two points. We add some new methods to perform these operations: Rect::OffsetFromOrigin() gives the offset between the position of the rect and the origin. Point::OffsetFromOrigin() gives the offset between the point and the origin. PointAtOffsetFromOrigin(Vector2d) converts a Vector2d to a Point at the given offset away from the origin. Rect::Offset(), Point::Add(), and Point::Subtract() now receive a Vector2d instead of a point. BUG=147395 R=sky Review URL: https://codereview.chromium.org/11269022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165198 0039d316-1c4b-4281-b951-d872f2087c98
* Implicit coversion operators from integer geometry types to floating point.danakj@chromium.org2012-10-111-0/+8
| | | | | | | | | | | | | | | | | | | This change allows you to call a function that expects a floating point object with an integer object and have things just work. The addition operator for Points is outside the Point classes so it can add/subtract integer and float points together implicitly. Tested to verify compilation with: ui_unittests:RectTest.ToRectF ui_unittests:SizeTest.ToSizeF ui_unittests:PointTest.ToPointF BUG=147395 R=sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/11028127 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161415 0039d316-1c4b-4281-b951-d872f2087c98
* Remove implicit flooring Scale() method from Point and Size.danakj@chromium.org2012-10-091-0/+8
| | | | | | | | | | | | | | | | | | When scaling an integer point or size, return a floating point result. Implicitly flooring hides design problems and bugs. Add conversion functions to floor or ceil a SizeF or PointF into an integer format again. All existing behaviour has been preserved by replacing uses of foo.Scale() with ToFlooredFoo(foo.Scale()). R=sky BUG=147395 Review URL: https://chromiumcodereview.appspot.com/11081007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160970 0039d316-1c4b-4281-b951-d872f2087c98
* Make adding and subtracting gfx:: point types simpler.danakj@chromium.org2012-10-051-5/+9
| | | | | | | | | | | | | | | | | | 1) Removed iffy flooring conversion from Float types to Int types. 2) Added methods to convert from Int to Float types so you can do things like add a Point to a PointF and viceversa. 3) Added operator+ and operator- for point types. This had to be done in both Point and PointF headers to allow (Point+PointF) to compile. 4) Move the PointF::~PointF() destructor to the .cc file to be consistent with other types. 5) Remove the unimplemented PointF::PointF(Point) constructor from the header. BUG=152473 R=sky,jamesr Review URL: https://codereview.chromium.org/10993094 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160426 0039d316-1c4b-4281-b951-d872f2087c98
* Remove the rest of #pragma once in one big CL.ajwong@chromium.org2012-07-111-1/+0
| | | | | | | | | For context see this thread: https://groups.google.com/a/chromium.org/forum/?fromgroups#!topic/chromium-dev/RMcVNGjB4II TBR=thakis,pkasting,jam git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146163 0039d316-1c4b-4281-b951-d872f2087c98
* Add instantiation declarations for PointBase, SizeBase, RectBasethakis@chromium.org2012-05-191-0/+4
| | | | | | | | | | | | | | | | | | | These templates have explicit instantiations in point.cc, point_f.cc, size.cc, size_f.cc, rect.cc, rect_f.cc. This suggests that the intent was to have these instantiations in a single translation unit. Without an explicit instantiation declaration, they would still be weakly emitted to all translation units that use point.h (etc). Add an explicit instantiation declaration to stop this from happening. Thanks to Rafael Espindola for help with this patch. BUG=90078 TEST=do a components debug build on mac. observe fewer linker errors. Normal builds get a bit faster too. Review URL: https://chromiumcodereview.appspot.com/10386220 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138012 0039d316-1c4b-4281-b951-d872f2087c98
* Move DIP translation from ui/aura to ui/compositor.oshima@chromium.org2012-05-081-4/+0
| | | | | | | | | | | | | Layer's coordinate system is now in DIP. Added support of dynamic density switching. Removed ENABLE_DIP gyp/macro and added runtime flag "--ui-enable-dip" BUG=105165, 114666 TEST=enabled monitor test. added new tests to compositor_unittests Review URL: https://chromiumcodereview.appspot.com/10221028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135888 0039d316-1c4b-4281-b951-d872f2087c98
* Noone should use base class, so it's safe to remove virtual destructors for ↵oshima@chromium.org2012-04-241-1/+1
| | | | | | | | | | | | point/size/rect BUG=none TEST=none Review URL: http://codereview.chromium.org/10203004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133795 0039d316-1c4b-4281-b951-d872f2087c98
* Use template for Point/Size/Rect and remove duplicates oshima@chromium.org2012-04-111-61/+5
| | | | | | | | | BUG=114664 TEST=none Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=131737 Review URL: https://chromiumcodereview.appspot.com/10014027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131764 0039d316-1c4b-4281-b951-d872f2087c98
* Revert r131737 "Use template for Point/Size/Rect and remove duplicates "oshima@chromium.org2012-04-111-5/+61
| | | | | | | | | | | TBR=oshima@chromium.org BUG=114664 TEST=none Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=131737 Review URL: https://chromiumcodereview.appspot.com/10020034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131738 0039d316-1c4b-4281-b951-d872f2087c98
* Use template for Point/Size/Rect and remove duplicates oshima@chromium.org2012-04-111-61/+5
| | | | | | | | BUG=114664 TEST=none Review URL: https://chromiumcodereview.appspot.com/10014027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131737 0039d316-1c4b-4281-b951-d872f2087c98
* Floating point based Point/Size/Rect and Insetsoshima@chromium.org2012-04-091-0/+93
This is copied from integer version, instead of using template, to minimize conflict with m19 branch, as using template requires updating forward declaration of these classes in many places. I put this behind gyp flag for now so that we can move forward without breaking non DIP build until we can get aura working with DIP. BUG=114664 TEST=none Review URL: http://codereview.chromium.org/10025004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131405 0039d316-1c4b-4281-b951-d872f2087c98