[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da
crogers at google.com
crogers at google.com
Wed Dec 22 17:45:34 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 5f32c2c6c0bde9ec88e7155baab8192c77d0df67
Author: crogers at google.com <crogers at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Nov 30 01:18:34 2010 +0000
2010-11-29 Chris Rogers <crogers at google.com>
Reviewed by Kenneth Russell.
Switch web audio code to use FloatPoint3D instead of Vector3
https://bugs.webkit.org/show_bug.cgi?id=50186
* wtf/Vector3.h: Removed.
2010-11-29 Chris Rogers <crogers at google.com>
Reviewed by Kenneth Russell.
Switch web audio code to use FloatPoint3D instead of Vector3
https://bugs.webkit.org/show_bug.cgi?id=50186
No new tests since audio API is not yet implemented.
* platform/audio/Cone.cpp:
(WebCore::ConeEffect::gain):
* platform/audio/Cone.h:
* platform/graphics/FloatPoint3D.h:
(WebCore::FloatPoint3D::isZero):
(WebCore::operator*):
(WebCore::FloatPoint3D::distanceTo):
* webaudio/AudioListener.h:
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::position):
(WebCore::AudioListener::setOrientation):
(WebCore::AudioListener::orientation):
(WebCore::AudioListener::setUpVector):
(WebCore::AudioListener::upVector):
(WebCore::AudioListener::setVelocity):
(WebCore::AudioListener::velocity):
* webaudio/AudioPannerNode.cpp:
(WebCore::AudioPannerNode::AudioPannerNode):
(WebCore::AudioPannerNode::getAzimuthElevation):
(WebCore::AudioPannerNode::dopplerRate):
(WebCore::AudioPannerNode::distanceConeGain):
* webaudio/AudioPannerNode.h:
(WebCore::AudioPannerNode::position):
(WebCore::AudioPannerNode::setPosition):
(WebCore::AudioPannerNode::orientation):
(WebCore::AudioPannerNode::setOrientation):
(WebCore::AudioPannerNode::velocity):
(WebCore::AudioPannerNode::setVelocity):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72853 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 7228087..4c7926d 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,12 @@
+2010-11-29 Chris Rogers <crogers at google.com>
+
+ Reviewed by Kenneth Russell.
+
+ Switch web audio code to use FloatPoint3D instead of Vector3
+ https://bugs.webkit.org/show_bug.cgi?id=50186
+
+ * wtf/Vector3.h: Removed.
+
2010-11-29 Steve Falkenburg <sfalken at apple.com>
Reviewed by Adam Roben.
diff --git a/JavaScriptCore/wtf/Vector3.h b/JavaScriptCore/wtf/Vector3.h
deleted file mode 100644
index 1850929..0000000
--- a/JavaScriptCore/wtf/Vector3.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef WTF_Vector3_h
-#define WTF_Vector3_h
-
-#include <math.h>
-
-namespace WTF {
-
-class Vector3 {
-public:
- Vector3()
- : m_x(0.0)
- , m_y(0.0)
- , m_z(0.0)
- {
- }
-
- Vector3(double x, double y, double z)
- : m_x(x)
- , m_y(y)
- , m_z(z)
- {
- }
-
- Vector3(const float p[3])
- : m_x(p[0])
- , m_y(p[1])
- , m_z(p[2])
- {
- }
-
- Vector3(const double p[3])
- : m_x(p[0])
- , m_y(p[1])
- , m_z(p[2])
- {
- }
-
- double abs() const
- {
- return sqrt(m_x * m_x + m_y * m_y + m_z * m_z);
- }
-
- bool isZero() const
- {
- return !m_x && !m_y && !m_z;
- }
-
- void normalize()
- {
- double absValue = abs();
- if (!absValue)
- return;
-
- double k = 1.0 / absValue;
- m_x *= k;
- m_y *= k;
- m_z *= k;
- }
-
- double x() const { return m_x; }
- double y() const { return m_y; }
- double z() const { return m_z; }
-
-private:
- double m_x;
- double m_y;
- double m_z;
-};
-
-inline Vector3 operator+(const Vector3& v1, const Vector3& v2)
-{
- return Vector3(v1.x() + v2.x(), v1.y() + v2.y(), v1.z() + v2.z());
-}
-
-inline Vector3 operator-(const Vector3& v1, const Vector3& v2)
-{
- return Vector3(v1.x() - v2.x(), v1.y() - v2.y(), v1.z() - v2.z());
-}
-
-inline Vector3 operator*(double k, const Vector3& v)
-{
- return Vector3(k * v.x(), k * v.y(), k * v.z());
-}
-
-inline Vector3 operator*(const Vector3& v, double k)
-{
- return Vector3(k * v.x(), k * v.y(), k * v.z());
-}
-
-inline double dot(const Vector3& v1, const Vector3& v2)
-{
- return v1.x() * v2.x() + v1.y() * v2.y() + v1.z() * v2.z();
-}
-
-inline Vector3 cross(const Vector3& v1, const Vector3& v2)
-{
- double x3 = v1.y() * v2.z() - v1.z() * v2.y();
- double y3 = v1.z() * v2.x() - v1.x() * v2.z();
- double z3 = v1.x() * v2.y() - v1.y() * v2.x();
- return Vector3(x3, y3, z3);
-}
-
-inline double distance(const Vector3& v1, const Vector3& v2)
-{
- return (v1 - v2).abs();
-}
-
-} // WTF
-
-#endif // WTF_Vector3_h
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c170276..1883046 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,41 @@
+2010-11-29 Chris Rogers <crogers at google.com>
+
+ Reviewed by Kenneth Russell.
+
+ Switch web audio code to use FloatPoint3D instead of Vector3
+ https://bugs.webkit.org/show_bug.cgi?id=50186
+
+ No new tests since audio API is not yet implemented.
+
+ * platform/audio/Cone.cpp:
+ (WebCore::ConeEffect::gain):
+ * platform/audio/Cone.h:
+ * platform/graphics/FloatPoint3D.h:
+ (WebCore::FloatPoint3D::isZero):
+ (WebCore::operator*):
+ (WebCore::FloatPoint3D::distanceTo):
+ * webaudio/AudioListener.h:
+ (WebCore::AudioListener::setPosition):
+ (WebCore::AudioListener::position):
+ (WebCore::AudioListener::setOrientation):
+ (WebCore::AudioListener::orientation):
+ (WebCore::AudioListener::setUpVector):
+ (WebCore::AudioListener::upVector):
+ (WebCore::AudioListener::setVelocity):
+ (WebCore::AudioListener::velocity):
+ * webaudio/AudioPannerNode.cpp:
+ (WebCore::AudioPannerNode::AudioPannerNode):
+ (WebCore::AudioPannerNode::getAzimuthElevation):
+ (WebCore::AudioPannerNode::dopplerRate):
+ (WebCore::AudioPannerNode::distanceConeGain):
+ * webaudio/AudioPannerNode.h:
+ (WebCore::AudioPannerNode::position):
+ (WebCore::AudioPannerNode::setPosition):
+ (WebCore::AudioPannerNode::orientation):
+ (WebCore::AudioPannerNode::setOrientation):
+ (WebCore::AudioPannerNode::velocity):
+ (WebCore::AudioPannerNode::setVelocity):
+
2010-11-29 Xiaomei Ji <xji at chromium.org>
Reviewed by David Hyatt.
diff --git a/WebCore/platform/audio/Cone.cpp b/WebCore/platform/audio/Cone.cpp
index 91813ab..843b3cc 100644
--- a/WebCore/platform/audio/Cone.cpp
+++ b/WebCore/platform/audio/Cone.cpp
@@ -41,20 +41,20 @@ ConeEffect::ConeEffect()
{
}
-double ConeEffect::gain(Vector3 sourcePosition, Vector3 sourceOrientation, Vector3 listenerPosition)
+double ConeEffect::gain(FloatPoint3D sourcePosition, FloatPoint3D sourceOrientation, FloatPoint3D listenerPosition)
{
if (sourceOrientation.isZero() || ((m_innerAngle == 360.0) && (m_outerAngle == 360.0)))
return 1.0; // no cone specified - unity gain
// Normalized source-listener vector
- Vector3 sourceToListener = listenerPosition - sourcePosition;
+ FloatPoint3D sourceToListener = listenerPosition - sourcePosition;
sourceToListener.normalize();
- Vector3 normalizedSourceOrientation = sourceOrientation;
+ FloatPoint3D normalizedSourceOrientation = sourceOrientation;
normalizedSourceOrientation.normalize();
// Angle between the source orientation vector and the source-listener vector
- double dotProduct = dot(sourceToListener, normalizedSourceOrientation);
+ double dotProduct = sourceToListener.dot(normalizedSourceOrientation);
double angle = 180.0 * acos(dotProduct) / M_PI;
double absAngle = fabs(angle);
diff --git a/WebCore/platform/audio/Cone.h b/WebCore/platform/audio/Cone.h
index 9936f28..f566018 100644
--- a/WebCore/platform/audio/Cone.h
+++ b/WebCore/platform/audio/Cone.h
@@ -29,7 +29,7 @@
#ifndef Cone_h
#define Cone_h
-#include <wtf/Vector3.h>
+#include "FloatPoint3D.h"
namespace WebCore {
@@ -40,7 +40,7 @@ public:
ConeEffect();
// Returns scalar gain for the given source/listener positions/orientations
- double gain(Vector3 sourcePosition, Vector3 sourceOrientation, Vector3 listenerPosition);
+ double gain(FloatPoint3D sourcePosition, FloatPoint3D sourceOrientation, FloatPoint3D listenerPosition);
// Angles in degrees
void setInnerAngle(double innerAngle) { m_innerAngle = innerAngle; }
diff --git a/WebCore/platform/graphics/FloatPoint3D.h b/WebCore/platform/graphics/FloatPoint3D.h
index b6cbaa8..ba0ee9d 100644
--- a/WebCore/platform/graphics/FloatPoint3D.h
+++ b/WebCore/platform/graphics/FloatPoint3D.h
@@ -84,6 +84,11 @@ public:
m_z *= sz;
}
+ bool isZero() const
+ {
+ return !m_x && !m_y && !m_z;
+ }
+
void normalize();
float dot(const FloatPoint3D& a) const
@@ -115,6 +120,8 @@ public:
float lengthSquared() const { return this->dot(*this); }
float length() const { return sqrtf(lengthSquared()); }
+
+ float distanceTo(const FloatPoint3D& a) const;
private:
float m_x;
@@ -160,6 +167,21 @@ inline float operator*(const FloatPoint3D& a, const FloatPoint3D& b)
return a.dot(b);
}
+inline FloatPoint3D operator*(float k, const FloatPoint3D& v)
+{
+ return FloatPoint3D(k * v.x(), k * v.y(), k * v.z());
+}
+
+inline FloatPoint3D operator*(const FloatPoint3D& v, float k)
+{
+ return FloatPoint3D(k * v.x(), k * v.y(), k * v.z());
+}
+
+inline float FloatPoint3D::distanceTo(const FloatPoint3D& a) const
+{
+ return (*this - a).length();
+}
+
} // namespace WebCore
#endif // FloatPoint3D_h
diff --git a/WebCore/webaudio/AudioListener.h b/WebCore/webaudio/AudioListener.h
index 2ac1520..5281a89 100644
--- a/WebCore/webaudio/AudioListener.h
+++ b/WebCore/webaudio/AudioListener.h
@@ -29,9 +29,9 @@
#ifndef AudioListener_h
#define AudioListener_h
+#include "FloatPoint3D.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
-#include <wtf/Vector3.h>
namespace WebCore {
@@ -45,27 +45,27 @@ public:
}
// Position
- void setPosition(double x, double y, double z) { setPosition(Vector3(x, y, z)); }
- void setPosition(const Vector3 &position) { m_position = position; }
- const Vector3& position() const { return m_position; }
+ void setPosition(double x, double y, double z) { setPosition(FloatPoint3D(x, y, z)); }
+ void setPosition(const FloatPoint3D &position) { m_position = position; }
+ const FloatPoint3D& position() const { return m_position; }
// Orientation
void setOrientation(double x, double y, double z, double upX, double upY, double upZ)
{
- setOrientation(Vector3(x, y, z));
- setUpVector(Vector3(upX, upY, upZ));
+ setOrientation(FloatPoint3D(x, y, z));
+ setUpVector(FloatPoint3D(upX, upY, upZ));
}
- void setOrientation(const Vector3 &orientation) { m_orientation = orientation; }
- const Vector3& orientation() const { return m_orientation; }
+ void setOrientation(const FloatPoint3D &orientation) { m_orientation = orientation; }
+ const FloatPoint3D& orientation() const { return m_orientation; }
// Up-vector
- void setUpVector(const Vector3 &upVector) { m_upVector = upVector; }
- const Vector3& upVector() const { return m_upVector; }
+ void setUpVector(const FloatPoint3D &upVector) { m_upVector = upVector; }
+ const FloatPoint3D& upVector() const { return m_upVector; }
// Velocity
- void setVelocity(double x, double y, double z) { setVelocity(Vector3(x, y, z)); }
- void setVelocity(const Vector3 &velocity) { m_velocity = velocity; }
- const Vector3& velocity() const { return m_velocity; }
+ void setVelocity(double x, double y, double z) { setVelocity(FloatPoint3D(x, y, z)); }
+ void setVelocity(const FloatPoint3D &velocity) { m_velocity = velocity; }
+ const FloatPoint3D& velocity() const { return m_velocity; }
// Doppler factor
void setDopplerFactor(double dopplerFactor) { m_dopplerFactor = dopplerFactor; }
@@ -79,11 +79,11 @@ private:
AudioListener();
// Position / Orientation
- Vector3 m_position;
- Vector3 m_orientation;
- Vector3 m_upVector;
+ FloatPoint3D m_position;
+ FloatPoint3D m_orientation;
+ FloatPoint3D m_upVector;
- Vector3 m_velocity;
+ FloatPoint3D m_velocity;
double m_dopplerFactor;
double m_speedOfSound;
diff --git a/WebCore/webaudio/AudioPannerNode.cpp b/WebCore/webaudio/AudioPannerNode.cpp
index 4afca27..5cd17cb 100644
--- a/WebCore/webaudio/AudioPannerNode.cpp
+++ b/WebCore/webaudio/AudioPannerNode.cpp
@@ -58,9 +58,9 @@ AudioPannerNode::AudioPannerNode(AudioContext* context, double sampleRate)
m_distanceGain = AudioGain::create("distanceGain", 1.0, 0.0, 1.0);
m_coneGain = AudioGain::create("coneGain", 1.0, 0.0, 1.0);
- m_position = Vector3(0, 0, 0);
- m_orientation = Vector3(1, 0, 0);
- m_velocity = Vector3(0, 0, 0);
+ m_position = FloatPoint3D(0, 0, 0);
+ m_orientation = FloatPoint3D(1, 0, 0);
+ m_velocity = FloatPoint3D(0, 0, 0);
setType(NodeTypePanner);
@@ -165,8 +165,8 @@ void AudioPannerNode::getAzimuthElevation(double* outAzimuth, double* outElevati
double azimuth = 0.0;
// Calculate the source-listener vector
- Vector3 listenerPosition = listener()->position();
- Vector3 sourceListener = m_position - listenerPosition;
+ FloatPoint3D listenerPosition = listener()->position();
+ FloatPoint3D sourceListener = m_position - listenerPosition;
if (sourceListener.isZero()) {
// degenerate case if source and listener are at the same point
@@ -178,26 +178,26 @@ void AudioPannerNode::getAzimuthElevation(double* outAzimuth, double* outElevati
sourceListener.normalize();
// Align axes
- Vector3 listenerFront = listener()->orientation();
- Vector3 listenerUp = listener()->upVector();
- Vector3 listenerRight = cross(listenerFront, listenerUp);
+ FloatPoint3D listenerFront = listener()->orientation();
+ FloatPoint3D listenerUp = listener()->upVector();
+ FloatPoint3D listenerRight = listenerFront.cross(listenerUp);
listenerRight.normalize();
- Vector3 listenerFrontNorm = listenerFront;
+ FloatPoint3D listenerFrontNorm = listenerFront;
listenerFrontNorm.normalize();
- Vector3 up = cross(listenerRight, listenerFrontNorm);
+ FloatPoint3D up = listenerRight.cross(listenerFrontNorm);
- double upProjection = dot(sourceListener, up);
+ double upProjection = sourceListener.dot(up);
- Vector3 projectedSource = sourceListener - upProjection * up;
+ FloatPoint3D projectedSource = sourceListener - upProjection * up;
projectedSource.normalize();
- azimuth = 180.0 * acos(dot(projectedSource, listenerRight)) / M_PI;
+ azimuth = 180.0 * acos(projectedSource.dot(listenerRight)) / M_PI;
fixNANs(azimuth); // avoid illegal values
// Source in front or behind the listener
- double frontBack = dot(projectedSource, listenerFrontNorm);
+ double frontBack = projectedSource.dot(listenerFrontNorm);
if (frontBack < 0.0)
azimuth = 360.0 - azimuth;
@@ -208,7 +208,7 @@ void AudioPannerNode::getAzimuthElevation(double* outAzimuth, double* outElevati
azimuth = 450.0 - azimuth;
// Elevation
- double elevation = 90.0 - 180.0 * acos(dot(sourceListener, up)) / M_PI;
+ double elevation = 90.0 - 180.0 * acos(sourceListener.dot(up)) / M_PI;
fixNANs(azimuth); // avoid illegal values
if (elevation > 90.0)
@@ -232,8 +232,8 @@ float AudioPannerNode::dopplerRate()
if (dopplerFactor > 0.0) {
double speedOfSound = listener()->speedOfSound();
- const Vector3 &sourceVelocity = m_velocity;
- const Vector3 &listenerVelocity = listener()->velocity();
+ const FloatPoint3D &sourceVelocity = m_velocity;
+ const FloatPoint3D &listenerVelocity = listener()->velocity();
// Don't bother if both source and listener have no velocity
bool sourceHasVelocity = !sourceVelocity.isZero();
@@ -241,13 +241,13 @@ float AudioPannerNode::dopplerRate()
if (sourceHasVelocity || listenerHasVelocity) {
// Calculate the source to listener vector
- Vector3 listenerPosition = listener()->position();
- Vector3 sourceToListener = m_position - listenerPosition;
+ FloatPoint3D listenerPosition = listener()->position();
+ FloatPoint3D sourceToListener = m_position - listenerPosition;
- double sourceListenerMagnitude = sourceToListener.abs();
+ double sourceListenerMagnitude = sourceToListener.length();
- double listenerProjection = dot(sourceToListener, listenerVelocity) / sourceListenerMagnitude;
- double sourceProjection = dot(sourceToListener, sourceVelocity) / sourceListenerMagnitude;
+ double listenerProjection = sourceToListener.dot(listenerVelocity) / sourceListenerMagnitude;
+ double sourceProjection = sourceToListener.dot(sourceVelocity) / sourceListenerMagnitude;
listenerProjection = -listenerProjection;
sourceProjection = -sourceProjection;
@@ -272,9 +272,9 @@ float AudioPannerNode::dopplerRate()
float AudioPannerNode::distanceConeGain()
{
- Vector3 listenerPosition = listener()->position();
+ FloatPoint3D listenerPosition = listener()->position();
- double listenerDistance = distance(m_position, listenerPosition);
+ double listenerDistance = m_position.distanceTo(listenerPosition);
double distanceGain = m_distanceEffect.gain(listenerDistance);
m_distanceGain->setValue(static_cast<float>(distanceGain));
diff --git a/WebCore/webaudio/AudioPannerNode.h b/WebCore/webaudio/AudioPannerNode.h
index 4d49bc8..61e34a9 100644
--- a/WebCore/webaudio/AudioPannerNode.h
+++ b/WebCore/webaudio/AudioPannerNode.h
@@ -31,9 +31,9 @@
#include "AudioNode.h"
#include "Cone.h"
#include "Distance.h"
+#include "FloatPoint3D.h"
#include "Panner.h"
#include <wtf/OwnPtr.h>
-#include <wtf/Vector3.h>
namespace WebCore {
@@ -75,16 +75,16 @@ public:
void setPanningModel(unsigned short);
// Position
- Vector3 position() const { return m_position; }
- void setPosition(float x, float y, float z) { m_position = Vector3(x, y, z); }
+ FloatPoint3D position() const { return m_position; }
+ void setPosition(float x, float y, float z) { m_position = FloatPoint3D(x, y, z); }
// Orientation
- Vector3 orientation() const { return m_position; }
- void setOrientation(float x, float y, float z) { m_orientation = Vector3(x, y, z); }
+ FloatPoint3D orientation() const { return m_position; }
+ void setOrientation(float x, float y, float z) { m_orientation = FloatPoint3D(x, y, z); }
// Velocity
- Vector3 velocity() const { return m_velocity; }
- void setVelocity(float x, float y, float z) { m_velocity = Vector3(x, y, z); }
+ FloatPoint3D velocity() const { return m_velocity; }
+ void setVelocity(float x, float y, float z) { m_velocity = FloatPoint3D(x, y, z); }
// Distance parameters
unsigned short distanceModel() { return m_distanceEffect.model(); }
@@ -129,10 +129,9 @@ private:
OwnPtr<Panner> m_panner;
unsigned m_panningModel;
- // FIXME: upgrade to FloatPoint3D from Vector3.
- Vector3 m_position;
- Vector3 m_orientation;
- Vector3 m_velocity;
+ FloatPoint3D m_position;
+ FloatPoint3D m_orientation;
+ FloatPoint3D m_velocity;
// Gain
RefPtr<AudioGain> m_distanceGain;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list