Bug 1113725. Rename VsyncDispatcher to CompositorVsyncDispatcher. r=kats

This commit is contained in:
Mason Chang 2014-12-19 12:52:42 -08:00
parent 6293e36ca4
commit f61559dfae
10 changed files with 57 additions and 60 deletions

View File

@ -205,7 +205,7 @@ CompositorVsyncObserver::CompositorVsyncObserver(CompositorParent* aCompositorPa
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWidget != nullptr);
mVsyncDispatcher = aWidget->GetVsyncDispatcher();
mCompositorVsyncDispatcher = aWidget->GetCompositorVsyncDispatcher();
#ifdef MOZ_WIDGET_GONK
GeckoTouchDispatcher::SetCompositorVsyncObserver(this);
#endif
@ -215,10 +215,10 @@ CompositorVsyncObserver::~CompositorVsyncObserver()
{
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
MOZ_ASSERT(!mIsObservingVsync);
// The VsyncDispatcher is cleaned up before this in the nsBaseWidget, which stops vsync listeners
// The CompositorVsyncDispatcher is cleaned up before this in the nsBaseWidget, which stops vsync listeners
CancelCurrentCompositeTask();
mCompositorParent = nullptr;
mVsyncDispatcher = nullptr;
mCompositorVsyncDispatcher = nullptr;
mNeedsComposite = false;
}
@ -301,7 +301,7 @@ void
CompositorVsyncObserver::ObserveVsync()
{
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
mVsyncDispatcher->SetCompositorVsyncObserver(this);
mCompositorVsyncDispatcher->SetCompositorVsyncObserver(this);
mIsObservingVsync = true;
}
@ -309,7 +309,7 @@ void
CompositorVsyncObserver::UnobserveVsync()
{
MOZ_ASSERT(CompositorParent::IsInCompositorThread() || NS_IsMainThread());
mVsyncDispatcher->SetCompositorVsyncObserver(nullptr);
mCompositorVsyncDispatcher->SetCompositorVsyncObserver(nullptr);
mIsObservingVsync = false;
}

View File

@ -118,7 +118,7 @@ private:
bool mNeedsComposite;
bool mIsObservingVsync;
nsRefPtr<CompositorParent> mCompositorParent;
nsRefPtr<VsyncDispatcher> mVsyncDispatcher;
nsRefPtr<CompositorVsyncDispatcher> mCompositorVsyncDispatcher;
mozilla::Monitor mCurrentCompositeTaskMonitor;
CancelableTask* mCurrentCompositeTask;

View File

@ -12,21 +12,21 @@ using namespace mozilla;
using namespace mozilla::gfx;
void
VsyncSource::AddVsyncDispatcher(VsyncDispatcher* aVsyncDispatcher)
VsyncSource::AddCompositorVsyncDispatcher(CompositorVsyncDispatcher* aCompositorVsyncDispatcher)
{
MOZ_ASSERT(NS_IsMainThread());
GetGlobalDisplay().AddVsyncDispatcher(aVsyncDispatcher);
GetGlobalDisplay().AddCompositorVsyncDispatcher(aCompositorVsyncDispatcher);
}
void
VsyncSource::RemoveVsyncDispatcher(VsyncDispatcher* aVsyncDispatcher)
VsyncSource::RemoveCompositorVsyncDispatcher(CompositorVsyncDispatcher* aCompositorVsyncDispatcher)
{
MOZ_ASSERT(NS_IsMainThread());
GetGlobalDisplay().RemoveVsyncDispatcher(aVsyncDispatcher);
GetGlobalDisplay().RemoveCompositorVsyncDispatcher(aCompositorVsyncDispatcher);
}
VsyncSource::Display&
VsyncSource::FindDisplay(VsyncDispatcher* aVsyncDispatcher)
VsyncSource::FindDisplay(CompositorVsyncDispatcher* aCompositorVsyncDispatcher)
{
return GetGlobalDisplay();
}
@ -35,8 +35,8 @@ void
VsyncSource::Display::NotifyVsync(TimeStamp aVsyncTimestamp)
{
// Called on the hardware vsync thread
for (size_t i = 0; i < mVsyncDispatchers.Length(); i++) {
mVsyncDispatchers[i]->NotifyVsync(aVsyncTimestamp);
for (size_t i = 0; i < mCompositorVsyncDispatchers.Length(); i++) {
mCompositorVsyncDispatchers[i]->NotifyVsync(aVsyncTimestamp);
}
}
@ -48,19 +48,19 @@ VsyncSource::Display::Display()
VsyncSource::Display::~Display()
{
MOZ_ASSERT(NS_IsMainThread());
mVsyncDispatchers.Clear();
mCompositorVsyncDispatchers.Clear();
}
void
VsyncSource::Display::AddVsyncDispatcher(VsyncDispatcher* aVsyncDispatcher)
VsyncSource::Display::AddCompositorVsyncDispatcher(CompositorVsyncDispatcher* aCompositorVsyncDispatcher)
{
MOZ_ASSERT(NS_IsMainThread());
mVsyncDispatchers.AppendElement(aVsyncDispatcher);
mCompositorVsyncDispatchers.AppendElement(aCompositorVsyncDispatcher);
}
void
VsyncSource::Display::RemoveVsyncDispatcher(VsyncDispatcher* aVsyncDispatcher)
VsyncSource::Display::RemoveCompositorVsyncDispatcher(CompositorVsyncDispatcher* aCompositorVsyncDispatcher)
{
MOZ_ASSERT(NS_IsMainThread());
mVsyncDispatchers.RemoveElement(aVsyncDispatcher);
mCompositorVsyncDispatchers.RemoveElement(aCompositorVsyncDispatcher);
}

View File

@ -9,7 +9,7 @@
#include "nsTArray.h"
namespace mozilla {
class VsyncDispatcher;
class CompositorVsyncDispatcher;
namespace gfx {
@ -24,8 +24,8 @@ public:
public:
Display();
virtual ~Display();
void AddVsyncDispatcher(mozilla::VsyncDispatcher* aVsyncDispatcher);
void RemoveVsyncDispatcher(mozilla::VsyncDispatcher* aVsyncDispatcher);
void AddCompositorVsyncDispatcher(mozilla::CompositorVsyncDispatcher* aCompositorVsyncDispatcher);
void RemoveCompositorVsyncDispatcher(mozilla::CompositorVsyncDispatcher* aCompositorVsyncDispatcher);
// Notified when this display's vsync occurs, on the hardware vsync thread
void NotifyVsync(mozilla::TimeStamp aVsyncTimestamp);
@ -35,15 +35,15 @@ public:
virtual bool IsVsyncEnabled() = 0;
private:
nsTArray<nsRefPtr<mozilla::VsyncDispatcher>> mVsyncDispatchers;
nsTArray<nsRefPtr<mozilla::CompositorVsyncDispatcher>> mCompositorVsyncDispatchers;
}; // end Display
void AddVsyncDispatcher(mozilla::VsyncDispatcher* aVsyncDispatcher);
void RemoveVsyncDispatcher(mozilla::VsyncDispatcher* aVsyncDispatcher);
void AddCompositorVsyncDispatcher(mozilla::CompositorVsyncDispatcher* aCompositorVsyncDispatcher);
void RemoveCompositorVsyncDispatcher(mozilla::CompositorVsyncDispatcher* aCompositorVsyncDispatcher);
protected:
virtual Display& GetGlobalDisplay() = 0; // Works across all displays
virtual Display& FindDisplay(mozilla::VsyncDispatcher* aVsyncDispatcher);
virtual Display& FindDisplay(mozilla::CompositorVsyncDispatcher* aCompositorVsyncDispatcher);
virtual ~VsyncSource() {}
}; // VsyncSource
} // gfx

View File

