Diff
Modified: trunk/Source/WTF/ChangeLog (149969 => 149970)
--- trunk/Source/WTF/ChangeLog 2013-05-12 18:46:37 UTC (rev 149969)
+++ trunk/Source/WTF/ChangeLog 2013-05-12 21:27:43 UTC (rev 149970)
@@ -1,3 +1,21 @@
+2013-05-12 Anders Carlsson <[email protected]>
+
+ Remove Complex.h from WTF
+ https://bugs.webkit.org/show_bug.cgi?id=115989
+
+ Reviewed by Beth Dakin.
+
+ Complex.h contains a typedef and a single function (that already has an equivalent in the STL).
+ The header is used by three files in WebCore, so just use std::complex<double> and std::polar directly.
+
+ * GNUmakefile.list.am:
+ * WTF.vcproj/WTF.vcproj:
+ * WTF.vcxproj/WTF.vcxproj:
+ * WTF.vcxproj/WTF.vcxproj.filters:
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/CMakeLists.txt:
+ * wtf/Complex.h: Removed.
+
2013-05-11 Martin Robinson <[email protected]>
[GTK] Add a basic cmake build for WTF and _javascript_Core
Modified: trunk/Source/WTF/GNUmakefile.list.am (149969 => 149970)
--- trunk/Source/WTF/GNUmakefile.list.am 2013-05-12 18:46:37 UTC (rev 149969)
+++ trunk/Source/WTF/GNUmakefile.list.am 2013-05-12 21:27:43 UTC (rev 149970)
@@ -26,7 +26,6 @@
Source/WTF/wtf/CheckedBoolean.h \
Source/WTF/wtf/CommaPrinter.h \
Source/WTF/wtf/Compiler.h \
- Source/WTF/wtf/Complex.h \
Source/WTF/wtf/CryptographicallyRandomNumber.cpp \
Source/WTF/wtf/CryptographicallyRandomNumber.h \
Source/WTF/wtf/CurrentTime.cpp \
Modified: trunk/Source/WTF/WTF.vcproj/WTF.vcproj (149969 => 149970)
--- trunk/Source/WTF/WTF.vcproj/WTF.vcproj 2013-05-12 18:46:37 UTC (rev 149969)
+++ trunk/Source/WTF/WTF.vcproj/WTF.vcproj 2013-05-12 21:27:43 UTC (rev 149970)
@@ -663,10 +663,6 @@
>
</File>
<File
- RelativePath="..\wtf\Complex.h"
- >
- </File>
- <File
RelativePath="..\wtf\CryptographicallyRandomNumber.cpp"
>
</File>
Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj (149969 => 149970)
--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj 2013-05-12 18:46:37 UTC (rev 149969)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj 2013-05-12 21:27:43 UTC (rev 149970)
@@ -111,7 +111,6 @@
<ClInclude Include="..\wtf\CheckedArithmetic.h" />
<ClInclude Include="..\wtf\CheckedBoolean.h" />
<ClInclude Include="..\wtf\Compiler.h" />
- <ClInclude Include="..\wtf\Complex.h" />
<ClInclude Include="..\wtf\CryptographicallyRandomNumber.h" />
<ClInclude Include="..\wtf\CurrentTime.h" />
<ClInclude Include="..\wtf\DataLog.h" />
Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters (149969 => 149970)
--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters 2013-05-12 18:46:37 UTC (rev 149969)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters 2013-05-12 21:27:43 UTC (rev 149970)
@@ -372,9 +372,6 @@
<ClInclude Include="..\wtf\Compiler.h">
<Filter>wtf</Filter>
</ClInclude>
- <ClInclude Include="..\wtf\Complex.h">
- <Filter>wtf</Filter>
- </ClInclude>
<ClInclude Include="..\wtf\CryptographicallyRandomNumber.h">
<Filter>wtf</Filter>
</ClInclude>
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (149969 => 149970)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2013-05-12 18:46:37 UTC (rev 149969)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2013-05-12 21:27:43 UTC (rev 149970)
@@ -75,7 +75,6 @@
A8A47394151A825B004123FF /* CheckedArithmetic.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4726A151A825A004123FF /* CheckedArithmetic.h */; };
A8A47395151A825B004123FF /* CheckedBoolean.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4726B151A825A004123FF /* CheckedBoolean.h */; };
A8A47398151A825B004123FF /* Compiler.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47270151A825A004123FF /* Compiler.h */; };
- A8A47399151A825B004123FF /* Complex.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47271151A825A004123FF /* Complex.h */; };
A8A4739A151A825B004123FF /* CryptographicallyRandomNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A47273151A825A004123FF /* CryptographicallyRandomNumber.cpp */; };
A8A4739B151A825B004123FF /* CryptographicallyRandomNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47274151A825A004123FF /* CryptographicallyRandomNumber.h */; };
A8A4739C151A825B004123FF /* CurrentTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A47275151A825A004123FF /* CurrentTime.cpp */; };
@@ -345,7 +344,6 @@
A8A4726A151A825A004123FF /* CheckedArithmetic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CheckedArithmetic.h; sourceTree = "<group>"; };
A8A4726B151A825A004123FF /* CheckedBoolean.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CheckedBoolean.h; sourceTree = "<group>"; };
A8A47270151A825A004123FF /* Compiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Compiler.h; sourceTree = "<group>"; };
- A8A47271151A825A004123FF /* Complex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Complex.h; sourceTree = "<group>"; };
A8A47273151A825A004123FF /* CryptographicallyRandomNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptographicallyRandomNumber.cpp; sourceTree = "<group>"; };
A8A47274151A825A004123FF /* CryptographicallyRandomNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptographicallyRandomNumber.h; sourceTree = "<group>"; };
A8A47275151A825A004123FF /* CurrentTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CurrentTime.cpp; sourceTree = "<group>"; };
@@ -629,7 +627,6 @@
A8A4726B151A825A004123FF /* CheckedBoolean.h */,
0FC4EDE51696149600F65041 /* CommaPrinter.h */,
A8A47270151A825A004123FF /* Compiler.h */,
- A8A47271151A825A004123FF /* Complex.h */,
A8A47273151A825A004123FF /* CryptographicallyRandomNumber.cpp */,
A8A47274151A825A004123FF /* CryptographicallyRandomNumber.h */,
A8A47275151A825A004123FF /* CurrentTime.cpp */,
@@ -944,7 +941,6 @@
A8A4745F151A825B004123FF /* Collator.h in Headers */,
0FC4EDE61696149600F65041 /* CommaPrinter.h in Headers */,
A8A47398151A825B004123FF /* Compiler.h in Headers */,
- A8A47399151A825B004123FF /* Complex.h in Headers */,
A8A4748C151A8264004123FF /* config.h in Headers */,
A8A4739B151A825B004123FF /* CryptographicallyRandomNumber.h in Headers */,
A8A4743A151A825B004123FF /* CString.h in Headers */,
Modified: trunk/Source/WTF/wtf/CMakeLists.txt (149969 => 149970)
--- trunk/Source/WTF/wtf/CMakeLists.txt 2013-05-12 18:46:37 UTC (rev 149969)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2013-05-12 21:27:43 UTC (rev 149970)
@@ -11,7 +11,6 @@
BumpPointerAllocator.h
ByteOrder.h
Compiler.h
- Complex.h
CryptographicallyRandomNumber.h
CurrentTime.h
DateMath.h
Deleted: trunk/Source/WTF/wtf/Complex.h (149969 => 149970)
--- trunk/Source/WTF/wtf/Complex.h 2013-05-12 18:46:37 UTC (rev 149969)
+++ trunk/Source/WTF/wtf/Complex.h 2013-05-12 21:27:43 UTC (rev 149970)
@@ -1,49 +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_Complex_h
-#define WTF_Complex_h
-
-#include <complex>
-#include <wtf/MathExtras.h>
-
-namespace WTF {
-
-typedef std::complex<double> Complex;
-
-inline Complex complexFromMagnitudePhase(double magnitude, double phase)
-{
- return Complex(magnitude * cos(phase), magnitude * sin(phase));
-}
-
-} // namespace WTF
-
-using WTF::Complex;
-using WTF::complexFromMagnitudePhase;
-
-#endif // WTF_Complex_h
Modified: trunk/Source/WebCore/ChangeLog (149969 => 149970)
--- trunk/Source/WebCore/ChangeLog 2013-05-12 18:46:37 UTC (rev 149969)
+++ trunk/Source/WebCore/ChangeLog 2013-05-12 21:27:43 UTC (rev 149970)
@@ -1,3 +1,28 @@
+2013-05-12 Anders Carlsson <[email protected]>
+
+ Remove Complex.h from WTF
+ https://bugs.webkit.org/show_bug.cgi?id=115989
+
+ Reviewed by Beth Dakin.
+
+ Replace Complex declarations with std::complex<double>. Pass by value since the struct
+ is small enough to go into two registers on X86-64.
+
+ * Modules/webaudio/RealtimeAnalyser.cpp:
+ (WebCore::RealtimeAnalyser::doFFTAnalysis):
+ (WebCore::RealtimeAnalyser::getFloatFrequencyData):
+ (WebCore::RealtimeAnalyser::getByteFrequencyData):
+ (WebCore::RealtimeAnalyser::getByteTimeDomainData):
+ * platform/audio/Biquad.cpp:
+ (WebCore::Biquad::setZeroPolePairs):
+ (WebCore::Biquad::setAllpassPole):
+ (WebCore::Biquad::getFrequencyResponse):
+ * platform/audio/Biquad.h:
+ * platform/audio/FFTFrame.cpp:
+ (WebCore::FFTFrame::interpolateFrequencyComponents):
+ (WebCore::FFTFrame::extractAverageGroupDelay):
+ (WebCore::FFTFrame::addConstantGroupDelay):
+
2013-05-12 Simon Fraser <[email protected]>
Dropdowns on http://www.exploratorium.edu don't show anything
Modified: trunk/Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp (149969 => 149970)
--- trunk/Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp 2013-05-12 18:46:37 UTC (rev 149969)
+++ trunk/Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp 2013-05-12 21:27:43 UTC (rev 149970)
@@ -32,17 +32,13 @@
#include "AudioUtilities.h"
#include "FFTFrame.h"
#include "VectorMath.h"
-
#include <algorithm>
-#include <limits.h>
-#include <wtf/Complex.h>
+#include <complex>
#include <wtf/Float32Array.h>
#include <wtf/MainThread.h>
#include <wtf/MathExtras.h>
#include <wtf/Uint8Array.h>
-using namespace std;
-
namespace WebCore {
const double RealtimeAnalyser::DefaultSmoothingTimeConstant = 0.8;
@@ -193,16 +189,16 @@
// A value of 0 does no averaging with the previous result. Larger values produce slower, but smoother changes.
double k = m_smoothingTimeConstant;
- k = max(0.0, k);
- k = min(1.0, k);
+ k = std::max(0.0, k);
+ k = std::min(1.0, k);
// Convert the analysis data from complex to magnitude and average with the previous result.
float* destination = magnitudeBuffer().data();
size_t n = magnitudeBuffer().size();
for (size_t i = 0; i < n; ++i) {
- Complex c(realP[i], imagP[i]);
+ std::complex<double> c(realP[i], imagP[i]);
double scalarMagnitude = abs(c) * magnitudeScale;
- destination[i] = float(k * destination[i] + (1 - k) * scalarMagnitude);
+ destination[i] = static_cast<float>(k * destination[i] + (1 - k) * scalarMagnitude);
}
}
@@ -218,7 +214,7 @@
// Convert from linear magnitude to floating-point decibels.
const double minDecibels = m_minDecibels;
unsigned sourceLength = magnitudeBuffer().size();
- size_t len = min(sourceLength, destinationArray->length());
+ size_t len = std::min(sourceLength, destinationArray->length());
if (len > 0) {
const float* source = magnitudeBuffer().data();
float* destination = destinationArray->data();
@@ -226,7 +222,7 @@
for (unsigned i = 0; i < len; ++i) {
float linearValue = source[i];
double dbMag = !linearValue ? minDecibels : AudioUtilities::linearToDecibels(linearValue);
- destination[i] = float(dbMag);
+ destination[i] = static_cast<float>(dbMag);
}
}
}
@@ -242,7 +238,7 @@
// Convert from linear magnitude to unsigned-byte decibels.
unsigned sourceLength = magnitudeBuffer().size();
- size_t len = min(sourceLength, destinationArray->length());
+ size_t len = std::min(sourceLength, destinationArray->length());
if (len > 0) {
const double rangeScaleFactor = m_maxDecibels == m_minDecibels ? 1 : 1 / (m_maxDecibels - m_minDecibels);
const double minDecibels = m_minDecibels;
@@ -276,7 +272,7 @@
return;
unsigned fftSize = this->fftSize();
- size_t len = min(fftSize, destinationArray->length());
+ size_t len = std::min(fftSize, destinationArray->length());
if (len > 0) {
bool isInputBufferGood = m_inputBuffer.size() == InputBufferSize && m_inputBuffer.size() > fftSize;
ASSERT(isInputBufferGood);
Modified: trunk/Source/WebCore/platform/audio/Biquad.cpp (149969 => 149970)
--- trunk/Source/WebCore/platform/audio/Biquad.cpp 2013-05-12 18:46:37 UTC (rev 149969)
+++ trunk/Source/WebCore/platform/audio/Biquad.cpp 2013-05-12 21:27:43 UTC (rev 149970)
@@ -38,6 +38,8 @@
#include <wtf/MathExtras.h>
#if OS(DARWIN)
+// Work around a bug where VForce.h forward declares std::complex in a way that's incompatible with libc++ complex.
+#define __VFORCE_H
#include <Accelerate/Accelerate.h>
#endif
@@ -522,7 +524,7 @@
}
}
-void Biquad::setZeroPolePairs(const Complex &zero, const Complex &pole)
+void Biquad::setZeroPolePairs(std::complex<double> zero, std::complex<double> pole)
{
double b0 = 1;
double b1 = -2 * zero.real();
@@ -537,9 +539,9 @@
setNormalizedCoefficients(b0, b1, b2, 1, a1, a2);
}
-void Biquad::setAllpassPole(const Complex &pole)
+void Biquad::setAllpassPole(std::complex<double> pole)
{
- Complex zero = Complex(1, 0) / pole;
+ std::complex<double> zero = std::complex<double>(1, 0) / pole;
setZeroPolePairs(zero, pole);
}
@@ -573,10 +575,10 @@
for (int k = 0; k < nFrequencies; ++k) {
double omega = -piDouble * frequency[k];
- Complex z = Complex(cos(omega), sin(omega));
- Complex numerator = b0 + (b1 + b2 * z) * z;
- Complex denominator = Complex(1, 0) + (a1 + a2 * z) * z;
- Complex response = numerator / denominator;
+ std::complex<double> z = std::complex<double>(cos(omega), sin(omega));
+ std::complex<double> numerator = b0 + (b1 + b2 * z) * z;
+ std::complex<double> denominator = std::complex<double>(1, 0) + (a1 + a2 * z) * z;
+ std::complex<double> response = numerator / denominator;
magResponse[k] = static_cast<float>(abs(response));
phaseResponse[k] = static_cast<float>(atan2(imag(response), real(response)));
}
Modified: trunk/Source/WebCore/platform/audio/Biquad.h (149969 => 149970)
--- trunk/Source/WebCore/platform/audio/Biquad.h 2013-05-12 18:46:37 UTC (rev 149969)
+++ trunk/Source/WebCore/platform/audio/Biquad.h 2013-05-12 21:27:43 UTC (rev 149970)
@@ -30,8 +30,8 @@
#define Biquad_h
#include "AudioArray.h"
+#include <complex>
#include <sys/types.h>
-#include <wtf/Complex.h>
#if USE(WEBAUDIO_IPP)
#include <ipps.h>
@@ -64,11 +64,11 @@
// Set the biquad coefficients given a single zero (other zero will be conjugate)
// and a single pole (other pole will be conjugate)
- void setZeroPolePairs(const Complex& zero, const Complex& pole);
+ void setZeroPolePairs(std::complex<double> zero, std::complex<double> pole);
// Set the biquad coefficients given a single pole (other pole will be conjugate)
// (The zeroes will be the inverse of the poles)
- void setAllpassPole(const Complex& pole);
+ void setAllpassPole(std::complex<double>);
// Resets filter state
void reset();
Modified: trunk/Source/WebCore/platform/audio/FFTFrame.cpp (149969 => 149970)
--- trunk/Source/WebCore/platform/audio/FFTFrame.cpp 2013-05-12 18:46:37 UTC (rev 149969)
+++ trunk/Source/WebCore/platform/audio/FFTFrame.cpp 2013-05-12 21:27:43 UTC (rev 149970)
@@ -32,15 +32,15 @@
#include "FFTFrame.h"
+#include "Logging.h"
+#include <complex>
+#include <wtf/MathExtras.h>
+#include <wtf/OwnPtr.h>
+
#ifndef NDEBUG
#include <stdio.h>
#endif
-#include "Logging.h"
-#include <wtf/Complex.h>
-#include <wtf/MathExtras.h>
-#include <wtf/OwnPtr.h>
-
namespace WebCore {
void FFTFrame::doPaddedFFT(const float* data, size_t dataSize)
@@ -99,8 +99,8 @@
int n = m_FFTSize / 2;
for (int i = 1; i < n; ++i) {
- Complex c1(realP1[i], imagP1[i]);
- Complex c2(realP2[i], imagP2[i]);
+ std::complex<double> c1(realP1[i], imagP1[i]);
+ std::complex<double> c2(realP2[i], imagP2[i]);
double mag1 = abs(c1);
double mag2 = abs(c2);
@@ -166,7 +166,7 @@
if (phaseAccum < -piDouble)
phaseAccum += 2.0 * piDouble;
- Complex c = complexFromMagnitudePhase(mag, phaseAccum);
+ std::complex<double> c = std::polar(mag, phaseAccum);
realP[i] = static_cast<float>(c.real());
imagP[i] = static_cast<float>(c.imag());
@@ -188,7 +188,7 @@
// Calculate weighted average group delay
for (int i = 0; i < halfSize; i++) {
- Complex c(realP[i], imagP[i]);
+ std::complex<double> c(realP[i], imagP[i]);
double mag = abs(c);
double phase = arg(c);
@@ -235,13 +235,13 @@
// Add constant group delay
for (int i = 1; i < halfSize; i++) {
- Complex c(realP[i], imagP[i]);
+ std::complex<double> c(realP[i], imagP[i]);
double mag = abs(c);
double phase = arg(c);
phase += i * phaseAdj;
- Complex c2 = complexFromMagnitudePhase(mag, phase);
+ std::complex<double> c2 = std::polar(mag, phase);
realP[i] = static_cast<float>(c2.real());
imagP[i] = static_cast<float>(c2.imag());