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
qohosegl.h
Go to the documentation of this file.
1// Copyright (C) 2025 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
4#ifndef QOHOSEGL_H
5#define QOHOSEGL_H
6
7#include "EGL/egl.h"
8#include "EGL/eglplatform.h"
9#include <GLES3/gl3.h>
10#include <QSharedPointer>
11#include <QtCore/qglobal.h>
12#include <QtCore/qsize.h>
13#include <qohosplugincore.h>
14
15QT_BEGIN_NAMESPACE
16
17class QOhosEGLSurface
18{
19public:
20 enum class SurfaceFlagBits {
21 PreserveBufferContentsOnSwap = 1 << 0,
22 };
23 Q_DECLARE_FLAGS(SurfaceFlags, SurfaceFlagBits)
24
25 QOhosEGLSurface() = default;
26
27 QOhosEGLSurface(const QOhosEGLSurface&) = delete;
28 QOhosEGLSurface& operator=(const QOhosEGLSurface&) = delete;
29
30 QOhosEGLSurface(QOhosEGLSurface &&) = delete;
31 QOhosEGLSurface& operator=(QOhosEGLSurface &&) = delete;
32
33 ~QOhosEGLSurface();
34
35 EGLSurface tryGetOrCreateEGLWindowSurface(
36 EGLDisplay display, EGLConfig config, bool swappingBuffers, SurfaceFlags flags = {});
37 void setNativeWindowSurface(
38 EGLNativeWindowType nativeWindow, const QOhosOptional<QSize> &optSurfaceSize);
39 SurfaceFlags currentSurfaceFlags() const;
40
41private:
42 void cleanup();
43 void tryCreateSurface(EGLDisplay display, EGLConfig config, SurfaceFlags surfaceFlags);
44 QOhosOptional<QSize> currentSurfaceSize() const;
45
46 EGLDisplay m_refCurrentDisplay = EGL_NO_DISPLAY;
47 EGLConfig m_refCurrentConfig = nullptr;
48 EGLNativeWindowType m_refCurrentNativeWindow = nullptr;
49 EGLNativeWindowType m_refTargetNativeWindow = nullptr;
50 EGLSurface m_ownEglSurface = EGL_NO_SURFACE;
51 SurfaceFlags m_currentSurfaceFlags = {};
52 QOhosOptional<QSize> m_targetSurfaceSize;
53};
54
56
57#endif // QOHOSEGL_H
static const QOhosPropertyDescriptor< bool > windowKeepScreenOnProperty
static const QOhosPropertyDescriptor< QColor > surfaceBackgroundColorProperty
void setWindowTitle(const QString &title) override
Reimplement to set the window title to title.
static void setWindowDragResizable(QObject *windowOrWidget, bool dragResizable)
QOhosPlatformScreen * platformScreen() const
static void setWindowOrWidgetNativeNodeRenderFitPolicyHint(QObject *windowOrWidget, NativeNodeRenderFitPolicy renderFitPolicy)
bool mainWindowTagValueOrFalse() const
Qt::WindowStates windowStates() const
static QOhosOptional< T > tryGetWindowOrWidgetProperty(QObject *windowOrWidget)
void setDisplayIdFromOhos(QOhosOptional< QOhosDisplayInfo::JsDisplayId > displayId)
bool setMouseGrabEnabled(bool grab) override
static void setWindowKeepScreenOn(QObject *windowOrWidget, bool keepScreenOn)
void setWindowStateFromOhos(Qt::WindowStates state)
static const QOhosPropertyDescriptor< int > windowBrightnessProperty
static const QOhosPropertyDescriptor< bool > mainWindowTagProperty
static const QOhosPropertyDescriptor< QWindow * > subWindowOfTagProperty
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
bool setKeyboardGrabEnabled(bool grab) override
static const QOhosPropertyDescriptor< bool > windowPrivacyModeSettingProperty
bool windowEvent(QEvent *event) override
Reimplement this method to be able to do any platform specific event handling.
QtOhos::InternalWindowId m_windowId
static const QOhosPropertyDescriptor< double > windowCornerRadiusProperty
static bool isWindowBeingClosedOrDestroyed(QWindow *window)
static void setSurfaceBackgroundColor(QObject *windowOrWidget, const QColor &color)
static void setSaturation(QObject *windowOrWidget, int saturation)
static std::shared_ptr< void > setSurfaceConsumer(QWindow *targetWindow, QObject *surfaceConsumerContext, std::function< void(QOhosOptional< void * >)> surfaceConsumer)
QRect lastRequestedWindowFrameGeometry() const
QOhosOptional< QCursor > m_cursor
static const QOhosPropertyDescriptor< int > windowSaturationProperty
void setExposedFromOhos(bool exposed)
static const QOhosPropertyDescriptor< int > windowContrastProperty
static QOhosPlatformWindow * fromQWindow(QWindow *window)
QOhosPropertiesProvider propertiesProvider()
static const QOhosPropertyDescriptor< bool > floatWindowTagProperty
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
static void tagWindowOrWidgetAsFloatWindow(QObject *windowOrWidgetToTag, bool showAsFloatWindow)
static const QOhosPropertyDescriptor< bool > windowDragResizableProperty
static void tagWindowOrWidgetAsSubWindowOf(QObject *windowOrWidgetToTag, QWindow *targetMainWindow)
virtual void onWindowFlagsChanged(Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags)
static const QOhosPropertyDescriptor< NativeNodeRenderFitPolicy > nativeNodeRenderFitPolicyHintProperty
QtOhos::InternalWindowId internalWindowId() const
static void tagWindowOrWidgetAsMainWindow(QObject *windowOrWidgetToTag, bool forceMainWindow)
Qt::WindowFlags m_windowFlags
void propagateSizeHints() override
Reimplement to propagate the size hints of the QWindow.
static QOhosPlatformWindow * fromQWindowOrNull(QWindow *window)
virtual QOhosSurface * ownedSurfaceOrNull() const
static void setWindowCornerRadius(QObject *windowOrWidget, double radius)
static QWindow * getWindowOrWidgetAsSubWindowOfTagValue(QObject *windowOrWidget)
virtual void onWindowStateChanged(Qt::WindowStates oldWindowState, Qt::WindowStates currentWindowState)
void setParent(const QPlatformWindow *newParent) override
This function is called to enable native child window in QPA.
QOhosPlatformWindow(QWindow *window)
void setCursor(const QCursor &cursor)
static void setBrightness(QObject *windowOrWidget, int brightness)
bool shouldDisplayAsOhosWindow() const
std::unique_ptr< QMargins > m_optFrameMargins
void setWindowGeometryFromOhos(const QRect &nativeWindowDrawGeometry)
QMargins frameMargins() const override
void initialize() override
Called as part of QWindow::create(), after constructing the window.
QPlatformScreen * screen() const override
static void setContrast(QObject *windowOrWidget, int contrast)
void setWindowFlags(Qt::WindowFlags flags) override
Requests setting the window flags of this surface to flags.
bool floatWindowTagValueOrFalse() const
void setWindowState(Qt::WindowStates state) override
Requests setting the window state of this surface to type.
void notifyInputSystemsWindowActiveStatusChanged(bool active)
static const QOhosPropertyDescriptor< bool > windowFixedSizeStateProperty
bool isExposed() const final
Returns if this window is exposed in the windowing system.
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
Qt::WindowStates m_windowState
DecorationPreset decorationPreset() const
static void setWindowPrivacyMode(QObject *window, bool privacyModeEnabled)
QWindow * validSubWindowOfTagValueOrNull() const
Qt::WindowFlags windowFlags() const
static void setWindowOrWidgetProperty(QObject *windowOrWidget, T propertyValue)
bool shouldShowWindowWithoutActivating() const
virtual QOhosView * ownedViewOrNull() const
void setWindowMarginsFromOhos(const QMargins &margins)
static Qt::WindowFlags platformWindowFlagsForQWindow(QWindow *window)
QOhosPropertiesProvider(QOhosPropertiesStore &store)
QOhosOptional< T > tryGetProperty() const
std::shared_ptr< void > addPropertyWriteCallback(QOhosConsumer< T > propertyWriteCallback)
QOhosPropertiesStore(QObject *qObject)
std::shared_ptr< void > addPropertyWriteCallback(QOhosConsumer< T > propertyWriteCallback)
void notifyPropertyWrite(const QByteArray &propertyName)
QOhosOptional< T > tryGetProperty() const
void setExtraUsageBitsForNativeWindowBuffer(std::uint64_t usageSetBits)
void setNativeWindowSurface(::OHNativeWindow *nativeWindow, const QOhosOptional< QSize > &optSurfaceSize)
QOhosOptional< QSize > surfaceResolution() const
::OHNativeWindow * nativeWindow() const
static constexpr ::OH_NativeBuffer_Format bufferFormat
void paintOnNativeWindowSurface(std::function< std::vector<::Region::Rect >(QImage &, ::BufferHandle *)> paintFunc, std::function< void(::BufferHandle *)> onFlushSuccessFunc)
static QImage::Format mapNativeBufferFormatToQImageFormatOrFail(std::int32_t format)
static QOhosOptional< QSize > tryGetBufferGeometryForWindow(::OHNativeWindow *nativeWindow)
QOhosSurface(::OHNativeWindow *nativeWindow)
EGLSurface tryGetOrCreateEGLWindowSurface(EGLDisplay display, EGLConfig config, bool swappingBuffers)
void clearNativeWindowSurface()
bool sendEvent(WindowSystemEvent *event) override
Combined button and popup list for selecting options.
QOhosView * mapQWindowToViewOrNull(QWindow *window)
QOhosOptional< T > tryMapFromQVariant(QVariant variant)
std::shared_ptr< QWindowSystemEventHandler > makeApplicationStateTracker()
QT_END_NAMESPACE Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::kit::ShareKit::systemShare::SelectionMode))
std::nullopt_t makeEmptyQOhosOptional()
void setQOhosPropertyOnQObject(QObject *qObject, T propertyValue)
QOhosOptional< T > tryGetQOhosPropertyFromQObject(QObject *qObject)