0
|
1 |
/****************************************************************************
|
|
2 |
**
|
4
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
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 |
#ifndef QPIXMAPDATA_VG_P_H
|
|
43 |
#define QPIXMAPDATA_VG_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 <QtGui/private/qpixmap_raster_p.h>
|
|
57 |
#include <private/qvg_p.h>
|
|
58 |
|
|
59 |
#if defined(Q_OS_SYMBIAN)
|
|
60 |
class RSGImage;
|
|
61 |
#endif
|
|
62 |
|
|
63 |
QT_BEGIN_NAMESPACE
|
|
64 |
|
|
65 |
class QEglContext;
|
3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
66 |
class QVGImagePool;
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
67 |
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
68 |
#if !defined(QT_NO_EGL)
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
69 |
class QVGPixmapData;
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
70 |
class QVGSharedContext;
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
71 |
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
72 |
void qt_vg_register_pixmap(QVGPixmapData *pd);
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
73 |
void qt_vg_unregister_pixmap(QVGPixmapData *pd);
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
74 |
void qt_vg_hibernate_pixmaps(QVGSharedContext *context);
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
75 |
#endif
|
0
|
76 |
|
|
77 |
class Q_OPENVG_EXPORT QVGPixmapData : public QPixmapData
|
|
78 |
{
|
|
79 |
public:
|
|
80 |
QVGPixmapData(PixelType type);
|
|
81 |
~QVGPixmapData();
|
|
82 |
|
|
83 |
QPixmapData *createCompatiblePixmapData() const;
|
|
84 |
|
|
85 |
// Is this pixmap valid (i.e. non-zero in size)?
|
|
86 |
bool isValid() const;
|
|
87 |
|
|
88 |
void resize(int width, int height);
|
|
89 |
void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
|
|
90 |
|
|
91 |
void fill(const QColor &color);
|
|
92 |
bool hasAlphaChannel() const;
|
|
93 |
void setAlphaChannel(const QPixmap &alphaChannel);
|
|
94 |
QImage toImage() const;
|
|
95 |
QImage *buffer();
|
|
96 |
QPaintEngine* paintEngine() const;
|
|
97 |
|
|
98 |
// Return the VGImage form of this pixmap, creating it if necessary.
|
|
99 |
// This assumes that there is a VG context current.
|
3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
100 |
virtual VGImage toVGImage();
|
0
|
101 |
|
|
102 |
// Return the VGImage form for a specific opacity setting.
|
3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
103 |
virtual VGImage toVGImage(qreal opacity);
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
104 |
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
105 |
// Detach this image from the image pool.
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
106 |
virtual void detachImageFromPool();
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
107 |
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
108 |
// Release the VG resources associated with this pixmap and copy
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
109 |
// the pixmap's contents out of the GPU back into main memory.
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
110 |
// The VG resource will be automatically recreated the next time
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
111 |
// toVGImage() is called. Does nothing if the pixmap cannot be
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
112 |
// hibernated for some reason (e.g. VGImage is shared with another
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
113 |
// process via a SgImage).
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
114 |
virtual void hibernate();
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
115 |
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
116 |
// Called when the QVGImagePool wants to reclaim this pixmap's
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
117 |
// VGImage objects to reuse storage.
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
118 |
virtual void reclaimImages();
|
0
|
119 |
|
|
120 |
QSize size() const { return QSize(w, h); }
|
|
121 |
|
|
122 |
#if defined(Q_OS_SYMBIAN)
|
|
123 |
void* toNativeType(NativeType type);
|
|
124 |
void fromNativeType(void* pixmap, NativeType type);
|
|
125 |
#endif
|
|
126 |
|
|
127 |
protected:
|
|
128 |
int metric(QPaintDevice::PaintDeviceMetric metric) const;
|
|
129 |
|
|
130 |
#if defined(Q_OS_SYMBIAN)
|
|
131 |
void cleanup();
|
|
132 |
#endif
|
|
133 |
|
|
134 |
private:
|
3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
135 |
QVGPixmapData *nextLRU;
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
136 |
QVGPixmapData *prevLRU;
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
137 |
bool inLRU;
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
138 |
friend class QVGImagePool;
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
139 |
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
140 |
#if !defined(QT_NO_EGL)
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
141 |
QVGPixmapData *next;
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
142 |
QVGPixmapData *prev;
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
143 |
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
144 |
friend void qt_vg_register_pixmap(QVGPixmapData *pd);
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
145 |
friend void qt_vg_unregister_pixmap(QVGPixmapData *pd);
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
146 |
friend void qt_vg_hibernate_pixmaps(QVGSharedContext *context);
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
147 |
#endif
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
148 |
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
149 |
protected:
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
150 |
QSize prevSize;
|
0
|
151 |
VGImage vgImage;
|
|
152 |
VGImage vgImageOpacity;
|
|
153 |
qreal cachedOpacity;
|
|
154 |
mutable QImage source;
|
|
155 |
mutable bool recreate;
|
3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
156 |
bool inImagePool;
|
0
|
157 |
#if !defined(QT_NO_EGL)
|
|
158 |
mutable QEglContext *context;
|
|
159 |
#endif
|
|
160 |
|
|
161 |
void forceToImage();
|
|
162 |
QImage::Format sourceFormat() const;
|
3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
163 |
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
164 |
void destroyImageAndContext();
|
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
|
165 |
void destroyImages();
|
0
|
166 |
};
|
|
167 |
|
|
168 |
QT_END_NAMESPACE
|
|
169 |
|
|
170 |
#endif
|