author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Fri, 16 Apr 2010 11:39:52 +0300 | |
branch | RCL_3 |
changeset 8 | 740e5562c97f |
parent 7 | 3f74d0d4af4c |
child 13 | c0432d11811c |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@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 QtOpenVG 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 |
#include "qpixmapdata_vg_p.h" |
|
43 |
#include "qpaintengine_vg_p.h" |
|
44 |
#include <QtGui/private/qdrawhelper_p.h> |
|
45 |
#include "qvg_p.h" |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
#include "qvgimagepool_p.h" |
0 | 47 |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
48 |
#if defined(Q_OS_SYMBIAN) |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
49 |
#include <private/qt_s60_p.h> |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
50 |
#include <fbs.h> |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
51 |
#endif |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
52 |
#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
53 |
#include <sgresource/sgimage.h> |
0 | 54 |
typedef EGLImageKHR (*pfnEglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, EGLint*); |
55 |
typedef EGLBoolean (*pfnEglDestroyImageKHR)(EGLDisplay, EGLImageKHR); |
|
56 |
typedef VGImage (*pfnVgCreateEGLImageTargetKHR)(VGeglImageKHR); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
57 |
#endif // QT_SYMBIAN_SUPPORTS_SGIMAGE |
0 | 58 |
|
59 |
QT_BEGIN_NAMESPACE |
|
60 |
||
61 |
static int qt_vg_pixmap_serial = 0; |
|
62 |
||
63 |
QVGPixmapData::QVGPixmapData(PixelType type) |
|
64 |
: QPixmapData(type, OpenVGClass) |
|
65 |
{ |
|
66 |
Q_ASSERT(type == QPixmapData::PixmapType); |
|
67 |
vgImage = VG_INVALID_HANDLE; |
|
68 |
vgImageOpacity = VG_INVALID_HANDLE; |
|
69 |
cachedOpacity = 1.0f; |
|
70 |
recreate = true; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
inImagePool = false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
inLRU = false; |
0 | 73 |
#if !defined(QT_NO_EGL) |
74 |
context = 0; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
75 |
qt_vg_register_pixmap(this); |
0 | 76 |
#endif |
77 |
setSerialNumber(++qt_vg_pixmap_serial); |
|
78 |
} |
|
79 |
||
80 |
QVGPixmapData::~QVGPixmapData() |
|
81 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
destroyImageAndContext(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
83 |
#if !defined(QT_NO_EGL) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
84 |
qt_vg_unregister_pixmap(this); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
85 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
87 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
88 |
void QVGPixmapData::destroyImages() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
90 |
if (inImagePool) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
91 |
QVGImagePool *pool = QVGImagePool::instance(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
92 |
if (vgImage != VG_INVALID_HANDLE) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
93 |
pool->releaseImage(this, vgImage); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
94 |
if (vgImageOpacity != VG_INVALID_HANDLE) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
95 |
pool->releaseImage(this, vgImageOpacity); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
96 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
97 |
if (vgImage != VG_INVALID_HANDLE) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
98 |
vgDestroyImage(vgImage); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
99 |
if (vgImageOpacity != VG_INVALID_HANDLE) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
100 |
vgDestroyImage(vgImageOpacity); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
101 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
102 |
vgImage = VG_INVALID_HANDLE; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
103 |
vgImageOpacity = VG_INVALID_HANDLE; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
104 |
inImagePool = false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
105 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
106 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
107 |
void QVGPixmapData::destroyImageAndContext() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
108 |
{ |
0 | 109 |
if (vgImage != VG_INVALID_HANDLE) { |
110 |
// We need to have a context current to destroy the image. |
|
111 |
#if !defined(QT_NO_EGL) |
|
112 |
if (context->isCurrent()) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
destroyImages(); |
0 | 114 |
} else { |
115 |
// We don't currently have a widget surface active, but we |
|
116 |
// need a surface to make the context current. So use the |
|
117 |
// shared pbuffer surface instead. |
|
118 |
context->makeCurrent(qt_vg_shared_surface()); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
119 |
destroyImages(); |
0 | 120 |
context->lazyDoneCurrent(); |
121 |
} |
|
122 |
#else |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
123 |
destroyImages(); |
0 | 124 |
#endif |
125 |
} |
|
126 |
#if !defined(QT_NO_EGL) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
if (context) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
128 |
qt_vg_destroy_context(context, QInternal::Pixmap); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
129 |
context = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
130 |
} |
0 | 131 |
#endif |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
recreate = true; |
0 | 133 |
} |
134 |
||
135 |
QPixmapData *QVGPixmapData::createCompatiblePixmapData() const |
|
136 |
{ |
|
137 |
return new QVGPixmapData(pixelType()); |
|
138 |
} |
|
139 |
||
140 |
bool QVGPixmapData::isValid() const |
|
141 |
{ |
|
142 |
return (w > 0 && h > 0); |
|
143 |
} |
|
144 |
||
145 |
void QVGPixmapData::resize(int wid, int ht) |
|
146 |
{ |
|
147 |
if (w == wid && h == ht) |
|
148 |
return; |
|
149 |
||
150 |
w = wid; |
|
151 |
h = ht; |
|
152 |
d = 32; // We always use ARGB_Premultiplied for VG pixmaps. |
|
153 |
is_null = (w <= 0 || h <= 0); |
|
154 |
source = QImage(); |
|
155 |
recreate = true; |
|
156 |
||
157 |
setSerialNumber(++qt_vg_pixmap_serial); |
|
158 |
} |
|
159 |
||
160 |
void QVGPixmapData::fromImage |
|
161 |
(const QImage &image, Qt::ImageConversionFlags flags) |
|
162 |
{ |
|
163 |
if (image.size() == QSize(w, h)) |
|
164 |
setSerialNumber(++qt_vg_pixmap_serial); |
|
165 |
else |
|
166 |
resize(image.width(), image.height()); |
|
167 |
source = image.convertToFormat(sourceFormat(), flags); |
|
168 |
recreate = true; |
|
169 |
} |
|
170 |
||
171 |
void QVGPixmapData::fill(const QColor &color) |
|
172 |
{ |
|
173 |
if (!isValid()) |
|
174 |
return; |
|
175 |
||
176 |
if (source.isNull()) |
|
177 |
source = QImage(w, h, sourceFormat()); |
|
178 |
||
179 |
if (source.depth() == 1) { |
|
180 |
// Pick the best approximate color in the image's colortable. |
|
181 |
int gray = qGray(color.rgba()); |
|
182 |
if (qAbs(qGray(source.color(0)) - gray) < qAbs(qGray(source.color(1)) - gray)) |
|
183 |
source.fill(0); |
|
184 |
else |
|
185 |
source.fill(1); |
|
186 |
} else { |
|
187 |
source.fill(PREMUL(color.rgba())); |
|
188 |
} |
|
189 |
||
190 |
// Re-upload the image to VG the next time toVGImage() is called. |
|
191 |
recreate = true; |
|
192 |
} |
|
193 |
||
194 |
bool QVGPixmapData::hasAlphaChannel() const |
|
195 |
{ |
|
196 |
if (!source.isNull()) |
|
197 |
return source.hasAlphaChannel(); |
|
198 |
else |
|
199 |
return isValid(); |
|
200 |
} |
|
201 |
||
202 |
void QVGPixmapData::setAlphaChannel(const QPixmap &alphaChannel) |
|
203 |
{ |
|
204 |
forceToImage(); |
|
205 |
source.setAlphaChannel(alphaChannel.toImage()); |
|
206 |
} |
|
207 |
||
208 |
QImage QVGPixmapData::toImage() const |
|
209 |
{ |
|
210 |
if (!isValid()) |
|
211 |
return QImage(); |
|
212 |
||
213 |
if (source.isNull()) { |
|
214 |
source = QImage(w, h, sourceFormat()); |
|
215 |
recreate = true; |
|
216 |
} |
|
217 |
||
218 |
return source; |
|
219 |
} |
|
220 |
||
221 |
QImage *QVGPixmapData::buffer() |
|
222 |
{ |
|
223 |
forceToImage(); |
|
224 |
return &source; |
|
225 |
} |
|
226 |
||
227 |
QPaintEngine* QVGPixmapData::paintEngine() const |
|
228 |
{ |
|
229 |
// If the application wants to paint into the QPixmap, we first |
|
230 |
// force it to QImage format and then paint into that. |
|
231 |
// This is simpler than juggling multiple VG contexts. |
|
232 |
const_cast<QVGPixmapData *>(this)->forceToImage(); |
|
233 |
return source.paintEngine(); |
|
234 |
} |
|
235 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
236 |
// This function works around QImage::bits() making a deep copy if the |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
237 |
// QImage is not const. We force it to be const and then get the bits. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
238 |
// XXX: Should add a QImage::constBits() in the future to replace this. |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
239 |
const uchar *qt_vg_imageBits(const QImage& image) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
240 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
241 |
return image.bits(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
242 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
243 |
|
0 | 244 |
VGImage QVGPixmapData::toVGImage() |
245 |
{ |
|
246 |
if (!isValid()) |
|
247 |
return VG_INVALID_HANDLE; |
|
248 |
||
249 |
#if !defined(QT_NO_EGL) |
|
250 |
// Increase the reference count on the shared context. |
|
251 |
if (!context) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
252 |
context = qt_vg_create_context(0, QInternal::Pixmap); |
0 | 253 |
#endif |
254 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
255 |
if (recreate && prevSize != QSize(w, h)) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
256 |
destroyImages(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
257 |
else if (recreate) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
258 |
cachedOpacity = -1.0f; // Force opacity image to be refreshed later. |
0 | 259 |
|
260 |
if (vgImage == VG_INVALID_HANDLE) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
261 |
vgImage = QVGImagePool::instance()->createImageForPixmap |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
262 |
(VG_sARGB_8888_PRE, w, h, VG_IMAGE_QUALITY_FASTER, this); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
263 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
264 |
// Bail out if we run out of GPU memory - try again next time. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
265 |
if (vgImage == VG_INVALID_HANDLE) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
266 |
return VG_INVALID_HANDLE; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
267 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
268 |
inImagePool = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
269 |
} else if (inImagePool) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
270 |
QVGImagePool::instance()->useImage(this); |
0 | 271 |
} |
272 |
||
273 |
if (!source.isNull() && recreate) { |
|
274 |
vgImageSubData |
|
275 |
(vgImage, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
276 |
qt_vg_imageBits(source), source.bytesPerLine(), |
0 | 277 |
VG_sARGB_8888_PRE, 0, 0, w, h); |
278 |
} |
|
279 |
||
280 |
recreate = false; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
281 |
prevSize = QSize(w, h); |
0 | 282 |
|
283 |
return vgImage; |
|
284 |
} |
|
285 |
||
286 |
VGImage QVGPixmapData::toVGImage(qreal opacity) |
|
287 |
{ |
|
288 |
#if !defined(QT_SHIVAVG) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
289 |
// Force the primary VG image to be recreated if necessary. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
290 |
if (toVGImage() == VG_INVALID_HANDLE) |
0 | 291 |
return VG_INVALID_HANDLE; |
292 |
||
293 |
if (opacity == 1.0f) |
|
294 |
return vgImage; |
|
295 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
296 |
// Create an alternative image for the selected opacity. |
0 | 297 |
if (vgImageOpacity == VG_INVALID_HANDLE || cachedOpacity != opacity) { |
298 |
if (vgImageOpacity == VG_INVALID_HANDLE) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
299 |
if (inImagePool) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
300 |
vgImageOpacity = QVGImagePool::instance()->createImageForPixmap |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
301 |
(VG_sARGB_8888_PRE, w, h, VG_IMAGE_QUALITY_FASTER, this); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
302 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
303 |
vgImageOpacity = vgCreateImage |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
304 |
(VG_sARGB_8888_PRE, w, h, VG_IMAGE_QUALITY_FASTER); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
305 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
306 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
307 |
// Bail out if we run out of GPU memory - try again next time. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
308 |
if (vgImageOpacity == VG_INVALID_HANDLE) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
309 |
return VG_INVALID_HANDLE; |
0 | 310 |
} |
311 |
VGfloat matrix[20] = { |
|
312 |
1.0f, 0.0f, 0.0f, 0.0f, |
|
313 |
0.0f, 1.0f, 0.0f, 0.0f, |
|
314 |
0.0f, 0.0f, 1.0f, 0.0f, |
|
315 |
0.0f, 0.0f, 0.0f, opacity, |
|
316 |
0.0f, 0.0f, 0.0f, 0.0f |
|
317 |
}; |
|
318 |
vgColorMatrix(vgImageOpacity, vgImage, matrix); |
|
319 |
cachedOpacity = opacity; |
|
320 |
} |
|
321 |
||
322 |
return vgImageOpacity; |
|
323 |
#else |
|
324 |
// vgColorMatrix() doesn't work with ShivaVG, so ignore the opacity. |
|
325 |
Q_UNUSED(opacity); |
|
326 |
return toVGImage(); |
|
327 |
#endif |
|
328 |
} |
|
329 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
330 |
void QVGPixmapData::detachImageFromPool() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
331 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
332 |
if (inImagePool) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
333 |
QVGImagePool::instance()->detachImage(this); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
334 |
inImagePool = false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
335 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
336 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
337 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
338 |
void QVGPixmapData::hibernate() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
339 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
340 |
// If the image was imported (e.g, from an SgImage under Symbian), |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
341 |
// then we cannot copy it back to main memory for storage. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
342 |
if (vgImage != VG_INVALID_HANDLE && source.isNull()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
343 |
return; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
344 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
345 |
forceToImage(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
346 |
destroyImageAndContext(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
347 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
348 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
349 |
void QVGPixmapData::reclaimImages() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
350 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
351 |
if (!inImagePool) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
352 |
return; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
353 |
forceToImage(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
354 |
destroyImages(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
355 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
356 |
|
0 | 357 |
extern int qt_defaultDpiX(); |
358 |
extern int qt_defaultDpiY(); |
|
359 |
||
360 |
int QVGPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const |
|
361 |
{ |
|
362 |
switch (metric) { |
|
363 |
case QPaintDevice::PdmWidth: |
|
364 |
return w; |
|
365 |
case QPaintDevice::PdmHeight: |
|
366 |
return h; |
|
367 |
case QPaintDevice::PdmNumColors: |
|
368 |
return 0; |
|
369 |
case QPaintDevice::PdmDepth: |
|
370 |
return d; |
|
371 |
case QPaintDevice::PdmWidthMM: |
|
372 |
return qRound(w * 25.4 / qt_defaultDpiX()); |
|
373 |
case QPaintDevice::PdmHeightMM: |
|
374 |
return qRound(h * 25.4 / qt_defaultDpiY()); |
|
375 |
case QPaintDevice::PdmDpiX: |
|
376 |
case QPaintDevice::PdmPhysicalDpiX: |
|
377 |
return qt_defaultDpiX(); |
|
378 |
case QPaintDevice::PdmDpiY: |
|
379 |
case QPaintDevice::PdmPhysicalDpiY: |
|
380 |
return qt_defaultDpiY(); |
|
381 |
default: |
|
382 |
qWarning("QVGPixmapData::metric(): Invalid metric"); |
|
383 |
return 0; |
|
384 |
} |
|
385 |
} |
|
386 |
||
387 |
// Force the pixmap data to be in QImage format. |
|
388 |
void QVGPixmapData::forceToImage() |
|
389 |
{ |
|
390 |
if (!isValid()) |
|
391 |
return; |
|
392 |
||
393 |
if (source.isNull()) |
|
394 |
source = QImage(w, h, sourceFormat()); |
|
395 |
||
396 |
recreate = true; |
|
397 |
} |
|
398 |
||
399 |
QImage::Format QVGPixmapData::sourceFormat() const |
|
400 |
{ |
|
401 |
return QImage::Format_ARGB32_Premultiplied; |
|
402 |
} |
|
403 |
||
404 |
/* |
|
405 |
\internal |
|
406 |
||
407 |
Returns the VGImage that is storing the contents of \a pixmap. |
|
408 |
Returns VG_INVALID_HANDLE if \a pixmap is not owned by the OpenVG |
|
409 |
graphics system or \a pixmap is invalid. |
|
410 |
||
411 |
This function is typically used to access the backing store |
|
412 |
for a pixmap when executing raw OpenVG calls. It must only |
|
413 |
be used when a QPainter is active and the OpenVG paint engine |
|
414 |
is in use by the QPainter. |
|
415 |
||
416 |
\sa {QtOpenVG Module} |
|
417 |
*/ |
|
418 |
Q_OPENVG_EXPORT VGImage qPixmapToVGImage(const QPixmap& pixmap) |
|
419 |
{ |
|
420 |
QPixmapData *pd = pixmap.pixmapData(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
421 |
if (!pd) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
422 |
return VG_INVALID_HANDLE; // null QPixmap |
0 | 423 |
if (pd->classId() == QPixmapData::OpenVGClass) { |
424 |
QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd); |
|
425 |
if (vgpd->isValid()) |
|
426 |
return vgpd->toVGImage(); |
|
427 |
} |
|
428 |
return VG_INVALID_HANDLE; |
|
429 |
} |
|
430 |
||
431 |
#if defined(Q_OS_SYMBIAN) |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
432 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
433 |
static CFbsBitmap* createBlitCopy(CFbsBitmap* bitmap) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
434 |
{ |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
435 |
CFbsBitmap *copy = q_check_ptr(new CFbsBitmap); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
436 |
if(!copy) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
437 |
return 0; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
438 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
439 |
if (copy->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()) != KErrNone) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
440 |
delete copy; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
441 |
copy = 0; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
442 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
443 |
return 0; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
444 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
445 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
446 |
CFbsBitmapDevice* bitmapDevice = 0; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
447 |
CFbsBitGc *bitmapGc = 0; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
448 |
QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(copy)); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
449 |
QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL()); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
450 |
bitmapGc->Activate(bitmapDevice); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
451 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
452 |
bitmapGc->BitBlt(TPoint(), bitmap); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
453 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
454 |
delete bitmapGc; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
455 |
delete bitmapDevice; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
456 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
457 |
return copy; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
458 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
459 |
|
0 | 460 |
void QVGPixmapData::cleanup() |
461 |
{ |
|
462 |
is_null = w = h = 0; |
|
463 |
recreate = false; |
|
464 |
source = QImage(); |
|
465 |
} |
|
466 |
||
467 |
void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) |
|
468 |
{ |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
469 |
if (type == QPixmapData::SgImage && pixmap) { |
0 | 470 |
#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL) |
471 |
RSgImage *sgImage = reinterpret_cast<RSgImage*>(pixmap); |
|
472 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
473 |
destroyImages(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
474 |
prevSize = QSize(); |
0 | 475 |
|
476 |
TInt err = 0; |
|
477 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
478 |
RSgDriver driver; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
479 |
err = driver.Open(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
480 |
if (err != KErrNone) { |
0 | 481 |
cleanup(); |
482 |
return; |
|
483 |
} |
|
484 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
485 |
if (sgImage->IsNull()) { |
0 | 486 |
cleanup(); |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
487 |
driver.Close(); |
0 | 488 |
return; |
489 |
} |
|
490 |
||
491 |
TSgImageInfo sgImageInfo; |
|
492 |
err = sgImage->GetInfo(sgImageInfo); |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
493 |
if (err != KErrNone) { |
0 | 494 |
cleanup(); |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
495 |
driver.Close(); |
0 | 496 |
return; |
497 |
} |
|
498 |
||
499 |
pfnEglCreateImageKHR eglCreateImageKHR = (pfnEglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR"); |
|
500 |
pfnEglDestroyImageKHR eglDestroyImageKHR = (pfnEglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR"); |
|
501 |
pfnVgCreateEGLImageTargetKHR vgCreateEGLImageTargetKHR = (pfnVgCreateEGLImageTargetKHR) eglGetProcAddress("vgCreateEGLImageTargetKHR"); |
|
502 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
503 |
if (eglGetError() != EGL_SUCCESS || !eglCreateImageKHR || !eglDestroyImageKHR || !vgCreateEGLImageTargetKHR) { |
0 | 504 |
cleanup(); |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
505 |
driver.Close(); |
0 | 506 |
return; |
507 |
} |
|
508 |
||
509 |
const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE}; |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
510 |
EGLImageKHR eglImage = eglCreateImageKHR(QEglContext::display(), |
0 | 511 |
EGL_NO_CONTEXT, |
512 |
EGL_NATIVE_PIXMAP_KHR, |
|
513 |
(EGLClientBuffer)sgImage, |
|
514 |
(EGLint*)KEglImageAttribs); |
|
515 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
516 |
if (eglGetError() != EGL_SUCCESS) { |
0 | 517 |
cleanup(); |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
518 |
driver.Close(); |
0 | 519 |
return; |
520 |
} |
|
521 |
||
522 |
vgImage = vgCreateEGLImageTargetKHR(eglImage); |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
523 |
if (vgGetError() != VG_NO_ERROR) { |
0 | 524 |
cleanup(); |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
525 |
eglDestroyImageKHR(QEglContext::display(), eglImage); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
526 |
driver.Close(); |
0 | 527 |
return; |
528 |
} |
|
529 |
||
530 |
w = sgImageInfo.iSizeInPixels.iWidth; |
|
531 |
h = sgImageInfo.iSizeInPixels.iHeight; |
|
532 |
d = 32; // We always use ARGB_Premultiplied for VG pixmaps. |
|
533 |
is_null = (w <= 0 || h <= 0); |
|
534 |
source = QImage(); |
|
535 |
recreate = false; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
536 |
prevSize = QSize(w, h); |
0 | 537 |
setSerialNumber(++qt_vg_pixmap_serial); |
538 |
// release stuff |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
539 |
eglDestroyImageKHR(QEglContext::display(), eglImage); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
540 |
driver.Close(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
541 |
#endif |
0 | 542 |
} else if (type == QPixmapData::FbsBitmap) { |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
543 |
CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap*>(pixmap); |
0 | 544 |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
545 |
bool deleteSourceBitmap = false; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
546 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
547 |
#ifdef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
548 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
549 |
// Rasterize extended bitmaps |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
550 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
551 |
TUid extendedBitmapType = bitmap->ExtendedBitmapType(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
552 |
if (extendedBitmapType != KNullUid) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
553 |
bitmap = createBlitCopy(bitmap); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
554 |
deleteSourceBitmap = true; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
555 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
556 |
#endif |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
557 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
558 |
if (bitmap->IsCompressedInRAM()) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
559 |
bitmap = createBlitCopy(bitmap); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
560 |
deleteSourceBitmap = true; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
561 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
562 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
563 |
TDisplayMode displayMode = bitmap->DisplayMode(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
564 |
QImage::Format format = qt_TDisplayMode2Format(displayMode); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
565 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
566 |
TSize size = bitmap->SizeInPixels(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
567 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
568 |
bitmap->BeginDataAccess(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
569 |
uchar *bytes = (uchar*)bitmap->DataAddress(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
570 |
QImage img = QImage(bytes, size.iWidth, size.iHeight, format); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
571 |
img = img.copy(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
572 |
bitmap->EndDataAccess(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
573 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
574 |
if(displayMode == EGray2) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
575 |
//Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
576 |
//So invert mono bitmaps so that masks work correctly. |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
577 |
img.invertPixels(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
578 |
} else if(displayMode == EColor16M) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
579 |
img = img.rgbSwapped(); // EColor16M is BGR |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
580 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
581 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
582 |
fromImage(img, Qt::AutoColor); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
583 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
584 |
if(deleteSourceBitmap) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
585 |
delete bitmap; |
0 | 586 |
} |
587 |
} |
|
588 |
||
589 |
void* QVGPixmapData::toNativeType(NativeType type) |
|
590 |
{ |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
591 |
if (type == QPixmapData::SgImage) { |
0 | 592 |
#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL) |
593 |
toVGImage(); |
|
594 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
595 |
if (!isValid() || vgImage == VG_INVALID_HANDLE) |
0 | 596 |
return 0; |
597 |
||
598 |
TInt err = 0; |
|
599 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
600 |
RSgDriver driver; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
601 |
err = driver.Open(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
602 |
if (err != KErrNone) |
0 | 603 |
return 0; |
604 |
||
605 |
TSgImageInfo sgInfo; |
|
606 |
sgInfo.iPixelFormat = EUidPixelFormatARGB_8888_PRE; |
|
607 |
sgInfo.iSizeInPixels.SetSize(w, h); |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
608 |
sgInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface; |
0 | 609 |
|
610 |
RSgImage *sgImage = q_check_ptr(new RSgImage()); |
|
611 |
err = sgImage->Create(sgInfo, NULL, NULL); |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
612 |
if (err != KErrNone) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
613 |
driver.Close(); |
0 | 614 |
return 0; |
615 |
} |
|
616 |
||
617 |
pfnEglCreateImageKHR eglCreateImageKHR = (pfnEglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR"); |
|
618 |
pfnEglDestroyImageKHR eglDestroyImageKHR = (pfnEglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR"); |
|
619 |
pfnVgCreateEGLImageTargetKHR vgCreateEGLImageTargetKHR = (pfnVgCreateEGLImageTargetKHR) eglGetProcAddress("vgCreateEGLImageTargetKHR"); |
|
620 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
621 |
if (eglGetError() != EGL_SUCCESS || !eglCreateImageKHR || !eglDestroyImageKHR || !vgCreateEGLImageTargetKHR) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
622 |
driver.Close(); |
0 | 623 |
return 0; |
624 |
} |
|
625 |
||
626 |
const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE}; |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
627 |
EGLImageKHR eglImage = eglCreateImageKHR(QEglContext::display(), |
0 | 628 |
EGL_NO_CONTEXT, |
629 |
EGL_NATIVE_PIXMAP_KHR, |
|
630 |
(EGLClientBuffer)sgImage, |
|
631 |
(EGLint*)KEglImageAttribs); |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
632 |
if (eglGetError() != EGL_SUCCESS) { |
0 | 633 |
sgImage->Close(); |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
634 |
driver.Close(); |
0 | 635 |
return 0; |
636 |
} |
|
637 |
||
638 |
VGImage dstVgImage = vgCreateEGLImageTargetKHR(eglImage); |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
639 |
if (vgGetError() != VG_NO_ERROR) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
640 |
eglDestroyImageKHR(QEglContext::display(), eglImage); |
0 | 641 |
sgImage->Close(); |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
642 |
driver.Close(); |
0 | 643 |
return 0; |
644 |
} |
|
645 |
||
646 |
vgCopyImage(dstVgImage, 0, 0, |
|
647 |
vgImage, 0, 0, |
|
648 |
w, h, VG_FALSE); |
|
649 |
||
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
650 |
if (vgGetError() != VG_NO_ERROR) { |
0 | 651 |
sgImage->Close(); |
652 |
sgImage = 0; |
|
653 |
} |
|
654 |
// release stuff |
|
655 |
vgDestroyImage(dstVgImage); |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
656 |
eglDestroyImageKHR(QEglContext::display(), eglImage); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
657 |
driver.Close(); |
0 | 658 |
return reinterpret_cast<void*>(sgImage); |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
659 |
#endif |
0 | 660 |
} else if (type == QPixmapData::FbsBitmap) { |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
661 |
CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
662 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
663 |
if (bitmap) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
664 |
if (bitmap->Create(TSize(source.width(), source.height()), |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
665 |
EColor16MAP) == KErrNone) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
666 |
const uchar *sptr = qt_vg_imageBits(source); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
667 |
bitmap->BeginDataAccess(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
668 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
669 |
uchar *dptr = (uchar*)bitmap->DataAddress(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
670 |
Mem::Copy(dptr, sptr, source.byteCount()); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
671 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
672 |
bitmap->EndDataAccess(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
673 |
} else { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
674 |
delete bitmap; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
675 |
bitmap = 0; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
676 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
677 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
678 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
679 |
return reinterpret_cast<void*>(bitmap); |
0 | 680 |
} |
681 |
return 0; |
|
682 |
} |
|
683 |
#endif //Q_OS_SYMBIAN |
|
684 |
||
685 |
QT_END_NAMESPACE |