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
101101 #include <VrMenu.h>
102102 #include <recording/Deck.h>
103103 #include <recording/Recorder.h>
104+#include <QmlWebWindowClass.h>
104105
105106 #include "AnimDebugDraw.h"
106107 #include "AudioClient.h"
@@ -362,6 +363,17 @@ Cube3DOverlay* _keyboardFocusHighlight{ nullptr }; · 255 unmodified lines
362363 int _keyboardFocusHighlightID{ -1 };
363364 PluginContainer* _pluginContainer;
364365
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
374+OffscreenGLCanvas* _chromiumShareContext { nullptr };
375+Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
376+
365377 Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
366378 QApplication(argc, argv),
367379 _dependencyManagerIsSetup(setupEssentials(argc, argv)),
@@ -623,6 +635,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 255 unmodified lines
623635 _glWidget->makeCurrent();
624636 _glWidget->initializeGL();
625637
638+ _chromiumShareContext = new OffscreenGLCanvas();
639+ _chromiumShareContext->create(_glWidget->context()->contextHandle());
640+ _chromiumShareContext->makeCurrent();
641+ qt_gl_set_global_share_context(_chromiumShareContext->getContext());
642+
626643 _offscreenContext = new OffscreenGLCanvas();
627644 _offscreenContext->create(_glWidget->context()->contextHandle());
628645 _offscreenContext->makeCurrent();
@@ -4138,6 +4155,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 3509 unmodified lines
41384155 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
41394156 LocationScriptingInterface::locationSetter);
41404157
4158+ scriptEngine->registerFunction("QmlWebWindow", QmlWebWindowClass::constructor);
41414159 scriptEngine->registerFunction("WebWindow", WebWindowClass::constructor, 1);
41424160
41434161 scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());