mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1231042 - clean current composition task and related flag when screen off. r=hshih
This commit is contained in:
parent
25341e0a6a
commit
129f69bac0
@ -75,6 +75,7 @@
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
#include "GeckoTouchDispatcher.h"
|
||||
#include "nsScreenManagerGonk.h"
|
||||
#endif
|
||||
|
||||
#include "LayerScope.h"
|
||||
@ -286,13 +287,18 @@ CompositorVsyncScheduler::Observer::Destroy()
|
||||
CompositorVsyncScheduler::CompositorVsyncScheduler(CompositorParent* aCompositorParent, nsIWidget* aWidget)
|
||||
: mCompositorParent(aCompositorParent)
|
||||
, mLastCompose(TimeStamp::Now())
|
||||
, mCurrentCompositeTask(nullptr)
|
||||
, mIsObservingVsync(false)
|
||||
, mNeedsComposite(0)
|
||||
, mVsyncNotificationsSkipped(0)
|
||||
, mCurrentCompositeTaskMonitor("CurrentCompositeTaskMonitor")
|
||||
, mCurrentCompositeTask(nullptr)
|
||||
, mSetNeedsCompositeMonitor("SetNeedsCompositeMonitor")
|
||||
, mSetNeedsCompositeTask(nullptr)
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
, mDisplayEnabled(false)
|
||||
, mSetDisplayMonitor("SetDisplayMonitor")
|
||||
, mSetDisplayTask(nullptr)
|
||||
#endif
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aWidget != nullptr);
|
||||
@ -300,6 +306,9 @@ CompositorVsyncScheduler::CompositorVsyncScheduler(CompositorParent* aCompositor
|
||||
mCompositorVsyncDispatcher = aWidget->GetCompositorVsyncDispatcher();
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
GeckoTouchDispatcher::GetInstance()->SetCompositorVsyncScheduler(this);
|
||||
|
||||
RefPtr<nsScreenManagerGonk> screenManager = nsScreenManagerGonk::GetInstance();
|
||||
screenManager->SetCompositorVsyncScheduler(this);
|
||||
#endif
|
||||
|
||||
// mAsapScheduling is set on the main thread during init,
|
||||
@ -317,6 +326,52 @@ CompositorVsyncScheduler::~CompositorVsyncScheduler()
|
||||
mCompositorVsyncDispatcher = nullptr;
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
void
|
||||
CompositorVsyncScheduler::SetDisplay(bool aDisplayEnable)
|
||||
{
|
||||
// SetDisplay() is usually called from nsScreenManager at main thread. Post
|
||||
// to compositor thread if needs.
|
||||
if (!CompositorParent::IsInCompositorThread()) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MonitorAutoLock lock(mSetDisplayMonitor);
|
||||
mSetDisplayTask = NewRunnableMethod(this,
|
||||
&CompositorVsyncScheduler::SetDisplay,
|
||||
aDisplayEnable);
|
||||
ScheduleTask(mSetDisplayTask, 0);
|
||||
return;
|
||||
} else {
|
||||
MonitorAutoLock lock(mSetDisplayMonitor);
|
||||
mSetDisplayTask = nullptr;
|
||||
}
|
||||
|
||||
if (mDisplayEnabled == aDisplayEnable) {
|
||||
return;
|
||||
}
|
||||
|
||||
mDisplayEnabled = aDisplayEnable;
|
||||
if (!mDisplayEnabled) {
|
||||
CancelCurrentSetNeedsCompositeTask();
|
||||
CancelCurrentCompositeTask();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CompositorVsyncScheduler::CancelSetDisplayTask()
|
||||
{
|
||||
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
|
||||
MonitorAutoLock lock(mSetDisplayMonitor);
|
||||
if (mSetDisplayTask) {
|
||||
mSetDisplayTask->Cancel();
|
||||
mSetDisplayTask = nullptr;
|
||||
}
|
||||
|
||||
// CancelSetDisplayTask is only be called in clean-up process, so
|
||||
// mDisplayEnabled could be false there.
|
||||
mDisplayEnabled = false;
|
||||
}
|
||||
#endif //MOZ_WIDGET_GONK
|
||||
|
||||
void
|
||||
CompositorVsyncScheduler::Destroy()
|
||||
{
|
||||
@ -324,6 +379,10 @@ CompositorVsyncScheduler::Destroy()
|
||||
UnobserveVsync();
|
||||
mVsyncObserver->Destroy();
|
||||
mVsyncObserver = nullptr;
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
CancelSetDisplayTask();
|
||||
#endif
|
||||
CancelCurrentSetNeedsCompositeTask();
|
||||
CancelCurrentCompositeTask();
|
||||
}
|
||||
@ -396,6 +455,13 @@ CompositorVsyncScheduler::SetNeedsComposite()
|
||||
mSetNeedsCompositeTask = nullptr;
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
// Skip composition when display off.
|
||||
if (!mDisplayEnabled) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
mNeedsComposite++;
|
||||
if (!mIsObservingVsync && mNeedsComposite) {
|
||||
ObserveVsync();
|
||||
|
@ -100,6 +100,15 @@ class CompositorVsyncScheduler
|
||||
|
||||
public:
|
||||
explicit CompositorVsyncScheduler(CompositorParent* aCompositorParent, nsIWidget* aWidget);
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
// SetDisplay() and CancelSetDisplayTask() are used for the display on/off.
|
||||
// It will clear all composition related task and flag, and skip another
|
||||
// composition task during the display off. That could prevent the problem
|
||||
// that compositor might show the old content at the first frame of display on.
|
||||
void SetDisplay(bool aDisplayEnable);
|
||||
#endif
|
||||
|
||||
bool NotifyVsync(TimeStamp aVsyncTimestamp);
|
||||
void SetNeedsComposite();
|
||||
void OnForceComposeToTarget();
|
||||
@ -126,7 +135,7 @@ public:
|
||||
return mExpectedComposeStartTime;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
private:
|
||||
virtual ~CompositorVsyncScheduler();
|
||||
|
||||
@ -136,6 +145,9 @@ private:
|
||||
void DispatchTouchEvents(TimeStamp aVsyncTimestamp);
|
||||
void DispatchVREvents(TimeStamp aVsyncTimestamp);
|
||||
void CancelCurrentSetNeedsCompositeTask();
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
void CancelSetDisplayTask();
|
||||
#endif
|
||||
|
||||
class Observer final : public VsyncObserver
|
||||
{
|
||||
@ -153,7 +165,6 @@ private:
|
||||
|
||||
CompositorParent* mCompositorParent;
|
||||
TimeStamp mLastCompose;
|
||||
CancelableTask* mCurrentCompositeTask;
|
||||
|
||||
#ifdef COMPOSITOR_PERFORMANCE_WARNING
|
||||
TimeStamp mExpectedComposeStartTime;
|
||||
@ -167,9 +178,16 @@ private:
|
||||
RefPtr<CompositorVsyncScheduler::Observer> mVsyncObserver;
|
||||
|
||||
mozilla::Monitor mCurrentCompositeTaskMonitor;
|
||||
CancelableTask* mCurrentCompositeTask;
|
||||
|
||||
mozilla::Monitor mSetNeedsCompositeMonitor;
|
||||
CancelableTask* mSetNeedsCompositeTask;
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
bool mDisplayEnabled;
|
||||
mozilla::Monitor mSetDisplayMonitor;
|
||||
CancelableTask* mSetDisplayTask;
|
||||
#endif
|
||||
};
|
||||
|
||||
class CompositorUpdateObserver
|
||||
|
@ -621,6 +621,10 @@ nsScreenManagerGonk::Initialize()
|
||||
void
|
||||
nsScreenManagerGonk::DisplayEnabled(bool aEnabled)
|
||||
{
|
||||
if (mCompositorVsyncScheduler) {
|
||||
mCompositorVsyncScheduler->SetDisplay(aEnabled);
|
||||
}
|
||||
|
||||
VsyncControl(aEnabled);
|
||||
NS_DispatchToMainThread(aEnabled ? mScreenOnEvent : mScreenOffEvent);
|
||||
}
|
||||
@ -853,3 +857,13 @@ nsScreenManagerGonk::RemoveScreen(GonkDisplay::DisplayType aDisplayType)
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsScreenManagerGonk::SetCompositorVsyncScheduler(mozilla::layers::CompositorVsyncScheduler *aObserver)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// We assume on b2g that there is only 1 CompositorParent
|
||||
MOZ_ASSERT(mCompositorVsyncScheduler == nullptr);
|
||||
mCompositorVsyncScheduler = aObserver;
|
||||
}
|
||||
|
@ -42,6 +42,9 @@ namespace mozilla {
|
||||
namespace gl {
|
||||
class GLContext;
|
||||
}
|
||||
namespace layers {
|
||||
class CompositorVsyncScheduler;
|
||||
}
|
||||
}
|
||||
|
||||
enum class NotifyDisplayChangedEvent : int8_t {
|
||||
@ -170,6 +173,8 @@ public:
|
||||
|
||||
nsresult RemoveScreen(GonkDisplay::DisplayType aDisplayType);
|
||||
|
||||
void SetCompositorVsyncScheduler(mozilla::layers::CompositorVsyncScheduler* aObserver);
|
||||
|
||||
protected:
|
||||
~nsScreenManagerGonk();
|
||||
void VsyncControl(bool aEnabled);
|
||||
@ -180,6 +185,7 @@ protected:
|
||||
nsTArray<RefPtr<nsScreenGonk>> mScreens;
|
||||
RefPtr<nsRunnable> mScreenOnEvent;
|
||||
RefPtr<nsRunnable> mScreenOffEvent;
|
||||
RefPtr<mozilla::layers::CompositorVsyncScheduler> mCompositorVsyncScheduler;
|
||||
};
|
||||
|
||||
#endif /* nsScreenManagerGonk_h___ */
|
||||
|
Loading…
Reference in New Issue
Block a user