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
qohossurface.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 QOHOSSURFACE_H
5#define QOHOSSURFACE_H
6
7#include <EGL/egl.h>
8#include <EGL/eglplatform.h>
9#include <QtCore/private/qohoscommon_p.h>
10#include <QtCore/qglobal.h>
11#include <QtCore/qsize.h>
12#include <QtGui/qimage.h>
13#include <memory>
14#include <native_buffer/native_buffer.h>
15#include <native_window/external_window.h>
16#include <qohosplugincore.h>
17#include <render/qohosegl.h>
18
19#if QT_CONFIG(vulkan)
20#include <render/qohosvulkansurface.h>
21class QVulkanInstance;
22#endif
23
25
26class QOhosSurface final
27{
28public:
29 static constexpr ::OH_NativeBuffer_Format bufferFormat = ::NATIVEBUFFER_PIXEL_FMT_BGRA_8888;
31 static QOhosOptional<QSize> tryGetBufferGeometryForWindow(::OHNativeWindow *nativeWindow);
32
33 explicit QOhosSurface(::OHNativeWindow *nativeWindow);
34
36 void setNativeWindowSurface(::OHNativeWindow *nativeWindow);
37 EGLSurface tryGetOrCreateEGLWindowSurface(EGLDisplay display, EGLConfig config);
39
41 std::function<std::vector<::Region::Rect>(QImage &, ::BufferHandle *)> paintFunc,
42 std::function<void(::BufferHandle *)> onFlushSuccessFunc);
44
45 void setExtraUsageBitsForNativeWindowBuffer(std::uint64_t usageSetBits);
46
47#if QT_CONFIG(vulkan)
48 VkSurfaceKHR *tryGetOrCreateVulkanWindowSurface(QVulkanInstance *instance);
49#endif
50
51private:
52 ::OHNativeWindow *m_nativeWindow;
53 std::unique_ptr<QOhosEGLSurface> m_eglSurface;
54#if QT_CONFIG(vulkan)
55 std::unique_ptr<QOhosVulkanSurface> m_vulkanSurface;
56#endif
57};
58
59QT_END_NAMESPACE
60
61#endif
std::enable_if_t< qohosplugincore_h_detail::isQOhosOptional< QOhosInvokeResult< Func, T > >, QOhosInvokeResult< Func, T > > andThen(Func &&func) const
static const QOhosPropertyDescriptor< bool > windowKeepScreenOnProperty
static const QOhosPropertyDescriptor< QColor > surfaceBackgroundColorProperty
void setWindowTitle(const QString &title) override
Reimplement to set the window title to title.
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 void setSurfaceBackgroundColor(QObject *windowOrWidget, const QColor &color)
static void setSaturation(QObject *windowOrWidget, int saturation)
QOhosOptional< QOhosDisplayInfo::JsDisplayId > tryTakeLastRequestedDisplayId()
static std::shared_ptr< void > setSurfaceConsumer(QWindow *targetWindow, QObject *surfaceConsumerContext, std::function< void(QOhosOptional< void * >)> surfaceConsumer)
QOhosOptional< QCursor > m_cursor
static const QOhosPropertyDescriptor< int > windowSaturationProperty
static const QOhosPropertyDescriptor< int > windowContrastProperty
static QOhosPlatformWindow * fromQWindow(QWindow *window)
QOhosPropertiesProvider propertiesProvider()
static const QOhosPropertyDescriptor< bool > floatWindowTagProperty
bool isWindowBeingClosedOrDestroyed(QWindow *window) const
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 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)
ScreenChangeResult tryChangeScreen(QOhosPlatformScreen *screen)
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)
EGLSurface tryGetOrCreateEGLWindowSurface(EGLDisplay display, EGLConfig config)
QOhosOptional< QSize > surfaceResolution() const
::OHNativeWindow * nativeWindow() const
void setNativeWindowSurface(::OHNativeWindow *nativeWindow)
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)
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(QOhosPlatformWindow::NativeNodeRenderFitPolicy))
QOhosOptional< void > makeEmptyQOhosOptional()
void setQOhosPropertyOnQObject(QObject *qObject, T propertyValue)
QOhosOptional< T > tryGetQOhosPropertyFromQObject(QObject *qObject)