Qt 4.8
qpixmapdata_p.h
Go to the documentation of this file.
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 
64 
65 class QImageReader;
66 
68 {
69 public:
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 
151 protected:
152 
153  void setSerialNumber(int serNo);
154  int w;
155  int h;
156  int d;
157  bool is_null;
158 
159 private:
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
166 
169 
171  int id;
172  int ser_no;
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
181 extern bool qt_xForm_helper(const QTransform&, int, int, int, uchar*, int, int, int, const uchar*, int, int, int);
182 
184 
185 #endif // QPIXMAPDATA_P_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual QPixmapData * runtimeData() const
The QAtomicInt class provides platform-independent atomic operations on integers. ...
Definition: qatomic.h:55
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
int width() const
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
The QString class provides a Unicode character string.
Definition: qstring.h:83
PixelType pixelType() const
unsigned char uchar
Definition: qglobal.h:994
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
int serialNumber() const
TransformationMode
Definition: qnamespace.h:1510
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
ClassId classId() const
__int64 qint64
Definition: qglobal.h:942
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
PixelType type
The QImageReader class provides a format independent interface for reading images from files or other...
Definition: qimagereader.h:62
QT_DEPRECATED int numColors() const
int depth() const
bool qt_xForm_helper(const QTransform &, int, int, int, uchar *, int, int, int, const uchar *, int, int, int)
Definition: qimage.cpp:6100
QAtomicInt ref
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int colorCount() const
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
#define QT_DEPRECATED
Definition: qglobal.h:1094
int height() const
bool isNull() const
qint64 cacheKey() const
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65