Skip to content
Permalink
Browse files

Bug 1116905 - part 1 - remove dependence on implicit conversion from …

…T* to TemporaryRef<T>, non-gfx changes;
  • Loading branch information...
rmottola committed Jan 1, 2019
1 parent f71d3ff commit f667149556ae0e64c9dbce08836bb5d957db2464
@@ -391,7 +391,8 @@ ImageEncoder::ExtractDataInternal(const nsAString& aType,
aOptions);
} else {
RefPtr<gfx::DataSourceSurface> dataSurface;
dataSurface = GetBRGADataSourceSurfaceSync(aImage);
RefPtr<layers::Image> image(aImage);
dataSurface = GetBRGADataSourceSurfaceSync(image.forget());

DataSourceSurface::MappedSurface map;
if (!dataSurface->Map(gfx::DataSourceSurface::MapType::READ, &map)) {
@@ -4179,14 +4179,16 @@ ExtractSubrect(SourceSurface* aSurface, mgfx::Rect* aSourceRect, DrawTarget* aTa
roundedOutSourceRect.RoundOut();
mgfx::IntRect roundedOutSourceRectInt;
if (!roundedOutSourceRect.ToIntRect(&roundedOutSourceRectInt)) {
return aSurface;
RefPtr<SourceSurface> surface(aSurface);
return surface.forget();
}

RefPtr<DrawTarget> subrectDT =
aTargetDT->CreateSimilarDrawTarget(roundedOutSourceRectInt.Size(), SurfaceFormat::B8G8R8A8);

if (!subrectDT) {
return aSurface;
RefPtr<SourceSurface> surface(aSurface);
return surface.forget();
}

*aSourceRect -= roundedOutSourceRect.TopLeft();
@@ -47,7 +47,8 @@ AudioSink::OnAudioEndTimeUpdateTask::Dispatch(int64_t aEndTime) {
MutexAutoLock lock(mMutex);
if (mStateMachine) {
mEndTime = aEndTime;
mStateMachine->TaskQueue()->Dispatch(this);
nsRefPtr<AudioSink::OnAudioEndTimeUpdateTask> runnable(this);
mStateMachine->TaskQueue()->Dispatch(runnable.forget());
}
}

@@ -185,7 +185,9 @@ class MediaDecoderStateMachine

void DispatchShutdown()
{
TaskQueue()->Dispatch(NS_NewRunnableMethod(this, &MediaDecoderStateMachine::Shutdown));
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::Shutdown);
TaskQueue()->Dispatch(runnable.forget());
}

void ShutdownReader();
@@ -241,7 +243,9 @@ class MediaDecoderStateMachine

void DispatchStartBuffering()
{
TaskQueue()->Dispatch(NS_NewRunnableMethod(this, &MediaDecoderStateMachine::StartBuffering));
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::StartBuffering);
TaskQueue()->Dispatch(runnable.forget());
}

// This is called on the state machine thread and audio thread.
@@ -737,15 +741,19 @@ class MediaDecoderStateMachine
public:
void DispatchOnAudioSinkComplete()
{
TaskQueue()->Dispatch(NS_NewRunnableMethod(this, &MediaDecoderStateMachine::OnAudioSinkComplete));
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::OnAudioSinkComplete);
TaskQueue()->Dispatch(runnable.forget());
}

// Called by the AudioSink to signal errors.
void OnAudioSinkError();

void DispatchOnAudioSinkError()
{
TaskQueue()->Dispatch(NS_NewRunnableMethod(this, &MediaDecoderStateMachine::OnAudioSinkError));
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::OnAudioSinkError);
TaskQueue()->Dispatch(runnable.forget());
}

// Return true if the video decoder's decode speed can not catch up the
@@ -76,11 +76,12 @@ AppleATDecoder::Input(MediaRawData* aSample)
(unsigned long long)aSample->Size());

// Queue a task to perform the actual decoding on a separate thread.
mTaskQueue->Dispatch(
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethodWithArg<nsRefPtr<MediaRawData>>(
this,
&AppleATDecoder::SubmitSample,
nsRefPtr<MediaRawData>(aSample)));
nsRefPtr<MediaRawData>(aSample));
mTaskQueue->Dispatch(runnable.forget());

return NS_OK;
}
@@ -106,11 +106,12 @@ AppleVDADecoder::Input(MediaRawData* aSample)
aSample->mKeyframe ? " keyframe" : "",
aSample->Size());

mTaskQueue->Dispatch(
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethodWithArg<nsRefPtr<MediaRawData>>(
this,
&AppleVDADecoder::SubmitFrame,
nsRefPtr<MediaRawData>(aSample)));
nsRefPtr<MediaRawData>(aSample));
mTaskQueue->Dispatch(runnable.forget());
return NS_OK;
}

