Backed out changesets a99bd0b3b075, a7fb851f823a, and 9fc2d99376cd (bug 552020) for non-unified bustage and OSX 10.6 tsvgr crashes.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2014-11-14 15:57:35 -05:00
parent f478793c34
commit 57225618ce
8 changed files with 27 additions and 151 deletions

View File

@ -1330,7 +1330,7 @@ InsertVsyncProfilerMarker(TimeStamp aVsyncTimestamp)
/*static */ void
CompositorParent::PostInsertVsyncProfilerMarker(TimeStamp aVsyncTimestamp)
{
if (profiler_is_active() && sCompositorThreadHolder) {
if (profiler_is_active()) {
CompositorLoop()->PostTask(FROM_HERE,
NewRunnableFunction(InsertVsyncProfilerMarker, aVsyncTimestamp));
}

View File

@ -8,11 +8,6 @@
#include "mozilla/layers/CompositorParent.h"
#include "gfxPrefs.h"
#ifdef MOZ_ENABLE_PROFILER_SPS
#include "GeckoProfiler.h"
#include "ProfilerMarkers.h"
#endif
#ifdef MOZ_WIDGET_GONK
#include "GeckoTouchDispatcher.h"
#endif
@ -46,12 +41,6 @@ VsyncDispatcher::~VsyncDispatcher()
mCompositorObservers.Clear();
}
void
VsyncDispatcher::SetVsyncSource(VsyncSource* aVsyncSource)
{
mVsyncSource = aVsyncSource;
}
void
VsyncDispatcher::DispatchTouchEvents(bool aNotifiedCompositors, TimeStamp aVsyncTime)
{
@ -68,12 +57,6 @@ void
VsyncDispatcher::NotifyVsync(TimeStamp aVsyncTimestamp)
{
bool notifiedCompositors = false;
#ifdef MOZ_ENABLE_PROFILER_SPS
if (profiler_is_active()) {
CompositorParent::PostInsertVsyncProfilerMarker(aVsyncTimestamp);
}
#endif
if (gfxPrefs::VsyncAlignedCompositor()) {
MutexAutoLock lock(mCompositorObserverLock);
notifiedCompositors = NotifyVsyncObservers(aVsyncTimestamp, mCompositorObservers);
@ -105,7 +88,7 @@ VsyncDispatcher::AddCompositorVsyncObserver(VsyncObserver* aVsyncObserver)
void
VsyncDispatcher::RemoveCompositorVsyncObserver(VsyncObserver* aVsyncObserver)
{
MOZ_ASSERT(CompositorParent::IsInCompositorThread() || NS_IsMainThread());
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
MutexAutoLock lock(mCompositorObserverLock);
if (mCompositorObservers.Contains(aVsyncObserver)) {
mCompositorObservers.RemoveElement(aVsyncObserver);

View File

@ -21,19 +21,6 @@ namespace layers {
class CompositorVsyncObserver;
}
// Controls how and when to enable/disable vsync.
class VsyncSource
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VsyncSource)
virtual void EnableVsync() = 0;
virtual void DisableVsync() = 0;
virtual bool IsVsyncEnabled() = 0;
protected:
virtual ~VsyncSource() {}
}; // VsyncSource
class VsyncObserver
{
// Must be destroyed on main thread since the compositor is as well
@ -47,7 +34,7 @@ public:
protected:
VsyncObserver() {}
virtual ~VsyncObserver() {}
}; // VsyncObserver
};
// VsyncDispatcher is used to dispatch vsync events to the registered observers.
class VsyncDispatcher
@ -57,13 +44,7 @@ class VsyncDispatcher
public:
static VsyncDispatcher* GetInstance();
// Called on the vsync thread when a hardware vsync occurs
// The aVsyncTimestamp can mean different things depending on the platform:
// b2g - The vsync timestamp of the previous frame that was just displayed
// OSX - The vsync timestamp of the upcoming frame
// TODO: Windows / Linux. DOCUMENT THIS WHEN IMPLEMENTING ON THOSE PLATFORMS
// Android: TODO
void NotifyVsync(TimeStamp aVsyncTimestamp);
void SetVsyncSource(VsyncSource* aVsyncSource);
// Compositor vsync observers must be added/removed on the compositor thread
void AddCompositorVsyncObserver(VsyncObserver* aVsyncObserver);
@ -80,8 +61,7 @@ private:
// Can have multiple compositors. On desktop, this is 1 compositor per window
Mutex mCompositorObserverLock;
nsTArray<nsRefPtr<VsyncObserver>> mCompositorObservers;
nsRefPtr<VsyncSource> mVsyncSource;
}; // VsyncDispatcher
};
} // namespace mozilla

