Replace 'i < len-1 && func(i+1)' by 'i+1 < len && func(i+1)'
[profile/ivi/qtbase.git] / src / gui / painting / qgraphicssystem_runtime_p.h
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 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QGRAPHICSSYSTEM_RUNTIME_P_H
43 #define QGRAPHICSSYSTEM_RUNTIME_P_H
44
45 //
46 //  W A R N I N G
47 //  -------------
48 //
49 // This file is not part of the Qt API.  It exists for the convenience
50 // of other Qt classes.  This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55
56 #include "qgraphicssystem_p.h"
57
58 #include <private/qpixmapdata_p.h>
59
60 QT_BEGIN_NAMESPACE
61
62 class QRuntimeGraphicsSystem;
63
64 class Q_GUI_EXPORT QRuntimePixmapData : public QPixmapData {
65 public:
66     QRuntimePixmapData(const QRuntimeGraphicsSystem *gs, PixelType type);
67     ~QRuntimePixmapData();
68
69     virtual QPixmapData *createCompatiblePixmapData() const;
70     virtual void resize(int width, int height);
71     virtual void fromImage(const QImage &image,
72                            Qt::ImageConversionFlags flags);
73
74     virtual bool fromFile(const QString &filename, const char *format,
75                           Qt::ImageConversionFlags flags);
76     virtual bool fromData(const uchar *buffer, uint len, const char *format,
77                           Qt::ImageConversionFlags flags);
78
79     virtual void copy(const QPixmapData *data, const QRect &rect);
80     virtual bool scroll(int dx, int dy, const QRect &rect);
81
82     virtual int metric(QPaintDevice::PaintDeviceMetric metric) const;
83     virtual void fill(const QColor &color);
84     virtual QBitmap mask() const;
85     virtual void setMask(const QBitmap &mask);
86     virtual bool hasAlphaChannel() const;
87     virtual QPixmap transformed(const QTransform &matrix,
88                                 Qt::TransformationMode mode) const;
89     virtual void setAlphaChannel(const QPixmap &alphaChannel);
90     virtual QPixmap alphaChannel() const;
91     virtual QImage toImage() const;
92     virtual QPaintEngine *paintEngine() const;
93
94     virtual QImage *buffer();
95
96     void readBackInfo();
97
98     QPixmapData *m_data;
99
100 #if defined(Q_OS_SYMBIAN)
101     void* toNativeType(NativeType type);
102     void fromNativeType(void* pixmap, NativeType type);
103 #endif
104
105     virtual QPixmapData *runtimeData() const;
106
107 private:
108     const QRuntimeGraphicsSystem *m_graphicsSystem;
109
110 };
111
112 class QRuntimeWindowSurface : public QWindowSurface {
113 public:
114     QRuntimeWindowSurface(const QRuntimeGraphicsSystem *gs, QWidget *window);
115     ~QRuntimeWindowSurface();
116
117     virtual QPaintDevice *paintDevice();
118     virtual void flush(QWidget *widget, const QRegion &region,
119                        const QPoint &offset);
120     virtual void setGeometry(const QRect &rect);
121
122     virtual bool scroll(const QRegion &area, int dx, int dy);
123
124     virtual void beginPaint(const QRegion &);
125     virtual void endPaint(const QRegion &);
126
127     virtual QImage* buffer(const QWidget *widget);
128     virtual QPixmap grabWidget(const QWidget *widget, const QRect& rectangle = QRect()) const;
129
130     virtual QPoint offset(const QWidget *widget) const;
131
132     virtual WindowSurfaceFeatures features() const;
133
134     QScopedPointer<QWindowSurface> m_windowSurface;
135     QScopedPointer<QWindowSurface> m_pendingWindowSurface;
136
137 private:
138     const QRuntimeGraphicsSystem *m_graphicsSystem;
139 };
140
141 class QRuntimeGraphicsSystem : public QGraphicsSystem
142 {
143 public:
144
145     enum WindowSurfaceDestroyPolicy
146     {
147         DestroyImmediately,
148         DestroyAfterFirstFlush
149     };
150
151 public:
152     QRuntimeGraphicsSystem();
153
154     QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
155     QWindowSurface *createWindowSurface(QWidget *widget) const;
156
157     void removePixmapData(QRuntimePixmapData *pixmapData) const;
158     void removeWindowSurface(QRuntimeWindowSurface *windowSurface) const;
159
160     void setGraphicsSystem(const QString &name);
161     QString graphicsSystemName() const { return m_graphicsSystemName; }
162
163     void setWindowSurfaceDestroyPolicy(WindowSurfaceDestroyPolicy policy)
164     {
165         m_windowSurfaceDestroyPolicy = policy;
166     }
167
168     int windowSurfaceDestroyPolicy() const { return m_windowSurfaceDestroyPolicy; }
169
170
171 private:
172     int m_windowSurfaceDestroyPolicy;
173     QGraphicsSystem *m_graphicsSystem;
174     mutable QList<QRuntimePixmapData *> m_pixmapDatas;
175     mutable QList<QRuntimeWindowSurface *> m_windowSurfaces;
176     QString m_graphicsSystemName;
177
178     QString m_pendingGraphicsSystemName;
179
180     friend class QRuntimePixmapData;
181     friend class QRuntimeWindowSurface;
182     friend class QMeeGoGraphicsSystem;
183 };
184
185 QT_END_NAMESPACE
186
187 #endif