Merge branch 'master' of git://github.com/highfidelity/hifi into fadeshape

This commit is contained in:
Olivier Prat 2017-07-18 10:47:21 +02:00
commit 236270d798
11 changed files with 192 additions and 35 deletions

View file

@ -69,6 +69,7 @@
#include <EntityScriptClient.h>
#include <EntityScriptServerLogClient.h>
#include <EntityScriptingInterface.h>
#include <HoverOverlayInterface.h>
#include <ErrorDialog.h>
#include <FileScriptingInterface.h>
#include <Finally.h>
@ -588,6 +589,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
DependencyManager::set<Snapshot>();
DependencyManager::set<CloseEventSender>();
DependencyManager::set<ResourceManager>();
DependencyManager::set<HoverOverlayInterface>();
return previousSessionCrashed;
}
@ -1514,6 +1516,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
properties["atp_mapping_requests"] = atpMappingRequests;
properties["throttled"] = _displayPlugin ? _displayPlugin->isThrottled() : false;
QJsonObject bytesDownloaded;
bytesDownloaded["atp"] = statTracker->getStat(STAT_ATP_RESOURCE_TOTAL_BYTES).toInt();
bytesDownloaded["http"] = statTracker->getStat(STAT_HTTP_RESOURCE_TOTAL_BYTES).toInt();
bytesDownloaded["file"] = statTracker->getStat(STAT_FILE_RESOURCE_TOTAL_BYTES).toInt();
bytesDownloaded["total"] = bytesDownloaded["atp"].toInt() + bytesDownloaded["http"].toInt()
+ bytesDownloaded["file"].toInt();
properties["bytesDownloaded"] = bytesDownloaded;
auto myAvatar = getMyAvatar();
glm::vec3 avatarPosition = myAvatar->getPosition();

View file

