mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
01583602a9
The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi --HG-- rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
99 lines
3.1 KiB
C++
99 lines
3.1 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef mozilla_widget_VsyncDispatcher_h
|
|
#define mozilla_widget_VsyncDispatcher_h
|
|
|
|
#include "mozilla/Mutex.h"
|
|
#include "mozilla/TimeStamp.h"
|
|
#include "nsISupportsImpl.h"
|
|
#include "nsTArray.h"
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
namespace mozilla {
|
|
|
|
class VsyncObserver
|
|
{
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VsyncObserver)
|
|
|
|
public:
|
|
// The method called when a vsync occurs. Return true if some work was done.
|
|
// In general, this vsync notification will occur on the hardware vsync
|
|
// thread from VsyncSource. But it might also be called on PVsync ipc thread
|
|
// if this notification is cross process. Thus all observer should check the
|
|
// thread model before handling the real task.
|
|
virtual bool NotifyVsync(TimeStamp aVsyncTimestamp) = 0;
|
|
|
|
protected:
|
|
VsyncObserver() {}
|
|
virtual ~VsyncObserver() {}
|
|
}; // VsyncObserver
|
|
|
|
// Used to dispatch vsync events in the parent process to compositors
|
|
class CompositorVsyncDispatcher final
|
|
{
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorVsyncDispatcher)
|
|
|
|
public:
|
|
CompositorVsyncDispatcher();
|
|
|
|
// Called on the vsync thread when a hardware vsync occurs
|
|
void NotifyVsync(TimeStamp aVsyncTimestamp);
|
|
|
|
// Compositor vsync observers must be added/removed on the compositor thread
|
|
void SetCompositorVsyncObserver(VsyncObserver* aVsyncObserver);
|
|
void Shutdown();
|
|
|
|
// This can be used to enable or disable thread assertions.
|
|
// This is useful for gtests because usually things run
|
|
// in only one thread in that environment
|
|
static void SetThreadAssertionsEnabled(bool aEnable);
|
|
|
|
private:
|
|
void AssertOnCompositorThread();
|
|
virtual ~CompositorVsyncDispatcher();
|
|
void ObserveVsync(bool aEnable);
|
|
|
|
Mutex mCompositorObserverLock;
|
|
RefPtr<VsyncObserver> mCompositorVsyncObserver;
|
|
bool mDidShutdown;
|
|
};
|
|
|
|
// Dispatch vsync event to ipc actor parent and chrome RefreshTimer.
|
|
class RefreshTimerVsyncDispatcher final
|
|
{
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RefreshTimerVsyncDispatcher)
|
|
|
|
public:
|
|
RefreshTimerVsyncDispatcher();
|
|
|
|
// Please check CompositorVsyncDispatcher::NotifyVsync().
|
|
void NotifyVsync(TimeStamp aVsyncTimestamp);
|
|
|
|
// Set chrome process's RefreshTimer to this dispatcher.
|
|
// This function can be called from any thread.
|
|
void SetParentRefreshTimer(VsyncObserver* aVsyncObserver);
|
|
|
|
// Add or remove the content process' RefreshTimer to this dispatcher. This
|
|
// will be a no-op for AddChildRefreshTimer() if the observer is already
|
|
// registered.
|
|
// These functions can be called from any thread.
|
|
void AddChildRefreshTimer(VsyncObserver* aVsyncObserver);
|
|
void RemoveChildRefreshTimer(VsyncObserver* aVsyncObserver);
|
|
|
|
private:
|
|
virtual ~RefreshTimerVsyncDispatcher();
|
|
void UpdateVsyncStatus();
|
|
bool NeedsVsync();
|
|
|
|
Mutex mRefreshTimersLock;
|
|
RefPtr<VsyncObserver> mParentRefreshTimer;
|
|
nsTArray<RefPtr<VsyncObserver>> mChildRefreshTimers;
|
|
};
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_widget_VsyncDispatcher_h
|