diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-08 06:26:50 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-08 06:26:50 +0000 |
commit | ac7c7f5ddf7ccddac616fd7700b020bd30446069 (patch) | |
tree | de606bdf0eda10da177b6c184762364dc09d5202 /cc/math_util.cc | |
parent | 12a11e2b86333af3bf71dbcf5b61e48f3d43a5bc (diff) | |
download | chromium_src-ac7c7f5ddf7ccddac616fd7700b020bd30446069.zip chromium_src-ac7c7f5ddf7ccddac616fd7700b020bd30446069.tar.gz chromium_src-ac7c7f5ddf7ccddac616fd7700b020bd30446069.tar.bz2 |
cc: Create a Region class that wraps SkRegion, to replace use of WebCore::Region.
We create a class in cc/ called Region which provides a gfx:: type-friendly API
to SkRegion, and allows for easily swapping out region implementations in the
future if required.
During the process, I removed tests dependency on a "size()" method on Region,
that used to give the number of rects in the Region's internal representation.
Instead, we always create a Region in the tests from our expected rects, and
compare the Regions directly. We use ToString() comparisons to get useful
failure outputs, similar to the unit tests of other geometry types in ui/gfx.
This uncovered a WTF::Vector holdout in the OcclusionTracker class, which is
converted to a std::vector.
Covered by existing tests; no change in behaviour.
R=enne
BUG=147395
Review URL: https://chromiumcodereview.appspot.com/11366094
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166617 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/math_util.cc')
-rw-r--r-- | cc/math_util.cc | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/cc/math_util.cc b/cc/math_util.cc index 83d156c..f18b8401 100644 --- a/cc/math_util.cc +++ b/cc/math_util.cc @@ -20,6 +20,9 @@ using WebKit::WebTransformationMatrix; namespace cc { +const double MathUtil::PI_DOUBLE = 3.14159265358979323846; +const float MathUtil::PI_FLOAT = 3.14159265358979323846f; + static HomogeneousCoordinate projectHomogeneousPoint(const WebTransformationMatrix& transform, const gfx::PointF& p) { // In this case, the layer we are trying to project onto is perpendicular to ray @@ -380,18 +383,12 @@ gfx::Vector2dF MathUtil::computeTransform2dScaleComponents(const WebTransformati return gfx::Vector2dF(xScale, yScale); } -static inline double rad2deg(double r) -{ - double pi = 3.14159265358979323846; - return r * 180.0 / pi; -} - float MathUtil::smallestAngleBetweenVectors(gfx::Vector2dF v1, gfx::Vector2dF v2) { double dotProduct = gfx::DotProduct(v1, v2) / v1.Length() / v2.Length(); // Clamp to compensate for rounding errors. dotProduct = std::max(-1.0, std::min(1.0, dotProduct)); - return static_cast<float>(rad2deg(std::acos(dotProduct))); + return static_cast<float>(Rad2Deg(std::acos(dotProduct))); } gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF destination) |