@ -26,6 +26,7 @@
#include <PerfStat.h>
#include <SceneScriptingInterface.h>
#include <ScriptEngine.h>
#include <HoverOverlayInterface.h>
#include "RenderableEntityItem.h"
@ -452,6 +453,8 @@ RayToEntityIntersectionResult EntityTreeRenderer::findRayIntersectionWorker(cons
void EntityTreeRenderer::connectSignalsToSlots(EntityScriptingInterface* entityScriptingInterface) {
auto hoverOverlayInterface = DependencyManager::get<HoverOverlayInterface>().data();
connect(this, &EntityTreeRenderer::mousePressOnEntity, entityScriptingInterface, &EntityScriptingInterface::mousePressOnEntity);
connect(this, &EntityTreeRenderer::mouseMoveOnEntity, entityScriptingInterface, &EntityScriptingInterface::mouseMoveOnEntity);
connect(this, &EntityTreeRenderer::mouseReleaseOnEntity, entityScriptingInterface, &EntityScriptingInterface::mouseReleaseOnEntity);
@ -461,8 +464,12 @@ void EntityTreeRenderer::connectSignalsToSlots(EntityScriptingInterface* entityS
connect(this, &EntityTreeRenderer::clickReleaseOnEntity, entityScriptingInterface, &EntityScriptingInterface::clickReleaseOnEntity);
connect(this, &EntityTreeRenderer::hoverEnterEntity, entityScriptingInterface, &EntityScriptingInterface::hoverEnterEntity);
connect(this, &EntityTreeRenderer::hoverEnterEntity, hoverOverlayInterface, &HoverOverlayInterface::createHoverOverlay);
connect(this, &EntityTreeRenderer::hoverOverEntity, entityScriptingInterface, &EntityScriptingInterface::hoverOverEntity);
connect(this, &EntityTreeRenderer::hoverLeaveEntity, entityScriptingInterface, &EntityScriptingInterface::hoverLeaveEntity);
connect(this, &EntityTreeRenderer::hoverLeaveEntity, hoverOverlayInterface, &HoverOverlayInterface::destroyHoverOverlay);
connect(this, &EntityTreeRenderer::enterEntity, entityScriptingInterface, &EntityScriptingInterface::enterEntity);
connect(this, &EntityTreeRenderer::leaveEntity, entityScriptingInterface, &EntityScriptingInterface::leaveEntity);

View file

@ -0,0 +1,30 @@
//
// HoverOverlayInterface.cpp
// libraries/entities/src
//
// Created by Zach Fox on 2017-07-14.
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "HoverOverlayInterface.h"
HoverOverlayInterface::HoverOverlayInterface() {
// "hover_overlay" debug log category disabled by default.
// Create your own "qtlogging.ini" file and set your "QT_LOGGING_CONF" environment variable
// if you'd like to enable/disable certain categories.
// More details: http://doc.qt.io/qt-5/qloggingcategory.html#configuring-categories
QLoggingCategory::setFilterRules(QStringLiteral("hifi.hover_overlay.debug=false"));
}
void HoverOverlayInterface::createHoverOverlay(const EntityItemID& entityItemID, const PointerEvent& event) {
qCDebug(hover_overlay) << "Creating Hover Overlay on top of entity with ID: " << entityItemID;
setCurrentHoveredEntity(entityItemID);
}
void HoverOverlayInterface::destroyHoverOverlay(const EntityItemID& entityItemID, const PointerEvent& event) {
qCDebug(hover_overlay) << "Destroying Hover Overlay on top of entity with ID: " << entityItemID;
setCurrentHoveredEntity(QUuid());
}

View file

@ -0,0 +1,44 @@
//
// HoverOverlayInterface.h
// libraries/entities/src
//
// Created by Zach Fox on 2017-07-14.
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#pragma once
#ifndef hifi_HoverOverlayInterface_h
#define hifi_HoverOverlayInterface_h
#include <QtCore/QObject>
#include <QUuid>
#include <DependencyManager.h>
#include <PointerEvent.h>
#include "EntityTree.h"
#include "HoverOverlayLogging.h"
class HoverOverlayInterface : public QObject, public Dependency {
Q_OBJECT
Q_PROPERTY(QUuid currentHoveredEntity READ getCurrentHoveredEntity WRITE setCurrentHoveredEntity)
public:
HoverOverlayInterface();
Q_INVOKABLE QUuid getCurrentHoveredEntity() { return _currentHoveredEntity; }
void setCurrentHoveredEntity(const QUuid& entityID) { _currentHoveredEntity = entityID; }
public slots:
void createHoverOverlay(const EntityItemID& entityItemID, const PointerEvent& event);
void destroyHoverOverlay(const EntityItemID& entityItemID, const PointerEvent& event);
private:
bool _verboseLogging { true };
QUuid _currentHoveredEntity{};
};
#endif // hifi_HoverOverlayInterface_h

View file

@ -0,0 +1,14 @@
//
// HoverOverlayLogging.cpp
// libraries/entities/src
//
// Created by Zach Fox on 2017-07-17
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "HoverOverlayLogging.h"
Q_LOGGING_CATEGORY(hover_overlay, "hifi.hover_overlay")

View file

@ -0,0 +1,20 @@
//
// HoverOverlayLogging.h
// libraries/entities/src
//
// Created by Zach Fox on 2017-07-17
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#pragma once
#ifndef hifi_HoverOverlayLogging_h
#define hifi_HoverOverlayLogging_h
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(hover_overlay)
#endif // hifi_HoverOverlayLogging_h

View file

@ -187,6 +187,9 @@ void AssetResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytes
emit progress(bytesReceived, bytesTotal);
auto now = p_high_resolution_clock::now();
// Recording ATP bytes downloaded in stats
DependencyManager::get<StatTracker>()->updateStat(STAT_ATP_RESOURCE_TOTAL_BYTES, bytesReceived);
// if we haven't received the full asset check if it is time to output progress to log
// we do so every X seconds to assist with ATP download tracking
@ -201,6 +204,5 @@ void AssetResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytes
_lastProgressDebug = now;
}
}

View file

@ -20,7 +20,7 @@
void FileResourceRequest::doSend() {
auto statTracker = DependencyManager::get<StatTracker>();
statTracker->incrementStat(STAT_FILE_REQUEST_STARTED);
int fileSize = 0;
QString filename = _url.toLocalFile();
// sometimes on windows, we see the toLocalFile() return null,
@ -53,6 +53,7 @@ void FileResourceRequest::doSend() {
}
_result = ResourceRequest::Success;
fileSize = file.size();
}
} else {
@ -68,6 +69,8 @@ void FileResourceRequest::doSend() {
if (_result == ResourceRequest::Success) {
statTracker->incrementStat(STAT_FILE_REQUEST_SUCCESS);
// Recording FILE bytes downloaded in stats
statTracker->updateStat(STAT_FILE_RESOURCE_TOTAL_BYTES,fileSize);
} else {
statTracker->incrementStat(STAT_FILE_REQUEST_FAILED);
}

View file

@ -201,6 +201,11 @@ void HTTPResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytesT
_sendTimer->start();
emit progress(bytesReceived, bytesTotal);
// Recording HTTP bytes downloaded in stats
DependencyManager::get<StatTracker>()->updateStat(STAT_HTTP_RESOURCE_TOTAL_BYTES, bytesReceived);
}
void HTTPResourceRequest::onTimeout() {

View file

@ -33,6 +33,9 @@ const QString STAT_HTTP_REQUEST_CACHE = "CacheHTTPRequest";
const QString STAT_ATP_MAPPING_REQUEST_STARTED = "StartedATPMappingRequest";
const QString STAT_ATP_MAPPING_REQUEST_FAILED = "FailedATPMappingRequest";
const QString STAT_ATP_MAPPING_REQUEST_SUCCESS = "SuccessfulATPMappingRequest";
const QString STAT_HTTP_RESOURCE_TOTAL_BYTES = "HTTPBytesDownloaded";
const QString STAT_ATP_RESOURCE_TOTAL_BYTES = "ATPBytesDownloaded";
const QString STAT_FILE_RESOURCE_TOTAL_BYTES = "FILEBytesDownloaded";
class ResourceRequest : public QObject {
Q_OBJECT

View file

@ -264,9 +264,6 @@ QNetworkAccessManager* QmlNetworkAccessManagerFactory::create(QObject* parent) {
return new QmlNetworkAccessManager(parent);
}
static QQmlEngine* globalEngine { nullptr };
static size_t globalEngineRefCount { 0 };
QString getEventBridgeJavascript() {
// FIXME: Refactor with similar code in RenderableWebEntityItem
QString javaScriptToInject;
@ -300,9 +297,44 @@ private:
};
#define SINGLE_QML_ENGINE 0
#if SINGLE_QML_ENGINE
static QQmlEngine* globalEngine{ nullptr };
static size_t globalEngineRefCount{ 0 };
#endif
void initializeQmlEngine(QQmlEngine* engine, QQuickWindow* window) {
engine->setNetworkAccessManagerFactory(new QmlNetworkAccessManagerFactory);
auto importList = engine->importPathList();
importList.insert(importList.begin(), PathUtils::resourcesPath());
engine->setImportPathList(importList);
for (const auto& path : importList) {
qDebug() << path;
}
if (!engine->incubationController()) {
engine->setIncubationController(window->incubationController());
}
auto rootContext = engine->rootContext();
rootContext->setContextProperty("GL", ::getGLContextData());
rootContext->setContextProperty("urlHandler", new UrlHandler());
rootContext->setContextProperty("resourceDirectoryUrl", QUrl::fromLocalFile(PathUtils::resourcesPath()));
rootContext->setContextProperty("pathToFonts", "../../");
rootContext->setContextProperty("ApplicationInterface", qApp);
auto javaScriptToInject = getEventBridgeJavascript();
if (!javaScriptToInject.isEmpty()) {
rootContext->setContextProperty("eventBridgeJavaScriptToInject", QVariant(javaScriptToInject));
}
rootContext->setContextProperty("FileTypeProfile", new FileTypeProfile(rootContext));
rootContext->setContextProperty("HFWebEngineProfile", new HFWebEngineProfile(rootContext));
rootContext->setContextProperty("HFTabletWebEngineProfile", new HFTabletWebEngineProfile(rootContext));
}
QQmlEngine* acquireEngine(QQuickWindow* window) {
Q_ASSERT(QThread::currentThread() == qApp->thread());
QQmlEngine* result = nullptr;
if (QThread::currentThread() != qApp->thread()) {
qCWarning(uiLogging) << "Cannot acquire QML engine on any thread but the main thread";
}
@ -311,47 +343,34 @@ QQmlEngine* acquireEngine(QQuickWindow* window) {
qmlRegisterType<SoundEffect>("Hifi", 1, 0, "SoundEffect");
});
#if SINGLE_QML_ENGINE
if (!globalEngine) {
Q_ASSERT(0 == globalEngineRefCount);
globalEngine = new QQmlEngine();
globalEngine->setNetworkAccessManagerFactory(new QmlNetworkAccessManagerFactory);
auto importList = globalEngine->importPathList();
importList.insert(importList.begin(), PathUtils::resourcesPath());
globalEngine->setImportPathList(importList);
for (const auto& path : importList) {
qDebug() << path;
}
if (!globalEngine->incubationController()) {
globalEngine->setIncubationController(window->incubationController());
}
auto rootContext = globalEngine->rootContext();
rootContext->setContextProperty("GL", ::getGLContextData());
rootContext->setContextProperty("urlHandler", new UrlHandler());
rootContext->setContextProperty("resourceDirectoryUrl", QUrl::fromLocalFile(PathUtils::resourcesPath()));
rootContext->setContextProperty("pathToFonts", "../../");
rootContext->setContextProperty("ApplicationInterface", qApp);
auto javaScriptToInject = getEventBridgeJavascript();
if (!javaScriptToInject.isEmpty()) {
rootContext->setContextProperty("eventBridgeJavaScriptToInject", QVariant(javaScriptToInject));
}
rootContext->setContextProperty("FileTypeProfile", new FileTypeProfile(rootContext));
rootContext->setContextProperty("HFWebEngineProfile", new HFWebEngineProfile(rootContext));
rootContext->setContextProperty("HFTabletWebEngineProfile", new HFTabletWebEngineProfile(rootContext));
initializeQmlEngine(result, window);
++globalEngineRefCount;
}
result = globalEngine;
#else
result = new QQmlEngine();
initializeQmlEngine(result, window);
#endif
++globalEngineRefCount;
return globalEngine;
return result;
}
void releaseEngine() {
void releaseEngine(QQmlEngine* engine) {
Q_ASSERT(QThread::currentThread() == qApp->thread());
#if SINGLE_QML_ENGINE
Q_ASSERT(0 != globalEngineRefCount);
if (0 == --globalEngineRefCount) {
globalEngine->deleteLater();
globalEngine = nullptr;
}
#else
engine->deleteLater();
#endif
}
void OffscreenQmlSurface::cleanup() {
@ -456,11 +475,11 @@ OffscreenQmlSurface::~OffscreenQmlSurface() {
QObject::disconnect(qApp);
cleanup();
auto engine = _qmlContext->engine();
_canvas->deleteLater();
_rootItem->deleteLater();
_quickWindow->deleteLater();
releaseEngine();
releaseEngine(engine);
}
void OffscreenQmlSurface::onAboutToQuit() {