History

Support web content inside QML

Brad Davis committed 10 years ago

Commit fa5bab01 parent 0c1ae5b24 files · +1873 −322Browse files

Showing the changes to interface/src/Application.cpp (1 of 24 files). Show all

Unified · Split

interface/src/Application.cpp+18−0
@@ -101,6 +101,7 @@ · 100 unmodified lines
101#include <VrMenu.h>101#include <VrMenu.h>
102#include <recording/Deck.h>102#include <recording/Deck.h>
103#include <recording/Recorder.h>103#include <recording/Recorder.h>
104#include <QmlWebWindowClass.h>
104 105
105#include "AnimDebugDraw.h"106#include "AnimDebugDraw.h"
106#include "AudioClient.h"107#include "AudioClient.h"
@@ -362,6 +363,17 @@ Cube3DOverlay* _keyboardFocusHighlight{ nullptr }; · 255 unmodified lines
362int _keyboardFocusHighlightID{ -1 };363int _keyboardFocusHighlightID{ -1 };
363PluginContainer* _pluginContainer;364PluginContainer* _pluginContainer;
364 365
366
367// FIXME hack access to the internal share context for the Chromium helper
368// Normally we'd want to use QWebEngine::initialize(), but we can't because
369// our primary context is a QGLWidget, which can't easily be initialized to share
370// from a QOpenGLContext.
371//
372// So instead we create a new offscreen context to share with the QGLWidget,
373// and manually set THAT to be the shared context for the Chromium helper
374OffscreenGLCanvas* _chromiumShareContext { nullptr };
375Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
376
365Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :377Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
366 QApplication(argc, argv),378 QApplication(argc, argv),
367 _dependencyManagerIsSetup(setupEssentials(argc, argv)),379 _dependencyManagerIsSetup(setupEssentials(argc, argv)),
@@ -623,6 +635,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 255 unmodified lines
623 _glWidget->makeCurrent();635 _glWidget->makeCurrent();
624 _glWidget->initializeGL();636 _glWidget->initializeGL();
625 637
638 _chromiumShareContext = new OffscreenGLCanvas();
639 _chromiumShareContext->create(_glWidget->context()->contextHandle());
640 _chromiumShareContext->makeCurrent();
641 qt_gl_set_global_share_context(_chromiumShareContext->getContext());
642
626 _offscreenContext = new OffscreenGLCanvas();643 _offscreenContext = new OffscreenGLCanvas();
627 _offscreenContext->create(_glWidget->context()->contextHandle());644 _offscreenContext->create(_glWidget->context()->contextHandle());
628 _offscreenContext->makeCurrent();645 _offscreenContext->makeCurrent();
@@ -4138,6 +4155,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 3509 unmodified lines
4138 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,4155 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
4139 LocationScriptingInterface::locationSetter);4156 LocationScriptingInterface::locationSetter);
4140 4157
4158 scriptEngine->registerFunction("QmlWebWindow", QmlWebWindowClass::constructor);
4141 scriptEngine->registerFunction("WebWindow", WebWindowClass::constructor, 1);4159 scriptEngine->registerFunction("WebWindow", WebWindowClass::constructor, 1);
4142 4160
4143 scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());4161 scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());