/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"AndroidVsync.h"
#include"AndroidBridge.h" #include"nsTArray.h"
/** * Implementation for the AndroidVsync class.
*/
/* static */ RefPtr<AndroidVsync> AndroidVsync::GetInstance() { auto weakInstance = sInstance.Lock();
RefPtr<AndroidVsync> instance(*weakInstance); if (!instance) {
instance = new AndroidVsync();
*weakInstance = instance;
} return instance;
}
/** * Owned by the Java AndroidVsync instance.
*/ class AndroidVsyncSupport final
: public java::AndroidVsync::Natives<AndroidVsyncSupport> { public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AndroidVsyncSupport)
using Base = java::AndroidVsync::Natives<AndroidVsyncSupport>; using Base::AttachNative; using Base::DisposeNative;
// Always called on the Java UI thread. void AndroidVsync::NotifyVsync(int64_t aFrameTimeNanos) {
MOZ_ASSERT(AndroidBridge::IsJavaUiThread());
// Convert aFrameTimeNanos to a TimeStamp. The value converts trivially to // the internal ticks representation of TimeStamp_posix; both use the // monotonic clock and are in nanoseconds.
TimeStamp timeStamp = TimeStamp::FromSystemTime(aFrameTimeNanos);
// Do not keep the lock held while calling OnVsync.
nsTArray<Observer*> observers;
{ auto impl = mImpl.Lock();
observers.AppendElements(impl->mInputObservers);
observers.AppendElements(impl->mRenderObservers);
} for (Observer* observer : observers) {
observer->OnVsync(timeStamp);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.