@@ -100,11 +100,12 @@ AppleVTDecoder::Input(MediaRawData* aSample)
LOG(" sha1 %s", digest.get());
#endif // LOG_MEDIA_SHA1

mTaskQueue->Dispatch(
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethodWithArg<nsRefPtr<MediaRawData>>(
this,
&AppleVTDecoder::SubmitFrame,
nsRefPtr<MediaRawData>(aSample)));
nsRefPtr<MediaRawData>(aSample));
mTaskQueue->Dispatch(runnable.forget());
return NS_OK;
}

@@ -164,9 +164,9 @@ FFmpegAudioDecoder<LIBAV_VER>::DecodePacket(MediaRawData* aSample)
nsresult
FFmpegAudioDecoder<LIBAV_VER>::Input(MediaRawData* aSample)
{
mTaskQueue->Dispatch(NS_NewRunnableMethodWithArg<nsRefPtr<MediaRawData> >(
nsCOMPtr<nsIRunnable> runnable(NS_NewRunnableMethodWithArg<nsRefPtr<MediaRawData>>(
this, &FFmpegAudioDecoder::DecodePacket, nsRefPtr<MediaRawData>(aSample)));

mTaskQueue->Dispatch(runnable.forget());
return NS_OK;
}

@@ -328,10 +328,11 @@ FFmpegH264Decoder<LIBAV_VER>::DecodeFrame(MediaRawData* aSample)
nsresult
FFmpegH264Decoder<LIBAV_VER>::Input(MediaRawData* aSample)
{
mTaskQueue->Dispatch(
nsCOMPtr<nsIRunnable> runnable(
NS_NewRunnableMethodWithArg<nsRefPtr<MediaRawData>>(
this, &FFmpegH264Decoder<LIBAV_VER>::DecodeFrame,
nsRefPtr<MediaRawData>(aSample)));
mTaskQueue->Dispatch(runnable.forget());

return NS_OK;
}
@@ -348,8 +349,9 @@ FFmpegH264Decoder<LIBAV_VER>::DoDrain()
nsresult
FFmpegH264Decoder<LIBAV_VER>::Drain()
{
mTaskQueue->Dispatch(
nsCOMPtr<nsIRunnable> runnable(
NS_NewRunnableMethod(this, &FFmpegH264Decoder<LIBAV_VER>::DoDrain));
mTaskQueue->Dispatch(runnable.forget());

return NS_OK;
}
@@ -161,11 +161,12 @@ GonkMediaDataDecoder::Shutdown()
nsresult
GonkMediaDataDecoder::Input(MediaRawData* aSample)
{
mTaskQueue->Dispatch(
nsCOMPtr<nsIRunnable> runnable(
NS_NewRunnableMethodWithArg<nsRefPtr<MediaRawData>>(
this,
&GonkMediaDataDecoder::ProcessDecode,
nsRefPtr<MediaRawData>(aSample)));
mTaskQueue->Dispatch(runnable.forget());
return NS_OK;
}

@@ -258,7 +259,9 @@ GonkMediaDataDecoder::ProcessDrain()
nsresult
GonkMediaDataDecoder::Drain()
{
mTaskQueue->Dispatch(NS_NewRunnableMethod(this, &GonkMediaDataDecoder::ProcessDrain));
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &GonkMediaDataDecoder::ProcessDrain);
mTaskQueue->Dispatch(runnable.forget());
return NS_OK;
}

@@ -49,15 +49,16 @@ WMFMediaDataDecoder::Init()
nsresult
WMFMediaDataDecoder::Shutdown()
{
mTaskQueue->Dispatch(
NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessShutdown));
#ifdef DEBUG
{
MonitorAutoLock mon(mMonitor);
// The MP4Reader should have flushed before calling Shutdown().
MOZ_ASSERT(!mIsDecodeTaskDispatched);
MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown);

if (mTaskQueue) {
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessShutdown);
mTaskQueue->Dispatch(runnable.forget());
} else {
ProcessShutdown();
}
#endif
mIsShutDown = true;

This comment has been minimized.

Copy link
@roytam1

roytam1 Jan 10, 2019

@rmottola breaks build. patch available belows:

diff --git a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp
index 01487a4ac..52660469f 100644
--- a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp
+++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp
@@ -77,9 +77,9 @@ WMFMediaDataDecoder::EnsureDecodeTaskDispatched()
 {
   mMonitor.AssertCurrentThreadOwns();
   if (!mIsDecodeTaskDispatched) {
-    mTaskQueue->Dispatch(
-      NS_NewRunnableMethod(this,
-      &WMFMediaDataDecoder::Decode));
+    nsCOMPtr<nsIRunnable> runnable =
+      NS_NewRunnableMethod(this, &WMFMediaDataDecoder::Decode);
+    mTaskQueue->Dispatch(runnable.forget());
     mIsDecodeTaskDispatched = true;
   }
 }
diff --git a/dom/media/platforms/wmf/WMFMediaDataDecoder.h b/dom/media/platforms/wmf/WMFMediaDataDecoder.h
index 0b67defbb..2edeca5bb 100644
--- a/dom/media/platforms/wmf/WMFMediaDataDecoder.h
+++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.h
@@ -104,6 +104,7 @@ private:
   std::queue<nsRefPtr<MediaRawData>> mInput;
   bool mIsDecodeTaskDispatched;
   bool mIsFlushing;
+  bool mIsShutDown;
 };

 } // namespace mozilla

This comment has been minimized.

Copy link
@rmottola

rmottola Jan 10, 2019

Author Contributor

@roytam1 am I correct to assume that WMF is built only on Windows so I did not test this code-path? I do a build for every patch I backport

This comment has been minimized.

Copy link
@roytam1

roytam1 Jan 10, 2019

@rmottola yes wmf is windows-only.

This comment has been minimized.

Copy link
@rmottola

rmottola Jan 22, 2019

Author Contributor

Forgot to write back - I commited a fix for this.

return NS_OK;
}

