mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 16:13:28 +02:00
make maxFPS a property
This commit is contained in:
parent
ae48dae96f
commit
28ade45f97
2 changed files with 28 additions and 2 deletions
|
@ -179,12 +179,20 @@ void Web3DOverlay::loadSourceURL() {
|
|||
tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface->getRootItem(), _webSurface.data());
|
||||
|
||||
// Override min fps for tablet UI, for silky smooth scrolling
|
||||
_webSurface->setMaxFps(90);
|
||||
setMaxFPS(90);
|
||||
}
|
||||
}
|
||||
_webSurface->getRootContext()->setContextProperty("globalPosition", vec3toVariant(getPosition()));
|
||||
}
|
||||
|
||||
void Web3DOverlay::setMaxFPS(uint8_t maxFPS) {
|
||||
_desiredMaxFPS = maxFPS;
|
||||
if (_webSurface) {
|
||||
_webSurface->setMaxFps(_desiredMaxFPS);
|
||||
_currentMaxFPS = _desiredMaxFPS;
|
||||
}
|
||||
}
|
||||
|
||||
void Web3DOverlay::render(RenderArgs* args) {
|
||||
if (!_visible || !getParentVisible()) {
|
||||
return;
|
||||
|
@ -194,9 +202,11 @@ void Web3DOverlay::render(RenderArgs* args) {
|
|||
QSurface * currentSurface = currentContext->surface();
|
||||
if (!_webSurface) {
|
||||
_webSurface = DependencyManager::get<OffscreenQmlSurfaceCache>()->acquire(pickURL());
|
||||
_webSurface->setMaxFps(10);
|
||||
// FIXME, the max FPS could be better managed by being dynamic (based on the number of current surfaces
|
||||
// and the current rendering load)
|
||||
if (_currentMaxFPS != _desiredMaxFPS) {
|
||||
setMaxFPS(_desiredMaxFPS);
|
||||
}
|
||||
loadSourceURL();
|
||||
_webSurface->resume();
|
||||
_webSurface->resize(QSize(_resolution.x, _resolution.y));
|
||||
|
@ -246,6 +256,10 @@ void Web3DOverlay::render(RenderArgs* args) {
|
|||
|
||||
_emitScriptEventConnection = connect(this, &Web3DOverlay::scriptEventReceived, _webSurface.data(), &OffscreenQmlSurface::emitScriptEvent);
|
||||
_webEventReceivedConnection = connect(_webSurface.data(), &OffscreenQmlSurface::webEventReceived, this, &Web3DOverlay::webEventReceived);
|
||||
} else {
|
||||
if (_currentMaxFPS != _desiredMaxFPS) {
|
||||
setMaxFPS(_desiredMaxFPS);
|
||||
}
|
||||
}
|
||||
|
||||
vec2 halfSize = getSize() / 2.0f;
|
||||
|
@ -401,6 +415,11 @@ void Web3DOverlay::setProperties(const QVariantMap& properties) {
|
|||
_dpi = dpi.toFloat();
|
||||
}
|
||||
|
||||
auto maxFPS = properties["maxFPS"];
|
||||
if (maxFPS.isValid()) {
|
||||
_desiredMaxFPS = maxFPS.toInt();
|
||||
}
|
||||
|
||||
auto showKeyboardFocusHighlight = properties["showKeyboardFocusHighlight"];
|
||||
if (showKeyboardFocusHighlight.isValid()) {
|
||||
_showKeyboardFocusHighlight = showKeyboardFocusHighlight.toBool();
|
||||
|
@ -420,6 +439,9 @@ QVariant Web3DOverlay::getProperty(const QString& property) {
|
|||
if (property == "dpi") {
|
||||
return _dpi;
|
||||
}
|
||||
if (property == "maxFPS") {
|
||||
return _desiredMaxFPS;
|
||||
}
|
||||
if (property == "showKeyboardFocusHighlight") {
|
||||
return _showKeyboardFocusHighlight;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
|
||||
QString pickURL();
|
||||
void loadSourceURL();
|
||||
void setMaxFPS(uint8_t maxFPS);
|
||||
virtual void render(RenderArgs* args) override;
|
||||
virtual const render::ShapeKey getShapeKey() override;
|
||||
|
||||
|
@ -75,6 +76,9 @@ private:
|
|||
bool _pressed{ false };
|
||||
QTouchDevice _touchDevice;
|
||||
|
||||
uint8_t _desiredMaxFPS { 10 };
|
||||
uint8_t _currentMaxFPS { 0 };
|
||||
|
||||
QMetaObject::Connection _mousePressConnection;
|
||||
QMetaObject::Connection _mouseReleaseConnection;
|
||||
QMetaObject::Connection _mouseMoveConnection;
|
||||
|
|
Loading…
Reference in a new issue