| 1 |
/**************************************************************************** |
| 2 |
** |
| 3 |
** Copyright (C) 2011 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 |
QT_DEPRECATED inline int numColors() const { return metric(QPaintDevice::PdmNumColors); } |
| 117 |
inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); } |
| 118 |
inline int depth() const { return d; } |
| 119 |
inline bool isNull() const { return is_null; } |
| 120 |
inline qint64 cacheKey() const { |
| 121 |
int classKey = id; |
| 122 |
if (classKey >= 1024) |
| 123 |
classKey = -(classKey >> 10); |
| 124 |
return ((((qint64) classKey) << 56) |
| 125 |
| (((qint64) ser_no) << 32) |
| 126 |
| ((qint64) detach_no)); |
| 127 |
} |
| 128 |
|
| 129 |
#if defined(Q_OS_SYMBIAN) |
| 130 |
virtual void* toNativeType(NativeType type); |
| 131 |
virtual void fromNativeType(void* pixmap, NativeType type); |
| 132 |
#endif |
| 133 |
|
| 134 |
static QPixmapData *create(int w, int h, PixelType type); |
| 135 |
|
| 136 |
protected: |
| 137 |
void setSerialNumber(int serNo); |
| 138 |
int w; |
| 139 |
int h; |
| 140 |
int d; |
| 141 |
bool is_null; |
| 142 |
|
| 143 |
private: |
| 144 |
friend class QPixmap; |
| 145 |
friend class QX11PixmapData; |
| 146 |
friend class QS60PixmapData; |
| 147 |
friend class QImagePixmapCleanupHooks; // Needs to set is_cached |
| 148 |
friend class QGLTextureCache; //Needs to check the reference count |
| 149 |
friend class QExplicitlySharedDataPointer<QPixmapData>; |
| 150 |
|
| 151 |
QAtomicInt ref; |
| 152 |
int detach_no; |
| 153 |
|
| 154 |
PixelType type; |
| 155 |
int id; |
| 156 |
int ser_no; |
| 157 |
uint is_cached; |
| 158 |
}; |
| 159 |
|
| 160 |
# define QT_XFORM_TYPE_MSBFIRST 0 |
| 161 |
# define QT_XFORM_TYPE_LSBFIRST 1 |
| 162 |
# if defined(Q_WS_WIN) |
| 163 |
# define QT_XFORM_TYPE_WINDOWSPIXMAP 2 |
| 164 |
# endif |
| 165 |
extern bool qt_xForm_helper(const QTransform&, int, int, int, uchar*, int, int, int, const uchar*, int, int, int); |
| 166 |
|
| 167 |
QT_END_NAMESPACE |
| 168 |
|
| 169 |
#endif // QPIXMAPDATA_P_H |