Skip to content

Commit

Permalink
Merge r155198 - Stop using fastNew/fastDelete in WebCore
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=120867

Reviewed by Geoffrey Garen.

Using fastNew/fastDelete can be dangerous, especially when put into a smart pointer
such as OwnPtr which uses regular delete. Because of this I'd like to remove fastNew/fastDelete.
Turns out it's only used in a couple of places in WebCore, so just use new/delete here instead.

* platform/audio/FFTFrame.h:
* platform/audio/gstreamer/FFTFrameGStreamer.cpp:
(WebCore::FFTFrame::FFTFrame):
(WebCore::FFTFrame::~FFTFrame):
(WebCore::FFTFrame::doFFT):
(WebCore::FFTFrame::doInverseFFT):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
(WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
* platform/graphics/gstreamer/VideoSinkGStreamer.cpp:
(webkitVideoSinkDispose):
  • Loading branch information
Anders Carlsson authored and carlosgcampos committed Sep 10, 2013
1 parent 787e8b1 commit c731240
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
23 changes: 23 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,26 @@
2013-09-06 Anders Carlsson <andersca@apple.com>

Stop using fastNew/fastDelete in WebCore
https://bugs.webkit.org/show_bug.cgi?id=120867

Reviewed by Geoffrey Garen.

Using fastNew/fastDelete can be dangerous, especially when put into a smart pointer
such as OwnPtr which uses regular delete. Because of this I'd like to remove fastNew/fastDelete.
Turns out it's only used in a couple of places in WebCore, so just use new/delete here instead.

* platform/audio/FFTFrame.h:
* platform/audio/gstreamer/FFTFrameGStreamer.cpp:
(WebCore::FFTFrame::FFTFrame):
(WebCore::FFTFrame::~FFTFrame):
(WebCore::FFTFrame::doFFT):
(WebCore::FFTFrame::doInverseFFT):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
(WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
* platform/graphics/gstreamer/VideoSinkGStreamer.cpp:
(webkitVideoSinkDispose):

2013-09-09 Claudio Saavedra <csaavedra@igalia.com>

[GTK] ghost cursor when mouse hovers over an image file in a tab
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/platform/audio/FFTFrame.h
Expand Up @@ -68,6 +68,7 @@ struct RDFTContext;
#endif // USE(WEBAUDIO_IPP)

#include <wtf/Forward.h>
#include <wtf/PassOwnArrayPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/Threading.h>

Expand Down Expand Up @@ -163,7 +164,7 @@ class FFTFrame {
#if USE(WEBAUDIO_GSTREAMER)
GstFFTF32* m_fft;
GstFFTF32* m_inverseFft;
GstFFTF32Complex* m_complexData;
OwnArrayPtr<GstFFTF32Complex> m_complexData;
AudioFloatArray m_realData;
AudioFloatArray m_imagData;
#endif // USE(WEBAUDIO_GSTREAMER)
Expand Down
13 changes: 4 additions & 9 deletions Source/WebCore/platform/audio/gstreamer/FFTFrameGStreamer.cpp
Expand Up @@ -42,11 +42,10 @@ namespace WebCore {
FFTFrame::FFTFrame(unsigned fftSize)
: m_FFTSize(fftSize)
, m_log2FFTSize(static_cast<unsigned>(log2(fftSize)))
, m_complexData(adoptArrayPtr(new GstFFTF32Complex[unpackedFFTDataSize(m_FFTSize)]))
, m_realData(unpackedFFTDataSize(m_FFTSize))
, m_imagData(unpackedFFTDataSize(m_FFTSize))
{
m_complexData = WTF::fastNewArray<GstFFTF32Complex>(unpackedFFTDataSize(m_FFTSize));

int fftLength = gst_fft_next_fast_length(m_FFTSize);
m_fft = gst_fft_f32_new(fftLength, FALSE);
m_inverseFft = gst_fft_f32_new(fftLength, TRUE);
Expand All @@ -56,7 +55,6 @@ FFTFrame::FFTFrame(unsigned fftSize)
FFTFrame::FFTFrame()
: m_FFTSize(0)
, m_log2FFTSize(0)
, m_complexData(0)
{
int fftLength = gst_fft_next_fast_length(m_FFTSize);
m_fft = gst_fft_f32_new(fftLength, FALSE);
Expand All @@ -67,11 +65,10 @@ FFTFrame::FFTFrame()
FFTFrame::FFTFrame(const FFTFrame& frame)
: m_FFTSize(frame.m_FFTSize)
, m_log2FFTSize(frame.m_log2FFTSize)
, m_complexData(adoptArrayPtr(new GstFFTF32Complex[unpackedFFTDataSize(m_FFTSize)]))
, m_realData(unpackedFFTDataSize(frame.m_FFTSize))
, m_imagData(unpackedFFTDataSize(frame.m_FFTSize))
{
m_complexData = WTF::fastNewArray<GstFFTF32Complex>(unpackedFFTDataSize(m_FFTSize));

int fftLength = gst_fft_next_fast_length(m_FFTSize);
m_fft = gst_fft_f32_new(fftLength, FALSE);
m_inverseFft = gst_fft_f32_new(fftLength, TRUE);
Expand Down Expand Up @@ -99,8 +96,6 @@ FFTFrame::~FFTFrame()

gst_fft_f32_free(m_inverseFft);
m_inverseFft = 0;

WTF::fastDeleteArray(m_complexData);
}

void FFTFrame::multiply(const FFTFrame& frame)
Expand Down Expand Up @@ -128,7 +123,7 @@ void FFTFrame::multiply(const FFTFrame& frame)

void FFTFrame::doFFT(const float* data)
{
gst_fft_f32_fft(m_fft, data, m_complexData);
gst_fft_f32_fft(m_fft, data, m_complexData.get());

// Scale the frequency domain data to match vecLib's scale factor
// on the Mac. FIXME: if we change the definition of FFTFrame to
Expand Down Expand Up @@ -156,7 +151,7 @@ void FFTFrame::doInverseFFT(float* data)
m_complexData[i].r = realData[i];
}

gst_fft_f32_inverse_fft(m_inverseFft, m_complexData, data);
gst_fft_f32_inverse_fft(m_inverseFft, m_complexData.get(), data);

// Scale so that a forward then inverse FFT yields exactly the original data.
const float scaleFactor = 1.0 / (2 * m_FFTSize);
Expand Down
Expand Up @@ -118,7 +118,7 @@ MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase(MediaPlayer* pl
, m_muteSignalHandler(0)
{
#if GLIB_CHECK_VERSION(2, 31, 0)
m_bufferMutex = WTF::fastNew<GMutex>();
m_bufferMutex = new GMutex;
g_mutex_init(m_bufferMutex);
#else
m_bufferMutex = g_mutex_new();
Expand All @@ -131,7 +131,7 @@ MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase()

#if GLIB_CHECK_VERSION(2, 31, 0)
g_mutex_clear(m_bufferMutex);
WTF::fastDelete(m_bufferMutex);
delete m_bufferMutex;
#else
g_mutex_free(m_bufferMutex);
#endif
Expand Down
Expand Up @@ -38,7 +38,7 @@
#include <gst/video/gstvideometa.h>
#include <gst/video/gstvideopool.h>
#endif
#include <wtf/FastAllocBase.h>
#include <wtf/OwnPtr.h>

// CAIRO_FORMAT_RGB24 used to render the video buffers is little/big endian dependant.
#ifdef GST_API_VERSION_1
Expand Down Expand Up @@ -117,9 +117,9 @@ static void webkit_video_sink_init(WebKitVideoSink* sink)
{
sink->priv = G_TYPE_INSTANCE_GET_PRIVATE(sink, WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSinkPrivate);
#if GLIB_CHECK_VERSION(2, 31, 0)
sink->priv->dataCondition = WTF::fastNew<GCond>();
sink->priv->dataCondition = new GCond;
g_cond_init(sink->priv->dataCondition);
sink->priv->bufferMutex = WTF::fastNew<GMutex>();
sink->priv->bufferMutex = new GMutex;
g_mutex_init(sink->priv->bufferMutex);
#else
sink->priv->dataCondition = g_cond_new();
Expand Down Expand Up @@ -279,7 +279,7 @@ static void webkitVideoSinkDispose(GObject* object)
if (priv->dataCondition) {
#if GLIB_CHECK_VERSION(2, 31, 0)
g_cond_clear(priv->dataCondition);
WTF::fastDelete(priv->dataCondition);
delete priv->dataCondition;
#else
g_cond_free(priv->dataCondition);
#endif
Expand All @@ -289,7 +289,7 @@ static void webkitVideoSinkDispose(GObject* object)
if (priv->bufferMutex) {
#if GLIB_CHECK_VERSION(2, 31, 0)
g_mutex_clear(priv->bufferMutex);
WTF::fastDelete(priv->bufferMutex);
delete priv->bufferMutex;
#else
g_mutex_free(priv->bufferMutex);
#endif
Expand Down

0 comments on commit c731240

Please sign in to comment.