QtBase  v6.3.1
qplatformpixmap.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
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 The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QPLATFORMPIXMAP_H
41 #define QPLATFORMPIXMAP_H
42 
43 //
44 // W A R N I N G
45 // -------------
46 //
47 // This file is part of the QPA API and is not meant to be used
48 // in applications. Usage of this API may make your code
49 // source and binary incompatible with future versions of Qt.
50 //
51 
52 #include <QtGui/qtguiglobal.h>
53 #include <QtGui/qpixmap.h>
54 #include <QtCore/qatomic.h>
55 
57 
58 
59 class QImageReader;
60 
61 class Q_GUI_EXPORT QPlatformPixmap
62 {
63 public:
64  enum PixelType {
65  // WARNING: Do not change the first two
66  // Must match QPixmap::Type
68  };
69 
70  enum ClassId { RasterClass, DirectFBClass,
71  BlitterClass, Direct2DClass,
72  X11Class, CustomClass = 1024 };
73 
74  QPlatformPixmap(PixelType pixelType, int classId);
75  virtual ~QPlatformPixmap();
76 
77  virtual QPlatformPixmap *createCompatiblePlatformPixmap() const;
78 
79  virtual void resize(int width, int height) = 0;
80  virtual void fromImage(const QImage &image,
81  Qt::ImageConversionFlags flags) = 0;
82  virtual void fromImageInPlace(QImage &image,
83  Qt::ImageConversionFlags flags)
84  {
85  fromImage(image, flags);
86  }
87 
88  virtual void fromImageReader(QImageReader *imageReader,
89  Qt::ImageConversionFlags flags);
90 
91  virtual bool fromFile(const QString &filename, const char *format,
92  Qt::ImageConversionFlags flags);
93  virtual bool fromData(const uchar *buffer, uint len, const char *format,
94  Qt::ImageConversionFlags flags);
95 
96  virtual void copy(const QPlatformPixmap *data, const QRect &rect);
97  virtual bool scroll(int dx, int dy, const QRect &rect);
98 
99  virtual int metric(QPaintDevice::PaintDeviceMetric metric) const = 0;
100  virtual void fill(const QColor &color) = 0;
101 
102  virtual QBitmap mask() const;
103  virtual void setMask(const QBitmap &mask);
104 
105  virtual bool hasAlphaChannel() const = 0;
106  virtual QPixmap transformed(const QTransform &matrix,
108 
109  virtual QImage toImage() const = 0;
110  virtual QImage toImage(const QRect &rect) const;
111  virtual QPaintEngine* paintEngine() const = 0;
112 
113  inline int serialNumber() const { return ser_no; }
114 
115  inline PixelType pixelType() const { return type; }
116  inline ClassId classId() const { return static_cast<ClassId>(id); }
117 
118  virtual qreal devicePixelRatio() const = 0;
119  virtual void setDevicePixelRatio(qreal scaleFactor) = 0;
120 
121  virtual QImage* buffer();
122 
123  inline int width() const { return w; }
124  inline int height() const { return h; }
125  inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); }
126  inline int depth() const { return d; }
127  inline bool isNull() const { return is_null; }
128  inline qint64 cacheKey() const {
129  int classKey = id;
130  if (classKey >= 1024)
131  classKey = -(classKey >> 10);
132  return ((((qint64) classKey) << 56)
133  | (((qint64) ser_no) << 32)
134  | ((qint64) detach_no));
135  }
136 
137  static QPlatformPixmap *create(int w, int h, PixelType type);
138 
139 protected:
140 
141  void setSerialNumber(int serNo);
142  void setDetachNumber(int detNo);
143  int w;
144  int h;
145  int d;
146  bool is_null;
147 
148 private:
149  friend class QPixmap;
150  friend class QX11PlatformPixmap;
151  friend class QImagePixmapCleanupHooks; // Needs to set is_cached
152  friend class QOpenGLTextureCache; //Needs to check the reference count
154 
155  QAtomicInt ref;
156  int detach_no;
157 
158  PixelType type;
159  int id;
160  int ser_no;
161  uint is_cached;
162 };
163 
164 # define QT_XFORM_TYPE_MSBFIRST 0
165 # define QT_XFORM_TYPE_LSBFIRST 1
166 Q_GUI_EXPORT bool qt_xForm_helper(const QTransform&, int, int, int, uchar*, qsizetype, int, int, const uchar*, qsizetype, int, int);
167 
169 
170 #endif // QPLATFORMPIXMAP_H
The QAtomicInt class provides platform-independent atomic operations on int.
Definition: qatomic.h:158
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:52
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object.
Definition: qshareddata.h:161
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:73
The QImageReader class provides a format independent interface for reading images from files or other...
Definition: qimagereader.h:59
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:87
The QPixmap class is an off-screen image representation that can be used as a paint device.
Definition: qpixmap.h:63
qint64 cacheKey() const
int depth() const
virtual int metric(QPaintDevice::PaintDeviceMetric metric) const =0
int serialNumber() const
int height() const
virtual void fromImageInPlace(QImage &image, Qt::ImageConversionFlags flags)
virtual QImage toImage() const =0
virtual void fill(const QColor &color)=0
virtual void resize(int width, int height)=0
int colorCount() const
virtual qreal devicePixelRatio() const =0
virtual bool hasAlphaChannel() const =0
virtual void setDevicePixelRatio(qreal scaleFactor)=0
bool isNull() const
ClassId classId() const
int width() const
virtual void fromImage(const QImage &image, Qt::ImageConversionFlags flags)=0
virtual QPaintEngine * paintEngine() const =0
PixelType pixelType() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:59
The QString class provides a Unicode character string.
Definition: qstring.h:388
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:56
rect
[4]
TransformationMode
Definition: qnamespace.h:1349
Definition: image.cpp:51
@ BitmapType
Definition: paintcommands.h:50
QT_BEGIN_INCLUDE_NAMESPACE typedef unsigned char uchar
Definition: qglobal.h:332
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
ptrdiff_t qsizetype
Definition: qglobal.h:308
unsigned int uint
Definition: qglobal.h:334
long long qint64
Definition: qglobal.h:298
GLenum GLuint id
[6]
Definition: qopengl.h:270
GLenum type
Definition: qopengl.h:270
GLenum mode
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint buffer
GLint GLsizei width
GLuint color
[2]
GLbitfield flags
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint ref
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLenum GLsizei len
Definition: qopenglext.h:3292
GLuint GLenum matrix
Definition: qopenglext.h:11564
Q_GUI_EXPORT bool qt_xForm_helper(const QTransform &, int, int, int, uchar *, qsizetype, int, int, const uchar *, qsizetype, int, int)
Definition: qimage.cpp:4335
view create()