mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Merge pull request #13748 from ElderOrb/FB16831
FB16831 qml-related warnings in log
This commit is contained in:
commit
032e67fd8e
5 changed files with 28 additions and 4 deletions
|
@ -2924,6 +2924,15 @@ void Application::initializeUi() {
|
||||||
|
|
||||||
// Pre-create a couple of Web3D overlays to speed up tablet UI
|
// Pre-create a couple of Web3D overlays to speed up tablet UI
|
||||||
auto offscreenSurfaceCache = DependencyManager::get<OffscreenQmlSurfaceCache>();
|
auto offscreenSurfaceCache = DependencyManager::get<OffscreenQmlSurfaceCache>();
|
||||||
|
offscreenSurfaceCache->setOnRootContextCreated([&](const QString& rootObject, QQmlContext* surfaceContext) {
|
||||||
|
if (rootObject == TabletScriptingInterface::QML) {
|
||||||
|
// in Qt 5.10.0 there is already an "Audio" object in the QML context
|
||||||
|
// though I failed to find it (from QtMultimedia??). So.. let it be "AudioScriptingInterface"
|
||||||
|
surfaceContext->setContextProperty("AudioScriptingInterface", DependencyManager::get<AudioScriptingInterface>().data());
|
||||||
|
surfaceContext->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
offscreenSurfaceCache->reserve(TabletScriptingInterface::QML, 1);
|
offscreenSurfaceCache->reserve(TabletScriptingInterface::QML, 1);
|
||||||
offscreenSurfaceCache->reserve(Web3DOverlay::QML, 2);
|
offscreenSurfaceCache->reserve(Web3DOverlay::QML, 2);
|
||||||
|
|
||||||
|
|
|
@ -184,9 +184,11 @@ void Web3DOverlay::buildWebSurface() {
|
||||||
_webSurface->getRootItem()->setProperty("scriptURL", _scriptURL);
|
_webSurface->getRootItem()->setProperty("scriptURL", _scriptURL);
|
||||||
} else {
|
} else {
|
||||||
_webSurface = QSharedPointer<OffscreenQmlSurface>(new OffscreenQmlSurface(), qmlSurfaceDeleter);
|
_webSurface = QSharedPointer<OffscreenQmlSurface>(new OffscreenQmlSurface(), qmlSurfaceDeleter);
|
||||||
|
connect(_webSurface.data(), &hifi::qml::OffscreenSurface::rootContextCreated, [this](QQmlContext* surfaceContext) {
|
||||||
|
setupQmlSurface(_url == TabletScriptingInterface::QML);
|
||||||
|
});
|
||||||
_webSurface->load(_url);
|
_webSurface->load(_url);
|
||||||
_cachedWebSurface = false;
|
_cachedWebSurface = false;
|
||||||
setupQmlSurface();
|
|
||||||
}
|
}
|
||||||
_webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(getWorldPosition()));
|
_webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(getWorldPosition()));
|
||||||
onResizeWebSurface();
|
onResizeWebSurface();
|
||||||
|
@ -214,7 +216,7 @@ bool Web3DOverlay::isWebContent() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Web3DOverlay::setupQmlSurface() {
|
void Web3DOverlay::setupQmlSurface(bool isTablet) {
|
||||||
_webSurface->getSurfaceContext()->setContextProperty("Users", DependencyManager::get<UsersScriptingInterface>().data());
|
_webSurface->getSurfaceContext()->setContextProperty("Users", DependencyManager::get<UsersScriptingInterface>().data());
|
||||||
_webSurface->getSurfaceContext()->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
|
_webSurface->getSurfaceContext()->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
|
||||||
_webSurface->getSurfaceContext()->setContextProperty("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data());
|
_webSurface->getSurfaceContext()->setContextProperty("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data());
|
||||||
|
@ -225,7 +227,7 @@ void Web3DOverlay::setupQmlSurface() {
|
||||||
_webSurface->getSurfaceContext()->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
_webSurface->getSurfaceContext()->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
||||||
_webSurface->getSurfaceContext()->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data());
|
_webSurface->getSurfaceContext()->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data());
|
||||||
|
|
||||||
if (_webSurface->getRootItem() && _webSurface->getRootItem()->objectName() == "tabletRoot") {
|
if (isTablet) {
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
auto flags = tabletScriptingInterface->getFlags();
|
auto flags = tabletScriptingInterface->getFlags();
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ protected:
|
||||||
Transform evalRenderTransform() override;
|
Transform evalRenderTransform() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupQmlSurface();
|
void setupQmlSurface(bool isTablet);
|
||||||
void rebuildWebSurface();
|
void rebuildWebSurface();
|
||||||
bool isWebContent() const;
|
bool isWebContent() const;
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,18 @@ void OffscreenQmlSurfaceCache::release(const QString& rootSource, const QSharedP
|
||||||
|
|
||||||
QSharedPointer<OffscreenQmlSurface> OffscreenQmlSurfaceCache::buildSurface(const QString& rootSource) {
|
QSharedPointer<OffscreenQmlSurface> OffscreenQmlSurfaceCache::buildSurface(const QString& rootSource) {
|
||||||
auto surface = QSharedPointer<OffscreenQmlSurface>(new OffscreenQmlSurface());
|
auto surface = QSharedPointer<OffscreenQmlSurface>(new OffscreenQmlSurface());
|
||||||
|
|
||||||
|
QObject::connect(surface.data(), &hifi::qml::OffscreenSurface::rootContextCreated, [this, rootSource](QQmlContext* surfaceContext) {
|
||||||
|
if (_onRootContextCreated) {
|
||||||
|
_onRootContextCreated(rootSource, surfaceContext);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
surface->load(rootSource);
|
surface->load(rootSource);
|
||||||
surface->resize(QSize(100, 100));
|
surface->resize(QSize(100, 100));
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OffscreenQmlSurfaceCache::setOnRootContextCreated(const std::function<void(const QString& rootSource, QQmlContext* rootContext)>& onRootContextCreated) {
|
||||||
|
_onRootContextCreated = onRootContextCreated;
|
||||||
|
}
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
|
|
||||||
|
class QQmlContext;
|
||||||
class OffscreenQmlSurface;
|
class OffscreenQmlSurface;
|
||||||
|
|
||||||
class OffscreenQmlSurfaceCache : public Dependency {
|
class OffscreenQmlSurfaceCache : public Dependency {
|
||||||
|
@ -25,10 +26,12 @@ public:
|
||||||
QSharedPointer<OffscreenQmlSurface> acquire(const QString& rootSource);
|
QSharedPointer<OffscreenQmlSurface> acquire(const QString& rootSource);
|
||||||
void release(const QString& rootSource, const QSharedPointer<OffscreenQmlSurface>& surface);
|
void release(const QString& rootSource, const QSharedPointer<OffscreenQmlSurface>& surface);
|
||||||
void reserve(const QString& rootSource, int count = 1);
|
void reserve(const QString& rootSource, int count = 1);
|
||||||
|
void setOnRootContextCreated(const std::function<void(const QString& rootSource, QQmlContext* rootContext)> & onRootContextCreated);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<OffscreenQmlSurface> buildSurface(const QString& rootSource);
|
QSharedPointer<OffscreenQmlSurface> buildSurface(const QString& rootSource);
|
||||||
QHash<QString, QList<QSharedPointer<OffscreenQmlSurface>>> _cache;
|
QHash<QString, QList<QSharedPointer<OffscreenQmlSurface>>> _cache;
|
||||||
|
std::function<void(const QString& rootSource, QQmlContext* rootContext)> _onRootContextCreated;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue