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
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
11{
12 setMaterial((QSGMaterial*)1);
13 setGeometry((QSGGeometry*)1);
14}
15
17{
18 delete m_texture;
19}
20
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
36{
37 if (m_sourceA != source) {
38 m_sourceA = source;
39 markDirty(DirtyMaterial);
40 }
41}
42
44{
45 if (m_sourceB != source) {
46 m_sourceB = source;
47 markDirty(DirtyMaterial);
48 }
49}
50
52{
53 if (m_spriteSize != size) {
54 m_spriteSize = size;
55 markDirty(DirtyMaterial);
56 }
57}
58
60{
61 if (m_sheetSize != size) {
62 m_sheetSize = size;
63 markDirty(DirtyMaterial);
64 }
65}
66
68{
69 if (m_size != size) {
70 m_size = size;
71 markDirty(DirtyGeometry);
72 }
73}
74
79
83
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
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:484
The QSGGeometry class provides low-level storage for graphics primitives in the \l{Qt Quick Scene Gra...
Definition qsggeometry.h:15
The QSGMaterial class encapsulates rendering state for a shader program.
Definition qsgmaterial.h:15
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
\inmodule QtQuick
Definition qsgtexture.h:20
Filtering
Specifies how sampling of texels should filter when texture coordinates are not pixel aligned.
Definition qsgtexture.h:34
\inmodule QtCore
Definition qsize.h:208
constexpr qreal width() const noexcept
Returns the width.
Definition qsize.h:332
constexpr qreal height() const noexcept
Returns the height.
Definition qsize.h:335
\inmodule QtCore
Definition qsize.h:25
Combined button and popup list for selecting options.
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint texture
GLsizei GLsizei GLchar * source
#define Q_UNUSED(x)
widget render & pixmap
QPainter painter(this)
[7]