/src/qtbase/src/gui/image/qplatformpixmap.h
Line | Count | Source (jump to first uncovered line) |
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 | | |
56 | | QT_BEGIN_NAMESPACE |
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 |
67 | | PixmapType, BitmapType |
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 | 0 | { |
85 | 0 | fromImage(image, flags); |
86 | 0 | } |
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, |
107 | | Qt::TransformationMode mode) const; |
108 | | |
109 | | virtual QImage toImage() const = 0; |
110 | | virtual QImage toImage(const QRect &rect) const; |
111 | | virtual QPaintEngine* paintEngine() const = 0; |
112 | | |
113 | 0 | inline int serialNumber() const { return ser_no; } |
114 | | |
115 | 0 | inline PixelType pixelType() const { return type; } |
116 | 0 | 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 | 0 | inline int width() const { return w; } |
124 | 0 | inline int height() const { return h; } |
125 | 0 | inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); } |
126 | 0 | inline int depth() const { return d; } |
127 | 0 | inline bool isNull() const { return is_null; } |
128 | 0 | inline qint64 cacheKey() const { |
129 | 0 | int classKey = id; |
130 | 0 | if (classKey >= 1024) |
131 | 0 | classKey = -(classKey >> 10); |
132 | 0 | return ((((qint64) classKey) << 56) |
133 | 0 | | (((qint64) ser_no) << 32) |
134 | 0 | | ((qint64) detach_no)); |
135 | 0 | } |
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 |
153 | | friend class QExplicitlySharedDataPointer<QPlatformPixmap>; |
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 | 0 | # define QT_XFORM_TYPE_MSBFIRST 0 |
165 | 0 | # define QT_XFORM_TYPE_LSBFIRST 1 |
166 | | Q_GUI_EXPORT bool qt_xForm_helper(const QTransform&, int, int, int, uchar*, int, int, int, const uchar*, int, int, int); |
167 | | |
168 | | QT_END_NAMESPACE |
169 | | |
170 | | #endif // QPLATFORMPIXMAP_H |