Bug 1276931. Add VsyncSource::Shutdown which shuts down global display. r=jrmuizel

This commit is contained in:
Mason Chang 2016-06-06 10:07:29 -07:00
Родитель 807cf956d8
Коммит 426f8dbfee
8 изменённых файлов: 53 добавлений и 27 удалений

Просмотреть файл

@ -20,7 +20,6 @@ SoftwareVsyncSource::SoftwareVsyncSource()
SoftwareVsyncSource::~SoftwareVsyncSource()
{
MOZ_ASSERT(NS_IsMainThread());
mGlobalDisplay->Shutdown();
mGlobalDisplay = nullptr;
}

Просмотреть файл

@ -27,7 +27,7 @@ public:
virtual void NotifyVsync(mozilla::TimeStamp aVsyncTimestamp) override;
virtual mozilla::TimeDuration GetVsyncRate() override;
void ScheduleNextVsync(mozilla::TimeStamp aVsyncTimestamp);
void Shutdown();
void Shutdown() override;
protected:
~SoftwareDisplay();

Просмотреть файл

@ -143,5 +143,11 @@ VsyncSource::Display::GetRefreshTimerVsyncDispatcher()
return mRefreshTimerVsyncDispatcher;
}
void
VsyncSource::Shutdown()
{
GetGlobalDisplay().Shutdown();
}
} //namespace gfx
} //namespace mozilla

Просмотреть файл

@ -56,6 +56,7 @@ public:
virtual void EnableVsync() = 0;
virtual void DisableVsync() = 0;
virtual bool IsVsyncEnabled() = 0;
virtual void Shutdown() = 0;
private:
void UpdateVsyncStatus();
@ -71,6 +72,7 @@ public:
RefPtr<RefreshTimerVsyncDispatcher> GetRefreshTimerVsyncDispatcher();
virtual Display& GetGlobalDisplay() = 0; // Works across all displays
void Shutdown();
protected:
virtual ~VsyncSource() {}

Просмотреть файл

@ -383,6 +383,12 @@ public:
~GonkDisplay()
{
MOZ_ASSERT(NS_IsMainThread());
}
virtual void Shutdown() override
{
MOZ_ASSERT(NS_IsMainThread());
DisableVsync();
}

Просмотреть файл

@ -785,6 +785,8 @@ static bool sLayersIPCIsUp = false;
void
gfxPlatform::Shutdown()
{
// In some cases, gPlatform may not be created but Shutdown() called,
// e.g., during xpcshell tests.
if (!gPlatform) {
return;
}
@ -804,29 +806,30 @@ gfxPlatform::Shutdown()
// Free the various non-null transforms and loaded profiles
ShutdownCMS();
// In some cases, gPlatform may not be created but Shutdown() called,
// e.g., during xpcshell tests.
if (gPlatform) {
/* Unregister our CMS Override callback. */
NS_ASSERTION(gPlatform->mSRGBOverrideObserver, "mSRGBOverrideObserver has alreay gone");
Preferences::RemoveObserver(gPlatform->mSRGBOverrideObserver, GFX_PREF_CMS_FORCE_SRGB);
gPlatform->mSRGBOverrideObserver = nullptr;
/* Unregister our CMS Override callback. */
NS_ASSERTION(gPlatform->mSRGBOverrideObserver, "mSRGBOverrideObserver has alreay gone");
Preferences::RemoveObserver(gPlatform->mSRGBOverrideObserver, GFX_PREF_CMS_FORCE_SRGB);
gPlatform->mSRGBOverrideObserver = nullptr;
NS_ASSERTION(gPlatform->mFontPrefsObserver, "mFontPrefsObserver has alreay gone");
Preferences::RemoveObservers(gPlatform->mFontPrefsObserver, kObservedPrefs);
gPlatform->mFontPrefsObserver = nullptr;
NS_ASSERTION(gPlatform->mFontPrefsObserver, "mFontPrefsObserver has alreay gone");
Preferences::RemoveObservers(gPlatform->mFontPrefsObserver, kObservedPrefs);
gPlatform->mFontPrefsObserver = nullptr;
NS_ASSERTION(gPlatform->mMemoryPressureObserver, "mMemoryPressureObserver has already gone");
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->RemoveObserver(gPlatform->mMemoryPressureObserver, "memory-pressure");
}
gPlatform->mMemoryPressureObserver = nullptr;
gPlatform->mSkiaGlue = nullptr;
gPlatform->mVsyncSource = nullptr;
NS_ASSERTION(gPlatform->mMemoryPressureObserver, "mMemoryPressureObserver has already gone");
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->RemoveObserver(gPlatform->mMemoryPressureObserver, "memory-pressure");
}
gPlatform->mMemoryPressureObserver = nullptr;
gPlatform->mSkiaGlue = nullptr;
if (XRE_IsParentProcess()) {
gPlatform->mVsyncSource->Shutdown();
}
gPlatform->mVsyncSource = nullptr;
#ifdef MOZ_WIDGET_ANDROID
// Shut down the texture pool
TexturePoolOGL::Shutdown();

Просмотреть файл

@ -416,9 +416,6 @@ public:
~OSXDisplay()
{
MOZ_ASSERT(NS_IsMainThread());
mTimer->Cancel();
mTimer = nullptr;
DisableVsync();
}
static void RetryEnableVsync(nsITimer* aTimer, void* aOsxDisplay)
@ -514,6 +511,14 @@ public:
return mVsyncRate;
}
virtual void Shutdown() override
{
MOZ_ASSERT(NS_IsMainThread());
mTimer->Cancel();
mTimer = nullptr;
DisableVsync();
}
// The vsync timestamps given by the CVDisplayLinkCallback are
// in the future for the NEXT frame. Large parts of Gecko, such
// as animations assume a timestamp at either now or in the past.

Просмотреть файл

@ -2732,6 +2732,14 @@ public:
}
}
virtual void Shutdown() override
{
MOZ_ASSERT(NS_IsMainThread());
DisableVsync();
mVsyncThread->Stop();
delete mVsyncThread;
}
virtual void EnableVsync() override
{
MOZ_ASSERT(NS_IsMainThread());
@ -2894,9 +2902,6 @@ public:
virtual ~D3DVsyncDisplay()
{
MOZ_ASSERT(NS_IsMainThread());
DisableVsync();
mVsyncThread->Stop();
delete mVsyncThread;
}
bool IsInVsyncThread()