56bool QQuickGridMesh::validateAttributes(
const QList<QByteArray> &attributes,
int *posIndex)
58 const int attrCount = attributes.size();
59 int positionIndex = attributes.indexOf(qtPositionAttributeName());
60 int texCoordIndex = attributes.indexOf(qtTexCoordAttributeName());
64 m_log = QLatin1String(
"Error: No attributes specified.");
67 if (positionIndex != 0) {
68 m_log = QLatin1String(
"Error: Missing \'") + QLatin1String(qtPositionAttributeName())
69 + QLatin1String(
"\' attribute.\n");
74 if (positionIndex == -1 || texCoordIndex == -1) {
76 if (positionIndex == -1) {
77 m_log = QLatin1String(
"Error: Missing \'") + QLatin1String(qtPositionAttributeName())
78 + QLatin1String(
"\' attribute.\n");
80 if (texCoordIndex == -1) {
81 m_log += QLatin1String(
"Error: Missing \'") + QLatin1String(qtTexCoordAttributeName())
82 + QLatin1String(
"\' attribute.\n");
88 m_log = QLatin1String(
"Error: Too many attributes specified.");
93 *posIndex = positionIndex;
98QSGGeometry *QQuickGridMesh::updateGeometry(QSGGeometry *geometry,
int attrCount,
int posIndex,
99 const QRectF &srcRect,
const QRectF &dstRect)
101 int vmesh = m_resolution.height();
102 int hmesh = m_resolution.width();
105 Q_ASSERT(attrCount == 1 || attrCount == 2);
106 geometry =
new QSGGeometry(attrCount == 1
107 ? QSGGeometry::defaultAttributes_Point2D()
108 : QSGGeometry::defaultAttributes_TexturedPoint2D(),
109 (vmesh + 1) * (hmesh + 1), vmesh * 2 * (hmesh + 2),
110 QSGGeometry::UnsignedShortType);
113 geometry->allocate((vmesh + 1) * (hmesh + 1), vmesh * 2 * (hmesh + 2));
116 QSGGeometry::Point2D *vdata =
static_cast<QSGGeometry::Point2D *>(geometry->vertexData());
118 for (
int iy = 0; iy <= vmesh; ++iy) {
119 float fy = iy /
float(vmesh);
120 float y =
float(dstRect.top()) + fy *
float(dstRect.height());
121 float ty =
float(srcRect.top()) + fy *
float(srcRect.height());
122 for (
int ix = 0; ix <= hmesh; ++ix) {
123 float fx = ix /
float(hmesh);
124 for (
int ia = 0; ia < attrCount; ++ia) {
125 if (ia == posIndex) {
126 vdata->x =
float(dstRect.left()) + fx *
float(dstRect.width());
130 vdata->x =
float(srcRect.left()) + fx *
float(srcRect.width());
138 quint16 *indices = (quint16 *)geometry->indexDataAsUShort();
140 for (
int iy = 0; iy < vmesh; ++iy) {
141 *(indices++) = i + hmesh + 1;
142 for (
int ix = 0; ix <= hmesh; ++ix, ++i) {
143 *(indices++) = i + hmesh + 1;
146 *(indices++) = i - 1;
296 const QRectF &srcRect,
const QRectF &rect)
301 QRectF innerSourceRect;
303 QRectF innerTargetRect;
304 QRectF subSourceRect;
306 QQuickBorderImagePrivate::calculateRects(m_border, m_size, rect.size(), m_horizontalTileMode, m_verticalTileMode,
307 1, &targetRect, &innerTargetRect, &innerSourceRect, &subSourceRect);
309 QRectF sourceRect = srcRect;
310 QRectF modifiedInnerSourceRect(sourceRect.x() + innerSourceRect.x() * sourceRect.width(),
311 sourceRect.y() + innerSourceRect.y() * sourceRect.height(),
312 innerSourceRect.width() * sourceRect.width(),
313 innerSourceRect.height() * sourceRect.height());
315 geometry = QSGBasicInternalImageNode::updateGeometry(targetRect, innerTargetRect, sourceRect,
316 modifiedInnerSourceRect, subSourceRect, geometry);