Warning: That file was not part of the compilation database. It may have many parsing errors.

1/****************************************************************************
2**
3** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the plugins of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QMEEGOGRAPHICSSYSTEMHELPER_H
43#define QMEEGOGRAPHICSSYSTEMHELPER_H
44
45#include <QtGui/QPixmap>
46#include <QtGui/QImage>
47#include "QtMeeGoGraphicsSystemHelper/qmeegolivepixmap.h"
48
49class QLibrary;
50
51//! The base class for accressing special meego graphics system features.
52/*!
53 This class is a helper class with static-only methods for accessing various
54 meego graphics system functionalities. The way it works is that the helper
55 dynamically calls-in to the loaded graphicssystem plugin... therefore, you're
56 expected to make sure that you're indeed running with 'meego' before using any
57 of the specialized methods.
58
59 In example:
60
61 \code
62 QPixmap p;
63 if (QMeeGoGraphicsSystemHelper::isRunningMeeGo()) {
64 p = QMeeGoGraphicsSystemHelper::pixmapWithGLTexture(64, 64);
65 } else {
66 p = QPixmap(64, 64);
67 }
68 \endcode
69
70 Calling any of the meego-specific features while not running meego might
71 give unpredictable results. The only functions safe to call at all times are:
72
73 \code
74 QMeeGoGraphicsSystemHelper::isRunningMeeGo();
75 QMeeGoGraphicsSystemHelper::runningGraphicsSystemName();
76 QMeeGoGraphicsSystemHelper::switchToMeeGo();
77 QMeeGoGraphicsSystemHelper::switchToRaster();
78 \endcode
79*/
80
81class Q_DECL_EXPORT QMeeGoGraphicsSystemHelper
82{
83public:
84 //! Returns true if running meego.
85 /*!
86 Returns true if the currently active (running) system is 'meego' with OpenGL.
87 This returns both true if the app was started with 'meego' or was started with
88 'runtime' graphics system and the currently active system through the runtime
89 switching is 'meego'.
90 */
91 static bool isRunningMeeGo();
92
93 //! Returns true if running with a 'runtime' graphicssystem.
94 /*!
95 This function can be used in combination with ::runningGraphicsSystemName to figure out
96 the existing situation.
97 */
98 static bool isRunningRuntime();
99
100 //! Enables the sending of QMeeGoSwitchEvent's when the graphicssystem switches.
101 /*!
102 An application that wishes to start receive QMeegoSwitchEvents must call this function.
103 */
104 static void enableSwitchEvents();
105
106 //! Switches to meego graphics system.
107 /*!
108 When running with the 'runtime' graphics system, sets the currently active
109 system to 'meego'. The window surface and all the resources are automatically
110 migrated to OpenGL. Will fail if the active graphics system is not 'runtime'.
111 Calling this function will emit QMeeGoSwitchEvent to the top level widgets.
112 If switch events are enabled, two events will be emitted for each switch --
113 one before the switch (QMeeGoSwitchEvent::WillSwitch) and one after the
114 switch (QMeeGoSwitchEvent::DidSwitch).
115 If the switch policy is set to NoSwitch, this function has no effect.
116 */
117 static void switchToMeeGo();
118
119 //! Switches to raster graphics system
120 /*!
121 When running with the 'runtime' graphics system, sets the currently active
122 system to 'raster'. The window surface and the graphics resources (including the
123 EGL shared image resources) are automatically migrated back to the CPU. All OpenGL
124 resources (surface, context, cache, font cache) are automaticall anihilated.
125 Calling this function will emit QMeeGoSwitchEvent to the top level widgets. If switch
126 events are enabled, two events will be emitted for each switch -- one before the
127 switch (QMeeGoSwitchEvent::WillSwitch) and one after the switch (QMeeGoSwitchEvent::DidSwitch).
128 If the switch policy is set to NoSwitch, this function has no effect.
129 */
130 static void switchToRaster();
131
132 //! Used to specify the policy for graphics system switching.
133 enum SwitchPolicy {
134 AutomaticSwitch, /**< Automatic switching */
135 ManualSwitch, /**< Switching is controleld by the application */
136 NoSwitch /**< Switching is disabled completely */
137 };
138
139 //! Sets the policy of graphicssystem switching
140 /*!
141 By default, the switch to raster happens automatically when all windows are either
142 minimized or when the last window is destroyed. This function lets the application
143 change the graphicssystem switching policy to prevent the switching from happening
144 automatically (that is if the application doesn't want switching at all or wishes
145 to control the switching manually).
146 */
147 static void setSwitchPolicy(SwitchPolicy policy);
148
149 //! Returns the name of the active graphics system
150 /*!
151 Returns the name of the currently active system. If running with 'runtime' graphics
152 system, returns the name of the active system inside the runtime graphics system
153 */
154 static QString runningGraphicsSystemName();
155
156 //! Creates a new EGL shared image.
157 /*!
158 Creates a new EGL shared image from the given image. The EGL shared image wraps
159 a GL texture in the native format and can be easily accessed from other processes.
160 */
161 static Qt::HANDLE imageToEGLSharedImage(const QImage &image);
162
163 //! Creates a QPixmap from an EGL shared image
164 /*!
165 Creates a new QPixmap from the given EGL shared image handle. The QPixmap can be
166 used for painting like any other pixmap. The softImage should point to an alternative,
167 software version of the graphical resource -- ie. obtained from theme daemon. The
168 softImage can be allocated on a QSharedMemory slice for easy sharing across processes
169 too. When the application is migrated ToRaster, this softImage will replace the
170 contents of the sharedImage.
171
172 It's ok to call this function too when not running 'meego' graphics system. In this
173 case it'll create a QPixmap backed with a raster data (from softImage)... but when
174 the system is switched back to 'meego', the QPixmap will be migrated to a EGL-shared image
175 backed storage (handle).
176 */
177 static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage);
178
179 //! Destroys an EGL shared image.
180 /*!
181 Destroys an EGLSharedImage previously created with an ::imageToEGLSharedImage call.
182 Returns true if the image was found and the destruction was successful. Notice that
183 this destroys the image for all processes using it.
184 */
185 static bool destroyEGLSharedImage(Qt::HANDLE handle);
186
187 //! Updates the QPixmap backed with an EGLShared image.
188 /*!
189 This function re-reads the softImage that was specified when creating the pixmap with
190 ::pixmapFromEGLSharedImage and updates the EGL Shared image contents. It can be used
191 to share cross-proccess mutable EGLShared images.
192 */
193 static void updateEGLSharedImagePixmap(QPixmap *p);
194
195 //! Create a new QPixmap with a GL texture.
196 /*!
197 Creates a new QPixmap which is backed by an OpenGL local texture. Drawing to this
198 QPixmap will be accelerated by hardware -- unlike the normal (new QPixmap()) pixmaps,
199 which are backed by a software engine and only migrated to GPU when used. Migrating those
200 GL-backed pixmaps when going ToRaster is expsensive (they need to be downloaded from
201 GPU to CPU) so use wisely.
202 */
203 static QPixmap pixmapWithGLTexture(int w, int h);
204
205 //! Sets translucency (alpha) on the base window surface.
206 /*!
207 This function needs to be called *before* any widget/content is created.
208 When called with true, the base window surface will be translucent and initialized
209 with QGLFormat.alpha == true.
210
211 This function is *deprecated*. Set Qt::WA_TranslucentBackground attribute
212 on the top-level widget *before* you show it instead.
213 */
214 static void setTranslucent(bool translucent);
215
216 //! Used to specify the mode for swapping buffers in double-buffered GL rendering.
217 enum SwapMode {
218 AutomaticSwap, /**< Automatically choose netween full and partial updates (25% threshold) */
219 AlwaysFullSwap, /**< Always do a full swap even if partial updates support present */
220 AlwaysPartialSwap, /**< Always do a partial swap (if support present) no matter what threshold */
221 KillSwap /**< Do not perform buffer swapping at all (no picture) */
222 };
223
224 //! Sets the buffer swapping mode.
225 /*!
226 This can be only called when running with the meego graphics system.
227 The KillSwap mode can be specififed to effectively block painting.
228
229 This functionality should be used only by applications counting on a specific behavior.
230 Most applications should use the default automatic behavior.
231 */
232 static void setSwapBehavior(SwapMode mode);
233};
234
235#endif
236

Warning: That file was not part of the compilation database. It may have many parsing errors.