Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsgbasicinternalimagenode.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// Qt-Security score:significant reason:default
4
6
7#include <QtCore/qvarlengtharray.h>
8#include <QtCore/qmath.h>
9
11
12namespace
13{
15 {
16 float x, y, u, v;
17 float dx, dy, du, dv;
18 };
19
21 {
22 static QSGGeometry::Attribute data[] = {
23 QSGGeometry::Attribute::createWithAttributeType(0, 2, QSGGeometry::FloatType, QSGGeometry::PositionAttribute),
24 QSGGeometry::Attribute::createWithAttributeType(1, 2, QSGGeometry::FloatType, QSGGeometry::TexCoordAttribute),
25 QSGGeometry::Attribute::createWithAttributeType(2, 2, QSGGeometry::FloatType, QSGGeometry::TexCoord1Attribute),
26 QSGGeometry::Attribute::createWithAttributeType(3, 2, QSGGeometry::FloatType, QSGGeometry::TexCoord2Attribute)
27 };
28 static QSGGeometry::AttributeSet attrs = { 4, sizeof(SmoothImageVertex), data };
29 return attrs;
30 }
31}
32
33QSGBasicInternalImageNode::QSGBasicInternalImageNode()
34 : m_innerSourceRect(0, 0, 1, 1)
35 , m_subSourceRect(0, 0, 1, 1)
36 , m_antialiasing(false)
37 , m_mirrorHorizontally(false)
38 , m_mirrorVertically(false)
39 , m_dirtyGeometry(false)
40 , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
41 , m_dynamicTexture(nullptr)
42{
43 setGeometry(&m_geometry);
44
45#ifdef QSG_RUNTIME_DESCRIPTION
46 qsgnode_set_description(this, QLatin1String("internalimage"));
47#endif
48}
49
50void QSGBasicInternalImageNode::setTargetRect(const QRectF &rect)
51{
52 if (rect == m_targetRect)
53 return;
54 m_targetRect = rect;
55 m_dirtyGeometry = true;
56}
57
58void QSGBasicInternalImageNode::setInnerTargetRect(const QRectF &rect)
59{
60 if (rect == m_innerTargetRect)
61 return;
62 m_innerTargetRect = rect;
63 m_dirtyGeometry = true;
64}
65
66void QSGBasicInternalImageNode::setInnerSourceRect(const QRectF &rect)
67{
68 if (rect == m_innerSourceRect)
69 return;
70 m_innerSourceRect = rect;
71 m_dirtyGeometry = true;
72}
73
74void QSGBasicInternalImageNode::setSubSourceRect(const QRectF &rect)
75{
76 if (rect == m_subSourceRect)
77 return;
78 m_subSourceRect = rect;
79 m_dirtyGeometry = true;
80}
81
82void QSGBasicInternalImageNode::setTexture(QSGTexture *texture)
83{
84 Q_ASSERT(texture);
85
86 setMaterialTexture(texture);
87 updateMaterialBlending();
88
89 markDirty(DirtyMaterial);
90
91 // Because the texture can be a different part of the atlas, we need to update it...
92 m_dirtyGeometry = true;
93}
94
95void QSGBasicInternalImageNode::setAntialiasing(bool antialiasing)
96{
97 if (antialiasing == m_antialiasing)
98 return;
99 m_antialiasing = antialiasing;
100 if (m_antialiasing) {
101 setGeometry(new QSGGeometry(smoothImageAttributeSet(), 0));
102 setFlag(OwnsGeometry, true);
103 } else {
104 setGeometry(&m_geometry);
105 setFlag(OwnsGeometry, false);
106 }
107 updateMaterialAntialiasing();
108 m_dirtyGeometry = true;
109}
110
111void QSGBasicInternalImageNode::setMirror(bool mirrorHorizontally, bool mirrorVertically)
112{
113 if (mirrorHorizontally == m_mirrorHorizontally && mirrorVertically == m_mirrorVertically)
114 return;
115 m_mirrorHorizontally = mirrorHorizontally;
116 m_mirrorVertically = mirrorVertically;
117 m_dirtyGeometry = true;
118}
119
120
121void QSGBasicInternalImageNode::update()
122{
123 if (m_dirtyGeometry)
124 updateGeometry();
125}
126
127void QSGBasicInternalImageNode::preprocess()
128{
129 bool doDirty = false;
130 QSGDynamicTexture *t = qobject_cast<QSGDynamicTexture *>(materialTexture());
131 if (t) {
132 doDirty = t->updateTexture();
133 if (doDirty) {
134 // The geometry may need updating. This is expensive however, so do
135 // it only when something relevant has changed.
136 if (t != m_dynamicTexture
137 || t->textureSize() != m_dynamicTextureSize
138 || t->normalizedTextureSubRect() != m_dynamicTextureSubRect) {
139 updateGeometry();
140 m_dynamicTextureSize = t->textureSize();
141 m_dynamicTextureSubRect = t->normalizedTextureSubRect();
142 }
143 }
144 }
145 m_dynamicTexture = t;
146
147 if (updateMaterialBlending())
148 doDirty = true;
149
150 if (doDirty)
151 markDirty(DirtyMaterial);
152}
153
154namespace {
155 struct X { float x, tx; };
156 struct Y { float y, ty; };
157}
158
159static inline void appendQuad(int indexType, void **indexData,
160 int topLeft, int topRight,
161 int bottomLeft, int bottomRight)
162{
163 if (indexType == QSGGeometry::UnsignedIntType) {
164 quint32 *indices = static_cast<quint32 *>(*indexData);
165 *indices++ = topLeft;
166 *indices++ = bottomLeft;
167 *indices++ = bottomRight;
168 *indices++ = bottomRight;
169 *indices++ = topRight;
170 *indices++ = topLeft;
171 *indexData = indices;
172 } else {
173 Q_ASSERT(indexType == QSGGeometry::UnsignedShortType);
174 quint16 *indices = static_cast<quint16 *>(*indexData);
175 *indices++ = topLeft;
176 *indices++ = bottomLeft;
177 *indices++ = bottomRight;
178 *indices++ = bottomRight;
179 *indices++ = topRight;
180 *indices++ = topLeft;
181 *indexData = indices;
182 }
183}
184
185QSGGeometry *QSGBasicInternalImageNode::updateGeometry(const QRectF &targetRect,
186 const QRectF &innerTargetRect,
187 const QRectF &sourceRect,
188 const QRectF &innerSourceRect,
189 const QRectF &subSourceRect,
190 QSGGeometry *geometry,
191 bool mirrorHorizontally,
192 bool mirrorVertically,
193 bool antialiasing)
194{
195 int floorLeft = qFloor(subSourceRect.left());
196 int ceilRight = qCeil(subSourceRect.right());
197 int floorTop = qFloor(subSourceRect.top());
198 int ceilBottom = qCeil(subSourceRect.bottom());
199 int hTiles = ceilRight - floorLeft;
200 int vTiles = ceilBottom - floorTop;
201
202 int hCells = hTiles;
203 int vCells = vTiles;
204 if (innerTargetRect.width() == 0)
205 hCells = 0;
206 if (innerTargetRect.left() != targetRect.left())
207 ++hCells;
208 if (innerTargetRect.right() != targetRect.right())
209 ++hCells;
210 if (innerTargetRect.height() == 0)
211 vCells = 0;
212 if (innerTargetRect.top() != targetRect.top())
213 ++vCells;
214 if (innerTargetRect.bottom() != targetRect.bottom())
215 ++vCells;
216
217 QVarLengthArray<X, 32> xData(2 * hCells);
218 QVarLengthArray<Y, 32> yData(2 * vCells);
219 X *xs = xData.data();
220 Y *ys = yData.data();
221
222 if (innerTargetRect.left() != targetRect.left()) {
223 xs[0].x = targetRect.left();
224 xs[0].tx = sourceRect.left();
225 xs[1].x = innerTargetRect.left();
226 xs[1].tx = innerSourceRect.left();
227 xs += 2;
228 }
229 if (innerTargetRect.width() != 0 && hTiles > 0) {
230 xs[0].x = innerTargetRect.left();
231 xs[0].tx = innerSourceRect.x() + (subSourceRect.left() - floorLeft) * innerSourceRect.width();
232 ++xs;
233 float b = innerTargetRect.width() / subSourceRect.width();
234 float a = innerTargetRect.x() - subSourceRect.x() * b;
235 for (int i = floorLeft + 1; i <= ceilRight - 1; ++i) {
236 xs[0].x = xs[1].x = a + b * i;
237 xs[0].tx = innerSourceRect.right();
238 xs[1].tx = innerSourceRect.left();
239 xs += 2;
240 }
241 xs[0].x = innerTargetRect.right();
242 xs[0].tx = innerSourceRect.x() + (subSourceRect.right() - ceilRight + 1) * innerSourceRect.width();
243 ++xs;
244 }
245 if (innerTargetRect.right() != targetRect.right()) {
246 xs[0].x = innerTargetRect.right();
247 xs[0].tx = innerSourceRect.right();
248 xs[1].x = targetRect.right();
249 xs[1].tx = sourceRect.right();
250 xs += 2;
251 }
252 Q_ASSERT(xs == xData.data() + xData.size());
253 if (mirrorHorizontally) {
254 float leftPlusRight = targetRect.left() + targetRect.right();
255 int count = xData.size();
256 xs = xData.data();
257 for (int i = 0; i < (count >> 1); ++i)
258 qSwap(xs[i], xs[count - 1 - i]);
259 for (int i = 0; i < count; ++i)
260 xs[i].x = leftPlusRight - xs[i].x;
261 }
262
263 if (innerTargetRect.top() != targetRect.top()) {
264 ys[0].y = targetRect.top();
265 ys[0].ty = sourceRect.top();
266 ys[1].y = innerTargetRect.top();
267 ys[1].ty = innerSourceRect.top();
268 ys += 2;
269 }
270 if (innerTargetRect.height() != 0 && vTiles > 0) {
271 ys[0].y = innerTargetRect.top();
272 ys[0].ty = innerSourceRect.y() + (subSourceRect.top() - floorTop) * innerSourceRect.height();
273 ++ys;
274 float b = innerTargetRect.height() / subSourceRect.height();
275 float a = innerTargetRect.y() - subSourceRect.y() * b;
276 for (int i = floorTop + 1; i <= ceilBottom - 1; ++i) {
277 ys[0].y = ys[1].y = a + b * i;
278 ys[0].ty = innerSourceRect.bottom();
279 ys[1].ty = innerSourceRect.top();
280 ys += 2;
281 }
282 ys[0].y = innerTargetRect.bottom();
283 ys[0].ty = innerSourceRect.y() + (subSourceRect.bottom() - ceilBottom + 1) * innerSourceRect.height();
284 ++ys;
285 }
286 if (innerTargetRect.bottom() != targetRect.bottom()) {
287 ys[0].y = innerTargetRect.bottom();
288 ys[0].ty = innerSourceRect.bottom();
289 ys[1].y = targetRect.bottom();
290 ys[1].ty = sourceRect.bottom();
291 ys += 2;
292 }
293 Q_ASSERT(ys == yData.data() + yData.size());
294 if (mirrorVertically) {
295 float topPlusBottom = targetRect.top() + targetRect.bottom();
296 int count = yData.size();
297 ys = yData.data();
298 for (int i = 0; i < (count >> 1); ++i)
299 qSwap(ys[i], ys[count - 1 - i]);
300 for (int i = 0; i < count; ++i)
301 ys[i].y = topPlusBottom - ys[i].y;
302 }
303
304 QSGGeometry::Type indexType = QSGGeometry::UnsignedShortType;
305 // We can handled up to 0xffff indices, but keep the limit lower here to
306 // merge better in the batch renderer.
307 if (hCells * vCells * 4 > 0x7fff)
308 indexType = QSGGeometry::UnsignedIntType;
309
310 if (antialiasing) {
311 if (!geometry || geometry->indexType() != indexType) {
312 geometry = new QSGGeometry(smoothImageAttributeSet(),
313 hCells * vCells * 4 + (hCells + vCells - 1) * 4,
314 hCells * vCells * 6 + (hCells + vCells) * 12,
315 indexType);
316 } else {
317 geometry->allocate(hCells * vCells * 4 + (hCells + vCells - 1) * 4,
318 hCells * vCells * 6 + (hCells + vCells) * 12);
319 }
320 QSGGeometry *g = geometry;
321 Q_ASSERT(g);
322
323 g->setDrawingMode(QSGGeometry::DrawTriangles);
324 auto *vertices = reinterpret_cast<SmoothImageVertex *>(g->vertexData());
325 memset(vertices, 0, g->vertexCount() * g->sizeOfVertex());
326 void *indexData = g->indexData();
327
328 // The deltas are how much the fuzziness can reach into the image.
329 // Only the border vertices are moved by the vertex shader, so the fuzziness
330 // can't reach further into the image than the closest interior vertices.
331 float leftDx = xData.at(1).x - xData.at(0).x;
332 float rightDx = xData.at(xData.size() - 1).x - xData.at(xData.size() - 2).x;
333 float topDy = yData.at(1).y - yData.at(0).y;
334 float bottomDy = yData.at(yData.size() - 1).y - yData.at(yData.size() - 2).y;
335
336 float leftDu = xData.at(1).tx - xData.at(0).tx;
337 float rightDu = xData.at(xData.size() - 1).tx - xData.at(xData.size() - 2).tx;
338 float topDv = yData.at(1).ty - yData.at(0).ty;
339 float bottomDv = yData.at(yData.size() - 1).ty - yData.at(yData.size() - 2).ty;
340
341 if (hCells == 1) {
342 leftDx = rightDx *= 0.5f;
343 leftDu = rightDu *= 0.5f;
344 }
345 if (vCells == 1) {
346 topDy = bottomDy *= 0.5f;
347 topDv = bottomDv *= 0.5f;
348 }
349
350 // This delta is how much the fuzziness can reach out from the image.
351 float delta = float(qAbs(targetRect.width()) < qAbs(targetRect.height())
352 ? targetRect.width() : targetRect.height()) * 0.5f;
353
354 int index = 0;
355 ys = yData.data();
356 for (int j = 0; j < vCells; ++j, ys += 2) {
357 xs = xData.data();
358 bool isTop = j == 0;
359 bool isBottom = j == vCells - 1;
360 for (int i = 0; i < hCells; ++i, xs += 2) {
361 bool isLeft = i == 0;
362 bool isRight = i == hCells - 1;
363
364 SmoothImageVertex *v = vertices + index;
365
366 int topLeft = index;
367 for (int k = (isTop || isLeft ? 2 : 1); k--; ++v, ++index) {
368 v->x = xs[0].x;
369 v->u = xs[0].tx;
370 v->y = ys[0].y;
371 v->v = ys[0].ty;
372 }
373
374 int topRight = index;
375 for (int k = (isTop || isRight ? 2 : 1); k--; ++v, ++index) {
376 v->x = xs[1].x;
377 v->u = xs[1].tx;
378 v->y = ys[0].y;
379 v->v = ys[0].ty;
380 }
381
382 int bottomLeft = index;
383 for (int k = (isBottom || isLeft ? 2 : 1); k--; ++v, ++index) {
384 v->x = xs[0].x;
385 v->u = xs[0].tx;
386 v->y = ys[1].y;
387 v->v = ys[1].ty;
388 }
389
390 int bottomRight = index;
391 for (int k = (isBottom || isRight ? 2 : 1); k--; ++v, ++index) {
392 v->x = xs[1].x;
393 v->u = xs[1].tx;
394 v->y = ys[1].y;
395 v->v = ys[1].ty;
396 }
397
398 appendQuad(g->indexType(), &indexData, topLeft, topRight, bottomLeft, bottomRight);
399
400 if (isTop) {
401 vertices[topLeft].dy = vertices[topRight].dy = topDy;
402 vertices[topLeft].dv = vertices[topRight].dv = topDv;
403 vertices[topLeft + 1].dy = vertices[topRight + 1].dy = -delta;
404 appendQuad(g->indexType(), &indexData, topLeft + 1, topRight + 1, topLeft, topRight);
405 }
406
407 if (isBottom) {
408 vertices[bottomLeft].dy = vertices[bottomRight].dy = -bottomDy;
409 vertices[bottomLeft].dv = vertices[bottomRight].dv = -bottomDv;
410 vertices[bottomLeft + 1].dy = vertices[bottomRight + 1].dy = delta;
411 appendQuad(g->indexType(), &indexData, bottomLeft, bottomRight, bottomLeft + 1, bottomRight + 1);
412 }
413
414 if (isLeft) {
415 vertices[topLeft].dx = vertices[bottomLeft].dx = leftDx;
416 vertices[topLeft].du = vertices[bottomLeft].du = leftDu;
417 vertices[topLeft + 1].dx = vertices[bottomLeft + 1].dx = -delta;
418 appendQuad(g->indexType(), &indexData, topLeft + 1, topLeft, bottomLeft + 1, bottomLeft);
419 }
420
421 if (isRight) {
422 vertices[topRight].dx = vertices[bottomRight].dx = -rightDx;
423 vertices[topRight].du = vertices[bottomRight].du = -rightDu;
424 vertices[topRight + 1].dx = vertices[bottomRight + 1].dx = delta;
425 appendQuad(g->indexType(), &indexData, topRight, topRight + 1, bottomRight, bottomRight + 1);
426 }
427 }
428 }
429
430 Q_ASSERT(index == g->vertexCount());
431 } else {
432 if (!geometry || geometry->indexType() != indexType) {
433 geometry = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(),
434 hCells * vCells * 4, hCells * vCells * 6,
435 indexType);
436 } else {
437 geometry->allocate(hCells * vCells * 4, hCells * vCells * 6);
438 }
439 geometry->setDrawingMode(QSGGeometry::DrawTriangles);
440 QSGGeometry::TexturedPoint2D *vertices = geometry->vertexDataAsTexturedPoint2D();
441 ys = yData.data();
442 for (int j = 0; j < vCells; ++j, ys += 2) {
443 xs = xData.data();
444 for (int i = 0; i < hCells; ++i, xs += 2) {
445 vertices[0].x = vertices[2].x = xs[0].x;
446 vertices[0].tx = vertices[2].tx = xs[0].tx;
447 vertices[1].x = vertices[3].x = xs[1].x;
448 vertices[1].tx = vertices[3].tx = xs[1].tx;
449
450 vertices[0].y = vertices[1].y = ys[0].y;
451 vertices[0].ty = vertices[1].ty = ys[0].ty;
452 vertices[2].y = vertices[3].y = ys[1].y;
453 vertices[2].ty = vertices[3].ty = ys[1].ty;
454
455 vertices += 4;
456 }
457 }
458 void *indexData = geometry->indexData();
459 for (int i = 0; i < 4 * vCells * hCells; i += 4)
460 appendQuad(geometry->indexType(), &indexData, i, i + 1, i + 2, i + 3);
461 }
462 return geometry;
463}
464
465void QSGBasicInternalImageNode::updateGeometry()
466{
467 Q_ASSERT(!m_targetRect.isEmpty());
468 const QSGTexture *t = materialTexture();
469 if (!t) {
470 QSGGeometry *g = geometry();
471 g->allocate(4);
472 g->setDrawingMode(QSGGeometry::DrawTriangleStrip);
473 memset(g->vertexData(), 0, g->sizeOfVertex() * 4);
474 } else {
475 QRectF sourceRect = t->normalizedTextureSubRect();
476
477 QRectF innerSourceRect(sourceRect.x() + m_innerSourceRect.x() * sourceRect.width(),
478 sourceRect.y() + m_innerSourceRect.y() * sourceRect.height(),
479 m_innerSourceRect.width() * sourceRect.width(),
480 m_innerSourceRect.height() * sourceRect.height());
481
482 bool hasMargins = m_targetRect != m_innerTargetRect;
483
484 int floorLeft = qFloor(m_subSourceRect.left());
485 int ceilRight = qCeil(m_subSourceRect.right());
486 int floorTop = qFloor(m_subSourceRect.top());
487 int ceilBottom = qCeil(m_subSourceRect.bottom());
488 int hTiles = ceilRight - floorLeft;
489 int vTiles = ceilBottom - floorTop;
490
491 bool hasTiles = hTiles > 1 || vTiles > 1;
492 bool fullTexture = innerSourceRect == QRectF(0, 0, 1, 1);
493
494 // An image can be rendered as a single quad if:
495 // - There are no margins, and either:
496 // - the image isn't repeated
497 // - the source rectangle fills the entire texture so that texture wrapping can be used,
498 // and NPOT is supported
499 if (!hasMargins && (!hasTiles || (fullTexture && supportsWrap(t->textureSize())))) {
500 QRectF sr;
501 if (!fullTexture) {
502 sr = QRectF(innerSourceRect.x() + (m_subSourceRect.left() - floorLeft) * innerSourceRect.width(),
503 innerSourceRect.y() + (m_subSourceRect.top() - floorTop) * innerSourceRect.height(),
504 m_subSourceRect.width() * innerSourceRect.width(),
505 m_subSourceRect.height() * innerSourceRect.height());
506 } else {
507 sr = QRectF(m_subSourceRect.left() - floorLeft, m_subSourceRect.top() - floorTop,
508 m_subSourceRect.width(), m_subSourceRect.height());
509 }
510 if (m_mirrorHorizontally) {
511 qreal oldLeft = sr.left();
512 sr.setLeft(sr.right());
513 sr.setRight(oldLeft);
514 }
515 if (m_mirrorVertically) {
516 qreal oldTop = sr.top();
517 sr.setTop(sr.bottom());
518 sr.setBottom(oldTop);
519 }
520
521 if (m_antialiasing) {
522 QSGGeometry *g = geometry();
523 Q_ASSERT(g != &m_geometry);
524 if (g->indexType() != QSGGeometry::UnsignedShortType) {
525 setGeometry(new QSGGeometry(smoothImageAttributeSet(), 0));
526 g = geometry();
527 }
528 g->allocate(8, 14);
529 g->setDrawingMode(QSGGeometry::DrawTriangleStrip);
530 auto *vertices = reinterpret_cast<SmoothImageVertex *>(g->vertexData());
531 float delta = float(qAbs(m_targetRect.width()) < qAbs(m_targetRect.height())
532 ? m_targetRect.width() : m_targetRect.height()) * 0.5f;
533 float sx = float(sr.width() / m_targetRect.width());
534 float sy = float(sr.height() / m_targetRect.height());
535 for (int d = -1; d <= 1; d += 2) {
536 for (int j = 0; j < 2; ++j) {
537 for (int i = 0; i < 2; ++i, ++vertices) {
538 vertices->x = m_targetRect.x() + i * m_targetRect.width();
539 vertices->y = m_targetRect.y() + j * m_targetRect.height();
540 vertices->u = sr.x() + i * sr.width();
541 vertices->v = sr.y() + j * sr.height();
542 vertices->dx = (i == 0 ? delta : -delta) * d;
543 vertices->dy = (j == 0 ? delta : -delta) * d;
544 vertices->du = (d < 0 ? 0 : vertices->dx * sx);
545 vertices->dv = (d < 0 ? 0 : vertices->dy * sy);
546 }
547 }
548 }
549 Q_ASSERT(vertices - g->vertexCount() == g->vertexData());
550 static const quint16 indices[] = {
551 0, 4, 1, 5, 3, 7, 2, 6, 0, 4,
552 4, 6, 5, 7
553 };
554 Q_ASSERT(g->sizeOfIndex() * g->indexCount() == sizeof(indices));
555 memcpy(g->indexDataAsUShort(), indices, sizeof(indices));
556 } else {
557 m_geometry.allocate(4);
558 m_geometry.setDrawingMode(QSGGeometry::DrawTriangleStrip);
559 QSGGeometry::updateTexturedRectGeometry(&m_geometry, m_targetRect, sr);
560 }
561 } else {
562 QSGGeometry *g = geometry();
563 g = updateGeometry(m_targetRect, m_innerTargetRect,
564 sourceRect, innerSourceRect, m_subSourceRect,
565 g, m_mirrorHorizontally, m_mirrorVertically, m_antialiasing);
566 if (g != geometry()) {
567 setGeometry(g);
568 setFlag(OwnsGeometry, true);
569 }
570 }
571 }
572 markDirty(DirtyGeometry);
573 m_dirtyGeometry = false;
574}
575
576QT_END_NAMESPACE
Combined button and popup list for selecting options.
const QSGGeometry::AttributeSet & smoothImageAttributeSet()
static void appendQuad(int indexType, void **indexData, int topLeft, int topRight, int bottomLeft, int bottomRight)