diff --git a/gfx/thebes/gfxAndroidPlatform.cpp b/gfx/thebes/gfxAndroidPlatform.cpp index 90e9d6487d3c..bf889c0f2e86 100644 --- a/gfx/thebes/gfxAndroidPlatform.cpp +++ b/gfx/thebes/gfxAndroidPlatform.cpp @@ -487,12 +487,12 @@ private: already_AddRefed 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 vsyncSource = new GonkVsyncSource(); VsyncSource::Display& display = vsyncSource->GetGlobalDisplay(); display.EnableVsync(); diff --git a/widget/gonk/HwcComposer2D.cpp b/widget/gonk/HwcComposer2D.cpp index d66621db6620..1f42dcc41f56 100644 --- a/widget/gonk/HwcComposer2D.cpp +++ b/widget/gonk/HwcComposer2D.cpp @@ -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).