mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 10:42:35 +02:00
Adding more libs, ifdefs for android incompatible code
This commit is contained in:
parent
0379ebad63
commit
9df9cf7a47
33 changed files with 409 additions and 106 deletions
|
@ -39,6 +39,17 @@ else()
|
|||
option(BUILD_TESTS "Build tests" ON)
|
||||
endif()
|
||||
|
||||
if (ANDROID)
|
||||
set(PLATFORM_QT_COMPONENTS AndroidExtras WebView)
|
||||
else ()
|
||||
set(PLATFORM_QT_COMPONENTS WebEngine WebEngineWidgets)
|
||||
endif ()
|
||||
|
||||
foreach(PLATFORM_QT_COMPONENT ${PLATFORM_QT_COMPONENTS})
|
||||
list(APPEND PLATFORM_QT_LIBRARIES "Qt5::${PLATFORM_QT_COMPONENT}")
|
||||
endforeach()
|
||||
|
||||
|
||||
option(BUILD_INSTALLER "Build installer" ON)
|
||||
|
||||
MESSAGE(STATUS "Build server: " ${BUILD_SERVER})
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
set(TARGET_NAME native-lib)
|
||||
setup_hifi_library(Gui Qml Quick)
|
||||
link_hifi_libraries(shared networking gl gpu gpu-gles image fbx render-utils physics entities octree)
|
||||
#link_hifi_libraries(shared networking gl gpu gpu-gles image fbx render-utils physics entities octree audio midi recording controllers script-engine ui)
|
||||
link_hifi_libraries(shared networking gl ui)
|
||||
|
||||
target_link_libraries(native-lib android log m)
|
||||
target_opengl()
|
||||
|
|
|
@ -55,7 +55,6 @@ android {
|
|||
dependencies {
|
||||
implementation 'com.google.vr:sdk-audio:1.80.0'
|
||||
implementation 'com.google.vr:sdk-base:1.80.0'
|
||||
implementation files('libs/QtAndroid-bundled.jar')
|
||||
implementation files('libs/QtAndroidBearer-bundled.jar')
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.highfidelity.iface">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.highfidelity.gvrinterface">
|
||||
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="26" />
|
||||
<uses-feature android:glEsVersion="0x00030002" android:required="true" />
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
|
@ -21,7 +21,7 @@
|
|||
android:roundIcon="@mipmap/ic_launcher_round">
|
||||
|
||||
<activity
|
||||
android:name="org.qtproject.qt5.android.bindings.QtActivity"
|
||||
android:name=".InterfaceActivity"
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation"
|
||||
android:launchMode="singleTop"
|
||||
|
|
19
android/app/src/main/cpp/+android/simple.qml
Normal file
19
android/app/src/main/cpp/+android/simple.qml
Normal file
|
@ -0,0 +1,19 @@
|
|||
import QtQuick 2.7
|
||||
import QtWebView 1.1
|
||||
|
||||
Rectangle {
|
||||
id: window
|
||||
anchors.fill: parent
|
||||
color: "red"
|
||||
ColorAnimation on color { from: "blue"; to: "yellow"; duration: 1000; loops: Animation.Infinite }
|
||||
|
||||
Text {
|
||||
text: "Hello"
|
||||
anchors.top: parent.top
|
||||
}
|
||||
WebView {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 10
|
||||
url: "http://doc.qt.io/qt-5/qml-qtwebview-webview.html"
|
||||
}
|
||||
}
|
|
@ -8,7 +8,50 @@
|
|||
#include <QtQml/QQmlEngine>
|
||||
#include <QtQml/QQmlFileSelector>
|
||||
#include <QtQuick/QQuickView>
|
||||
#include <PhysicsEngine.h>
|
||||
#include <QtGui/QOpenGLContext>
|
||||
#include <QtCore/QLoggingCategory>
|
||||
#include <QtWebView/QtWebView>
|
||||
|
||||
#include <gl/Config.h>
|
||||
#include <gl/OffscreenGLCanvas.h>
|
||||
#include <gl/GLWindow.h>
|
||||
|
||||
#include <ui/OffscreenQmlSurface.h>
|
||||
|
||||
Q_LOGGING_CATEGORY(gpugllogging, "hifi.gl")
|
||||
|
||||
bool checkGLError(const char* name) {
|
||||
GLenum error = glGetError();
|
||||
if (!error) {
|
||||
return false;
|
||||
} else {
|
||||
switch (error) {
|
||||
case GL_INVALID_ENUM:
|
||||
qCDebug(gpugllogging) << "GLBackend::" << name << ": An unacceptable value is specified for an enumerated argument.The offending command is ignored and has no other side effect than to set the error flag.";
|
||||
break;
|
||||
case GL_INVALID_VALUE:
|
||||
qCDebug(gpugllogging) << "GLBackend" << name << ": A numeric argument is out of range.The offending command is ignored and has no other side effect than to set the error flag";
|
||||
break;
|
||||
case GL_INVALID_OPERATION:
|
||||
qCDebug(gpugllogging) << "GLBackend" << name << ": The specified operation is not allowed in the current state.The offending command is ignored and has no other side effect than to set the error flag..";
|
||||
break;
|
||||
case GL_INVALID_FRAMEBUFFER_OPERATION:
|
||||
qCDebug(gpugllogging) << "GLBackend" << name << ": The framebuffer object is not complete.The offending command is ignored and has no other side effect than to set the error flag.";
|
||||
break;
|
||||
case GL_OUT_OF_MEMORY:
|
||||
qCDebug(gpugllogging) << "GLBackend" << name << ": There is not enough memory left to execute the command.The state of the GL is undefined, except for the state of the error flags, after this error is recorded.";
|
||||
break;
|
||||
default:
|
||||
qCDebug(gpugllogging) << "GLBackend" << name << ": Unknown error: " << error;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool checkGLErrorDebug(const char* name) {
|
||||
return checkGLError(name);
|
||||
}
|
||||
|
||||
|
||||
int QtMsgTypeToAndroidPriority(QtMsgType type) {
|
||||
|
@ -28,35 +71,87 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt
|
|||
__android_log_write(QtMsgTypeToAndroidPriority(type), "Interface", message.toStdString().c_str());
|
||||
}
|
||||
|
||||
void qt_gl_set_global_share_context(QOpenGLContext *context);
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
qInstallMessageHandler(messageHandler);
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
|
||||
auto physicsEngine = new PhysicsEngine({});
|
||||
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
|
||||
QGuiApplication app(argc,argv);
|
||||
app.setOrganizationName("QtProject");
|
||||
app.setOrganizationDomain("qt-project.org");
|
||||
app.setApplicationName(QFileInfo(app.applicationFilePath()).baseName());
|
||||
QtWebView::initialize();
|
||||
qputenv("QSG_RENDERER_DEBUG", (QStringList() << "render" << "build" << "change" << "upload" << "roots" << "dump").join(';').toUtf8());
|
||||
|
||||
auto screen = app.primaryScreen();
|
||||
if (screen) {
|
||||
auto rect = screen->availableGeometry();
|
||||
auto size = screen->availableSize();
|
||||
auto foo = screen->availableVirtualGeometry();
|
||||
auto pixelRatio = screen->devicePixelRatio();
|
||||
qDebug() << pixelRatio;
|
||||
qDebug() << rect.width();
|
||||
qDebug() << rect.height();
|
||||
OffscreenGLCanvas sharedCanvas;
|
||||
if (!sharedCanvas.create()) {
|
||||
qFatal("Unable to create primary offscreen context");
|
||||
}
|
||||
QQuickView view;
|
||||
view.connect(view.engine(), &QQmlEngine::quit, &app, &QCoreApplication::quit);
|
||||
new QQmlFileSelector(view.engine(), &view);
|
||||
view.setSource(QUrl("qrc:///simple.qml"));
|
||||
if (view.status() == QQuickView::Error)
|
||||
return -1;
|
||||
view.setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
view.show();
|
||||
qt_gl_set_global_share_context(sharedCanvas.getContext());
|
||||
|
||||
auto globalContext = QOpenGLContext::globalShareContext();
|
||||
bool threadedGlRendering = QOpenGLContext::supportsThreadedOpenGL();
|
||||
|
||||
GLWindow window;
|
||||
window.create();
|
||||
window.setGeometry(qApp->primaryScreen()->availableGeometry());
|
||||
window.createContext(globalContext);
|
||||
if (!window.makeCurrent()) {
|
||||
qFatal("Unable to make primary window GL context current");
|
||||
}
|
||||
|
||||
GLuint fbo = 0;
|
||||
glGenFramebuffers(1, &fbo);
|
||||
|
||||
|
||||
|
||||
ivec2 offscreenSize { 640, 480 };
|
||||
|
||||
OffscreenQmlSurface::setSharedContext(sharedCanvas.getContext());
|
||||
OffscreenQmlSurface* qmlSurface = new OffscreenQmlSurface();
|
||||
qmlSurface->create();
|
||||
qmlSurface->resize(fromGlm(offscreenSize));
|
||||
qmlSurface->load("qrc:///simple.qml");
|
||||
qmlSurface->resume();
|
||||
|
||||
auto discardLambda = qmlSurface->getDiscardLambda();
|
||||
|
||||
window.showFullScreen();
|
||||
QTimer timer;
|
||||
timer.setInterval(10);
|
||||
timer.setSingleShot(false);
|
||||
OffscreenQmlSurface::TextureAndFence currentTextureAndFence;
|
||||
timer.connect(&timer, &QTimer::timeout, &app, [&]{
|
||||
window.makeCurrent();
|
||||
glClearColor(0, 1, 0, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
OffscreenQmlSurface::TextureAndFence newTextureAndFence;
|
||||
if (qmlSurface->fetchTexture(newTextureAndFence)) {
|
||||
if (currentTextureAndFence.first) {
|
||||
discardLambda(currentTextureAndFence.first, currentTextureAndFence.second);
|
||||
}
|
||||
currentTextureAndFence = newTextureAndFence;
|
||||
}
|
||||
checkGLErrorDebug(__FUNCTION__);
|
||||
|
||||
if (currentTextureAndFence.second) {
|
||||
glWaitSync((GLsync)currentTextureAndFence.second, 0, GL_TIMEOUT_IGNORED);
|
||||
glDeleteSync((GLsync)currentTextureAndFence.second);
|
||||
currentTextureAndFence.second = nullptr;
|
||||
}
|
||||
|
||||
if (currentTextureAndFence.first) {
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
|
||||
glFramebufferTexture(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, currentTextureAndFence.first, 0);
|
||||
glBlitFramebuffer(0, 0, offscreenSize.x, offscreenSize.y, 100, 100, offscreenSize.x + 100, offscreenSize.y + 100, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
window.swapBuffers();
|
||||
window.doneCurrent();
|
||||
});
|
||||
timer.start();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>simple.qml</file>
|
||||
<file>+android/simple.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
//
|
||||
// InterfaceActivity.java
|
||||
// gvr-interface/java
|
||||
//
|
||||
// Created by Stephen Birarda on 1/26/15.
|
||||
// Copyright 2015 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
|
||||
//
|
||||
|
||||
package io.highfidelity.gvrinterface;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.util.Log;
|
||||
import org.qtproject.qt5.android.bindings.QtActivity;
|
||||
|
||||
public class InterfaceActivity extends QtActivity {
|
||||
|
||||
public static native void handleHifiURL(String hifiURLString);
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
// Get the intent that started this activity in case we have a hifi:// URL to parse
|
||||
Intent intent = getIntent();
|
||||
if (intent.getAction() == Intent.ACTION_VIEW) {
|
||||
Uri data = intent.getData();
|
||||
|
||||
if (data.getScheme().equals("hifi")) {
|
||||
handleHifiURL(data.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
BIN
android/app/src/main/res/drawable/icon.png
Normal file
BIN
android/app/src/main/res/drawable/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.7 KiB |
|
@ -39,7 +39,24 @@ ext {
|
|||
RELEASE_TYPE = project.hasProperty('RELEASE_TYPE') ? project.getProperty('RELEASE_TYPE') : 'DEV'
|
||||
BUILD_BRANCH = project.hasProperty('BUILD_BRANCH') ? project.getProperty('BUILD_BRANCH') : ''
|
||||
EXEC_SUFFIX = Os.isFamily(Os.FAMILY_WINDOWS) ? '.exe' : ''
|
||||
QT5_DEPS = [ 'Qt5Core', 'Qt5Gui', 'Qt5Network', 'Qt5Qml', 'Qt5Quick', 'Qt5Script', 'Qt5Widgets', 'Qt5OpenGL' ]
|
||||
QT5_DEPS = [
|
||||
'Qt5Core',
|
||||
'Qt5Gui',
|
||||
'Qt5Multimedia',
|
||||
'Qt5Network',
|
||||
'Qt5OpenGL',
|
||||
'Qt5Qml',
|
||||
'Qt5Quick',
|
||||
'Qt5Script',
|
||||
'Qt5ScriptTools',
|
||||
'Qt5WebChannel',
|
||||
'Qt5WebSockets',
|
||||
'Qt5Widgets',
|
||||
'Qt5XmlPatterns',
|
||||
// Android specific
|
||||
'Qt5AndroidExtras',
|
||||
'Qt5WebView',
|
||||
]
|
||||
}
|
||||
|
||||
def baseFolder = new File(HIFI_ANDROID_PRECOMPILED)
|
||||
|
@ -47,11 +64,11 @@ def appDir = new File(projectDir, 'app')
|
|||
def jniFolder = new File(appDir, 'src/main/jniLibs/arm64-v8a')
|
||||
def baseUrl = 'https://hifi-public.s3.amazonaws.com/austin/android/'
|
||||
|
||||
def qtFile='qt-5.9.3_linux_armv8-libcpp.tgz'
|
||||
def qtChecksum='547da3547d5690144e23d6504c6d6e91'
|
||||
def qtFile='qt-5.9.3_linux_armv8-libcpp_openssl.tgz'
|
||||
def qtChecksum='04599670ccca84bd2b15f6915568eb2d'
|
||||
if (Os.isFamily(Os.FAMILY_MAC)) {
|
||||
qtFile = 'qt-5.9.3_osx_armv8-libcpp.tgz'
|
||||
qtChecksum='6fa3e068cfdee863fc909b294a3a0cc6'
|
||||
qtFile = 'qt-5.9.3_osx_armv8-libcpp_openssl.tgz'
|
||||
qtChecksum='4b02de9d67d6bfb202355a808d2d9c59'
|
||||
} else if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
qtFile = 'qt-5.9.3_win_armv8-libcpp_openssl.tgz'
|
||||
qtChecksum='a93d22c0c59aa112fda18c4c6d157d17'
|
||||
|
@ -146,6 +163,7 @@ def scanQmlImports = { File qmlRootPath ->
|
|||
" -importPath ${qmlRoot.absolutePath}/qml"
|
||||
|
||||
def commandResult = captureOutput(command)
|
||||
println commandResult
|
||||
new JsonSlurper().parseText(commandResult).each {
|
||||
if (!it.containsKey('path')) {
|
||||
println "Warning: QML import could not be resolved in any of the import paths: ${it.name}"
|
||||
|
@ -358,7 +376,8 @@ task extractGvrBinaries(dependsOn: extractDependencies) {
|
|||
task qtBundle {
|
||||
doLast {
|
||||
parseQtDependencies(QT5_DEPS)
|
||||
scanQmlImports(new File("${appDir}/../../interface/resources/qml/"))
|
||||
//scanQmlImports(new File("${appDir}/../../interface/resources/qml/"))
|
||||
scanQmlImports(new File("${projectDir}/app/src/main/cpp"))
|
||||
|
||||
def libDestinationDirectory = jniFolder
|
||||
def jarDestinationDirectory = new File(appDir, 'libs')
|
||||
|
|
|
@ -1,3 +1,36 @@
|
|||
Different libraries require different mechanism for building. Some are easiest with the standalone toolchain. Some are easiest with the ndk-build tool. Some can rely on CMake to do the right thing.
|
||||
|
||||
## Setup
|
||||
|
||||
### Android build environment
|
||||
|
||||
You need the Android NDK and SDK. The easiest way to get these is to download Android Studio for your platform and use the SDK manager in Studio to install the items. In particular you will need Android API levels 24 and 26, as well as the NDK, CMake, and LLDB. You should be using NDK version 16 or higher.
|
||||
|
||||
The Studio installation can install the SDK wherver you like. This guide assumes you install it to `$HOME/Android/SDK`. It will install the NDK inside the SDK in a folder named `ndk-bundle` but for convenience we will assume a symlink from `$HOME/Android/NDK` to the actual NDK folder exists
|
||||
|
||||
Additionally, some of the tools require a standalone toolchain in order to build. From the NDK build/tools directory you can execute the following command
|
||||
|
||||
`./make-standalone-toolchain.sh --arch=arm64 --platform=android-24 --install-dir=$HOME/Android/arm64_toolchain`
|
||||
|
||||
This will create the toolchain and install it in `$HOME/Android/arm64_toolchain`
|
||||
|
||||
When doing a build that relies on the toolchain you can execute the following commands to enable it
|
||||
|
||||
```
|
||||
target_host=aarch64-linux-android
|
||||
export PATH=$PATH:$HOME/Android/arm64_toolchain/bin
|
||||
export AR=$target_host-ar
|
||||
export AS=$target_host-as
|
||||
export CC=$target_host-gcc
|
||||
export CXX=$target_host-g++
|
||||
export LD=$target_host-ld
|
||||
export STRIP=$target_host-strip
|
||||
export CFLAGS="-fPIE -fPIC"
|
||||
export LDFLAGS="-pie"
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Qt
|
||||
|
||||
### Windows host
|
||||
|
@ -15,6 +48,10 @@
|
|||
* python
|
||||
* gmake
|
||||
* If any of them fail, fix your path and restart the bash prompt
|
||||
* Fetch the pre-built OpenSSL binaries for Android/iOS from here: https://github.com/leenjewel/openssl_for_ios_and_android/releases
|
||||
* Grab the latest release of the 1.0.2 series
|
||||
* Open the archive and extract the `/android/openssl-arm64-v8a` folder
|
||||
|
||||
* Download the Qt sources
|
||||
* `git clone git://code.qt.io/qt/qt5.git`
|
||||
* `cd qt5`
|
||||
|
@ -23,5 +60,28 @@
|
|||
* `git submodule update --recursive`
|
||||
* `cd ..`
|
||||
* Create a build directory with the command `mkdir qt5build`
|
||||
* Configure the Qt5 build with the command `../qt5/configure -xplatform android-clang -android-ndk-host windows-x86_64 -confirm-license -opensource --disable-rpath -nomake tests -nomake examples -skip qttranslations -skip qtserialport -skip qt3d -skip qtwebengine -skip qtlocation -skip qtwayland -skip qtsensors -skip qtgamepad -skip qtgamepad -skip qtspeech -skip qtcharts -skip qtx11extras -skip qtmacextras -skip qtvirtualkeyboard -skip qtpurchasing -skip qtdatavis3d -android-ndk C:/Android/NDK -android-toolchain-version 4.9 -android-arch arm64-v8a -no-warnings-are-errors -android-ndk-platform android-24 -v -platform win32-g++ -prefix C:/qt5build_debug -android-sdk C:/Android/SDK `
|
||||
|
||||
* Configure the Qt5 build with the command `../qt5/configure -xplatform android-clang -android-ndk-host windows-x86_64 -confirm-license -opensource --disable-rpath -nomake tests -nomake examples -skip qttranslations -skip qtserialport -skip qt3d -skip qtwebengine -skip qtlocation -skip qtwayland -skip qtsensors -skip qtgamepad -skip qtgamepad -skip qtspeech -skip qtcharts -skip qtx11extras -skip qtmacextras -skip qtvirtualkeyboard -skip qtpurchasing -skip qtdatavis3d -android-ndk C:/Android/NDK -android-toolchain-version 4.9 -android-arch arm64-v8a -no-warnings-are-errors -android-ndk-platform android-24 -v -platform win32-g++ -prefix C:/qt5build_debug -android-sdk C:/Android/SDK -c++std c++14 -openssl-linked -L<PATH_TO_SSL>/lib -I<PATH_TO_SSL>/include`
|
||||
|
||||
|
||||
|
||||
## TBB
|
||||
|
||||
Use the ndk-build tool
|
||||
|
||||
ndk-build tbb tbbmalloc target=android arch=ia32 tbb_os=windows ndk_version=16
|
||||
|
||||
## OpenSSL
|
||||
|
||||
Use a standalone toolchain
|
||||
|
||||
* Grab the latest 1.1.0x series source from https://github.com/openssl/openssl/releases
|
||||
* Follow the NDK guidelines for building a standalone toolchain for aarch64
|
||||
* Use the following script to configure and build OpenSSL
|
||||
* Enable the standalone toolchain with the export commands described above
|
||||
* Configure SSL with the command `./Configure android64-aarch64 no-asm no-ssl2 no-ssl3 no-comp no-hw no-engine --prefix=$HOME/Android/openssl_1.1.0g`
|
||||
* Build and install SSL with the command `make depend && make && make install`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -56,14 +56,6 @@ else ()
|
|||
list(REMOVE_ITEM INTERFACE_SRCS ${SPEECHRECOGNIZER_CPP})
|
||||
endif ()
|
||||
|
||||
if (ANDROID)
|
||||
set(PLATFORM_QT_COMPONENTS AndroidExtras)
|
||||
set(PLATFORM_QT_LIBRARIES Qt5::AndroidExtras)
|
||||
else ()
|
||||
set(PLATFORM_QT_COMPONENTS WebEngine WebEngineWidgets)
|
||||
set(PLATFORM_QT_LIBRARIES Qt5::WebEngine Qt5::WebEngineWidgets)
|
||||
endif ()
|
||||
|
||||
find_package(
|
||||
Qt5 COMPONENTS
|
||||
Gui Multimedia Network OpenGL Qml Quick Script Svg
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#if defined(QT_OPENGL_ES_3_1)
|
||||
// Minimum GL ES version required is 3.1
|
||||
#if defined(Q_OS_ANDROID)
|
||||
// Minimum GL ES version required is 3.2
|
||||
#define GL_MIN_VERSION_MAJOR 0x03
|
||||
#define GL_MIN_VERSION_MINOR 0x01
|
||||
#define GL_MIN_VERSION_MINOR 0x02
|
||||
#define GL_DEFAULT_VERSION_MAJOR GL_MIN_VERSION_MAJOR
|
||||
#define GL_DEFAULT_VERSION_MINOR GL_MIN_VERSION_MINOR
|
||||
#else
|
||||
|
@ -33,7 +33,7 @@
|
|||
#if defined(Q_OS_ANDROID)
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES3/gl31.h>
|
||||
#include <GLES3/gl32.h>
|
||||
|
||||
#define GL_DEPTH_COMPONENT32_OES 0x81A7
|
||||
#define GL_TIME_ELAPSED_EXT 0x88BF
|
||||
|
|
|
@ -28,7 +28,7 @@ const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
|
|||
static QSurfaceFormat format;
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
#if defined(QT_OPENGL_ES_3_1)
|
||||
#if defined(Q_OS_ANDROID)
|
||||
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
||||
format.setRedBufferSize(8);
|
||||
format.setGreenBufferSize(8);
|
||||
|
|
|
@ -25,8 +25,9 @@ class QSurfaceFormat;
|
|||
class QGLFormat;
|
||||
|
||||
template<class F>
|
||||
#if defined(QT_OPENGL_ES_3_1)
|
||||
void setGLFormatVersion(F& format, int major = 3, int minor = 1)
|
||||
// https://bugreports.qt.io/browse/QTBUG-64703 prevents us from using "defined(QT_OPENGL_ES_3_1)"
|
||||
#if defined(Q_OS_ANDROID)
|
||||
void setGLFormatVersion(F& format, int major = 3, int minor = 2)
|
||||
#else
|
||||
void setGLFormatVersion(F& format, int major = 4, int minor = 5)
|
||||
#endif
|
||||
|
|
|
@ -46,15 +46,28 @@ bool OffscreenGLCanvas::create(QOpenGLContext* sharedContext) {
|
|||
_context->setShareContext(sharedContext);
|
||||
}
|
||||
_context->setFormat(getDefaultOpenGLSurfaceFormat());
|
||||
|
||||
if (_context->create()) {
|
||||
_offscreenSurface->setFormat(_context->format());
|
||||
_offscreenSurface->create();
|
||||
return _offscreenSurface->isValid();
|
||||
if (!_context->create()) {
|
||||
qFatal("Failed to create OffscreenGLCanvas context");
|
||||
}
|
||||
qWarning("Failed to create OffscreenGLCanvas context");
|
||||
|
||||
return false;
|
||||
_offscreenSurface->setFormat(_context->format());
|
||||
_offscreenSurface->create();
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
if (!_context->makeCurrent(_offscreenSurface)) {
|
||||
qFatal("Unable to make offscreen surface current");
|
||||
}
|
||||
#else
|
||||
// For some reason, the offscreen surface is considered invalid on android
|
||||
// possibly because of a bad format? Would need to add some logging to the
|
||||
// eglpbuffer implementation used from the android platform plugin.
|
||||
// Alternatively investigate the use of an invisible surface view to do
|
||||
// a 'native' offscreen surface
|
||||
if (!_offscreenSurface->isValid()) {
|
||||
qFatal("Offscreen surface is invalid");
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OffscreenGLCanvas::makeCurrent() {
|
||||
|
|
|
@ -177,10 +177,6 @@ const SteamClientPluginPointer PluginManager::getSteamClientPlugin() {
|
|||
return steamClientPlugin;
|
||||
}
|
||||
|
||||
#ifndef Q_OS_ANDROID
|
||||
|
||||
static DisplayPluginList displayPlugins;
|
||||
|
||||
const DisplayPluginList& PluginManager::getDisplayPlugins() {
|
||||
static std::once_flag once;
|
||||
static auto deviceAddedCallback = [](QString deviceName) {
|
||||
|
@ -194,7 +190,7 @@ const DisplayPluginList& PluginManager::getDisplayPlugins() {
|
|||
|
||||
std::call_once(once, [&] {
|
||||
// Grab the built in plugins
|
||||
displayPlugins = _displayPluginProvider();
|
||||
_displayPlugins = _displayPluginProvider();
|
||||
|
||||
|
||||
// Now grab the dynamic plugins
|
||||
|
@ -202,11 +198,11 @@ const DisplayPluginList& PluginManager::getDisplayPlugins() {
|
|||
DisplayProvider* displayProvider = qobject_cast<DisplayProvider*>(loader->instance());
|
||||
if (displayProvider) {
|
||||
for (auto displayPlugin : displayProvider->getDisplayPlugins()) {
|
||||
displayPlugins.push_back(displayPlugin);
|
||||
_displayPlugins.push_back(displayPlugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto plugin : displayPlugins) {
|
||||
for (auto plugin : _displayPlugins) {
|
||||
connect(plugin.get(), &Plugin::deviceConnected, this, deviceAddedCallback, Qt::QueuedConnection);
|
||||
connect(plugin.get(), &Plugin::subdeviceConnected, this, subdeviceAddedCallback, Qt::QueuedConnection);
|
||||
plugin->setContainer(_container);
|
||||
|
@ -214,21 +210,17 @@ const DisplayPluginList& PluginManager::getDisplayPlugins() {
|
|||
}
|
||||
|
||||
});
|
||||
return displayPlugins;
|
||||
return _displayPlugins;
|
||||
}
|
||||
|
||||
void PluginManager::disableDisplayPlugin(const QString& name) {
|
||||
for (size_t i = 0; i < displayPlugins.size(); ++i) {
|
||||
if (displayPlugins[i]->getName() == name) {
|
||||
displayPlugins.erase(displayPlugins.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
std::remove_if(_displayPlugins.begin(), _displayPlugins.end(), [&](const DisplayPluginPointer& plugin){
|
||||
return plugin->getName() == name;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const InputPluginList& PluginManager::getInputPlugins() {
|
||||
static InputPluginList inputPlugins;
|
||||
static std::once_flag once;
|
||||
static auto deviceAddedCallback = [](QString deviceName) {
|
||||
qCDebug(plugins) << "Added device: " << deviceName;
|
||||
|
@ -240,7 +232,7 @@ const InputPluginList& PluginManager::getInputPlugins() {
|
|||
};
|
||||
|
||||
std::call_once(once, [&] {
|
||||
inputPlugins = _inputPluginProvider();
|
||||
_inputPlugins = _inputPluginProvider();
|
||||
|
||||
// Now grab the dynamic plugins
|
||||
for (auto loader : getLoadedPlugins()) {
|
||||
|
@ -248,20 +240,20 @@ const InputPluginList& PluginManager::getInputPlugins() {
|
|||
if (inputProvider) {
|
||||
for (auto inputPlugin : inputProvider->getInputPlugins()) {
|
||||
if (inputPlugin->isSupported()) {
|
||||
inputPlugins.push_back(inputPlugin);
|
||||
_inputPlugins.push_back(inputPlugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto plugin : inputPlugins) {
|
||||
for (auto plugin : _inputPlugins) {
|
||||
connect(plugin.get(), &Plugin::deviceConnected, this, deviceAddedCallback, Qt::QueuedConnection);
|
||||
connect(plugin.get(), &Plugin::subdeviceConnected, this, subdeviceAddedCallback, Qt::QueuedConnection);
|
||||
plugin->setContainer(_container);
|
||||
plugin->init();
|
||||
}
|
||||
});
|
||||
return inputPlugins;
|
||||
return _inputPlugins;
|
||||
}
|
||||
|
||||
void PluginManager::setPreferredDisplayPlugins(const QStringList& displays) {
|
||||
|
@ -328,4 +320,3 @@ void PluginManager::shutdown() {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -44,4 +44,6 @@ private:
|
|||
CodecPluginProvider _codecPluginProvider { []()->CodecPluginList { return {}; } };
|
||||
InputPluginSettingsPersister _inputSettingsPersister { [](const InputPluginList& list) {} };
|
||||
PluginContainer* _container { nullptr };
|
||||
DisplayPluginList _displayPlugins;
|
||||
InputPluginList _inputPlugins;
|
||||
};
|
||||
|
|
|
@ -9,21 +9,25 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QTemporaryDir>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
#include <QBuffer>
|
||||
#include <QTextCodec>
|
||||
#include <QIODevice>
|
||||
#include <QUrl>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QFileInfo>
|
||||
#include "FileScriptingInterface.h"
|
||||
|
||||
#include <QtCore/QTemporaryDir>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QTextCodec>
|
||||
#include <QtCore/QIODevice>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QFileInfo>
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
#include <quazip5/quazip.h>
|
||||
#include <quazip5/JlCompress.h>
|
||||
#endif
|
||||
|
||||
#include "FileScriptingInterface.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "ScriptEngineLogging.h"
|
||||
|
||||
|
@ -68,7 +72,9 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool
|
|||
}
|
||||
|
||||
QStringList FileScriptingInterface::unzipFile(QString path, QString tempDir) {
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
return QStringList();
|
||||
#else
|
||||
QDir dir(path);
|
||||
QString dirName = dir.path();
|
||||
qCDebug(scriptengine) << "Directory to unzip: " << dirName;
|
||||
|
@ -83,7 +89,7 @@ QStringList FileScriptingInterface::unzipFile(QString path, QString tempDir) {
|
|||
qCDebug(scriptengine) << "Extraction failed";
|
||||
return list;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
// fix to check that we are only referring to a temporary directory
|
||||
|
@ -131,11 +137,12 @@ void FileScriptingInterface::recursiveFileScan(QFileInfo file, QString* dirName)
|
|||
return;
|
||||
}*/
|
||||
QFileInfoList files;
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
if (file.fileName().contains(".zip")) {
|
||||
qCDebug(scriptengine) << "Extracting archive: " + file.fileName();
|
||||
JlCompress::extractDir(file.fileName());
|
||||
}
|
||||
#endif
|
||||
files = file.dir().entryInfoList();
|
||||
|
||||
/*if (files.empty()) {
|
||||
|
|
|
@ -1607,14 +1607,14 @@ QVariantMap ScriptEngine::fetchModuleSource(const QString& modulePath, const boo
|
|||
if (!loader->isFinished()) {
|
||||
QTimer monitor;
|
||||
QEventLoop loop;
|
||||
QObject::connect(loader, &BatchLoader::finished, this, [this, &monitor, &loop]{
|
||||
QObject::connect(loader, &BatchLoader::finished, this, [&monitor, &loop]{
|
||||
monitor.stop();
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
// this helps detect the case where stop() is invoked during the download
|
||||
// but not seen in time to abort processing in onload()...
|
||||
connect(&monitor, &QTimer::timeout, this, [this, &loop, &loader]{
|
||||
connect(&monitor, &QTimer::timeout, this, [this, &loop]{
|
||||
if (isStopping()) {
|
||||
loop.exit(-1);
|
||||
}
|
||||
|
@ -2247,7 +2247,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co
|
|||
QTimer timeout;
|
||||
timeout.setSingleShot(true);
|
||||
timeout.start(SANDBOX_TIMEOUT);
|
||||
connect(&timeout, &QTimer::timeout, [&sandbox, SANDBOX_TIMEOUT, scriptOrURL]{
|
||||
connect(&timeout, &QTimer::timeout, [&sandbox, scriptOrURL]{
|
||||
qCDebug(scriptengine) << "ScriptEngine::entityScriptContentAvailable timeout(" << scriptOrURL << ")";
|
||||
|
||||
// Guard against infinite loops and non-performant code
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set(TARGET_NAME ui)
|
||||
setup_hifi_library(OpenGL Multimedia Network Qml Quick Script WebChannel WebEngine WebSockets XmlPatterns)
|
||||
setup_hifi_library(OpenGL Multimedia Network Qml Quick Script WebChannel WebSockets XmlPatterns ${PLATFORM_QT_COMPONENTS})
|
||||
link_hifi_libraries(shared networking gl audio audio-client plugins pointers)
|
||||
include_hifi_library_headers(controllers)
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <QtQml/QtQml>
|
||||
#include <QtQml/QQmlEngine>
|
||||
#include <QtQml/QQmlComponent>
|
||||
#include <QtQml/QQmlFileSelector>
|
||||
#include <QtQuick/QQuickItem>
|
||||
#include <QtQuick/QQuickWindow>
|
||||
#include <QtQuick/QQuickRenderControl>
|
||||
|
@ -276,7 +277,9 @@ private:
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 8.0f);
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -0.2f);
|
||||
#endif
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 8.0f);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, size.x, size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||
return newTexture;
|
||||
|
@ -416,6 +419,8 @@ static size_t globalEngineRefCount{ 0 };
|
|||
#endif
|
||||
|
||||
void initializeQmlEngine(QQmlEngine* engine, QQuickWindow* window) {
|
||||
new QQmlFileSelector(engine, window);
|
||||
|
||||
// register the pixmap image provider (used only for security image, for now)
|
||||
engine->addImageProvider(ImageProvider::PROVIDER_NAME, new ImageProvider());
|
||||
|
||||
|
@ -440,8 +445,10 @@ void initializeQmlEngine(QQmlEngine* engine, QQuickWindow* window) {
|
|||
if (!javaScriptToInject.isEmpty()) {
|
||||
rootContext->setContextProperty("eventBridgeJavaScriptToInject", QVariant(javaScriptToInject));
|
||||
}
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
rootContext->setContextProperty("FileTypeProfile", new FileTypeProfile(rootContext));
|
||||
rootContext->setContextProperty("HFWebEngineProfile", new HFWebEngineProfile(rootContext));
|
||||
#endif
|
||||
rootContext->setContextProperty("Paths", DependencyManager::get<PathUtils>().data());
|
||||
}
|
||||
|
||||
|
@ -615,10 +622,12 @@ void OffscreenQmlSurface::onAboutToQuit() {
|
|||
}
|
||||
|
||||
void OffscreenQmlSurface::disconnectAudioOutputTimer() {
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
if (_audioOutputUpdateTimer.isActive()) {
|
||||
_audioOutputUpdateTimer.stop();
|
||||
}
|
||||
QObject::disconnect(&_audioOutputUpdateTimer);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OffscreenQmlSurface::create() {
|
||||
|
@ -668,7 +677,8 @@ void OffscreenQmlSurface::create() {
|
|||
// Find a way to flag older scripts using this mechanism and wanr that this is deprecated
|
||||
_qmlContext->setContextProperty("eventBridgeWrapper", new EventBridgeWrapper(this, _qmlContext));
|
||||
_renderControl->initialize(_canvas->getContext());
|
||||
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
// Connect with the audio client and listen for audio device changes
|
||||
auto audioIO = DependencyManager::get<AudioClient>();
|
||||
connect(audioIO.data(), &AudioClient::deviceChanged, this, [&](QAudio::Mode mode, const QAudioDeviceInfo& device) {
|
||||
|
@ -684,6 +694,7 @@ void OffscreenQmlSurface::create() {
|
|||
int waitForAudioQmlMs = 200;
|
||||
_audioOutputUpdateTimer.setInterval(waitForAudioQmlMs);
|
||||
_audioOutputUpdateTimer.setSingleShot(true);
|
||||
#endif
|
||||
|
||||
// When Quick says there is a need to render, we will not render immediately. Instead,
|
||||
// a timer with a small interval is used to get better performance.
|
||||
|
@ -695,20 +706,25 @@ void OffscreenQmlSurface::create() {
|
|||
}
|
||||
|
||||
void OffscreenQmlSurface::changeAudioOutputDevice(const QString& deviceName, bool isHtmlUpdate) {
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
if (_rootItem != nullptr && !isHtmlUpdate) {
|
||||
QMetaObject::invokeMethod(this, "forceQmlAudioOutputDeviceUpdate", Qt::QueuedConnection);
|
||||
}
|
||||
emit audioOutputDeviceChanged(deviceName);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OffscreenQmlSurface::forceHtmlAudioOutputDeviceUpdate() {
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
auto audioIO = DependencyManager::get<AudioClient>();
|
||||
QString deviceName = audioIO->getActiveAudioDevice(QAudio::AudioOutput).deviceName();
|
||||
QMetaObject::invokeMethod(this, "changeAudioOutputDevice", Qt::QueuedConnection,
|
||||
Q_ARG(QString, deviceName), Q_ARG(bool, true));
|
||||
#endif
|
||||
}
|
||||
|
||||
void OffscreenQmlSurface::forceQmlAudioOutputDeviceUpdate() {
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
if (QThread::currentThread() != qApp->thread()) {
|
||||
QMetaObject::invokeMethod(this, "forceQmlAudioOutputDeviceUpdate", Qt::QueuedConnection);
|
||||
} else {
|
||||
|
@ -719,6 +735,7 @@ void OffscreenQmlSurface::forceQmlAudioOutputDeviceUpdate() {
|
|||
}
|
||||
_audioOutputUpdateTimer.start();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static uvec2 clampSize(const uvec2& size, uint32_t maxDimension) {
|
||||
|
@ -1348,14 +1365,11 @@ void OffscreenQmlSurface::lowerKeyboard() {
|
|||
void OffscreenQmlSurface::setKeyboardRaised(QObject* object, bool raised, bool numeric, bool passwordField) {
|
||||
qCDebug(uiLogging) << "setKeyboardRaised: " << object << ", raised: " << raised << ", numeric: " << numeric << ", password: " << passwordField;
|
||||
|
||||
#if Q_OS_ANDROID
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
// if HMD is being worn, allow keyboard to open. allow it to close, HMD or not.
|
||||
if (!raised || qApp->property(hifi::properties::HMD).toBool()) {
|
||||
QQuickItem* item = dynamic_cast<QQuickItem*>(object);
|
||||
|
@ -1392,6 +1406,7 @@ void OffscreenQmlSurface::setKeyboardRaised(QObject* object, bool raised, bool n
|
|||
item = dynamic_cast<QQuickItem*>(item->parentItem());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void OffscreenQmlSurface::emitScriptEvent(const QVariant& message) {
|
||||
|
|
|
@ -173,9 +173,11 @@ private:
|
|||
uint64_t _lastRenderTime { 0 };
|
||||
uvec2 _size;
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
QTimer _audioOutputUpdateTimer;
|
||||
QString _currentAudioOutputDevice;
|
||||
|
||||
#endif
|
||||
|
||||
// Texture management
|
||||
TextureAndFence _latestTextureAndFence { 0, 0 };
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "FileTypeRequestInterceptor.h"
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
static const QString QML_WEB_ENGINE_STORAGE_NAME = "qmlWebEngine";
|
||||
|
||||
FileTypeProfile::FileTypeProfile(QObject* parent) :
|
||||
|
@ -24,3 +25,4 @@ FileTypeProfile::FileTypeProfile(QObject* parent) :
|
|||
auto requestInterceptor = new FileTypeRequestInterceptor(this);
|
||||
setRequestInterceptor(requestInterceptor);
|
||||
}
|
||||
#endif
|
|
@ -14,12 +14,15 @@
|
|||
#ifndef hifi_FileTypeProfile_h
|
||||
#define hifi_FileTypeProfile_h
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
#include <QtWebEngine/QQuickWebEngineProfile>
|
||||
|
||||
class FileTypeProfile : public QQuickWebEngineProfile {
|
||||
public:
|
||||
FileTypeProfile(QObject* parent = Q_NULLPTR);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // hifi_FileTypeProfile_h
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
|
||||
#include "RequestFilters.h"
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
|
||||
void FileTypeRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) {
|
||||
RequestFilters::interceptHFWebEngineRequest(info);
|
||||
RequestFilters::interceptFileType(info);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -14,6 +14,9 @@
|
|||
#ifndef hifi_FileTypeRequestInterceptor_h
|
||||
#define hifi_FileTypeRequestInterceptor_h
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
#include <QWebEngineUrlRequestInterceptor>
|
||||
|
||||
class FileTypeRequestInterceptor : public QWebEngineUrlRequestInterceptor {
|
||||
|
@ -22,5 +25,6 @@ public:
|
|||
|
||||
virtual void interceptRequest(QWebEngineUrlRequestInfo& info) override;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // hifi_FileTypeRequestInterceptor_h
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#include "HFWebEngineRequestInterceptor.h"
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
|
||||
static const QString QML_WEB_ENGINE_STORAGE_NAME = "qmlWebEngine";
|
||||
|
||||
HFWebEngineProfile::HFWebEngineProfile(QObject* parent) :
|
||||
|
@ -24,3 +26,5 @@ HFWebEngineProfile::HFWebEngineProfile(QObject* parent) :
|
|||
auto requestInterceptor = new HFWebEngineRequestInterceptor(this);
|
||||
setRequestInterceptor(requestInterceptor);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -14,12 +14,15 @@
|
|||
#ifndef hifi_HFWebEngineProfile_h
|
||||
#define hifi_HFWebEngineProfile_h
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
#include <QtWebEngine/QQuickWebEngineProfile>
|
||||
|
||||
class HFWebEngineProfile : public QQuickWebEngineProfile {
|
||||
public:
|
||||
HFWebEngineProfile(QObject* parent = Q_NULLPTR);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // hifi_HFWebEngineProfile_h
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
#include "AccountManager.h"
|
||||
#include "RequestFilters.h"
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
|
||||
void HFWebEngineRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) {
|
||||
RequestFilters::interceptHFWebEngineRequest(info);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -14,6 +14,9 @@
|
|||
#ifndef hifi_HFWebEngineRequestInterceptor_h
|
||||
#define hifi_HFWebEngineRequestInterceptor_h
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
#include <QWebEngineUrlRequestInterceptor>
|
||||
|
||||
class HFWebEngineRequestInterceptor : public QWebEngineUrlRequestInterceptor {
|
||||
|
@ -22,5 +25,6 @@ public:
|
|||
|
||||
virtual void interceptRequest(QWebEngineUrlRequestInfo& info) override;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // hifi_HFWebEngineRequestInterceptor_h
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include "AccountManager.h"
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
|
||||
namespace {
|
||||
|
||||
bool isAuthableHighFidelityURL(const QUrl& url) {
|
||||
|
@ -77,3 +79,4 @@ void RequestFilters::interceptFileType(QWebEngineUrlRequestInfo& info) {
|
|||
info.setHttpHeader(CONTENT_HEADER.toLocal8Bit(), TYPE_VALUE.toLocal8Bit());
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -14,15 +14,17 @@
|
|||
#ifndef hifi_RequestFilters_h
|
||||
#define hifi_RequestFilters_h
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
#include <QObject>
|
||||
#include <QWebEngineUrlRequestInfo>
|
||||
|
||||
class RequestFilters : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
static void interceptHFWebEngineRequest(QWebEngineUrlRequestInfo& info);
|
||||
static void interceptFileType(QWebEngineUrlRequestInfo& info);
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // hifi_RequestFilters_h
|
||||
|
|
Loading…
Reference in a new issue