Bug 1142957 Fallback to main display CVDisplayLink if active displays aren't available. r=mstange

This commit is contained in:
Mason Chang 2015-03-14 21:23:53 -07:00
parent 45c2f888bf
commit 9b0dfb4e5f
2 changed files with 19 additions and 2 deletions

View File

@ -124,6 +124,10 @@ VsyncSource::Display::UpdateVsyncStatus()
} else {
DisableVsync();
}
if (IsVsyncEnabled() != enableVsync) {
NS_WARNING("Vsync status did not change.");
}
}
nsRefPtr<RefreshTimerVsyncDispatcher>

View File

@ -469,18 +469,31 @@ public:
// 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;
NS_WARNING("Could not create a display link with all active displays. Falling back to main display\n");
CVDisplayLinkRelease(mDisplayLink);
// bug 1142708 - When coming back from sleep, there may be no active displays ready yet,
// even if listening for the kIOMessageSystemHasPoweredOn event from OS X sleep notifications.
// Active displays are those that are drawable.
// In these cases, default back to the main display to try to get a vsync event.
// The alternative would be to keep polling the CGActiveDisplayList for the displays to be ready.
if (CVDisplayLinkCreateWithCGDisplay(CGMainDisplayID(), &mDisplayLink) != kCVReturnSuccess) {
MOZ_CRASH("Could not create a CVDisplayLink with either active displays or the main display");
}
NS_WARNING("Using the CVDisplayLink from the main display\n");
}
if (CVDisplayLinkSetOutputCallback(mDisplayLink, &VsyncCallback, this) != kCVReturnSuccess) {
NS_WARNING("Could not set displaylink output callback");
CVDisplayLinkRelease(mDisplayLink);
mDisplayLink = nullptr;
return;
}
mPreviousTimestamp = TimeStamp::Now();
if (CVDisplayLinkStart(mDisplayLink) != kCVReturnSuccess) {
NS_WARNING("Could not activate the display link");
CVDisplayLinkRelease(mDisplayLink);
mDisplayLink = nullptr;
}
}