Backed out changeset 14fcdf7cc920 (bug 1075025)

This commit is contained in:
Sebastian Hengst 2016-12-21 09:33:39 +01:00
Родитель 74021bb1c4
Коммит 04338008ec
1 изменённых файлов: 1 добавлений и 95 удалений

Просмотреть файл

@ -29,8 +29,6 @@
#include FT_FREETYPE_H
#include FT_MODULE_H
#include "GeneratedJNINatives.h"
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::gfx;
@ -332,100 +330,8 @@ gfxAndroidPlatform::RequiresLinearZoom()
return gfxPlatform::RequiresLinearZoom();
}
class AndroidVsyncSource final : public VsyncSource {
public:
class JavaVsyncSupport final : public java::VsyncSource::Natives<JavaVsyncSupport>
{
public:
using Base = java::VsyncSource::Natives<JavaVsyncSupport>;
using Base::DisposeNative;
static void NotifyVsync() {
GetDisplayInstance().NotifyVsync(TimeStamp::Now());
}
};
class Display final : public VsyncSource::Display {
public:
Display()
: mJavaVsync(java::VsyncSource::GetInstance())
, mObservingVsync(false)
{
JavaVsyncSupport::Init(); // To register native methods.
}
~Display() { DisableVsync(); }
bool IsVsyncEnabled() override
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mJavaVsync);
return mObservingVsync;
}
void EnableVsync() override
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mJavaVsync);
if (mObservingVsync) {
return;
}
bool ok = mJavaVsync->ObserveVsync(true);
if (ok && !mVsyncDuration) {
float fps = mJavaVsync->GetRefreshRate();
mVsyncDuration = TimeDuration::FromMilliseconds(1000.0 / fps);
}
mObservingVsync = ok;
MOZ_ASSERT(mObservingVsync);
}
void DisableVsync() override
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mJavaVsync);
if (!mObservingVsync) {
return;
}
mObservingVsync = mJavaVsync->ObserveVsync(false);
MOZ_ASSERT(!mObservingVsync);
}
TimeDuration GetVsyncRate() override { return mVsyncDuration; }
void Shutdown() override {
DisableVsync();
mJavaVsync = nullptr;
}
private:
java::VsyncSource::GlobalRef mJavaVsync;
bool mObservingVsync;
TimeDuration mVsyncDuration;
};
Display& GetGlobalDisplay() final { return GetDisplayInstance(); }
private:
virtual ~AndroidVsyncSource() {}
static Display& GetDisplayInstance()
{
static Display globalDisplay;
return globalDisplay;
}
};
already_AddRefed<mozilla::gfx::VsyncSource>
gfxAndroidPlatform::CreateHardwareVsyncSource()
{
if (java::VsyncSource::IsVsyncSupported()) {
RefPtr<AndroidVsyncSource> vsyncSource = new AndroidVsyncSource();
return vsyncSource.forget();
}
NS_WARNING("Vsync not supported. Falling back to software vsync");
return gfxPlatform::CreateHardwareVsyncSource();
}