View File

@ -5,7 +5,7 @@
/*
* Runs the main native Cocoa run loop, interrupting it as needed to process
* Gecko events.
* Gecko events.
*/
#ifndef nsAppShell_h_
@ -30,7 +30,7 @@ class nsAppShell : public nsBaseAppShell
{
public:
NS_IMETHOD ResumeNative(void);
nsAppShell();
nsresult Init();

View File

@ -9,7 +9,6 @@
*/
#import <Cocoa/Cocoa.h>
#import <CoreVideo/CoreVideo.h>
#include "CustomCocoaEvents.h"
#include "mozilla/WidgetTraceEvent.h"
@ -38,9 +37,6 @@
#include <IOKit/pwr_mgt/IOPMLib.h>
#include "nsIDOMWakeLockListener.h"
#include "nsIPowerManagerService.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/VsyncDispatcher.h"
#include "gfxPrefs.h"
using namespace mozilla::widget;
@ -91,85 +87,7 @@ private:
}
return NS_OK;
}
}; // MacWakeLockListener
// This is the renderer output callback function, called on the vsync thread
static CVReturn VsyncCallback(CVDisplayLinkRef aDisplayLink,
const CVTimeStamp* aNow,
const CVTimeStamp* aOutputTime,
CVOptionFlags aFlagsIn,
CVOptionFlags* aFlagsOut,
void* aDisplayLinkContext)
{
VsyncSource* vsyncSource = (VsyncSource*) aDisplayLinkContext;
if (vsyncSource->IsVsyncEnabled()) {
// Now refers to "Now" as in when this callback is called or when the current frame
// is displayed. aOutputTime is when the next frame should be displayed.
// Now is VERY VERY noisy, aOutputTime is in the future though.
int64_t timestamp = aOutputTime->hostTime;
mozilla::TimeStamp vsyncTime = mozilla::TimeStamp::FromSystemTime(timestamp);
mozilla::VsyncDispatcher::GetInstance()->NotifyVsync(vsyncTime);
return kCVReturnSuccess;
} else {
return kCVReturnDisplayLinkNotRunning;
}
}
class OSXVsyncSource MOZ_FINAL : public VsyncSource
{
public:
OSXVsyncSource()
{
EnableVsync();
}
virtual void EnableVsync() MOZ_OVERRIDE
{
// 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
// situations. According to the docs, it is compatible with all displays running on the computer
// But if we have different monitors at different display rates, we may hit issues.
if (CVDisplayLinkCreateWithActiveCGDisplays(&mDisplayLink) != kCVReturnSuccess) {
NS_WARNING("Could not create a display link, returning");
return;
}
// Set the renderer output callback function
if (CVDisplayLinkSetOutputCallback(mDisplayLink, &VsyncCallback, this) != kCVReturnSuccess) {
NS_WARNING("Could not set displaylink output callback");
return;
}
// Activate the display link
if (CVDisplayLinkStart(mDisplayLink) != kCVReturnSuccess) {
NS_WARNING("Could not activate the display link");
mDisplayLink = nullptr;
}
}
virtual void DisableVsync() MOZ_OVERRIDE
{
// Release the display link
if (mDisplayLink) {
CVDisplayLinkRelease(mDisplayLink);
mDisplayLink = nullptr;
}
}
virtual bool IsVsyncEnabled() MOZ_OVERRIDE
{
return mDisplayLink != nullptr;
}
private:
virtual ~OSXVsyncSource()
{
DisableVsync();
}
// Manages the display link render thread
CVDisplayLinkRef mDisplayLink;
}; // OSXVsyncSource
};
// defined in nsCocoaWindow.mm
extern int32_t gXULModalLevel;
@ -369,7 +287,7 @@ nsAppShell::Init()
// context.version = 0;
context.info = this;
context.perform = ProcessGeckoEvents;
mCFRunLoopSource = ::CFRunLoopSourceCreate(kCFAllocatorDefault, 0, &context);
NS_ENSURE_STATE(mCFRunLoopSource);
@ -377,15 +295,6 @@ nsAppShell::Init()
rv = nsBaseAppShell::Init();
// gfxPrefs are init on the main thread and we need it super early
// to see if we should enable vsync aligned compositor
gfxPrefs::GetSingleton();
if (gfxPrefs::HardwareVsyncEnabled() && gfxPrefs::VsyncAlignedCompositor())
{
nsRefPtr<VsyncSource> osxVsyncSource = new OSXVsyncSource();
mozilla::VsyncDispatcher::GetInstance()->SetVsyncSource(osxVsyncSource);
}
#ifndef __LP64__
TextInputHandler::InstallPluginKeyEventsHandler();
#endif

