Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qplatformpixmap.h
Go to the documentation of this file.
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
21QT_BEGIN_NAMESPACE
22
23
24class QImageReader;
25
26class Q_GUI_EXPORT QPlatformPixmap : public QSharedData
27{
28public:
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 {
50 fromImage(image, flags);
51 }
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 inline int serialNumber() const { return ser_no; }
79
80 inline PixelType pixelType() const { return type; }
81 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 inline int width() const { return w; }
89 inline int height() const { return h; }
90 inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); }
91 inline int depth() const { return d; }
92 inline bool isNull() const { return is_null; }
93 inline qint64 cacheKey() const {
94 int classKey = id;
95 if (classKey >= 1024)
96 classKey = -(classKey >> 10);
97 return ((((qint64) classKey) << 56)
98 | (((qint64) ser_no) << 32)
99 | ((qint64) detach_no));
100 }
101
102 static QPlatformPixmap *create(int w, int h, PixelType type);
103
104protected:
105
106 void setSerialNumber(int serNo);
107 void setDetachNumber(int detNo);
108 int w;
109 int h;
110 int d;
111 bool is_null;
112
113private:
114 friend class QPixmap;
115 friend class QImagePixmapCleanupHooks; // Needs to set is_cached
116
117 int detach_no;
118
119 PixelType type;
120 int id;
121 int ser_no;
122 uint is_cached;
123};
124
125QT_END_NAMESPACE
126
127#endif // QPLATFORMPIXMAP_H
The QPlatformPixmap class provides an abstraction for native pixmaps.
Combined button and popup list for selecting options.
static QImage makeBitmapCompliantIfNeeded(QPlatformPixmap *d, QImage image, Qt::ImageConversionFlags flags)