summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Sorvig <morten.sorvig@nokia.com>2010-03-12 09:46:28 +0100
committerMorten Sorvig <morten.sorvig@nokia.com>2010-03-12 09:46:28 +0100
commitcac6207adb7a9e266b8c632faf307f04df79c4d8 (patch)
tree34c700568a81a095997d9412d6488c67aef5b2b4
parent090abf7302f78d74564635e0d67983b4e7fae084 (diff)
Make QtGui host the pepper example.
Small milestone reached, you can now compile any Qt example, and it will show the pepper sample 3D graphics. Some surprises was encountered: We need to reference the NPAPI plugin entry points somewhere in Qt, otherwise the compiler will reomve them. See qeventdispatcher_pepper.cpp. In addition, the main() function must be renamed (looks like it interferes with plugin startup). This is accomplised by a "#define main nacl_main", in qcoreapplication.h, which I`m sure will never cause any trouble.
-rw-r--r--src/corelib/kernel/qcoreapplication.h8
-rw-r--r--src/gui/gui.pro5
-rw-r--r--src/gui/kernel/kernel.pri6
-rw-r--r--src/gui/kernel/qapplication_lite.cpp6
-rw-r--r--src/gui/kernel/qeventdispatcher_pepper.cpp25
-rw-r--r--src/gui/kernel/qeventdispatcher_pepper_p.h7
-rw-r--r--src/gui/painting/painting.pri8
-rw-r--r--src/gui/painting/qgraphicssystemfactory.cpp2
-rw-r--r--src/gui/pepper/pepper.pri1
-rw-r--r--src/gui/pepper/plugin_object.cc8
10 files changed, 51 insertions, 25 deletions
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index 097b8b4823..ea23b0ccb5 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -54,6 +54,14 @@
typedef struct tagMSG MSG;
#endif
+#ifdef Q_OS_NACL
+// Pepper-based nacl modules can`t define main(). Rename it
+// here to hide it. nacl_main will be called by the "main"
+// thread started in NPP_Initialize.
+// This is a hack really, we`ll see if it works.
+#define main nacl_main
+#endif
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index 9a0a1a35a6..6fdaa2cf5d 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -39,7 +39,10 @@ include(util/util.pri)
include(statemachine/statemachine.pri)
include(math3d/math3d.pri)
include(effects/effects.pri)
-include(pepper/pepper.pri)
+
+nacl {
+ include(pepper/pepper.pri)
+}
contains(QT_CONFIG, egl): include(egl/egl.pri)
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 9bd4e3662e..0f375fc54c 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -212,10 +212,8 @@ embedded_lite {
}
nacl {
- HEADERS += kernel/qeventdispatcher_nacl_p.h \
- kernel/qeventdispatcher_pepper_p.h
- SOURCES += kernel/qeventdispatcher_nacl.cpp \
- kernel/qeventdispatcher_pepper.cpp
+ HEADERS += kernel/qeventdispatcher_pepper_p.h
+ SOURCES += kernel/qeventdispatcher_pepper.cpp
}
!embedded:!embedded_lite:!x11:mac {
diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp
index 341217c3f5..25ed298d0b 100644
--- a/src/gui/kernel/qapplication_lite.cpp
+++ b/src/gui/kernel/qapplication_lite.cpp
@@ -46,7 +46,6 @@
#include "private/qeventdispatcher_glib_p.h"
#endif
#ifdef Q_OS_NACL
-#include "private/qeventdispatcher_nacl_p.h"
#include "private/qeventdispatcher_pepper_p.h"
#endif
#include "private/qeventdispatcher_unix_p.h"
@@ -84,18 +83,17 @@ QString QApplicationPrivate::appName() const
return QT_PREPEND_NAMESPACE(appName);
}
+
void QApplicationPrivate::createEventDispatcher()
{
Q_Q(QApplication);
+
#if !defined(QT_NO_GLIB)
if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported())
eventDispatcher = new QEventDispatcherGlib(q);
else
#elif defined(Q_OS_NACL)
- if (QEventDispatcherPepper::hasPepperSupport())
eventDispatcher = new QEventDispatcherPepper();
- else
- eventDispatcher = new QEventDispatcherNaCl(q);
#else
eventDispatcher = new QEventDispatcherUNIX(q);
#endif
diff --git a/src/gui/kernel/qeventdispatcher_pepper.cpp b/src/gui/kernel/qeventdispatcher_pepper.cpp
index 7fe8a6167d..c1b9b05c26 100644
--- a/src/gui/kernel/qeventdispatcher_pepper.cpp
+++ b/src/gui/kernel/qeventdispatcher_pepper.cpp
@@ -78,9 +78,32 @@ bool QEventDispatcherPepper::hasPepperSupport()
return hasSupport;
}
+extern "C" {
+NPError NP_Initialize(NPNetscapeFuncs* browser_funcs,
+ NPPluginFuncs* plugin_funcs);
+NPError NP_GetEntryPoints(NPPluginFuncs* plugin_funcs);
+NPError NP_Shutdown();
+NPError NP_GetValue(void* instance, NPPVariable variable, void* value);
+char* NP_GetMIMEDescription();
+}
+
QEventDispatcherPepper::QEventDispatcherPepper(QObject *parent)
: QEventDispatcherUNIX(*new QEventDispatcherPepperPrivate, parent)
-{ }
+{
+
+ // Reference the NP entry points without actually calling
+ // them at run-time. This is neccasary to make sure they
+ // are not removed by the optimizer.
+ // ### must be a better way...
+ volatile bool val = false;
+ if (val) {
+ NP_Initialize(0,0);
+ NP_GetEntryPoints(0);
+ NP_Shutdown();
+ NP_GetValue(0, NPPVariable(), 0);
+ NP_GetMIMEDescription();
+ }
+}
QEventDispatcherPepper::~QEventDispatcherPepper()
{ }
diff --git a/src/gui/kernel/qeventdispatcher_pepper_p.h b/src/gui/kernel/qeventdispatcher_pepper_p.h
index 34253cc070..75e2e5cef3 100644
--- a/src/gui/kernel/qeventdispatcher_pepper_p.h
+++ b/src/gui/kernel/qeventdispatcher_pepper_p.h
@@ -44,6 +44,9 @@
typedef unsigned int size_t;
#include <nacl/npapi_extensions.h>
+#include <qqueue.h>
+#include <qwaitcondition.h>
+#include <qmutex.h>
//
// W A R N I N G
@@ -94,6 +97,10 @@ private:
void processMinimizeEvent(NPMinimizeEvent *minimize);
void processFocusEvent(NPFocusEvent *focus);
void processDeviceEvent(NPDeviceEvent *device);
+
+ QWaitCondition eventReady;
+ QMutex mutex;
+ QQueue<NPPepperEvent> eventQueue;
};
QT_END_NAMESPACE
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 9934953808..8f975b5d8d 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -391,14 +391,6 @@ embedded {
SOURCES += painting/qwindowsurface_qws.cpp
}
-nacl {
- HEADERS += painting/qgraphicssystem_nacl.h \
- painting/qwindowsurface_nacl.h
-
- SOURCES += painting/qgraphicssystem_nacl.cpp \
- painting/qwindowsurface_nacl.cpp
-}
-
# pepper
nacl {
HEADERS += painting/qgraphicssystem_pepper.h \
diff --git a/src/gui/painting/qgraphicssystemfactory.cpp b/src/gui/painting/qgraphicssystemfactory.cpp
index 865813dec9..0175133c8c 100644
--- a/src/gui/painting/qgraphicssystemfactory.cpp
+++ b/src/gui/painting/qgraphicssystemfactory.cpp
@@ -78,7 +78,7 @@ QGraphicsSystem *QGraphicsSystemFactory::create(const QString& key)
#endif
#ifdef Q_OS_NACL
- return new QNaClGraphicsSystem();
+
#endif
if (system == QLatin1String("raster"))
diff --git a/src/gui/pepper/pepper.pri b/src/gui/pepper/pepper.pri
index ed089cc981..7790efd39c 100644
--- a/src/gui/pepper/pepper.pri
+++ b/src/gui/pepper/pepper.pri
@@ -4,5 +4,6 @@ DEPENDIR += $$PWD
SOURCES += $$PWD/event_handler.cc \
$$PWD/plugin_object.cc \
$$PWD/test_object.cc \
+ $$PWD/gles2_demo_cc.cc \
$$PWD/main.cc
diff --git a/src/gui/pepper/plugin_object.cc b/src/gui/pepper/plugin_object.cc
index 9672d31090..3d6f443fcf 100644
--- a/src/gui/pepper/plugin_object.cc
+++ b/src/gui/pepper/plugin_object.cc
@@ -309,13 +309,9 @@ void PluginObject::New(NPMIMEType pluginType,
int16 argc,
char* argn[],
char* argv[]) {
- // Default to 2D rendering.
- dimensions_ = 2;
+ // Default to 3D rendering.
+ dimensions_ = 3;
- for (int i = 0; i < argc; ++i) {
- if (strcmp(argn[i], "dimensions") == 0)
- dimensions_ = atoi(argv[i]);
- }
if (!extensions) {
browser->getvalue(npp_, NPNVPepperExtensions,