View File

@ -29,6 +29,12 @@
#include "mozilla/StaticPtr.h"
#include "cutils/properties.h"
#include "gfx2DGlue.h"
#include "GeckoTouchDispatcher.h"
#ifdef MOZ_ENABLE_PROFILER_SPS
#include "GeckoProfiler.h"
#include "ProfilerMarkers.h"
#endif
#if ANDROID_VERSION >= 17
#include "libdisplay/FramebufferSurface.h"
@ -231,12 +237,19 @@ HwcComposer2D::RunVsyncEventControl(bool aEnable)
void
HwcComposer2D::Vsync(int aDisplay, nsecs_t aVsyncTimestamp)
{
TimeStamp vsyncTime = mozilla::TimeStamp::FromSystemTime(aVsyncTimestamp);
TimeStamp vsyncTime = mozilla::TimeStamp(aVsyncTimestamp);
nsecs_t vsyncInterval = aVsyncTimestamp - mLastVsyncTime;
if (vsyncInterval < 16000000 || vsyncInterval > 17000000) {
LOGE("Non-uniform vsync interval: %lld\n", vsyncInterval);
}
mLastVsyncTime = aVsyncTimestamp;
#ifdef MOZ_ENABLE_PROFILER_SPS
if (profiler_is_active()) {
CompositorParent::PostInsertVsyncProfilerMarker(vsyncTime);
}
#endif
VsyncDispatcher::GetInstance()->NotifyVsync(vsyncTime);
}

View File

@ -715,7 +715,7 @@ GeckoInputDispatcher::notifyMotion(const NotifyMotionArgs* args)
int32_t action = args->action & AMOTION_EVENT_ACTION_MASK;
int touchCount = args->pointerCount;
MOZ_ASSERT(touchCount <= MAX_POINTERS);
TimeStamp timestamp = mozilla::TimeStamp::FromSystemTime(args->eventTime);
TimeStamp timestamp = TimeStamp(args->eventTime);
Modifiers modifiers = getDOMModifiers(args->metaState);
MultiTouchInput::MultiTouchType touchType = MultiTouchInput::MULTITOUCH_CANCEL;

View File

@ -387,20 +387,11 @@ public:
MOZ_CONSTEXPR TimeStamp() : mValue(0) {}
// Default copy-constructor and assignment are OK
/**
* The system timestamps are the same as the TimeStamp
* retrieved by mozilla::TimeStamp. Since we need this for
* vsync timestamps, we enable the creation of mozilla::TimeStamps
* on platforms that support vsync aligned refresh drivers / compositors
* Verified true as of Nov 7, 2014: B2G and OS X
* UNTESTED ON OTHER PLATFORMS
*/
#if defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_COCOA)
static TimeStamp FromSystemTime(int64_t aSystemTime)
#ifdef MOZ_WIDGET_GONK
TimeStamp(int64_t aAndroidTime) : mValue(aAndroidTime)
{
static_assert(sizeof(aSystemTime) == sizeof(TimeStampValue),
"System timestamp should be same units as TimeStampValue");
return TimeStamp(aSystemTime);
static_assert(sizeof(aAndroidTime) == sizeof(TimeStampValue),
"Android timestamp should be same units as TimeStampValue");
}
#endif