[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
kbr at google.com
kbr at google.com
Wed Dec 22 12:53:07 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit f656cafeacdeb99b1a8ee3c62ba345cce164509a
Author: kbr at google.com <kbr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Sep 1 00:38:26 2010 +0000
2010-08-31 Kenneth Russell <kbr at google.com>
Reviewed by Chris Marrin.
Add length and related operations to FloatPoint and FloatSize
https://bugs.webkit.org/show_bug.cgi?id=44994
Added length and squared length operations to both FloatPoint and
FloatSize, and added set(x, y), dot and normalize operations to
FloatPoint. These changes have been tested with new code to be
added later.
* platform/graphics/FloatPoint.cpp:
(WebCore::FloatPoint::normalize):
(WebCore::FloatPoint::length):
* platform/graphics/FloatPoint.h:
(WebCore::FloatPoint::set):
(WebCore::FloatPoint::dot):
(WebCore::FloatPoint::lengthSquared):
(WebCore::operator*):
* platform/graphics/FloatSize.cpp:
(WebCore::FloatSize::diagonalLength):
* platform/graphics/FloatSize.h:
(WebCore::FloatSize::diagonalLengthSquared):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66560 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index a0ad741..16fb327 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2010-08-31 Kenneth Russell <kbr at google.com>
+
+ Reviewed by Chris Marrin.
+
+ Add length and related operations to FloatPoint and FloatSize
+ https://bugs.webkit.org/show_bug.cgi?id=44994
+
+ Added length and squared length operations to both FloatPoint and
+ FloatSize, and added set(x, y), dot and normalize operations to
+ FloatPoint. These changes have been tested with new code to be
+ added later.
+
+ * platform/graphics/FloatPoint.cpp:
+ (WebCore::FloatPoint::normalize):
+ (WebCore::FloatPoint::length):
+ * platform/graphics/FloatPoint.h:
+ (WebCore::FloatPoint::set):
+ (WebCore::FloatPoint::dot):
+ (WebCore::FloatPoint::lengthSquared):
+ (WebCore::operator*):
+ * platform/graphics/FloatSize.cpp:
+ (WebCore::FloatSize::diagonalLength):
+ * platform/graphics/FloatSize.h:
+ (WebCore::FloatSize::diagonalLengthSquared):
+
2010-08-31 Zhenyao Mo <zmo at google.com>
Reviewed by Kenneth Russell.
diff --git a/WebCore/platform/graphics/FloatPoint.cpp b/WebCore/platform/graphics/FloatPoint.cpp
index cf3d548..7e85b52 100644
--- a/WebCore/platform/graphics/FloatPoint.cpp
+++ b/WebCore/platform/graphics/FloatPoint.cpp
@@ -30,6 +30,7 @@
#include "TransformationMatrix.h"
#include "FloatConversion.h"
#include "IntPoint.h"
+#include <math.h>
namespace WebCore {
@@ -37,6 +38,21 @@ FloatPoint::FloatPoint(const IntPoint& p) : m_x(p.x()), m_y(p.y())
{
}
+void FloatPoint::normalize()
+{
+ float tempLength = length();
+
+ if (tempLength) {
+ m_x /= tempLength;
+ m_y /= tempLength;
+ }
+}
+
+float FloatPoint::length() const
+{
+ return sqrtf(lengthSquared());
+}
+
FloatPoint FloatPoint::matrixTransform(const AffineTransform& transform) const
{
double newX, newY;
diff --git a/WebCore/platform/graphics/FloatPoint.h b/WebCore/platform/graphics/FloatPoint.h
index 5018f1d..73a1bac 100644
--- a/WebCore/platform/graphics/FloatPoint.h
+++ b/WebCore/platform/graphics/FloatPoint.h
@@ -80,6 +80,11 @@ public:
void setX(float x) { m_x = x; }
void setY(float y) { m_y = y; }
+ void set(float x, float y)
+ {
+ m_x = x;
+ m_y = y;
+ }
void move(float dx, float dy)
{
m_x += dx;
@@ -91,6 +96,19 @@ public:
m_y *= sy;
}
+ void normalize();
+
+ float dot(const FloatPoint& a) const
+ {
+ return m_x * a.x() + m_y * a.y();
+ }
+
+ float length() const;
+ float lengthSquared() const
+ {
+ return m_x * m_x + m_y * m_y;
+ }
+
#if PLATFORM(CG)
FloatPoint(const CGPoint&);
operator CGPoint() const;
@@ -173,6 +191,12 @@ inline bool operator!=(const FloatPoint& a, const FloatPoint& b)
return a.x() != b.x() || a.y() != b.y();
}
+inline float operator*(const FloatPoint& a, const FloatPoint& b)
+{
+ // dot product
+ return a.dot(b);
+}
+
inline IntPoint roundedIntPoint(const FloatPoint& p)
{
return IntPoint(static_cast<int>(roundf(p.x())), static_cast<int>(roundf(p.y())));
diff --git a/WebCore/platform/graphics/FloatSize.cpp b/WebCore/platform/graphics/FloatSize.cpp
index 86fa4c0..c199297 100644
--- a/WebCore/platform/graphics/FloatSize.cpp
+++ b/WebCore/platform/graphics/FloatSize.cpp
@@ -29,6 +29,7 @@
#include "FloatConversion.h"
#include "IntSize.h"
+#include <math.h>
namespace WebCore {
@@ -36,6 +37,11 @@ FloatSize::FloatSize(const IntSize& size) : m_width(size.width()), m_height(size
{
}
+float FloatSize::diagonalLength() const
+{
+ return sqrtf(diagonalLengthSquared());
+}
+
FloatSize FloatSize::narrowPrecision(double width, double height)
{
return FloatSize(narrowPrecisionToFloat(width), narrowPrecisionToFloat(height));
diff --git a/WebCore/platform/graphics/FloatSize.h b/WebCore/platform/graphics/FloatSize.h
index ff3d4de..160fc9a 100644
--- a/WebCore/platform/graphics/FloatSize.h
+++ b/WebCore/platform/graphics/FloatSize.h
@@ -83,6 +83,12 @@ public:
m_height < other.m_height ? m_height : other.m_height);
}
+ float diagonalLength() const;
+ float diagonalLengthSquared() const
+ {
+ return m_width * m_width + m_height * m_height;
+ }
+
#if PLATFORM(CG) || (PLATFORM(WX) && OS(DARWIN))
explicit FloatSize(const CGSize&); // don't do this implicitly since it's lossy
operator CGSize() const;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list