Debian Codegraph @

tests/manual/rhi/rhiwidgetproto/rhiwidget.h

raw
1 // Copyright (C) 2021 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 #ifndef RHIWIDGET_H
5 #define RHIWIDGET_H
6
7 #include <QWidget>
8 #include <rhi/qrhi.h>
9
10 class QRhiWidgetPrivate;
11
12 class QRhiWidget : public QWidget
13 {
14 Q_OBJECT
15 Q_DECLARE_PRIVATE(QRhiWidget)
16 Q_PROPERTY(QSize explicitSize READ explicitSize WRITE setExplicitSize NOTIFY explicitSizeChanged)
17
18 public:
19 QRhiWidget(QWidget *parent = nullptr, Qt::WindowFlags f = {});
20 ~QRhiWidget();
21
22 enum Api {
23 OpenGL,
24 Metal,
25 Vulkan,
26 D3D11,
27 Null
28 };
29
30 Api api() const;
31 void setApi(Api api);
32
33 bool isDebugLayerEnabled() const;
34 void setDebugLayer(bool enable);
35
36 QRhiTexture::Format textureFormat() const;
37 void setTextureFormat(QRhiTexture::Format format);
38
39 QSize explicitSize() const;
40 void setExplicitSize(const QSize &pixelSize);
41
42 virtual void initialize(QRhi *rhi, QRhiTexture *outputTexture);
43 virtual void render(QRhiCommandBuffer *cb);
44
45 QImage grabTexture();
46
47 Q_SIGNALS:
48 void explicitSizeChanged(const QSize &pixelSize);
49
50 protected:
51 void resizeEvent(QResizeEvent *e) override;
52 void paintEvent(QPaintEvent *e) override;
53 bool event(QEvent *e) override;
54 };
55
56 #endif