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
4#include "qsgdefaultninepatchnode_p.h"
5
6QT_BEGIN_NAMESPACE
7
8QSGDefaultNinePatchNode::QSGDefaultNinePatchNode()
9 : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
10{
11 m_geometry.setDrawingMode(QSGGeometry::DrawTriangleStrip);
12 setGeometry(&m_geometry);
13 setMaterial(&m_material);
14}
15
16QSGDefaultNinePatchNode::~QSGDefaultNinePatchNode()
17{
18 delete m_material.texture();
19}
20
21void QSGDefaultNinePatchNode::setTexture(QSGTexture *texture)
22{
23 delete m_material.texture();
24 m_material.setTexture(texture);
25}
26
27void QSGDefaultNinePatchNode::setBounds(const QRectF &bounds)
28{
29 m_bounds = bounds;
30}
31
32void QSGDefaultNinePatchNode::setDevicePixelRatio(qreal ratio)
33{
34 m_devicePixelRatio = ratio;
35}
36
37void QSGDefaultNinePatchNode::setPadding(qreal left, qreal top, qreal right, qreal bottom)
38{
39 m_padding = QVector4D(left, top, right, bottom);
40}
41
42void QSGDefaultNinePatchNode::update()
43{
44 rebuildGeometry(texture: m_material.texture(), geometry: &m_geometry, padding: m_padding, bounds: m_bounds, dpr: m_devicePixelRatio);
45 markDirty(bits: QSGNode::DirtyGeometry | QSGNode::DirtyMaterial);
46}
47
48QT_END_NAMESPACE
49

source code of qtdeclarative/src/quick/scenegraph/util/qsgdefaultninepatchnode.cpp