Bug 1155797 - P3: turn on vsync for kk, l and up. r=mwu

--HG--
extra : rebase_source : 6fb3d2c7c1c94fe8bbffb8d1e1e7a87049068738
This commit is contained in:
JerryShih 2015-05-17 18:12:00 +02:00
parent 8f5182d756
commit b90f6b5dcc
2 changed files with 19 additions and 10 deletions

View File

@ -487,12 +487,12 @@ private:
already_AddRefed<mozilla::gfx::VsyncSource>
gfxAndroidPlatform::CreateHardwareVsyncSource()
{
// Only enable true hardware vsync on kit-kat due to L HwcComposer issues
// Jelly Bean has inaccurate hardware vsync so disable on JB
// Android pre-JB doesn't have hardware vsync
// Once L HwcComposer issues have been resolved, re-enable for L devices
// L is andriod version 21, Kit-kat is 19, 20 is kit-kat for wearables
#if defined(MOZ_WIDGET_GONK) && (ANDROID_VERSION == 19)
// Only enable true hardware vsync on kit-kat and L device. Jelly Bean has
// inaccurate hardware vsync so disable on JB. Android pre-JB doesn't have
// hardware vsync.
// L is android version 21, L-MR1 is 22, kit-kat is 19, 20 is kit-kat for
// wearables.
#if defined(MOZ_WIDGET_GONK) && (ANDROID_VERSION == 19 || ANDROID_VERSION >= 21)
nsRefPtr<GonkVsyncSource> vsyncSource = new GonkVsyncSource();
VsyncSource::Display& display = vsyncSource->GetGlobalDisplay();
display.EnableVsync();

View File

@ -177,7 +177,9 @@ HwcComposer2D::GetInstance()
bool
HwcComposer2D::EnableVsync(bool aEnable)
{
#if ANDROID_VERSION >= 17
// Only support hardware vsync on kitkat, L and up due to inaccurate timings
// with JellyBean.
#if (ANDROID_VERSION == 19 || ANDROID_VERSION >= 21)
MOZ_ASSERT(NS_IsMainThread());
if (!mHasHWVsync) {
return false;
@ -208,9 +210,9 @@ HwcComposer2D::RegisterHwcEventCallback()
device->eventControl(device, HWC_DISPLAY_PRIMARY, HWC_EVENT_VSYNC, false);
device->registerProcs(device, &sHWCProcs);
// Only support actual hardware vsync on kitkat due to innaccurate timings
// with JellyBean, and HwcComposer bugs with L. Reenable for L later
#if ANDROID_VERSION == 19
// Only support hardware vsync on kitkat, L and up due to inaccurate timings
// with JellyBean.
#if (ANDROID_VERSION == 19 || ANDROID_VERSION >= 21)
mHasHWVsync = gfxPrefs::HardwareVsyncEnabled();
#else
mHasHWVsync = false;
@ -221,8 +223,15 @@ HwcComposer2D::RegisterHwcEventCallback()
void
HwcComposer2D::Vsync(int aDisplay, nsecs_t aVsyncTimestamp)
{
// Only support hardware vsync on kitkat, L and up due to inaccurate timings
// with JellyBean.
#if (ANDROID_VERSION == 19 || ANDROID_VERSION >= 21)
TimeStamp vsyncTime = mozilla::TimeStamp::FromSystemTime(aVsyncTimestamp);
gfxPlatform::GetPlatform()->GetHardwareVsync()->GetGlobalDisplay().NotifyVsync(vsyncTime);
#else
// If this device doesn't support vsync, this function should not be used.
MOZ_ASSERT(false);
#endif
}
// Called on the "invalidator" thread (run from HAL).