1/****************************************************************************
2**
3** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
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#ifdef Q_OS_SYMBIAN
60#include <QtGui/private/qvolatileimage_p.h>
61#endif
62
63QT_BEGIN_NAMESPACE
64
65class QImageReader;
66
67class Q_GUI_EXPORT QPixmapData
68{
69public:
70 enum PixelType {
71 // WARNING: Do not change the first two
72 // Must match QPixmap::Type
73 PixmapType, BitmapType
74 };
75#if defined(Q_OS_SYMBIAN)
76 enum NativeType {
77 FbsBitmap,
78 SgImage,
79 VolatileImage,
80 NativeImageHandleProvider
81 };
82#endif
83 enum ClassId { RasterClass, X11Class, MacClass, DirectFBClass,
84 OpenGLClass, OpenVGClass, RuntimeClass, BlitterClass,
85 CustomClass = 1024 };
86
87 QPixmapData(PixelType pixelType, int classId);
88 virtual ~QPixmapData();
89
90 virtual QPixmapData *createCompatiblePixmapData() const;
91
92 virtual void resize(int width, int height) = 0;
93 virtual void fromImage(const QImage &image,
94 Qt::ImageConversionFlags flags) = 0;
95 virtual void fromImageReader(QImageReader *imageReader,
96 Qt::ImageConversionFlags flags);
97
98 virtual bool fromFile(const QString &filename, const char *format,
99 Qt::ImageConversionFlags flags);
100 virtual bool fromData(const uchar *buffer, uint len, const char *format,
101 Qt::ImageConversionFlags flags);
102
103 virtual void copy(const QPixmapData *data, const QRect &rect);
104 virtual bool scroll(int dx, int dy, const QRect &rect);
105
106 virtual int metric(QPaintDevice::PaintDeviceMetric metric) const = 0;
107 virtual void fill(const QColor &color) = 0;
108 virtual QBitmap mask() const;
109 virtual void setMask(const QBitmap &mask);
110 virtual bool hasAlphaChannel() const = 0;
111 virtual QPixmap transformed(const QTransform &matrix,
112 Qt::TransformationMode mode) const;
113 virtual void setAlphaChannel(const QPixmap &alphaChannel);
114 virtual QPixmap alphaChannel() const;
115 virtual QImage toImage() const = 0;
116 virtual QImage toImage(const QRect &rect) const;
117 virtual QPaintEngine* paintEngine() const = 0;
118
119 inline int serialNumber() const { return ser_no; }
120
121 inline PixelType pixelType() const { return type; }
122 inline ClassId classId() const { return static_cast<ClassId>(id); }
123
124 virtual QImage* buffer();
125
126 inline int width() const { return w; }
127 inline int height() const { return h; }
128 QT_DEPRECATED inline int numColors() const { return metric(QPaintDevice::PdmNumColors); }
129 inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); }
130 inline int depth() const { return d; }
131 inline bool isNull() const { return is_null; }
132 inline qint64 cacheKey() const {
133 int classKey = id;
134 if (classKey >= 1024)
135 classKey = -(classKey >> 10);
136 return ((((qint64) classKey) << 56)
137 | (((qint64) ser_no) << 32)
138 | ((qint64) detach_no));
139 }
140
141#if defined(Q_OS_SYMBIAN)
142 virtual QVolatileImage toVolatileImage() const;
143 virtual void* toNativeType(NativeType type);
144 virtual void fromNativeType(void* pixmap, NativeType type);
145#endif
146
147 static QPixmapData *create(int w, int h, PixelType type);
148
149 virtual QPixmapData *runtimeData() const { return 0; }
150
151protected:
152
153 void setSerialNumber(int serNo);
154 int w;
155 int h;
156 int d;
157 bool is_null;
158
159private:
160 friend class QPixmap;
161 friend class QX11PixmapData;
162 friend class QSymbianRasterPixmapData;
163 friend class QImagePixmapCleanupHooks; // Needs to set is_cached
164 friend class QGLTextureCache; //Needs to check the reference count
165 friend class QExplicitlySharedDataPointer<QPixmapData>;
166
167 QAtomicInt ref;
168 int detach_no;
169
170 PixelType type;
171 int id;
172 int ser_no;
173 uint is_cached;
174};
175
176# define QT_XFORM_TYPE_MSBFIRST 0
177# define QT_XFORM_TYPE_LSBFIRST 1
178# if defined(Q_WS_WIN)
179# define QT_XFORM_TYPE_WINDOWSPIXMAP 2
180# endif
181extern bool qt_xForm_helper(const QTransform&, int, int, int, uchar*, int, int, int, const uchar*, int, int, int);
182
183QT_END_NAMESPACE
184
185#endif // QPIXMAPDATA_P_H
186