@ -23,21 +23,21 @@ using namespace mozilla::layers;
namespace mozilla {
VsyncDispatcher::VsyncDispatcher()
CompositorVsyncDispatcher::CompositorVsyncDispatcher()
: mCompositorObserverLock("CompositorObserverLock")
{
MOZ_ASSERT(XRE_IsParentProcess());
gfxPlatform::GetPlatform()->GetHardwareVsync()->AddVsyncDispatcher(this);
gfxPlatform::GetPlatform()->GetHardwareVsync()->AddCompositorVsyncDispatcher(this);
}
VsyncDispatcher::~VsyncDispatcher()
CompositorVsyncDispatcher::~CompositorVsyncDispatcher()
{
// We auto remove this vsync dispatcher from the vsync source in the nsBaseWidget
MOZ_ASSERT(NS_IsMainThread());
}
void
VsyncDispatcher::NotifyVsync(TimeStamp aVsyncTimestamp)
CompositorVsyncDispatcher::NotifyVsync(TimeStamp aVsyncTimestamp)
{
// In hardware vsync thread
#ifdef MOZ_ENABLE_PROFILER_SPS
@ -53,7 +53,7 @@ VsyncDispatcher::NotifyVsync(TimeStamp aVsyncTimestamp)
}
void
VsyncDispatcher::SetCompositorVsyncObserver(VsyncObserver* aVsyncObserver)
CompositorVsyncDispatcher::SetCompositorVsyncObserver(VsyncObserver* aVsyncObserver)
{
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
MutexAutoLock lock(mCompositorObserverLock);
@ -61,13 +61,13 @@ VsyncDispatcher::SetCompositorVsyncObserver(VsyncObserver* aVsyncObserver)
}
void
VsyncDispatcher::Shutdown()
CompositorVsyncDispatcher::Shutdown()
{
// Need to explicitly remove VsyncDispatcher when the nsBaseWidget shuts down.
// Need to explicitly remove CompositorVsyncDispatcher when the nsBaseWidget shuts down.
// Otherwise, we would get dead vsync notifications between when the nsBaseWidget
// shuts down and the CompositorParent shuts down.
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
gfxPlatform::GetPlatform()->GetHardwareVsync()->RemoveVsyncDispatcher(this);
gfxPlatform::GetPlatform()->GetHardwareVsync()->RemoveCompositorVsyncDispatcher(this);
}
} // namespace mozilla

View File

@ -21,7 +21,6 @@ class CompositorVsyncObserver;
class VsyncObserver
{
// Must be destroyed on main thread since the compositor is as well
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VsyncObserver)
public:
@ -34,13 +33,11 @@ protected:
virtual ~VsyncObserver() {}
}; // VsyncObserver
// VsyncDispatcher is used to dispatch vsync events to the registered observers.
class VsyncDispatcher
class CompositorVsyncDispatcher MOZ_FINAL
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VsyncDispatcher)
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorVsyncDispatcher)
public:
VsyncDispatcher();
CompositorVsyncDispatcher();
// Called on the vsync thread when a hardware vsync occurs
// The aVsyncTimestamp can mean different things depending on the platform:
@ -55,10 +52,10 @@ public:
void Shutdown();
private:
virtual ~VsyncDispatcher();
virtual ~CompositorVsyncDispatcher();
Mutex mCompositorObserverLock;
nsRefPtr<VsyncObserver> mCompositorVsyncObserver;
}; // VsyncDispatcher
};
} // namespace mozilla

View File

