|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 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 QtGui 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_P_H |
|
43 #define QPIXMAPDATA_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 <QtGui/qpixmap.h> |
|
57 #include <QtCore/qatomic.h> |
|
58 |
|
59 QT_BEGIN_NAMESPACE |
|
60 |
|
61 class Q_GUI_EXPORT QPixmapData |
|
62 { |
|
63 public: |
|
64 enum PixelType { |
|
65 // WARNING: Do not change the first two |
|
66 // Must match QPixmap::Type |
|
67 PixmapType, BitmapType |
|
68 }; |
|
69 #if defined(Q_OS_SYMBIAN) |
|
70 enum NativeType { |
|
71 FbsBitmap, |
|
72 SgImage |
|
73 }; |
|
74 #endif |
|
75 enum ClassId { RasterClass, X11Class, MacClass, DirectFBClass, |
|
76 OpenGLClass, OpenVGClass, CustomClass = 1024 }; |
|
77 |
|
78 QPixmapData(PixelType pixelType, int classId); |
|
79 virtual ~QPixmapData(); |
|
80 |
|
81 virtual QPixmapData *createCompatiblePixmapData() const; |
|
82 |
|
83 virtual void resize(int width, int height) = 0; |
|
84 virtual void fromImage(const QImage &image, |
|
85 Qt::ImageConversionFlags flags) = 0; |
|
86 |
|
87 virtual bool fromFile(const QString &filename, const char *format, |
|
88 Qt::ImageConversionFlags flags); |
|
89 virtual bool fromData(const uchar *buffer, uint len, const char *format, |
|
90 Qt::ImageConversionFlags flags); |
|
91 |
|
92 virtual void copy(const QPixmapData *data, const QRect &rect); |
|
93 virtual bool scroll(int dx, int dy, const QRect &rect); |
|
94 |
|
95 virtual int metric(QPaintDevice::PaintDeviceMetric metric) const = 0; |
|
96 virtual void fill(const QColor &color) = 0; |
|
97 virtual QBitmap mask() const; |
|
98 virtual void setMask(const QBitmap &mask); |
|
99 virtual bool hasAlphaChannel() const = 0; |
|
100 virtual QPixmap transformed(const QTransform &matrix, |
|
101 Qt::TransformationMode mode) const; |
|
102 virtual void setAlphaChannel(const QPixmap &alphaChannel); |
|
103 virtual QPixmap alphaChannel() const; |
|
104 virtual QImage toImage() const = 0; |
|
105 virtual QPaintEngine* paintEngine() const = 0; |
|
106 |
|
107 inline int serialNumber() const { return ser_no; } |
|
108 |
|
109 inline PixelType pixelType() const { return type; } |
|
110 inline ClassId classId() const { return static_cast<ClassId>(id); } |
|
111 |
|
112 virtual QImage* buffer(); |
|
113 |
|
114 inline int width() const { return w; } |
|
115 inline int height() const { return h; } |
|
116 inline int numColors() const { return metric(QPaintDevice::PdmNumColors); } |
|
117 inline int depth() const { return d; } |
|
118 inline bool isNull() const { return is_null; } |
|
119 |
|
120 #if defined(Q_OS_SYMBIAN) |
|
121 virtual void* toNativeType(NativeType type); |
|
122 virtual void fromNativeType(void* pixmap, NativeType type); |
|
123 #endif |
|
124 |
|
125 protected: |
|
126 void setSerialNumber(int serNo); |
|
127 int w; |
|
128 int h; |
|
129 int d; |
|
130 bool is_null; |
|
131 |
|
132 private: |
|
133 friend class QPixmap; |
|
134 friend class QGLContextPrivate; |
|
135 friend class QX11PixmapData; |
|
136 friend class QS60PixmapData; |
|
137 friend class QGLTextureCache; //Needs to check the reference count |
|
138 friend class QExplicitlySharedDataPointer<QPixmapData>; |
|
139 friend bool qt_createEGLSurfaceForPixmap(QPixmapData*, bool); // Needs to set is_cached |
|
140 |
|
141 QAtomicInt ref; |
|
142 int detach_no; |
|
143 |
|
144 PixelType type; |
|
145 int id; |
|
146 int ser_no; |
|
147 uint is_cached; |
|
148 }; |
|
149 |
|
150 # define QT_XFORM_TYPE_MSBFIRST 0 |
|
151 # define QT_XFORM_TYPE_LSBFIRST 1 |
|
152 # if defined(Q_WS_WIN) |
|
153 # define QT_XFORM_TYPE_WINDOWSPIXMAP 2 |
|
154 # endif |
|
155 extern bool qt_xForm_helper(const QTransform&, int, int, int, uchar*, int, int, int, const uchar*, int, int, int); |
|
156 |
|
157 QT_END_NAMESPACE |
|
158 |
|
159 #endif // QPIXMAPDATA_P_H |