41void QSGNinePatchNode::rebuildGeometry(QSGTexture *texture, QSGGeometry *geometry,
const QVector4D &padding,
42 const QRectF &bounds, qreal dpr)
44 if (padding.x() <= 0 && padding.y() <= 0 && padding.z() <= 0 && padding.w() <= 0) {
45 geometry->allocate(4, 0);
46 QSGGeometry::updateTexturedRectGeometry(geometry, bounds, texture->normalizedTextureSubRect());
50 QRectF tc = texture->normalizedTextureSubRect();
51 QSize ts = texture->textureSize();
52 ts.setHeight(ts.height() / dpr);
53 ts.setWidth(ts.width() / dpr);
55 qreal invtw = tc.width() / ts.width();
56 qreal invth = tc.height() / ts.height();
58 struct Coord { qreal p; qreal t; };
59 Coord cx[4] = { { bounds.left(), tc.left() },
60 { bounds.left() + padding.x(), tc.left() + padding.x() * invtw },
61 { bounds.right() - padding.z(), tc.right() - padding.z() * invtw },
62 { bounds.right(), tc.right() }
64 Coord cy[4] = { { bounds.top(), tc.top() },
65 { bounds.top() + padding.y(), tc.top() + padding.y() * invth },
66 { bounds.bottom() - padding.w(), tc.bottom() - padding.w() * invth },
67 { bounds.bottom(), tc.bottom() }
70 geometry->allocate(16, 28);
71 QSGGeometry::TexturedPoint2D *v = geometry->vertexDataAsTexturedPoint2D();
72 for (
int y = 0; y < 4; ++y) {
73 for (
int x = 0; x < 4; ++x) {
74 v->set(cx[x].p, cy[y].p, cx[x].t, cy[y].t);
79 quint16 *i = geometry->indexDataAsUShort();
80 for (
int r = 0; r < 3; ++r) {
83 for (
int c = 0; c < 4; ++c) {