QRhiWidget: Add a protected constructor
This can be useful for QRhiWidget subclasses with PIMPL. Also add Q_WIDGETS_EXPORT for QRhiWidgetPrivate. Change-Id: Idec480454dca59313f8baaa8d6369cb4a85ea567 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
0b044e8b05
commit
8386dfee05
@ -174,18 +174,36 @@ QRhiWidget::QRhiWidget(QWidget *parent, Qt::WindowFlags f)
|
||||
: QWidget(*(new QRhiWidgetPrivate), parent, f)
|
||||
{
|
||||
Q_D(QRhiWidget);
|
||||
d->init();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
*/
|
||||
QRhiWidget::QRhiWidget(QRhiWidgetPrivate &dd, QWidget *parent, Qt::WindowFlags f)
|
||||
: QWidget(dd, parent, f)
|
||||
{
|
||||
Q_D(QRhiWidget);
|
||||
d->init();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
*/
|
||||
void QRhiWidgetPrivate::init()
|
||||
{
|
||||
if (Q_UNLIKELY(!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RhiBasedRendering)))
|
||||
qWarning("QRhiWidget: QRhi is not supported on this platform.");
|
||||
else
|
||||
d->setRenderToTexture();
|
||||
setRenderToTexture();
|
||||
|
||||
d->config.setEnabled(true);
|
||||
config.setEnabled(true);
|
||||
#if defined(Q_OS_DARWIN)
|
||||
d->config.setApi(QPlatformBackingStoreRhiConfig::Metal);
|
||||
config.setApi(QPlatformBackingStoreRhiConfig::Metal);
|
||||
#elif defined(Q_OS_WIN)
|
||||
d->config.setApi(QPlatformBackingStoreRhiConfig::D3D11);
|
||||
config.setApi(QPlatformBackingStoreRhiConfig::D3D11);
|
||||
#else
|
||||
d->config.setApi(QPlatformBackingStoreRhiConfig::OpenGL);
|
||||
config.setApi(QPlatformBackingStoreRhiConfig::OpenGL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,8 @@ public:
|
||||
QImage grabFramebuffer() const;
|
||||
|
||||
protected:
|
||||
QRhiWidget(QRhiWidgetPrivate &dd, QWidget *parent = nullptr, Qt::WindowFlags f = {});
|
||||
|
||||
bool isAutoRenderTargetEnabled() const;
|
||||
void setAutoRenderTarget(bool enabled);
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QRhiWidgetPrivate : public QWidgetPrivate
|
||||
class Q_WIDGETS_EXPORT QRhiWidgetPrivate : public QWidgetPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QRhiWidget)
|
||||
public:
|
||||
@ -32,6 +32,7 @@ public:
|
||||
void endCompose() override;
|
||||
QImage grabFramebuffer() override;
|
||||
|
||||
void init();
|
||||
void ensureRhi();
|
||||
void ensureTexture(bool *changed);
|
||||
bool invokeInitialize(QRhiCommandBuffer *cb);
|
||||
|
Loading…
x
Reference in New Issue
Block a user