@@ -195,7 +196,9 @@ WMFMediaDataDecoder::ProcessDrain()
nsresult
WMFMediaDataDecoder::Drain()
{
mTaskQueue->Dispatch(NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessDrain));
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessDrain);
mTaskQueue->Dispatch(runnable.forget());
return NS_OK;
}

@@ -150,7 +150,9 @@ TemporaryRef<DtlsIdentity> DtlsIdentity::Generate() {
}
certificate->derCert = *signedCert;

return new DtlsIdentity(private_key.forget(), certificate.forget());
RefPtr<DtlsIdentity> identity =
new DtlsIdentity(private_key.forget(), certificate.forget());
return identity.forget();
}


@@ -44,7 +44,8 @@ NewFoo()
TemporaryRef<Foo>
NewBar()
{
return new Bar();
RefPtr<Bar> bar = new Bar();
return bar.forget();
}

void
@@ -268,7 +268,8 @@ SystemElf::Load(const char *path, int flags)
if (handle) {
SystemElf *elf = new SystemElf(path, handle);
ElfLoader::Singleton.Register(elf);
return elf;
RefPtr<LibHandle> lib(elf);
return lib.forget();
}
return nullptr;
}
@@ -355,12 +356,16 @@ ElfLoader::Load(const char *path, int flags, LibHandle *parent)
* path is not absolute, compare file names, otherwise compare full paths. */
if (name == path) {
for (LibHandleList::iterator it = handles.begin(); it < handles.end(); ++it)
if ((*it)->GetName() && (strcmp((*it)->GetName(), name) == 0))
return *it;
if ((*it)->GetName() && (strcmp((*it)->GetName(), name) == 0)) {
handle = *it;
return handle.forget();
}
} else {
for (LibHandleList::iterator it = handles.begin(); it < handles.end(); ++it)
if ((*it)->GetPath() && (strcmp((*it)->GetPath(), path) == 0))
return *it;
if ((*it)->GetPath() && (strcmp((*it)->GetPath(), path) == 0)) {
handle = *it;
return handle.forget();
}
}

char *abs_path = nullptr;
@@ -398,16 +403,18 @@ ElfLoader::Load(const char *path, int flags, LibHandle *parent)
reinterpret_cast<void *>(parent), parent ? parent->GetPath() : "",
static_cast<void *>(handle));

return handle;
return handle.forget();
}

mozilla::TemporaryRef<LibHandle>
ElfLoader::GetHandleByPtr(void *addr)
{
/* Scan the list of handles we already have for a match */
for (LibHandleList::iterator it = handles.begin(); it < handles.end(); ++it) {
if ((*it)->Contains(addr))
return *it;
if ((*it)->Contains(addr)) {
RefPtr<LibHandle> lib = *it;
return lib.forget();
}
}
return nullptr;
}
@@ -187,8 +187,10 @@ ZipCollection::GetZip(const char *path)
/* Search the list of Zips we already have for a match */
for (std::vector<Zip *>::iterator it = Singleton.zips.begin();
it < Singleton.zips.end(); ++it) {
if ((*it)->GetName() && (strcmp((*it)->GetName(), path) == 0))
return *it;
if ((*it)->GetName() && (strcmp((*it)->GetName(), path) == 0)) {
mozilla::RefPtr<Zip> zip = *it;
return zip.forget();
}
}
return Zip::Create(path);
}

0 comments on commit f667149

Please sign in to comment.
You can’t perform that action at this time.