/src/qtbase/src/gui/image/qplatformpixmap.h
Line | Count | Source |
1 | | // Copyright (C) 2016 The Qt Company Ltd. |
2 | | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | | // Qt-Security score:significant reason:default |
4 | | |
5 | | #ifndef QPLATFORMPIXMAP_H |
6 | | #define QPLATFORMPIXMAP_H |
7 | | |
8 | | // |
9 | | // W A R N I N G |
10 | | // ------------- |
11 | | // |
12 | | // This file is part of the QPA API and is not meant to be used |
13 | | // in applications. Usage of this API may make your code |
14 | | // source and binary incompatible with future versions of Qt. |
15 | | // |
16 | | |
17 | | #include <QtGui/qtguiglobal.h> |
18 | | #include <QtGui/qpixmap.h> |
19 | | #include <QtCore/qatomic.h> |
20 | | |
21 | | QT_BEGIN_NAMESPACE |
22 | | |
23 | | |
24 | | class QImageReader; |
25 | | |
26 | | class Q_GUI_EXPORT QPlatformPixmap : public QSharedData |
27 | | { |
28 | | public: |
29 | | enum PixelType { |
30 | | // WARNING: Do not change the first two |
31 | | // Must match QPixmap::Type |
32 | | PixmapType, BitmapType |
33 | | }; |
34 | | |
35 | | enum ClassId { RasterClass, DirectFBClass, |
36 | | BlitterClass, Direct2DClass, |
37 | | CustomClass = 1024 }; |
38 | | |
39 | | QPlatformPixmap(PixelType pixelType, int classId); |
40 | | virtual ~QPlatformPixmap(); |
41 | | |
42 | | virtual QPlatformPixmap *createCompatiblePlatformPixmap() const; |
43 | | |
44 | | virtual void resize(int width, int height) = 0; |
45 | | virtual void fromImage(const QImage &image, |
46 | | Qt::ImageConversionFlags flags) = 0; |
47 | | virtual void fromImageInPlace(QImage &image, |
48 | | Qt::ImageConversionFlags flags) |
49 | 0 | { |
50 | 0 | fromImage(image, flags); |
51 | 0 | } |
52 | | |
53 | | virtual void fromImageReader(QImageReader *imageReader, |
54 | | Qt::ImageConversionFlags flags); |
55 | | |
56 | | virtual bool fromFile(const QString &filename, const char *format, |
57 | | Qt::ImageConversionFlags flags); |
58 | | virtual bool fromData(const uchar *buffer, uint len, const char *format, |
59 | | Qt::ImageConversionFlags flags); |
60 | | |
61 | | virtual void copy(const QPlatformPixmap *data, const QRect &rect); |
62 | | virtual bool scroll(int dx, int dy, const QRect &rect); |
63 | | |
64 | | virtual int metric(QPaintDevice::PaintDeviceMetric metric) const = 0; |
65 | | virtual void fill(const QColor &color) = 0; |
66 | | |
67 | | virtual QBitmap mask() const; |
68 | | virtual void setMask(const QBitmap &mask); |
69 | | |
70 | | virtual bool hasAlphaChannel() const = 0; |
71 | | virtual QPixmap transformed(const QTransform &matrix, |
72 | | Qt::TransformationMode mode) const; |
73 | | |
74 | | virtual QImage toImage() const = 0; |
75 | | virtual QImage toImage(const QRect &rect) const; |
76 | | virtual QPaintEngine* paintEngine() const = 0; |
77 | | |
78 | 0 | inline int serialNumber() const { return ser_no; } |
79 | | |
80 | 0 | inline PixelType pixelType() const { return type; } |
81 | 0 | inline ClassId classId() const { return static_cast<ClassId>(id); } |
82 | | |
83 | | virtual qreal devicePixelRatio() const = 0; |
84 | | virtual void setDevicePixelRatio(qreal scaleFactor) = 0; |
85 | | |
86 | | virtual QImage* buffer(); |
87 | | |
88 | 0 | inline int width() const { return w; } |
89 | 0 | inline int height() const { return h; } |
90 | 0 | inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); } |
91 | 0 | inline int depth() const { return d; } |
92 | 0 | inline bool isNull() const { return is_null; } |
93 | 0 | inline qint64 cacheKey() const { |
94 | 0 | int classKey = id; |
95 | 0 | if (classKey >= 1024) |
96 | 0 | classKey = -(classKey >> 10); |
97 | 0 | return ((((qint64) classKey) << 56) |
98 | 0 | | (((qint64) ser_no) << 32) |
99 | 0 | | ((qint64) detach_no)); |
100 | 0 | } |
101 | | |
102 | | static QPlatformPixmap *create(int w, int h, PixelType type); |
103 | | |
104 | | protected: |
105 | | |
106 | | void setSerialNumber(int serNo); |
107 | | void setDetachNumber(int detNo); |
108 | | void callDestructionHooks(); |
109 | | int w; |
110 | | int h; |
111 | | int d; |
112 | | bool is_null; |
113 | | |
114 | | private: |
115 | | friend class QPixmap; |
116 | | friend class QImagePixmapCleanupHooks; // Needs to set is_cached |
117 | | |
118 | | int detach_no; |
119 | | |
120 | | PixelType type; |
121 | | int id; |
122 | | int ser_no; |
123 | | uint is_cached; |
124 | | }; |
125 | | |
126 | | QT_END_NAMESPACE |
127 | | |
128 | | #endif // QPLATFORMPIXMAP_H |