aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/util
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2021-01-11 15:41:39 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2021-01-14 10:12:13 +0100
commitc2c180e4ee58f8cfc104207b3b56e83ddcb7e79a (patch)
tree9473794cc5d112ee383032380a48aaad6901c670 /src/quick/scenegraph/util
parent653d5a4745ad2f20ae924527b7b31580eedc651b (diff)
Enable importing OpenGL textures for the GL_TEXTURE_EXTERNAL_OES target
Introduce a QSGOpenGLTexture::fromNativeExternalOES() function which internally passes in the flag QRhiTexture::ExternalOES when creating the wrapping QRhiTexture. Change-Id: I919e2539304d3aeaa6bc8e5953d96adc810abb12 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/scenegraph/util')
-rw-r--r--src/quick/scenegraph/util/qsgplaintexture.cpp17
-rw-r--r--src/quick/scenegraph/util/qsgplaintexture_p.h9
2 files changed, 17 insertions, 9 deletions
diff --git a/src/quick/scenegraph/util/qsgplaintexture.cpp b/src/quick/scenegraph/util/qsgplaintexture.cpp
index 030a496e33..6e59f9e607 100644
--- a/src/quick/scenegraph/util/qsgplaintexture.cpp
+++ b/src/quick/scenegraph/util/qsgplaintexture.cpp
@@ -101,14 +101,19 @@ void QSGPlainTexture::setTexture(QRhiTexture *texture) // RHI only
}
void QSGPlainTexture::setTextureFromNativeTexture(QRhi *rhi,
- quint64 nativeObjectHandle, int nativeLayout,
- const QSize &size, bool mipmap)
+ quint64 nativeObjectHandle,
+ int nativeLayout,
+ const QSize &size,
+ QQuickWindow::CreateTextureOptions options,
+ QQuickWindowPrivate::TextureFromNativeTextureFlags flags)
{
- QRhiTexture::Flags flags;
- if (mipmap)
- flags |= QRhiTexture::MipMapped | QRhiTexture::UsedWithGenerateMips;
+ QRhiTexture::Flags texFlags;
+ if (options.testFlag(QQuickWindow::TextureHasMipmaps))
+ texFlags |= QRhiTexture::MipMapped | QRhiTexture::UsedWithGenerateMips;
+ if (flags.testFlag(QQuickWindowPrivate::NativeTextureIsExternalOES))
+ texFlags |= QRhiTexture::ExternalOES;
- QRhiTexture *t = rhi->newTexture(QRhiTexture::RGBA8, size, 1, flags);
+ QRhiTexture *t = rhi->newTexture(QRhiTexture::RGBA8, size, 1, texFlags);
// ownership of the native object is never taken
t->createFrom({nativeObjectHandle, nativeLayout});
diff --git a/src/quick/scenegraph/util/qsgplaintexture_p.h b/src/quick/scenegraph/util/qsgplaintexture_p.h
index 33f47f7fa0..56e0492afa 100644
--- a/src/quick/scenegraph/util/qsgplaintexture_p.h
+++ b/src/quick/scenegraph/util/qsgplaintexture_p.h
@@ -53,7 +53,7 @@
#include <QtQuick/private/qtquickglobal_p.h>
#include <QtQuick/private/qsgtexture_p.h>
-#include <QtQuick/qquickwindow.h>
+#include <QtQuick/private/qquickwindow_p.h>
QT_BEGIN_NAMESPACE
@@ -88,8 +88,11 @@ public:
void setTexture(QRhiTexture *texture);
void setTextureFromNativeTexture(QRhi *rhi,
- quint64 nativeObjectHandle, int nativeLayout,
- const QSize &size, bool mipmap);
+ quint64 nativeObjectHandle,
+ int nativeLayout,
+ const QSize &size,
+ QQuickWindow::CreateTextureOptions options,
+ QQuickWindowPrivate::TextureFromNativeTextureFlags flags);
static QSGPlainTexture *fromImage(const QImage &image) {
QSGPlainTexture *t = new QSGPlainTexture();