Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#include "qsgvideotexture_p.h"
5#include <QtQuick/qsgtexturematerial.h>
6#include <QtQuick/qsgmaterial.h>
7
9
11{
12 Q_DECLARE_PUBLIC(QSGVideoTexture)
13
14private:
15 QSGVideoTexture *q_ptr = nullptr;
16 QRhiTexture::Format m_format;
17 QSize m_size;
18 QByteArray m_data;
19 QRhiTexture *m_texture = nullptr;
20};
21
23 : d_ptr(new QSGVideoTexturePrivate)
24{
25 d_ptr->q_ptr = this;
26
27 // Nearest filtering just looks bad for any text in videos
29}
30
32
34{
35 Q_D(const QSGVideoTexture);
36 if (d->m_texture)
37 return qint64(qintptr(d->m_texture));
38
39 // two textures (and so materials) with not-yet-created texture underneath are never equal
40 return qint64(qintptr(this));
41}
42
44{
45 return d_func()->m_texture;
46}
47
49{
50 return d_func()->m_size;
51}
52
54{
55 Q_D(const QSGVideoTexture);
56 return d->m_format == QRhiTexture::RGBA8 || d->m_format == QRhiTexture::BGRA8;
57}
58
63
65{
66 Q_D(QSGVideoTexture);
67 d->m_size = s;
68 d->m_format = f;
69 d->m_data = {reinterpret_cast<const char *>(data), bytes};
70}
71
73{
74 d_func()->m_texture = texture;
75}
76
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtGui
Definition qrhi.h:895
Format
Specifies the texture format.
Definition qrhi.h:914
QSGTexture::Filtering mipmapFiltering() const
Returns whether mipmapping should be used when sampling from this texture.
void setFiltering(Filtering filter)
Sets the sampling mode to filter.
QScopedPointer< QSGVideoTexturePrivate > d_ptr
QRhiTexture * rhiTexture() const override
bool hasAlphaChannel() const override
Returns true if the texture data contains an alpha channel.
qint64 comparisonKey() const override
Returns a key suitable for comparing textures.
QSize textureSize() const override
Returns the size of the texture in pixels.
bool hasMipmaps() const override
Returns true if the texture data contains mipmap levels.
void setData(QRhiTexture::Format f, const QSize &s, const uchar *data, int bytes)
void setRhiTexture(QRhiTexture *texture)
\inmodule QtCore
Definition qsize.h:25
Combined button and popup list for selecting options.
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat f
GLenum GLuint texture
GLdouble s
[6]
Definition qopenglext.h:235
unsigned char uchar
Definition qtypes.h:32
long long qint64
Definition qtypes.h:60
ptrdiff_t qintptr
Definition qtypes.h:166