1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
6 | **
|
---|
7 | ** This file is part of the plugins of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at qt-info@nokia.com.
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "qmeegoruntime.h"
|
---|
43 |
|
---|
44 | #include <private/qlibrary_p.h>
|
---|
45 | #include <private/qfactoryloader_p.h>
|
---|
46 | #include <private/qgraphicssystemplugin_p.h>
|
---|
47 | #include <stdio.h>
|
---|
48 |
|
---|
49 | #define ENSURE_INITIALIZED {if (!initialized) initialize();}
|
---|
50 |
|
---|
51 | bool QMeeGoRuntime::initialized = false;
|
---|
52 |
|
---|
53 | typedef int (*QMeeGoImageToEglSharedImageFunc) (const QImage&);
|
---|
54 | typedef QPixmapData* (*QMeeGoPixmapDataFromEglSharedImageFunc) (Qt::HANDLE handle, const QImage&);
|
---|
55 | typedef QPixmapData* (*QMeeGoPixmapDataWithGLTextureFunc) (int w, int h);
|
---|
56 | typedef bool (*QMeeGoDestroyEGLSharedImageFunc) (Qt::HANDLE handle);
|
---|
57 | typedef void (*QMeeGoUpdateEglSharedImagePixmapFunc) (QPixmap*);
|
---|
58 | typedef void (*QMeeGoSetSurfaceFixedSizeFunc) (int w, int h);
|
---|
59 | typedef void (*QMeeGoSetSurfaceScalingFunc) (int x, int y, int w, int h);
|
---|
60 | typedef void (*QMeeGoSetTranslucentFunc) (bool translucent);
|
---|
61 | typedef QPixmapData* (*QMeeGoPixmapDataWithNewLiveTextureFunc) (int w, int h, QImage::Format format);
|
---|
62 | typedef QPixmapData* (*QMeeGoPixmapDataFromLiveTextureHandleFunc) (Qt::HANDLE h);
|
---|
63 | typedef QImage* (*QMeeGoLiveTextureLockFunc) (QPixmap*, void* fenceSync);
|
---|
64 | typedef bool (*QMeeGoLiveTextureReleaseFunc) (QPixmap*, QImage *i);
|
---|
65 | typedef Qt::HANDLE (*QMeeGoLiveTextureGetHandleFunc) (QPixmap*);
|
---|
66 | typedef void* (*QMeeGoCreateFenceSyncFunc) (void);
|
---|
67 | typedef void (*QMeeGoDestroyFenceSyncFunc) (void *fs);
|
---|
68 |
|
---|
69 | static QMeeGoImageToEglSharedImageFunc qt_meego_image_to_egl_shared_image = NULL;
|
---|
70 | static QMeeGoPixmapDataFromEglSharedImageFunc qt_meego_pixmapdata_from_egl_shared_image = NULL;
|
---|
71 | static QMeeGoPixmapDataWithGLTextureFunc qt_meego_pixmapdata_with_gl_texture = NULL;
|
---|
72 | static QMeeGoDestroyEGLSharedImageFunc qt_meego_destroy_egl_shared_image = NULL;
|
---|
73 | static QMeeGoUpdateEglSharedImagePixmapFunc qt_meego_update_egl_shared_image_pixmap = NULL;
|
---|
74 | static QMeeGoSetSurfaceFixedSizeFunc qt_meego_set_surface_fixed_size = NULL;
|
---|
75 | static QMeeGoSetSurfaceScalingFunc qt_meego_set_surface_scaling = NULL;
|
---|
76 | static QMeeGoSetTranslucentFunc qt_meego_set_translucent = NULL;
|
---|
77 | static QMeeGoPixmapDataWithNewLiveTextureFunc qt_meego_pixmapdata_with_new_live_texture = NULL;
|
---|
78 | static QMeeGoPixmapDataFromLiveTextureHandleFunc qt_meego_pixmapdata_from_live_texture_handle = NULL;
|
---|
79 | static QMeeGoLiveTextureLockFunc qt_meego_live_texture_lock = NULL;
|
---|
80 | static QMeeGoLiveTextureReleaseFunc qt_meego_live_texture_release = NULL;
|
---|
81 | static QMeeGoLiveTextureGetHandleFunc qt_meego_live_texture_get_handle = NULL;
|
---|
82 | static QMeeGoCreateFenceSyncFunc qt_meego_create_fence_sync = NULL;
|
---|
83 | static QMeeGoDestroyFenceSyncFunc qt_meego_destroy_fence_sync = NULL;
|
---|
84 |
|
---|
85 | void QMeeGoRuntime::initialize()
|
---|
86 | {
|
---|
87 | QFactoryLoader loader(QGraphicsSystemFactoryInterface_iid, QLatin1String("/graphicssystems"), Qt::CaseInsensitive);
|
---|
88 |
|
---|
89 | QLibraryPrivate *libraryPrivate = loader.library(QLatin1String("meego"));
|
---|
90 | Q_ASSERT(libraryPrivate);
|
---|
91 |
|
---|
92 | QLibrary library(libraryPrivate->fileName, libraryPrivate->fullVersion);
|
---|
93 |
|
---|
94 | bool success = library.load();
|
---|
95 |
|
---|
96 | if (success) {
|
---|
97 | qt_meego_image_to_egl_shared_image = (QMeeGoImageToEglSharedImageFunc) library.resolve("qt_meego_image_to_egl_shared_image");
|
---|
98 | qt_meego_pixmapdata_from_egl_shared_image = (QMeeGoPixmapDataFromEglSharedImageFunc) library.resolve("qt_meego_pixmapdata_from_egl_shared_image");
|
---|
99 | qt_meego_pixmapdata_with_gl_texture = (QMeeGoPixmapDataWithGLTextureFunc) library.resolve("qt_meego_pixmapdata_with_gl_texture");
|
---|
100 | qt_meego_destroy_egl_shared_image = (QMeeGoDestroyEGLSharedImageFunc) library.resolve("qt_meego_destroy_egl_shared_image");
|
---|
101 | qt_meego_update_egl_shared_image_pixmap = (QMeeGoUpdateEglSharedImagePixmapFunc) library.resolve("qt_meego_update_egl_shared_image_pixmap");
|
---|
102 | qt_meego_set_surface_fixed_size = (QMeeGoSetSurfaceFixedSizeFunc) library.resolve("qt_meego_set_surface_fixed_size");
|
---|
103 | qt_meego_set_surface_scaling = (QMeeGoSetSurfaceScalingFunc) library.resolve("qt_meego_set_surface_scaling");
|
---|
104 | qt_meego_set_translucent = (QMeeGoSetTranslucentFunc) library.resolve("qt_meego_set_translucent");
|
---|
105 | qt_meego_pixmapdata_with_new_live_texture = (QMeeGoPixmapDataWithNewLiveTextureFunc) library.resolve("qt_meego_pixmapdata_with_new_live_texture");
|
---|
106 | qt_meego_pixmapdata_from_live_texture_handle = (QMeeGoPixmapDataFromLiveTextureHandleFunc) library.resolve("qt_meego_pixmapdata_from_live_texture_handle");
|
---|
107 | qt_meego_live_texture_lock = (QMeeGoLiveTextureLockFunc) library.resolve("qt_meego_live_texture_lock");
|
---|
108 | qt_meego_live_texture_release = (QMeeGoLiveTextureReleaseFunc) library.resolve("qt_meego_live_texture_release");
|
---|
109 | qt_meego_live_texture_get_handle = (QMeeGoLiveTextureGetHandleFunc) library.resolve("qt_meego_live_texture_get_handle");
|
---|
110 | qt_meego_create_fence_sync = (QMeeGoCreateFenceSyncFunc) library.resolve("qt_meego_create_fence_sync");
|
---|
111 | qt_meego_destroy_fence_sync = (QMeeGoDestroyFenceSyncFunc) library.resolve("qt_meego_destroy_fence_sync");
|
---|
112 |
|
---|
113 | if (qt_meego_image_to_egl_shared_image && qt_meego_pixmapdata_from_egl_shared_image &&
|
---|
114 | qt_meego_pixmapdata_with_gl_texture && qt_meego_destroy_egl_shared_image && qt_meego_update_egl_shared_image_pixmap &&
|
---|
115 | qt_meego_set_surface_fixed_size && qt_meego_set_surface_scaling && qt_meego_set_translucent &&
|
---|
116 | qt_meego_pixmapdata_with_new_live_texture && qt_meego_pixmapdata_from_live_texture_handle &&
|
---|
117 | qt_meego_live_texture_lock && qt_meego_live_texture_release && qt_meego_live_texture_get_handle &&
|
---|
118 | qt_meego_create_fence_sync && qt_meego_destroy_fence_sync)
|
---|
119 | {
|
---|
120 | qDebug("Successfully resolved MeeGo graphics system: %s %s\n", qPrintable(libraryPrivate->fileName), qPrintable(libraryPrivate->fullVersion));
|
---|
121 | } else {
|
---|
122 | Q_ASSERT(false);
|
---|
123 | }
|
---|
124 | } else {
|
---|
125 | Q_ASSERT(false);
|
---|
126 | }
|
---|
127 |
|
---|
128 | initialized = true;
|
---|
129 | }
|
---|
130 |
|
---|
131 | Qt::HANDLE QMeeGoRuntime::imageToEGLSharedImage(const QImage &image)
|
---|
132 | {
|
---|
133 | ENSURE_INITIALIZED;
|
---|
134 | Q_ASSERT(qt_meego_image_to_egl_shared_image);
|
---|
135 | return qt_meego_image_to_egl_shared_image(image);
|
---|
136 | }
|
---|
137 |
|
---|
138 | QPixmapData* QMeeGoRuntime::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage)
|
---|
139 | {
|
---|
140 | ENSURE_INITIALIZED;
|
---|
141 | Q_ASSERT(qt_meego_pixmapdata_from_egl_shared_image);
|
---|
142 | return qt_meego_pixmapdata_from_egl_shared_image(handle, softImage);
|
---|
143 | }
|
---|
144 |
|
---|
145 | QPixmapData* QMeeGoRuntime::pixmapDataWithGLTexture(int w, int h)
|
---|
146 | {
|
---|
147 | ENSURE_INITIALIZED;
|
---|
148 | Q_ASSERT(qt_meego_pixmapdata_with_gl_texture);
|
---|
149 | return qt_meego_pixmapdata_with_gl_texture(w, h);
|
---|
150 | }
|
---|
151 |
|
---|
152 | bool QMeeGoRuntime::destroyEGLSharedImage(Qt::HANDLE handle)
|
---|
153 | {
|
---|
154 | ENSURE_INITIALIZED;
|
---|
155 | Q_ASSERT(qt_meego_destroy_egl_shared_image);
|
---|
156 | return qt_meego_destroy_egl_shared_image(handle);
|
---|
157 | }
|
---|
158 |
|
---|
159 | void QMeeGoRuntime::updateEGLSharedImagePixmap(QPixmap *p)
|
---|
160 | {
|
---|
161 | ENSURE_INITIALIZED;
|
---|
162 | Q_ASSERT(qt_meego_update_egl_shared_image_pixmap);
|
---|
163 | return qt_meego_update_egl_shared_image_pixmap(p);
|
---|
164 | }
|
---|
165 |
|
---|
166 | void QMeeGoRuntime::setSurfaceFixedSize(int w, int h)
|
---|
167 | {
|
---|
168 | ENSURE_INITIALIZED;
|
---|
169 | Q_ASSERT(qt_meego_set_surface_fixed_size);
|
---|
170 | qt_meego_set_surface_fixed_size(w, h);
|
---|
171 | }
|
---|
172 |
|
---|
173 | void QMeeGoRuntime::setSurfaceScaling(int x, int y, int w, int h)
|
---|
174 | {
|
---|
175 | ENSURE_INITIALIZED;
|
---|
176 | Q_ASSERT(qt_meego_set_surface_scaling);
|
---|
177 | qt_meego_set_surface_scaling(x, y, w, h);
|
---|
178 | }
|
---|
179 |
|
---|
180 | void QMeeGoRuntime::setTranslucent(bool translucent)
|
---|
181 | {
|
---|
182 | ENSURE_INITIALIZED;
|
---|
183 | Q_ASSERT(qt_meego_set_translucent);
|
---|
184 | qt_meego_set_translucent(translucent);
|
---|
185 | }
|
---|
186 |
|
---|
187 | QPixmapData* QMeeGoRuntime::pixmapDataWithNewLiveTexture(int w, int h, QImage::Format format)
|
---|
188 | {
|
---|
189 | ENSURE_INITIALIZED;
|
---|
190 | Q_ASSERT(qt_meego_pixmapdata_with_new_live_texture);
|
---|
191 | return qt_meego_pixmapdata_with_new_live_texture(w, h, format);
|
---|
192 | }
|
---|
193 |
|
---|
194 | QPixmapData* QMeeGoRuntime::pixmapDataFromLiveTextureHandle(Qt::HANDLE h)
|
---|
195 | {
|
---|
196 | ENSURE_INITIALIZED;
|
---|
197 | Q_ASSERT(qt_meego_pixmapdata_from_live_texture_handle);
|
---|
198 | return qt_meego_pixmapdata_from_live_texture_handle(h);
|
---|
199 | }
|
---|
200 |
|
---|
201 | QImage* QMeeGoRuntime::lockLiveTexture(QPixmap *p, void* fenceSync)
|
---|
202 | {
|
---|
203 | ENSURE_INITIALIZED;
|
---|
204 | Q_ASSERT(qt_meego_live_texture_lock);
|
---|
205 | return qt_meego_live_texture_lock(p, fenceSync);
|
---|
206 | }
|
---|
207 |
|
---|
208 | bool QMeeGoRuntime::releaseLiveTexture(QPixmap *p, QImage *i)
|
---|
209 | {
|
---|
210 | ENSURE_INITIALIZED;
|
---|
211 | Q_ASSERT(qt_meego_live_texture_release);
|
---|
212 | return qt_meego_live_texture_release(p, i);
|
---|
213 | }
|
---|
214 |
|
---|
215 | Qt::HANDLE QMeeGoRuntime::getLiveTextureHandle(QPixmap *pixmap)
|
---|
216 | {
|
---|
217 | ENSURE_INITIALIZED;
|
---|
218 | Q_ASSERT(qt_meego_live_texture_get_handle);
|
---|
219 | return qt_meego_live_texture_get_handle(pixmap);
|
---|
220 | }
|
---|
221 |
|
---|
222 | void* QMeeGoRuntime::createFenceSync()
|
---|
223 | {
|
---|
224 | ENSURE_INITIALIZED;
|
---|
225 | Q_ASSERT(qt_meego_create_fence_sync);
|
---|
226 | return qt_meego_create_fence_sync();
|
---|
227 | }
|
---|
228 |
|
---|
229 | void QMeeGoRuntime::destroyFenceSync(void *fs)
|
---|
230 | {
|
---|
231 | ENSURE_INITIALIZED;
|
---|
232 | Q_ASSERT(qt_meego_destroy_fence_sync);
|
---|
233 | qt_meego_destroy_fence_sync(fs);
|
---|
234 | }
|
---|