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
qsgsoftwarespritenode.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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// Qt-Security score:significant reason:default
4
7#include <QtGui/QPainter>
8
10
11QSGSoftwareSpriteNode::QSGSoftwareSpriteNode()
12{
13 setMaterial((QSGMaterial*)1);
14 setGeometry((QSGGeometry*)1);
15}
16
18{
19 delete m_texture;
20}
21
22void QSGSoftwareSpriteNode::setTexture(QSGTexture *texture)
23{
24 m_texture = qobject_cast<QSGSoftwarePixmapTexture*>(texture);
25 markDirty(DirtyMaterial);
26}
27
29{
30 if (m_time != time) {
31 m_time = time;
32 markDirty(DirtyMaterial);
33 }
34}
35
36void QSGSoftwareSpriteNode::setSourceA(const QPoint &source)
37{
38 if (m_sourceA != source) {
39 m_sourceA = source;
40 markDirty(DirtyMaterial);
41 }
42}
43
44void QSGSoftwareSpriteNode::setSourceB(const QPoint &source)
45{
46 if (m_sourceB != source) {
47 m_sourceB = source;
48 markDirty(DirtyMaterial);
49 }
50}
51
52void QSGSoftwareSpriteNode::setSpriteSize(const QSize &size)
53{
54 if (m_spriteSize != size) {
55 m_spriteSize = size;
56 markDirty(DirtyMaterial);
57 }
58}
59
60void QSGSoftwareSpriteNode::setSheetSize(const QSize &size)
61{
62 if (m_sheetSize != size) {
63 m_sheetSize = size;
64 markDirty(DirtyMaterial);
65 }
66}
67
68void QSGSoftwareSpriteNode::setSize(const QSizeF &size)
69{
70 if (m_size != size) {
71 m_size = size;
72 markDirty(DirtyGeometry);
73 }
74}
75
76void QSGSoftwareSpriteNode::setFiltering(QSGTexture::Filtering filtering)
77{
78 Q_UNUSED(filtering);
79}
80
84
85void QSGSoftwareSpriteNode::paint(QPainter *painter)
86{
87 //Get the pixmap handle from the texture
88 if (!m_texture)
89 return;
90
91 const QPixmap &pixmap = m_texture->pixmap();
92
93 // XXX try to do some kind of interpolation between sourceA and sourceB using time
94 painter->drawPixmap(QRectF(0, 0, m_size.width(), m_size.height()),
95 pixmap,
96 QRectF(m_sourceA * pixmap.devicePixelRatio(), m_spriteSize * pixmap.devicePixelRatio()));
97}
98
100{
101 return false;
102}
103
105{
106 return QRectF(0, 0, m_size.width(), m_size.height());
107}
108
109QT_END_NAMESPACE
void paint(QPainter *painter)
void setSize(const QSizeF &size) override
void setTexture(QSGTexture *texture) override
void setTime(float time) override
void setSourceB(const QPoint &source) override
void setSpriteSize(const QSize &size) override
void setFiltering(QSGTexture::Filtering filtering) override
void setSheetSize(const QSize &size) override
void setSourceA(const QPoint &source) override
Combined button and popup list for selecting options.