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