Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsgvideotexture.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QtQuick/qsgmaterial.h>
7#include <QtQuick/qsgtexturematerial.h>
8
10
12{
13 Q_DECLARE_PUBLIC(QSGVideoTexture)
14
15private:
16 QSGVideoTexture *q_ptr = nullptr;
17 QRhiTexture::Format m_format{};
18 QSize m_size;
19 QByteArray m_data;
20 QRhiTexture *m_texture = nullptr;
21};
22
23QSGVideoTexture::QSGVideoTexture()
24 : d_ptr(new QSGVideoTexturePrivate)
25{
26 d_ptr->q_ptr = this;
27
28 // Nearest filtering just looks bad for any text in videos
29 setFiltering(Linear);
30}
31
32QSGVideoTexture::~QSGVideoTexture() = default;
33
34qint64 QSGVideoTexture::comparisonKey() const
35{
36 Q_D(const QSGVideoTexture);
37 if (d->m_texture)
38 return qint64(qintptr(d->m_texture));
39
40 // two textures (and so materials) with not-yet-created texture underneath are never equal
41 return qint64(qintptr(this));
42}
43
44QRhiTexture *QSGVideoTexture::rhiTexture() const
45{
46 return d_func()->m_texture;
47}
48
49QSize QSGVideoTexture::textureSize() const
50{
51 return d_func()->m_size;
52}
53
54bool QSGVideoTexture::hasAlphaChannel() const
55{
56 Q_D(const QSGVideoTexture);
57 return d->m_format == QRhiTexture::RGBA8 || d->m_format == QRhiTexture::BGRA8;
58}
59
60bool QSGVideoTexture::hasMipmaps() const
61{
62 return mipmapFiltering() != QSGTexture::None;
63}
64
65void QSGVideoTexture::setData(QRhiTexture::Format f, const QSize &s, const uchar *data, int bytes)
66{
67 Q_D(QSGVideoTexture);
68 d->m_size = s;
69 d->m_format = f;
70 d->m_data = {reinterpret_cast<const char *>(data), bytes};
71}
72
73void QSGVideoTexture::setRhiTexture(QRhiTexture *texture)
74{
75 d_func()->m_texture = texture;
76}
77
78QT_END_NAMESPACE
Combined button and popup list for selecting options.