Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qandroidplatformscreen.h
Go to the documentation of this file.
1// Copyright (C) 2014 BogDan Vatra <bogdan@kde.org>
2// Copyright (C) 2016 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QANDROIDPLATFORMSCREEN_H
6#define QANDROIDPLATFORMSCREEN_H
7
9
10#include <QList>
11#include <QPainter>
12#include <QTimer>
13#include <QWaitCondition>
14#include <QtCore/QJniObject>
15#include <qpa/qplatformscreen.h>
16#include <qpa/qplatformscreen_p.h>
17
18#include <android/native_window.h>
19
21
23
26 public QNativeInterface::Private::QAndroidScreen
27{
29public:
30 QAndroidPlatformScreen(const QJniObject &displayObject);
32
33 QRect geometry() const override { return QRect(QPoint(), m_size); }
34 QRect availableGeometry() const override { return m_availableGeometry; }
35 int depth() const override { return m_depth; }
36 QImage::Format format() const override { return m_format; }
37 QSizeF physicalSize() const override { return m_physicalSize; }
38
39 QString name() const override { return m_name; }
40 QList<Mode> modes() const override { return m_modes; }
41 int currentMode() const override { return m_currentMode; }
42 int preferredMode() const override { return m_currentMode; }
43 qreal refreshRate() const override { return m_refreshRate; }
44 inline QWindow *topWindow() const;
45 QWindow *topLevelAt(const QPoint & p) const override;
46
47 // compositor api
52
53 void scheduleUpdate();
55 int rasterSurfaces();
56 int displayId() const override;
57
58public slots:
59 void setDirty(const QRect &rect);
60 void setPhysicalSize(const QSize &size);
61 void setAvailableGeometry(const QRect &rect);
62 void setSize(const QSize &size);
63 void setSizeParameters(const QSize &physicalSize, const QSize &size,
67
68protected:
69 bool event(QEvent *event) override;
70
74 bool m_updatePending = false;
75
84 int m_displayId = -1;
85
86private:
87 QDpi logicalDpi() const override;
88 QDpi logicalBaseDpi() const override;
89 Qt::ScreenOrientation orientation() const override;
91 QPixmap grabWindow(WId window, int x, int y, int width, int height) const override;
92 void surfaceChanged(JNIEnv *env, jobject surface, int w, int h) override;
93 void releaseSurface();
94 void applicationStateChanged(Qt::ApplicationState);
95 QPixmap doScreenShot(QRect grabRect = QRect());
96
97private slots:
98 void doRedraw(QImage *screenGrabImage = nullptr);
99
100private:
101 int m_surfaceId = -1;
102 QAtomicInt m_rasterSurfaces = 0;
103 ANativeWindow* m_nativeSurface = nullptr;
104 QWaitCondition m_surfaceWaitCondition;
105 QSize m_size;
106
107 QImage m_lastScreenshot;
109 bool m_repaintOccurred = false;
110};
111
113#endif
void setDirty(const QRect &rect)
Qt::ScreenOrientation orientation() const override
Reimplement this function in subclass to return the current orientation of the screen,...
QSizeF physicalSize() const override
Reimplement this function in subclass to return the physical size of the screen, in millimeters.
void lower(QAndroidPlatformWindow *window)
QString name() const override
int currentMode() const override
Reimplement this function in subclass to return the index of the current mode from the modes list.
QWindow * topLevelAt(const QPoint &p) const override
Return the given top level window for a given position.
QList< QAndroidPlatformWindow * > WindowStackType
void setSizeParameters(const QSize &physicalSize, const QSize &size, const QRect &availableGeometry)
QDpi logicalBaseDpi() const override
Reimplement to return the base logical DPI for the platform.
QDpi logicalDpi() const override
Reimplement this function in subclass to return the logical horizontal and vertical dots per inch met...
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
void raise(QAndroidPlatformWindow *window)
int preferredMode() const override
Reimplement this function in subclass to return the preferred mode index from the modes list.
void setPhysicalSize(const QSize &size)
void setAvailableGeometry(const QRect &rect)
void setOrientation(Qt::ScreenOrientation orientation)
QRect availableGeometry() const override
Reimplement in subclass to return the pixel geometry of the available space This normally is the desk...
QPixmap grabWindow(WId window, int x, int y, int width, int height) const override
This function is called when Qt needs to be able to grab the content of a window.
void removeWindow(QAndroidPlatformWindow *window)
Qt::ScreenOrientation nativeOrientation() const override
Reimplement this function in subclass to return the native orientation of the screen,...
QImage::Format format() const override
Reimplement in subclass to return the image format which corresponds to the screen format.
void setSize(const QSize &size)
void setRefreshRate(qreal refreshRate)
void surfaceChanged(JNIEnv *env, jobject surface, int w, int h) override
QList< Mode > modes() const override
Reimplement this function in subclass to return the list of modes for this screen.
qreal refreshRate() const override
Reimplement this function in subclass to return the vertical refresh rate of the screen,...
void addWindow(QAndroidPlatformWindow *window)
int depth() const override
Reimplement in subclass to return current depth of the screen.
\inmodule QtCore
Definition qatomic.h:112
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtGui
Definition qimage.h:37
Format
The following image formats are available in Qt.
Definition qimage.h:41
@ Format_RGBA8888_Premultiplied
Definition qimage.h:60
\inmodule QtCore
Definition qlist.h:74
\inmodule QtCore
Definition qobject.h:90
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
The QPlatformScreen class provides an abstraction for visual displays.
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:207
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtGui
Definition qwindow.h:63
rect
[4]
Combined button and popup list for selecting options.
ScreenOrientation
Definition qnamespace.h:270
ApplicationState
Definition qnamespace.h:261
QPair< qreal, qreal > QDpi
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei width
GLint y
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
GLfloat GLfloat p
[1]
#define Q_OBJECT
#define slots
double qreal
Definition qtypes.h:92
aWidget window() -> setWindowTitle("New Window Title")
[2]