Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtWidgets/qrhiwidget.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2023 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QRHIWIDGET_H
0005 #define QRHIWIDGET_H
0006 
0007 #include <QtWidgets/qwidget.h>
0008 
0009 QT_BEGIN_NAMESPACE
0010 
0011 class QRhiWidgetPrivate;
0012 class QRhi;
0013 class QRhiTexture;
0014 class QRhiRenderBuffer;
0015 class QRhiRenderTarget;
0016 class QRhiCommandBuffer;
0017 
0018 class Q_WIDGETS_EXPORT QRhiWidget : public QWidget
0019 {
0020     Q_OBJECT
0021     Q_DECLARE_PRIVATE(QRhiWidget)
0022     Q_PROPERTY(int sampleCount READ sampleCount WRITE setSampleCount NOTIFY sampleCountChanged)
0023     Q_PROPERTY(TextureFormat colorBufferFormat READ colorBufferFormat WRITE setColorBufferFormat NOTIFY colorBufferFormatChanged)
0024     Q_PROPERTY(QSize fixedColorBufferSize READ fixedColorBufferSize WRITE setFixedColorBufferSize NOTIFY fixedColorBufferSizeChanged)
0025     Q_PROPERTY(bool mirrorVertically READ isMirrorVerticallyEnabled WRITE setMirrorVertically NOTIFY mirrorVerticallyChanged)
0026     QDOC_PROPERTY(bool autoRenderTarget READ isAutoRenderTargetEnabled WRITE setAutoRenderTarget)
0027 
0028 public:
0029     explicit QRhiWidget(QWidget *parent = nullptr, Qt::WindowFlags f = {});
0030     ~QRhiWidget() override;
0031 
0032     enum class Api {
0033         Null,
0034         OpenGL,
0035         Metal,
0036         Vulkan,
0037         Direct3D11,
0038         Direct3D12,
0039     };
0040     Q_ENUM(Api)
0041 
0042     enum class TextureFormat {
0043         RGBA8,
0044         RGBA16F,
0045         RGBA32F,
0046         RGB10A2,
0047     };
0048     Q_ENUM(TextureFormat)
0049 
0050     Api api() const;
0051     void setApi(Api api);
0052 
0053     bool isDebugLayerEnabled() const;
0054     void setDebugLayerEnabled(bool enable);
0055 
0056     int sampleCount() const;
0057     void setSampleCount(int samples);
0058 
0059     TextureFormat colorBufferFormat() const;
0060     void setColorBufferFormat(TextureFormat format);
0061 
0062     QSize fixedColorBufferSize() const;
0063     void setFixedColorBufferSize(QSize pixelSize);
0064     void setFixedColorBufferSize(int w, int h) { setFixedColorBufferSize(QSize(w, h)); }
0065 
0066     bool isMirrorVerticallyEnabled() const;
0067     void setMirrorVertically(bool enabled);
0068 
0069     QImage grabFramebuffer() const;
0070 
0071 protected:
0072     bool isAutoRenderTargetEnabled() const;
0073     void setAutoRenderTarget(bool enabled);
0074 
0075     virtual void initialize(QRhiCommandBuffer *cb);
0076     virtual void render(QRhiCommandBuffer *cb);
0077     virtual void releaseResources();
0078 
0079     QRhi *rhi() const;
0080     QRhiTexture *colorTexture() const;
0081     QRhiRenderBuffer *msaaColorBuffer() const;
0082     QRhiTexture *resolveTexture() const;
0083     QRhiRenderBuffer *depthStencilBuffer() const;
0084     QRhiRenderTarget *renderTarget() const;
0085 
0086     void resizeEvent(QResizeEvent *e) override;
0087     void paintEvent(QPaintEvent *e) override;
0088     bool event(QEvent *e) override;
0089 
0090 Q_SIGNALS:
0091     void frameSubmitted();
0092     void renderFailed();
0093     void sampleCountChanged(int samples);
0094     void colorBufferFormatChanged(TextureFormat format);
0095     void fixedColorBufferSizeChanged(const QSize &pixelSize);
0096     void mirrorVerticallyChanged(bool enabled);
0097 };
0098 
0099 QT_END_NAMESPACE
0100 
0101 #endif