author | eckhart.koppen@nokia.com |
Wed, 31 Mar 2010 11:06:36 +0300 | |
changeset 7 | f7bc934e204c |
parent 3 | 41300fa6a67c |
child 33 | 3e2da88830cd |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
7
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtOpenGL module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
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 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef QPIXMAPDATA_GL_P_H |
|
43 |
#define QPIXMAPDATA_GL_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 purely as an |
|
50 |
// implementation detail. 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 "qgl_p.h" |
|
57 |
#include "qgl.h" |
|
58 |
||
59 |
#include "private/qpixmapdata_p.h" |
|
60 |
#include "private/qglpaintdevice_p.h" |
|
61 |
||
62 |
QT_BEGIN_NAMESPACE |
|
63 |
||
64 |
class QPaintEngine; |
|
65 |
class QGLFramebufferObject; |
|
66 |
class QGLFramebufferObjectFormat; |
|
67 |
class QGLPixmapData; |
|
68 |
||
69 |
class QGLFramebufferObjectPool |
|
70 |
{ |
|
71 |
public: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
QGLFramebufferObject *acquire(const QSize &size, const QGLFramebufferObjectFormat &format, bool strictSize = false); |
0 | 73 |
void release(QGLFramebufferObject *fbo); |
74 |
||
75 |
private: |
|
76 |
QList<QGLFramebufferObject *> m_fbos; |
|
77 |
}; |
|
78 |
||
79 |
QGLFramebufferObjectPool* qgl_fbo_pool(); |
|
80 |
||
81 |
||
82 |
class QGLPixmapGLPaintDevice : public QGLPaintDevice |
|
83 |
{ |
|
84 |
public: |
|
85 |
QPaintEngine* paintEngine() const; |
|
86 |
||
87 |
void beginPaint(); |
|
88 |
void endPaint(); |
|
89 |
QGLContext* context() const; |
|
90 |
QSize size() const; |
|
7
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
91 |
bool alphaRequested() const; |
0 | 92 |
|
93 |
void setPixmapData(QGLPixmapData*); |
|
94 |
private: |
|
95 |
QGLPixmapData *data; |
|
96 |
}; |
|
97 |
||
98 |
||
99 |
class QGLPixmapData : public QPixmapData |
|
100 |
{ |
|
101 |
public: |
|
102 |
QGLPixmapData(PixelType type); |
|
103 |
~QGLPixmapData(); |
|
104 |
||
105 |
QPixmapData *createCompatiblePixmapData() const; |
|
106 |
||
107 |
// Re-implemented from QPixmapData: |
|
108 |
void resize(int width, int height); |
|
109 |
void fromImage(const QImage &image, Qt::ImageConversionFlags flags); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
110 |
bool fromFile(const QString &filename, const char *format, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
111 |
Qt::ImageConversionFlags flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
112 |
bool fromData(const uchar *buffer, uint len, const char *format, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
Qt::ImageConversionFlags flags); |
0 | 114 |
void copy(const QPixmapData *data, const QRect &rect); |
115 |
bool scroll(int dx, int dy, const QRect &rect); |
|
116 |
void fill(const QColor &color); |
|
117 |
bool hasAlphaChannel() const; |
|
118 |
QImage toImage() const; |
|
119 |
QPaintEngine *paintEngine() const; |
|
120 |
int metric(QPaintDevice::PaintDeviceMetric metric) const; |
|
121 |
||
122 |
// For accessing as a target: |
|
123 |
QGLPaintDevice *glDevice() const; |
|
124 |
||
125 |
// For accessing as a source: |
|
126 |
bool isValidContext(const QGLContext *ctx) const; |
|
127 |
GLuint bind(bool copyBack = true) const; |
|
128 |
QGLTexture *texture() const; |
|
129 |
||
130 |
private: |
|
131 |
bool isValid() const; |
|
132 |
||
133 |
void ensureCreated() const; |
|
134 |
||
135 |
bool isUninitialized() const { return m_dirty && m_source.isNull(); } |
|
136 |
||
137 |
bool needsFill() const { return m_hasFillColor; } |
|
138 |
QColor fillColor() const { return m_fillColor; } |
|
139 |
||
140 |
||
141 |
||
142 |
QGLPixmapData(const QGLPixmapData &other); |
|
143 |
QGLPixmapData &operator=(const QGLPixmapData &other); |
|
144 |
||
145 |
void copyBackFromRenderFbo(bool keepCurrentFboBound) const; |
|
146 |
QSize size() const { return QSize(w, h); } |
|
147 |
||
148 |
static bool useFramebufferObjects(); |
|
149 |
||
150 |
QImage fillImage(const QColor &color) const; |
|
151 |
||
152 |
mutable QGLFramebufferObject *m_renderFbo; |
|
153 |
mutable QPaintEngine *m_engine; |
|
154 |
mutable QGLContext *m_ctx; |
|
155 |
mutable QImage m_source; |
|
156 |
mutable QGLTexture m_texture; |
|
157 |
||
158 |
// the texture is not in sync with the source image |
|
159 |
mutable bool m_dirty; |
|
160 |
||
161 |
// fill has been called and no painting has been done, so the pixmap is |
|
162 |
// represented by a single fill color |
|
163 |
mutable QColor m_fillColor; |
|
164 |
mutable bool m_hasFillColor; |
|
165 |
||
166 |
mutable bool m_hasAlpha; |
|
167 |
||
168 |
mutable QGLPixmapGLPaintDevice m_glDevice; |
|
169 |
||
170 |
friend class QGLPixmapGLPaintDevice; |
|
171 |
}; |
|
172 |
||
173 |
QT_END_NAMESPACE |
|
174 |
||
175 |
#endif // QPIXMAPDATA_GL_P_H |
|
176 |
||
177 |