From b2ef75097e608afc717604884c4b6e4b22e78dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 7 Sep 2010 11:49:34 +0200 Subject: Use QFactoryLoader to ensure we get the correct graphics system plugin. Also, this prevents hard-coding the path to the meego plugin. --- src/corelib/plugin/qfactoryloader.cpp | 8 ++++ src/corelib/plugin/qfactoryloader_p.h | 4 ++ .../graphicssystems/meego/qmeegographicssystem.h | 16 ++++---- .../qmeegographicssystemhelper.h | 2 +- tools/qmeegographicssystemhelper/qmeegoruntime.cpp | 47 +++++++++++++++------- tools/qmeegographicssystemhelper/qmeegoruntime.h | 4 +- 6 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 62d565a..a26dcd8 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -244,6 +244,14 @@ QObject *QFactoryLoader::instance(const QString &key) const return 0; } +#ifdef Q_WS_X11 +QLibraryPrivate *QFactoryLoader::library(const QString &key) const +{ + Q_D(const QFactoryLoader); + return d->keyMap.value(d->cs ? key : key.toLower()); +} +#endif + void QFactoryLoader::refreshAll() { QMutexLocker locker(qt_factoryloader_mutex()); diff --git a/src/corelib/plugin/qfactoryloader_p.h b/src/corelib/plugin/qfactoryloader_p.h index 10e6e2a..068c6c7 100644 --- a/src/corelib/plugin/qfactoryloader_p.h +++ b/src/corelib/plugin/qfactoryloader_p.h @@ -77,6 +77,10 @@ public: QStringList keys() const; QObject *instance(const QString &key) const; +#ifdef Q_WS_X11 + QLibraryPrivate *library(const QString &key) const; +#endif + void update(); static void refreshAll(); diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h index 59392ad..905f0c3 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.h +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h @@ -72,14 +72,14 @@ private: /* C api */ extern "C" { - int qt_meego_image_to_egl_shared_image(const QImage &image); - QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage); - QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h); - void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap); - bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle); - void qt_meego_set_surface_fixed_size(int width, int height); - void qt_meego_set_surface_scaling(int x, int y, int width, int height); - void qt_meego_set_translucent(bool translucent); + Q_DECL_EXPORT int qt_meego_image_to_egl_shared_image(const QImage &image); + Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage); + Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h); + Q_DECL_EXPORT void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap); + Q_DECL_EXPORT bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle); + Q_DECL_EXPORT void qt_meego_set_surface_fixed_size(int width, int height); + Q_DECL_EXPORT void qt_meego_set_surface_scaling(int x, int y, int width, int height); + Q_DECL_EXPORT void qt_meego_set_translucent(bool translucent); } #endif diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h index aa301b1..02f2fa2 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h @@ -78,7 +78,7 @@ class QLibrary; \endcode */ -class QMeeGoGraphicsSystemHelper +class Q_DECL_EXPORT QMeeGoGraphicsSystemHelper { public: //! Returns true if running meego. diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp index 66bae1d..70b5dc1 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp @@ -41,9 +41,12 @@ #include "qmeegoruntime.h" +#include +#include +#include + #define ENSURE_INITIALIZED {if (!initialized) initialize();} -QLibrary* QMeeGoRuntime::library = NULL; bool QMeeGoRuntime::initialized = false; typedef int (*QMeeGoImageToEglSharedImageFunc) (const QImage&); @@ -66,19 +69,35 @@ static QMeeGoSetTranslucentFunc qt_meego_set_translucent = NULL; void QMeeGoRuntime::initialize() { - library = new QLibrary("/usr/lib/qt4/plugins/graphicssystems/libmeegographicssystem.so"); - Q_ASSERT(library); - - qt_meego_image_to_egl_shared_image = (QMeeGoImageToEglSharedImageFunc) library->resolve("qt_meego_image_to_egl_shared_image"); - qt_meego_pixmapdata_from_egl_shared_image = (QMeeGoPixmapDataFromEglSharedImageFunc) library->resolve("qt_meego_pixmapdata_from_egl_shared_image"); - qt_meego_pixmapdata_with_gl_texture = (QMeeGoPixmapDataWithGLTextureFunc) library->resolve("qt_meego_pixmapdata_with_gl_texture"); - qt_meego_destroy_egl_shared_image = (QMeeGoDestroyEGLSharedImageFunc) library->resolve("qt_meego_destroy_egl_shared_image"); - qt_meego_update_egl_shared_image_pixmap = (QMeeGoUpdateEglSharedImagePixmapFunc) library->resolve("qt_meego_update_egl_shared_image_pixmap"); - qt_meego_set_surface_fixed_size = (QMeeGoSetSurfaceFixedSizeFunc) library->resolve("qt_meego_set_surface_fixed_size"); - qt_meego_set_surface_scaling = (QMeeGoSetSurfaceScalingFunc) library->resolve("qt_meego_set_surface_scaling"); - qt_meego_set_translucent = (QMeeGoSetTranslucentFunc) library->resolve("qt_meego_set_translucent"); - - + QFactoryLoader loader(QGraphicsSystemFactoryInterface_iid, QLatin1String("/graphicssystems"), Qt::CaseInsensitive); + + QLibraryPrivate *libraryPrivate = loader.library(QLatin1String("meego")); + Q_ASSERT(libraryPrivate); + + QLibrary library(libraryPrivate->fileName, libraryPrivate->fullVersion); + + bool success = library.load(); + + if (success) { + qt_meego_image_to_egl_shared_image = (QMeeGoImageToEglSharedImageFunc) library.resolve("qt_meego_image_to_egl_shared_image"); + qt_meego_pixmapdata_from_egl_shared_image = (QMeeGoPixmapDataFromEglSharedImageFunc) library.resolve("qt_meego_pixmapdata_from_egl_shared_image"); + qt_meego_pixmapdata_with_gl_texture = (QMeeGoPixmapDataWithGLTextureFunc) library.resolve("qt_meego_pixmapdata_with_gl_texture"); + qt_meego_destroy_egl_shared_image = (QMeeGoDestroyEGLSharedImageFunc) library.resolve("qt_meego_destroy_egl_shared_image"); + qt_meego_update_egl_shared_image_pixmap = (QMeeGoUpdateEglSharedImagePixmapFunc) library.resolve("qt_meego_update_egl_shared_image_pixmap"); + qt_meego_set_surface_fixed_size = (QMeeGoSetSurfaceFixedSizeFunc) library.resolve("qt_meego_set_surface_fixed_size"); + qt_meego_set_surface_scaling = (QMeeGoSetSurfaceScalingFunc) library.resolve("qt_meego_set_surface_scaling"); + qt_meego_set_translucent = (QMeeGoSetTranslucentFunc) library.resolve("qt_meego_set_translucent"); + + if (qt_meego_image_to_egl_shared_image && qt_meego_pixmapdata_from_egl_shared_image && qt_meego_pixmapdata_with_gl_texture + && qt_meego_destroy_egl_shared_image && qt_meego_update_egl_shared_image_pixmap && qt_meego_set_surface_fixed_size + && qt_meego_set_surface_scaling && qt_meego_set_translucent) + { + qDebug("Successfully resolved MeeGo graphics system: %s %s\n", qPrintable(libraryPrivate->fileName), qPrintable(libraryPrivate->fullVersion)); + } + } else { + Q_ASSERT(false); + } + initialized = true; } diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h index 98bf5b0..82fdb52 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.h +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include #include #include @@ -47,7 +46,7 @@ class QMeeGoRuntime { public: static void initialize(); - + static Qt::HANDLE imageToEGLSharedImage(const QImage &image); static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); static QPixmap pixmapWithGLTexture(int w, int h); @@ -59,5 +58,4 @@ public: private: static bool initialized; - static QLibrary *library; }; -- cgit v0.12