@ -220,7 +220,7 @@ nsWindow::NotifyVsync(TimeStamp aVsyncTimestamp)
return;
}
VsyncDispatcher* vsyncDispatcher = gFocusedWindow->GetVsyncDispatcher();
CompositorVsyncDispatcher* vsyncDispatcher = gFocusedWindow->GetCompositorVsyncDispatcher();
// During bootup, there is a delay between when the nsWindow is created
// and when the Compositor is created, but vsync is already turned on
if (vsyncDispatcher) {

View File

@ -114,7 +114,7 @@ nsBaseWidget::nsBaseWidget()
: mWidgetListener(nullptr)
, mAttachedWidgetListener(nullptr)
, mContext(nullptr)
, mVsyncDispatcher(nullptr)
, mCompositorVsyncDispatcher(nullptr)
, mCursor(eCursor_standard)
, mUpdateCursor(true)
, mBorderStyle(eBorderStyle_none)
@ -234,9 +234,9 @@ nsBaseWidget::~nsBaseWidget()
NS_IF_RELEASE(mContext);
delete mOriginalBounds;
// Can have base widgets that are things like tooltips which don't have vsyncDispatchers
if (mVsyncDispatcher) {
mVsyncDispatcher->Shutdown();
// Can have base widgets that are things like tooltips which don't have CompositorVsyncDispatchers
if (mCompositorVsyncDispatcher) {
mCompositorVsyncDispatcher->Shutdown();
}
}
@ -973,22 +973,22 @@ nsBaseWidget::GetPreferredCompositorBackends(nsTArray<LayersBackend>& aHints)
aHints.AppendElement(LayersBackend::LAYERS_BASIC);
}
void nsBaseWidget::CreateVsyncDispatcher()
void nsBaseWidget::CreateCompositorVsyncDispatcher()
{
if (gfxPrefs::HardwareVsyncEnabled()) {
// Parent directly listens to the vsync source whereas
// child process communicate via IPC
// Should be called AFTER gfxPlatform is initialized
if (XRE_IsParentProcess()) {
mVsyncDispatcher = new VsyncDispatcher();
mCompositorVsyncDispatcher = new CompositorVsyncDispatcher();
}
}
}
VsyncDispatcher*
nsBaseWidget::GetVsyncDispatcher()
CompositorVsyncDispatcher*
nsBaseWidget::GetCompositorVsyncDispatcher()
{
return mVsyncDispatcher;
return mCompositorVsyncDispatcher;
}
void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
@ -1008,7 +1008,7 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
return;
}
CreateVsyncDispatcher();
CreateCompositorVsyncDispatcher();
mCompositorParent = NewCompositorParent(aWidth, aHeight);
MessageChannel *parentChannel = mCompositorParent->GetIPCChannel();
nsRefPtr<ClientLayerManager> lm = new ClientLayerManager(this);

View File

@ -39,7 +39,7 @@ class GeckoContentController;
struct ScrollableLayerGuid;
}
class VsyncDispatcher;
class CompositorVsyncDispatcher;
}
namespace base {
@ -142,8 +142,8 @@ public:
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
bool* aAllowRetaining = nullptr);
VsyncDispatcher* GetVsyncDispatcher() MOZ_OVERRIDE;
virtual void CreateVsyncDispatcher();
CompositorVsyncDispatcher* GetCompositorVsyncDispatcher() MOZ_OVERRIDE;
virtual void CreateCompositorVsyncDispatcher();
virtual CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight);
virtual void CreateCompositor();
virtual void CreateCompositor(int aWidth, int aHeight);
@ -426,7 +426,7 @@ protected:
nsRefPtr<LayerManager> mBasicLayerManager;
nsRefPtr<CompositorChild> mCompositorChild;
nsRefPtr<CompositorParent> mCompositorParent;
nsRefPtr<mozilla::VsyncDispatcher> mVsyncDispatcher;
nsRefPtr<mozilla::CompositorVsyncDispatcher> mCompositorVsyncDispatcher;
nsRefPtr<APZCTreeManager> mAPZC;
nsRefPtr<WidgetShutdownObserver> mShutdownObserver;
nsCursor mCursor;

View File

@ -36,7 +36,7 @@ class nsIntRegion;
class nsIScreen;
namespace mozilla {
class VsyncDispatcher;
class CompositorVsyncDispatcher;
namespace dom {
class TabChild;
}
@ -692,7 +692,7 @@ class nsIWidget : public nsISupports {
typedef mozilla::widget::InputContext InputContext;
typedef mozilla::widget::InputContextAction InputContextAction;
typedef mozilla::widget::SizeConstraints SizeConstraints;
typedef mozilla::VsyncDispatcher VsyncDispatcher;
typedef mozilla::CompositorVsyncDispatcher CompositorVsyncDispatcher;
// Used in UpdateThemeGeometries.
struct ThemeGeometry {
@ -872,9 +872,9 @@ class nsIWidget : public nsISupports {
virtual float GetDPI() = 0;
/**
* Returns the VsyncDispatcher associated with this widget
* Returns the CompositorVsyncDispatcher associated with this widget
*/
virtual VsyncDispatcher* GetVsyncDispatcher() = 0;
virtual CompositorVsyncDispatcher* GetCompositorVsyncDispatcher() = 0;
/**
* Return the default scale factor for the window. This is the