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
qpixmap_x11_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 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#pragma once
6
7#include <QBitmap>
8#include <QPixmap>
9
10#include <qpa/qplatformpixmap.h>
12
13typedef unsigned long XID;
14typedef XID Drawable;
15typedef XID Picture;
16typedef XID Pixmap;
17
18QT_BEGIN_NAMESPACE
19
20class QX11PaintEngine;
21struct QXImageWrapper;
22
24{
25public:
26 QX11PlatformPixmap(PixelType pixelType);
28
30 void resize(int width, int height) override;
31 void fromImage(const QImage &img, Qt::ImageConversionFlags flags) override;
32 void copy(const QPlatformPixmap *data, const QRect &rect) override;
33 bool scroll(int dx, int dy, const QRect &rect) override;
34 int metric(QPaintDevice::PaintDeviceMetric metric) const override;
35 void fill(const QColor &fillColor) override;
36 QBitmap mask() const override;
37 void setMask(const QBitmap &mask) override;
38 bool hasAlphaChannel() const override;
39 QPixmap transformed(const QTransform &matrix, Qt::TransformationMode mode) const override;
40 QImage toImage() const override;
41 QImage toImage(const QRect &rect) const override;
42 QPaintEngine *paintEngine() const override;
43 qreal devicePixelRatio() const override;
44 void setDevicePixelRatio(qreal scaleFactor) override;
45
46 inline Drawable handle() const { return hd; }
47 inline Picture x11PictureHandle() const { return picture; }
48 inline const QXcbX11Info *x11_info() const { return &xinfo; }
49
51 static XID createBitmapFromImage(const QImage &image);
52
53#if QT_CONFIG(xrender)
54 void convertToARGB32(bool preserveContents = true);
55#endif
56
57 bool isBackingStore() const;
58 void setIsBackingStore(bool on);
59private:
60 friend class QX11PaintEngine;
61 friend const QXcbX11Info &qt_x11Info(const QPixmap &pixmap);
62 friend void qt_x11SetScreen(QPixmap &pixmap, int screen);
63
64 void release();
65 QImage toImage(const QXImageWrapper &xi, const QRect &rect) const;
66 QBitmap mask_to_bitmap(int screen) const;
67 static Pixmap bitmap_to_mask(const QBitmap &, int screen);
68 void bitmapFromImage(const QImage &image);
69 bool canTakeQImageFromXImage(const QXImageWrapper &xi) const;
70 QImage takeQImageFromXImage(const QXImageWrapper &xi) const;
71
72 Pixmap hd = 0;
73
74 enum Flag {
75 NoFlags = 0x0,
76 Uninitialized = 0x1,
77 Readonly = 0x2,
78 InvertedWhenBoundToTexture = 0x4,
79 GlSurfaceCreatedWithAlpha = 0x8,
80 IsBackingStore = 0x10
81 };
82 uint flags;
83
84 QXcbX11Info xinfo;
85 Pixmap x11_mask;
86 Picture picture;
87 Picture mask_picture;
88 Pixmap hd2; // sorted in the default display depth
89 //QPixmap::ShareMode share_mode;
90 qreal dpr;
91
92 QX11PaintEngine *pengine;
93};
94
95inline QX11PlatformPixmap *qt_x11Pixmap(const QPixmap &pixmap)
96{
97 return (pixmap.handle() && pixmap.handle()->classId() == QPlatformPixmap::X11Class)
98 ? static_cast<QX11PlatformPixmap *>(pixmap.handle())
99 : nullptr;
100}
101
102inline Picture qt_x11PictureHandle(const QPixmap &pixmap)
103{
104 if (QX11PlatformPixmap *pm = qt_x11Pixmap(pixmap))
105 return pm->x11PictureHandle();
106
107 return 0;
108}
109
110inline Pixmap qt_x11PixmapHandle(const QPixmap &pixmap)
111{
112 if (QX11PlatformPixmap *pm = qt_x11Pixmap(pixmap))
113 return pm->handle();
114
115 return 0;
116}
117
118inline const QXcbX11Info &qt_x11Info(const QPixmap &pixmap)
119{
120 if (QX11PlatformPixmap *pm = qt_x11Pixmap(pixmap)) {
121 return pm->xinfo;
122 } else {
123 static QXcbX11Info nullX11Info;
124 return nullX11Info;
125 }
126}
127
128int qt_x11SetDefaultScreen(int screen);
129void qt_x11SetScreen(QPixmap &pixmap, int screen);
130
131QT_END_NAMESPACE
\inmodule QtGui
Definition qwindow.h:63
qreal devicePixelRatio() const override
bool isBackingStore() const
void copy(const QPlatformPixmap *data, const QRect &rect) override
QBitmap mask() const override
QPlatformPixmap * createCompatiblePlatformPixmap() const override
Drawable handle() const
void setIsBackingStore(bool on)
static XID createBitmapFromImage(const QImage &image)
Pixmap x11ConvertToDefaultDepth()
void fromImage(const QImage &img, Qt::ImageConversionFlags flags) override
QImage toImage() const override
QPaintEngine * paintEngine() const override
QX11PlatformPixmap(PixelType pixelType)
const QXcbX11Info * x11_info() const
void fill(const QColor &fillColor) override
Picture x11PictureHandle() const
void resize(int width, int height) override
void setMask(const QBitmap &mask) override
QImage toImage(const QRect &rect) const override
friend const QXcbX11Info & qt_x11Info(const QPixmap &pixmap)
void setDevicePixelRatio(qreal scaleFactor) override
bool hasAlphaChannel() const override
bool scroll(int dx, int dy, const QRect &rect) override
int metric(QPaintDevice::PaintDeviceMetric metric) const override
QPixmap transformed(const QTransform &matrix, Qt::TransformationMode mode) const override
void beginPaint(const QRegion &region) override
This function is called before painting onto the surface begins, with the region in which the paintin...
QXcbNativeBackingStore(QWindow *window)
void flush(QWindow *window, const QRegion &region, const QPoint &offset) override
Flushes the given region from the specified window.
QImage toImage() const override
Implemented in subclasses to return the content of the backingstore as a QImage.
QPaintDevice * paintDevice() override
Implement this function to return the appropriate paint device.
void resize(const QSize &size, const QRegion &staticContents) override
bool scroll(const QRegion &area, int dx, int dy) override
Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative.
friend void qt_x11SetScreen(QPixmap &pixmap, int screen)
XID Picture
XID Pixmap
Pixmap qt_x11PixmapHandle(const QPixmap &pixmap)
Picture qt_x11PictureHandle(const QPixmap &pixmap)
QX11PlatformPixmap * qt_x11Pixmap(const QPixmap &pixmap)
int qt_x11SetDefaultScreen(int screen)
unsigned long XID