1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtQml module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "qsgdefaultimagenode_p.h"
44 #include <QtCore/qvarlengtharray.h>
45 #include <QtCore/qmath.h>
46 #include <QtGui/qopenglfunctions.h>
48 #include <qsgtexturematerial.h>
49 #include <private/qsgtexturematerial_p.h>
50 #include <qsgmaterial.h>
62 const QSGGeometry::AttributeSet &smoothAttributeSet()
64 static QSGGeometry::Attribute data[] = {
65 QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true),
66 QSGGeometry::Attribute::create(1, 2, GL_FLOAT, false),
67 QSGGeometry::Attribute::create(2, 2, GL_FLOAT, false),
68 QSGGeometry::Attribute::create(3, 2, GL_FLOAT, false)
70 static QSGGeometry::AttributeSet attrs = { 4, sizeof(SmoothVertex), data };
75 class SmoothTextureMaterialShader : public QSGTextureMaterialShader
78 virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect);
79 virtual char const *const *attributeNames() const;
82 virtual void initialize();
83 virtual const char *vertexShader() const;
84 virtual const char *fragmentShader() const;
90 SmoothTextureMaterial::SmoothTextureMaterial()
92 setFlag(RequiresFullMatrixExceptTranslate, true);
93 setFlag(Blending, true);
96 void SmoothTextureMaterial::setTexture(QSGTexture *texture)
101 QSGMaterialType *SmoothTextureMaterial::type() const
103 static QSGMaterialType type;
107 QSGMaterialShader *SmoothTextureMaterial::createShader() const
109 return new SmoothTextureMaterialShader;
112 void SmoothTextureMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
114 if (oldEffect == 0) {
115 // The viewport is constant, so set the pixel size uniform only once.
116 QRect r = state.viewportRect();
117 program()->setUniformValue(m_pixelSizeLoc, 2.0f / r.width(), 2.0f / r.height());
119 QSGTextureMaterialShader::updateState(state, newEffect, oldEffect);
122 char const *const *SmoothTextureMaterialShader::attributeNames() const
124 static char const *const attributes[] = {
134 void SmoothTextureMaterialShader::initialize()
136 m_pixelSizeLoc = program()->uniformLocation("pixelSize");
137 QSGTextureMaterialShader::initialize();
140 const char *SmoothTextureMaterialShader::vertexShader() const
143 "uniform highp vec2 pixelSize; \n"
144 "uniform highp mat4 qt_Matrix; \n"
145 "uniform lowp float opacity; \n"
146 "attribute highp vec4 vertex; \n"
147 "attribute highp vec2 multiTexCoord; \n"
148 "attribute highp vec2 vertexOffset; \n"
149 "attribute highp vec2 texCoordOffset; \n"
150 "varying highp vec2 texCoord; \n"
151 "varying lowp float vertexOpacity; \n"
153 " highp vec4 pos = qt_Matrix * vertex; \n"
154 " gl_Position = pos; \n"
155 " texCoord = multiTexCoord; \n"
157 " if (vertexOffset.x != 0.) { \n"
158 " highp vec4 delta = qt_Matrix[0] * vertexOffset.x; \n"
159 " highp vec2 dir = delta.xy * pos.w - pos.xy * delta.w; \n"
160 " highp vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize); \n"
161 " dir -= ndir * delta.w * pos.w; \n"
162 " highp float scale = min(1., dot(dir, ndir * pos.w * pos.w) / dot(dir, dir)); \n"
163 " if (scale < 0.) scale = 1.; \n"
164 " gl_Position += scale * delta; \n"
165 " texCoord.x += scale * texCoordOffset.x; \n"
168 " if (vertexOffset.y != 0.) { \n"
169 " highp vec4 delta = qt_Matrix[1] * vertexOffset.y; \n"
170 " highp vec2 dir = delta.xy * pos.w - pos.xy * delta.w; \n"
171 " highp vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize); \n"
172 " dir -= ndir * delta.w * pos.w; \n"
173 " highp float scale = min(1., dot(dir, ndir * pos.w * pos.w) / dot(dir, dir)); \n"
174 " if (scale < 0.) scale = 1.; \n"
175 " gl_Position += scale * delta; \n"
176 " texCoord.y += scale * texCoordOffset.y; \n"
179 " bool onEdge = any(notEqual(vertexOffset, vec2(0.))); \n"
180 " bool outerEdge = all(equal(texCoordOffset, vec2(0.))); \n"
181 " vertexOpacity = onEdge && outerEdge ? 0. : opacity; \n"
185 const char *SmoothTextureMaterialShader::fragmentShader() const
188 "uniform sampler2D qt_Texture; \n"
189 "varying highp vec2 texCoord; \n"
190 "varying lowp float vertexOpacity; \n"
192 " gl_FragColor = texture2D(qt_Texture, texCoord) * vertexOpacity; \n"
196 QSGDefaultImageNode::QSGDefaultImageNode()
197 : m_innerSourceRect(0, 0, 1, 1)
198 , m_subSourceRect(0, 0, 1, 1)
199 , m_antialiasing(false)
201 , m_dirtyGeometry(false)
202 , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
204 setMaterial(&m_materialO);
205 setOpaqueMaterial(&m_material);
206 setGeometry(&m_geometry);
208 #ifdef QML_RUNTIME_TESTING
209 description = QLatin1String("image");
213 void QSGDefaultImageNode::setTargetRect(const QRectF &rect)
215 if (rect == m_targetRect)
218 m_dirtyGeometry = true;
221 void QSGDefaultImageNode::setInnerTargetRect(const QRectF &rect)
223 if (rect == m_innerTargetRect)
225 m_innerTargetRect = rect;
226 m_dirtyGeometry = true;
229 void QSGDefaultImageNode::setInnerSourceRect(const QRectF &rect)
231 if (rect == m_innerSourceRect)
233 m_innerSourceRect = rect;
234 m_dirtyGeometry = true;
237 void QSGDefaultImageNode::setSubSourceRect(const QRectF &rect)
239 if (rect == m_subSourceRect)
241 m_subSourceRect = rect;
242 m_dirtyGeometry = true;
245 void QSGDefaultImageNode::setFiltering(QSGTexture::Filtering filtering)
247 if (m_material.filtering() == filtering)
250 m_material.setFiltering(filtering);
251 m_materialO.setFiltering(filtering);
252 m_smoothMaterial.setFiltering(filtering);
253 markDirty(DirtyMaterial);
257 void QSGDefaultImageNode::setMipmapFiltering(QSGTexture::Filtering filtering)
259 if (m_material.mipmapFiltering() == filtering)
262 m_material.setMipmapFiltering(filtering);
263 m_materialO.setMipmapFiltering(filtering);
264 m_smoothMaterial.setMipmapFiltering(filtering);
265 markDirty(DirtyMaterial);
268 void QSGDefaultImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode)
270 if (m_material.verticalWrapMode() == wrapMode)
273 m_material.setVerticalWrapMode(wrapMode);
274 m_materialO.setVerticalWrapMode(wrapMode);
275 m_smoothMaterial.setVerticalWrapMode(wrapMode);
276 markDirty(DirtyMaterial);
279 void QSGDefaultImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode)
281 if (m_material.horizontalWrapMode() == wrapMode)
284 m_material.setHorizontalWrapMode(wrapMode);
285 m_materialO.setHorizontalWrapMode(wrapMode);
286 m_smoothMaterial.setHorizontalWrapMode(wrapMode);
287 markDirty(DirtyMaterial);
291 void QSGDefaultImageNode::setTexture(QSGTexture *texture)
293 if (texture == m_material.texture())
296 m_material.setTexture(texture);
297 m_materialO.setTexture(texture);
298 m_smoothMaterial.setTexture(texture);
300 // if (!texture.isNull())
301 // m_material.setBlending(texture->hasAlphaChannel());
302 markDirty(DirtyMaterial);
304 // Because the texture can be a different part of the atlas, we need to update it...
305 m_dirtyGeometry = true;
308 void QSGDefaultImageNode::setAntialiasing(bool antialiasing)
310 if (antialiasing == m_antialiasing)
312 m_antialiasing = antialiasing;
313 if (m_antialiasing) {
314 setMaterial(&m_smoothMaterial);
315 setOpaqueMaterial(0);
316 setGeometry(new QSGGeometry(smoothAttributeSet(), 0));
317 setFlag(OwnsGeometry, true);
319 setMaterial(&m_materialO);
320 setOpaqueMaterial(&m_material);
321 setGeometry(&m_geometry);
322 setFlag(OwnsGeometry, false);
324 m_dirtyGeometry = true;
327 void QSGDefaultImageNode::setMirror(bool mirror)
329 if (mirror == m_mirror)
332 m_dirtyGeometry = true;
336 void QSGDefaultImageNode::update()
342 void QSGDefaultImageNode::preprocess()
344 bool doDirty = false;
345 QSGDynamicTexture *t = qobject_cast<QSGDynamicTexture *>(m_material.texture());
347 doDirty = t->updateTexture();
350 // ### texture cleanup
351 // bool alpha = m_material.blending();
352 // if (!m_material->texture().isNull() && alpha != m_material.texture()->hasAlphaChannel()) {
353 // m_material.setBlending(!alpha);
358 markDirty(DirtyMaterial);
361 inline static bool isPowerOfTwo(int x)
363 // Assumption: x >= 1
364 return x == (x & -x);
368 struct X { float x, tx; };
369 struct Y { float y, ty; };
372 static inline void appendQuad(quint16 **indices, quint16 topLeft, quint16 topRight,
373 quint16 bottomLeft, quint16 bottomRight)
375 *(*indices)++ = topLeft;
376 *(*indices)++ = bottomLeft;
377 *(*indices)++ = bottomRight;
378 *(*indices)++ = bottomRight;
379 *(*indices)++ = topRight;
380 *(*indices)++ = topLeft;
383 void QSGDefaultImageNode::updateGeometry()
385 Q_ASSERT(!m_targetRect.isEmpty());
386 const QSGTexture *t = m_material.texture();
388 QSGGeometry *g = geometry();
390 g->setDrawingMode(GL_TRIANGLE_STRIP);
391 memset(g->vertexData(), 0, g->sizeOfVertex() * 4);
393 QRectF sourceRect = t->normalizedTextureSubRect();
395 QRectF innerSourceRect(sourceRect.x() + m_innerSourceRect.x() * sourceRect.width(),
396 sourceRect.y() + m_innerSourceRect.y() * sourceRect.height(),
397 m_innerSourceRect.width() * sourceRect.width(),
398 m_innerSourceRect.height() * sourceRect.height());
400 bool hasMargins = m_targetRect != m_innerTargetRect;
402 int floorLeft = qFloor(m_subSourceRect.left());
403 int ceilRight = qCeil(m_subSourceRect.right());
404 int floorTop = qFloor(m_subSourceRect.top());
405 int ceilBottom = qCeil(m_subSourceRect.bottom());
406 int hTiles = ceilRight - floorLeft;
407 int vTiles = ceilBottom - floorTop;
409 bool hasTiles = hTiles != 1 || vTiles != 1;
410 bool fullTexture = innerSourceRect == QRectF(0, 0, 1, 1);
412 #ifdef QT_OPENGL_ES_2
413 QOpenGLContext *ctx = QOpenGLContext::currentContext();
414 bool npotSupported = ctx->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat);
415 QSize size = t->textureSize();
416 bool isNpot = !isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height());
417 bool wrapSupported = npotSupported || !isNpot;
419 bool wrapSupported = true;
422 // An image can be rendered as a single quad if:
423 // - There are no margins, and either:
424 // - the image isn't repeated
425 // - the source rectangle fills the entire texture so that texture wrapping can be used,
426 // and NPOT is supported
427 if (!hasMargins && (!hasTiles || (fullTexture && wrapSupported))) {
430 sr = QRectF(innerSourceRect.x() + (m_subSourceRect.left() - floorLeft) * innerSourceRect.width(),
431 innerSourceRect.y() + (m_subSourceRect.top() - floorTop) * innerSourceRect.height(),
432 m_subSourceRect.width() * innerSourceRect.width(),
433 m_subSourceRect.height() * innerSourceRect.height());
435 sr = QRectF(m_subSourceRect.left() - floorLeft, m_subSourceRect.top() - floorTop,
436 m_subSourceRect.width(), m_subSourceRect.height());
439 qreal oldLeft = sr.left();
440 sr.setLeft(sr.right());
441 sr.setRight(oldLeft);
444 if (m_antialiasing) {
445 QSGGeometry *g = geometry();
446 Q_ASSERT(g != &m_geometry);
448 g->setDrawingMode(GL_TRIANGLE_STRIP);
449 SmoothVertex *vertices = reinterpret_cast<SmoothVertex *>(g->vertexData());
450 float delta = float(qAbs(m_targetRect.width()) < qAbs(m_targetRect.height())
451 ? m_targetRect.width() : m_targetRect.height()) * 0.5f;
452 float sx = float(sr.width() / m_targetRect.width());
453 float sy = float(sr.height() / m_targetRect.height());
454 for (int d = -1; d <= 1; d += 2) {
455 for (int j = 0; j < 2; ++j) {
456 for (int i = 0; i < 2; ++i, ++vertices) {
457 vertices->x = m_targetRect.x() + i * m_targetRect.width();
458 vertices->y = m_targetRect.y() + j * m_targetRect.height();
459 vertices->u = sr.x() + i * sr.width();
460 vertices->v = sr.y() + j * sr.height();
461 vertices->dx = (i == 0 ? delta : -delta) * d;
462 vertices->dy = (j == 0 ? delta : -delta) * d;
463 vertices->du = (d < 0 ? 0 : vertices->dx * sx);
464 vertices->dv = (d < 0 ? 0 : vertices->dy * sy);
468 Q_ASSERT(vertices - g->vertexCount() == g->vertexData());
469 static const quint16 indices[] = {
470 0, 4, 1, 5, 3, 7, 2, 6, 0, 4,
473 Q_ASSERT(g->sizeOfIndex() * g->indexCount() == sizeof(indices));
474 memcpy(g->indexDataAsUShort(), indices, sizeof(indices));
476 m_geometry.allocate(4);
477 m_geometry.setDrawingMode(GL_TRIANGLE_STRIP);
478 QSGGeometry::updateTexturedRectGeometry(&m_geometry, m_targetRect, sr);
483 if (m_innerTargetRect.width() == 0)
485 if (m_innerTargetRect.left() != m_targetRect.left())
487 if (m_innerTargetRect.right() != m_targetRect.right())
489 if (m_innerTargetRect.height() == 0)
491 if (m_innerTargetRect.top() != m_targetRect.top())
493 if (m_innerTargetRect.bottom() != m_targetRect.bottom())
495 QVarLengthArray<X, 32> xData(2 * hCells);
496 QVarLengthArray<Y, 32> yData(2 * vCells);
497 X *xs = xData.data();
498 Y *ys = yData.data();
500 if (m_innerTargetRect.left() != m_targetRect.left()) {
501 xs[0].x = m_targetRect.left();
502 xs[0].tx = sourceRect.left();
503 xs[1].x = m_innerTargetRect.left();
504 xs[1].tx = innerSourceRect.left();
507 if (m_innerTargetRect.width() != 0) {
508 xs[0].x = m_innerTargetRect.left();
509 xs[0].tx = innerSourceRect.x() + (m_subSourceRect.left() - floorLeft) * innerSourceRect.width();
511 float b = m_innerTargetRect.width() / m_subSourceRect.width();
512 float a = m_innerTargetRect.x() - m_subSourceRect.x() * b;
513 for (int i = floorLeft + 1; i <= ceilRight - 1; ++i) {
514 xs[0].x = xs[1].x = a + b * i;
515 xs[0].tx = innerSourceRect.right();
516 xs[1].tx = innerSourceRect.left();
519 xs[0].x = m_innerTargetRect.right();
520 xs[0].tx = innerSourceRect.x() + (m_subSourceRect.right() - ceilRight + 1) * innerSourceRect.width();
523 if (m_innerTargetRect.right() != m_targetRect.right()) {
524 xs[0].x = m_innerTargetRect.right();
525 xs[0].tx = innerSourceRect.right();
526 xs[1].x = m_targetRect.right();
527 xs[1].tx = sourceRect.right();
530 Q_ASSERT(xs == xData.data() + xData.size());
532 float leftPlusRight = m_targetRect.left() + m_targetRect.right();
533 int count = xData.size();
535 for (int i = 0; i < count >> 1; ++i)
536 qSwap(xs[i], xs[count - 1 - i]);
537 for (int i = 0; i < count; ++i)
538 xs[i].x = leftPlusRight - xs[i].x;
541 if (m_innerTargetRect.top() != m_targetRect.top()) {
542 ys[0].y = m_targetRect.top();
543 ys[0].ty = sourceRect.top();
544 ys[1].y = m_innerTargetRect.top();
545 ys[1].ty = innerSourceRect.top();
548 if (m_innerTargetRect.height() != 0) {
549 ys[0].y = m_innerTargetRect.top();
550 ys[0].ty = innerSourceRect.y() + (m_subSourceRect.top() - floorTop) * innerSourceRect.height();
552 float b = m_innerTargetRect.height() / m_subSourceRect.height();
553 float a = m_innerTargetRect.y() - m_subSourceRect.y() * b;
554 for (int i = floorTop + 1; i <= ceilBottom - 1; ++i) {
555 ys[0].y = ys[1].y = a + b * i;
556 ys[0].ty = innerSourceRect.bottom();
557 ys[1].ty = innerSourceRect.top();
560 ys[0].y = m_innerTargetRect.bottom();
561 ys[0].ty = innerSourceRect.y() + (m_subSourceRect.bottom() - ceilBottom + 1) * innerSourceRect.height();
564 if (m_innerTargetRect.bottom() != m_targetRect.bottom()) {
565 ys[0].y = m_innerTargetRect.bottom();
566 ys[0].ty = innerSourceRect.bottom();
567 ys[1].y = m_targetRect.bottom();
568 ys[1].ty = sourceRect.bottom();
571 Q_ASSERT(ys == yData.data() + yData.size());
573 if (m_antialiasing) {
574 QSGGeometry *g = geometry();
575 Q_ASSERT(g != &m_geometry);
577 g->allocate(hCells * vCells * 4 + (hCells + vCells - 1) * 4,
578 hCells * vCells * 6 + (hCells + vCells) * 12);
579 g->setDrawingMode(GL_TRIANGLES);
580 SmoothVertex *vertices = reinterpret_cast<SmoothVertex *>(g->vertexData());
581 memset(vertices, 0, g->vertexCount() * g->sizeOfVertex());
582 quint16 *indices = g->indexDataAsUShort();
584 // The deltas are how much the fuzziness can reach into the image.
585 // Only the border vertices are moved by the vertex shader, so the fuzziness
586 // can't reach further into the image than the closest interior vertices.
587 float leftDx = xData.at(1).x - xData.at(0).x;
588 float rightDx = xData.at(xData.size() - 1).x - xData.at(xData.size() - 2).x;
589 float topDy = yData.at(1).y - yData.at(0).y;
590 float bottomDy = yData.at(yData.size() - 1).y - yData.at(yData.size() - 2).y;
592 float leftDu = xData.at(1).tx - xData.at(0).tx;
593 float rightDu = xData.at(xData.size() - 1).tx - xData.at(xData.size() - 2).tx;
594 float topDv = yData.at(1).ty - yData.at(0).ty;
595 float bottomDv = yData.at(yData.size() - 1).ty - yData.at(yData.size() - 2).ty;
598 leftDx = rightDx *= 0.5f;
599 leftDu = rightDu *= 0.5f;
602 topDy = bottomDy *= 0.5f;
603 topDv = bottomDv *= 0.5f;
606 // This delta is how much the fuzziness can reach out from the image.
607 float delta = float(qAbs(m_targetRect.width()) < qAbs(m_targetRect.height())
608 ? m_targetRect.width() : m_targetRect.height()) * 0.5f;
612 for (int j = 0; j < vCells; ++j, ys += 2) {
615 bool isBottom = j == vCells - 1;
616 for (int i = 0; i < hCells; ++i, xs += 2) {
617 bool isLeft = i == 0;
618 bool isRight = i == hCells - 1;
620 SmoothVertex *v = vertices + index;
622 quint16 topLeft = index;
623 for (int k = (isTop || isLeft ? 2 : 1); k--; ++v, ++index) {
630 quint16 topRight = index;
631 for (int k = (isTop || isRight ? 2 : 1); k--; ++v, ++index) {
638 quint16 bottomLeft = index;
639 for (int k = (isBottom || isLeft ? 2 : 1); k--; ++v, ++index) {
646 quint16 bottomRight = index;
647 for (int k = (isBottom || isRight ? 2 : 1); k--; ++v, ++index) {
654 appendQuad(&indices, topLeft, topRight, bottomLeft, bottomRight);
657 vertices[topLeft].dy = vertices[topRight].dy = topDy;
658 vertices[topLeft].dv = vertices[topRight].dv = topDv;
659 vertices[topLeft + 1].dy = vertices[topRight + 1].dy = -delta;
660 appendQuad(&indices, topLeft + 1, topRight + 1, topLeft, topRight);
664 vertices[bottomLeft].dy = vertices[bottomRight].dy = -bottomDy;
665 vertices[bottomLeft].dv = vertices[bottomRight].dv = -bottomDv;
666 vertices[bottomLeft + 1].dy = vertices[bottomRight + 1].dy = delta;
667 appendQuad(&indices, bottomLeft, bottomRight, bottomLeft + 1, bottomRight + 1);
671 vertices[topLeft].dx = vertices[bottomLeft].dx = leftDx;
672 vertices[topLeft].du = vertices[bottomLeft].du = leftDu;
673 vertices[topLeft + 1].dx = vertices[bottomLeft + 1].dx = -delta;
674 appendQuad(&indices, topLeft + 1, topLeft, bottomLeft + 1, bottomLeft);
678 vertices[topRight].dx = vertices[bottomRight].dx = -rightDx;
679 vertices[topRight].du = vertices[bottomRight].du = -rightDu;
680 vertices[topRight + 1].dx = vertices[bottomRight + 1].dx = delta;
681 appendQuad(&indices, topRight, topRight + 1, bottomRight, bottomRight + 1);
686 Q_ASSERT(index == g->vertexCount());
687 Q_ASSERT(indices - g->indexCount() == g->indexData());
689 m_geometry.allocate(hCells * vCells * 4, hCells * vCells * 6);
690 m_geometry.setDrawingMode(GL_TRIANGLES);
691 QSGGeometry::TexturedPoint2D *vertices = m_geometry.vertexDataAsTexturedPoint2D();
693 for (int j = 0; j < vCells; ++j, ys += 2) {
695 for (int i = 0; i < hCells; ++i, xs += 2) {
696 vertices[0].x = vertices[2].x = xs[0].x;
697 vertices[0].tx = vertices[2].tx = xs[0].tx;
698 vertices[1].x = vertices[3].x = xs[1].x;
699 vertices[1].tx = vertices[3].tx = xs[1].tx;
701 vertices[0].y = vertices[1].y = ys[0].y;
702 vertices[0].ty = vertices[1].ty = ys[0].ty;
703 vertices[2].y = vertices[3].y = ys[1].y;
704 vertices[2].ty = vertices[3].ty = ys[1].ty;
710 quint16 *indices = m_geometry.indexDataAsUShort();
711 for (int i = 0; i < 4 * vCells * hCells; i += 4)
712 appendQuad(&indices, i, i + 1, i + 2, i + 3);
716 markDirty(DirtyGeometry);
717 m_dirtyGeometry = false;