зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1095242. Part 3 - Make enable/disable vsync noops if already enabled/disabled. r=kats
This commit is contained in:
Родитель
2ddd329607
Коммит
9093be777c
|
@ -22,7 +22,8 @@ SoftwareVsyncSource::~SoftwareVsyncSource()
|
|||
}
|
||||
|
||||
SoftwareDisplay::SoftwareDisplay()
|
||||
: mCurrentTaskMonitor("SoftwareVsyncCurrentTaskMonitor")
|
||||
: mVsyncEnabled(false)
|
||||
, mCurrentTaskMonitor("SoftwareVsyncCurrentTaskMonitor")
|
||||
{
|
||||
// Mimic 60 fps
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -35,22 +36,32 @@ void
|
|||
SoftwareDisplay::EnableVsync()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mozilla::MonitorAutoLock lock(mCurrentTaskMonitor);
|
||||
mVsyncEnabled = true;
|
||||
MOZ_ASSERT(!mVsyncThread->IsRunning());
|
||||
MOZ_RELEASE_ASSERT(mVsyncThread->Start(), "Could not start software vsync thread");
|
||||
mCurrentVsyncTask = NewRunnableMethod(this,
|
||||
&SoftwareDisplay::NotifyVsync,
|
||||
mozilla::TimeStamp::Now());
|
||||
mVsyncThread->message_loop()->PostTask(FROM_HERE, mCurrentVsyncTask);
|
||||
if (IsVsyncEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
{ // scope lock
|
||||
mozilla::MonitorAutoLock lock(mCurrentTaskMonitor);
|
||||
mVsyncEnabled = true;
|
||||
MOZ_ASSERT(!mVsyncThread->IsRunning());
|
||||
MOZ_RELEASE_ASSERT(mVsyncThread->Start(), "Could not start software vsync thread");
|
||||
mCurrentVsyncTask = NewRunnableMethod(this,
|
||||
&SoftwareDisplay::NotifyVsync,
|
||||
mozilla::TimeStamp::Now());
|
||||
mVsyncThread->message_loop()->PostTask(FROM_HERE, mCurrentVsyncTask);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SoftwareDisplay::DisableVsync()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!IsVsyncEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mVsyncThread->IsRunning());
|
||||
{ // Scope lock
|
||||
{ // scope lock
|
||||
mozilla::MonitorAutoLock lock(mCurrentTaskMonitor);
|
||||
mVsyncEnabled = false;
|
||||
if (mCurrentVsyncTask) {
|
||||
|
|
|
@ -452,12 +452,18 @@ public:
|
|||
virtual void EnableVsync() MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (IsVsyncEnabled()) {
|
||||
return;
|
||||
}
|
||||
mVsyncEnabled = HwcComposer2D::GetInstance()->EnableVsync(true);
|
||||
}
|
||||
|
||||
virtual void DisableVsync() MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!IsVsyncEnabled()) {
|
||||
return;
|
||||
}
|
||||
mVsyncEnabled = HwcComposer2D::GetInstance()->EnableVsync(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -448,6 +448,9 @@ public:
|
|||
virtual void EnableVsync() MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (IsVsyncEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a display link capable of being used with all active displays
|
||||
// TODO: See if we need to create an active DisplayLink for each monitor in multi-monitor
|
||||
|
@ -473,6 +476,9 @@ public:
|
|||
virtual void DisableVsync() MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!IsVsyncEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Release the display link
|
||||
if (mDisplayLink) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче