aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/util
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-06-29 16:09:46 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-08-03 16:32:30 +0200
commitfb96109bbc2ec5d83171a70d6c164d79695d2ddd (patch)
treeba31b5ab614cd57695b43860ddae3eae6e508a54 /src/quick/scenegraph/util
parent6826b2decc21cbf390076efa3a0d6c412563f94a (diff)
Add type safe native texture accessors
Following the pattern from QtGui. Task-number: QTBUG-85239 Change-Id: I07b4456028d0f45223ad10e55ce65f423bab6a9b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/quick/scenegraph/util')
-rw-r--r--src/quick/scenegraph/util/qsgdefaultpainternode.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgplaintexture.cpp10
-rw-r--r--src/quick/scenegraph/util/qsgplaintexture_p.h7
-rw-r--r--src/quick/scenegraph/util/qsgrhiatlastexture.cpp2
4 files changed, 10 insertions, 11 deletions
diff --git a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
index 83bdc42687..844247521e 100644
--- a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
+++ b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
#define QT_MINIMUM_DYNAMIC_FBO_SIZE 64U
QSGPainterTexture::QSGPainterTexture()
- : QSGPlainTexture(*(new QSGPlainTexturePrivate))
+ : QSGPlainTexture(*(new QSGPlainTexturePrivate(this)))
{
m_retain_image = true;
}
diff --git a/src/quick/scenegraph/util/qsgplaintexture.cpp b/src/quick/scenegraph/util/qsgplaintexture.cpp
index 9069804b35..030a496e33 100644
--- a/src/quick/scenegraph/util/qsgplaintexture.cpp
+++ b/src/quick/scenegraph/util/qsgplaintexture.cpp
@@ -51,7 +51,7 @@
QT_BEGIN_NAMESPACE
QSGPlainTexture::QSGPlainTexture()
- : QSGTexture(*(new QSGPlainTexturePrivate))
+ : QSGTexture(*(new QSGPlainTexturePrivate(this)))
, m_texture(nullptr)
, m_has_alpha(false)
, m_dirty_texture(false)
@@ -100,12 +100,10 @@ void QSGPlainTexture::setTexture(QRhiTexture *texture) // RHI only
m_mipmaps_generated = false;
}
-void QSGPlainTexture::setTextureFromNativeObject(QRhi *rhi, QQuickWindow::NativeObjectType type,
- quint64 nativeObjectHandle, int nativeLayout,
- const QSize &size, bool mipmap)
+void QSGPlainTexture::setTextureFromNativeTexture(QRhi *rhi,
+ quint64 nativeObjectHandle, int nativeLayout,
+ const QSize &size, bool mipmap)
{
- Q_UNUSED(type);
-
QRhiTexture::Flags flags;
if (mipmap)
flags |= QRhiTexture::MipMapped | QRhiTexture::UsedWithGenerateMips;
diff --git a/src/quick/scenegraph/util/qsgplaintexture_p.h b/src/quick/scenegraph/util/qsgplaintexture_p.h
index 58a22cbfcf..33f47f7fa0 100644
--- a/src/quick/scenegraph/util/qsgplaintexture_p.h
+++ b/src/quick/scenegraph/util/qsgplaintexture_p.h
@@ -87,9 +87,9 @@ public:
void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
void setTexture(QRhiTexture *texture);
- void setTextureFromNativeObject(QRhi *rhi, QQuickWindow::NativeObjectType type,
- quint64 nativeObjectHandle, int nativeLayout,
- const QSize &size, bool mipmap);
+ void setTextureFromNativeTexture(QRhi *rhi,
+ quint64 nativeObjectHandle, int nativeLayout,
+ const QSize &size, bool mipmap);
static QSGPlainTexture *fromImage(const QImage &image) {
QSGPlainTexture *t = new QSGPlainTexture();
@@ -119,6 +119,7 @@ class QSGPlainTexturePrivate : public QSGTexturePrivate
{
Q_DECLARE_PUBLIC(QSGPlainTexture)
public:
+ QSGPlainTexturePrivate(QSGTexture *t) : QSGTexturePrivate(t) { }
QSGTexture::Filtering m_last_mipmap_filter = QSGTexture::None;
};
diff --git a/src/quick/scenegraph/util/qsgrhiatlastexture.cpp b/src/quick/scenegraph/util/qsgrhiatlastexture.cpp
index 82aa680faf..10c8f934f8 100644
--- a/src/quick/scenegraph/util/qsgrhiatlastexture.cpp
+++ b/src/quick/scenegraph/util/qsgrhiatlastexture.cpp
@@ -338,7 +338,7 @@ void Atlas::enqueueTextureUpload(TextureBase *t, QRhiResourceUpdateBatch *resour
}
TextureBase::TextureBase(AtlasBase *atlas, const QRect &textureRect)
- : QSGTexture(*(new QSGTexturePrivate))
+ : QSGTexture(*(new QSGTexturePrivate(this)))
, m_allocated_rect(textureRect)
, m_atlas(atlas)
{