};
QRectF nsrect(sourceRect.x() / d->pix.width(),
- 1 - sourceRect.y() / d->pix.height(),
+ sourceRect.y() / d->pix.height(),
sourceRect.width() / d->pix.width(),
- -sourceRect.height() / d->pix.height());
+ sourceRect.height() / d->pix.height());
node->setHorizontalWrapMode(hWrap);
node->setVerticalWrapMode(vWrap);
xChunkSize = xTexSize;
} else if (m_horizontalTileMode == QSGBorderImage::Round) {
xChunkCount = qCeil(xSize / xTexSize);
- xChunkSize = xSize / xChunkCount;
+ qreal fullWidth = xChunkCount * xTexSize;
+ xChunkSize = xTexSize * xSize / fullWidth;
} else {
xChunkCount = 1;
xChunkSize = xSize;
yChunkSize = yTexSize;
} else if (m_verticalTileMode == QSGBorderImage::Round) {
yChunkCount = qCeil(ySize / yTexSize);
- yChunkSize = ySize / yChunkCount;
+ qreal fullHeight = yChunkCount * yTexSize;
+ yChunkSize = yTexSize * ySize / fullHeight;
} else {
yChunkCount = 1;
yChunkSize = ySize;
// Fill in the vertices.. The loop below is pretty much an exact replica
// of the one inside fillRow.
- float yTexChunk1 = 1 - m_innerRect.top() / th;
- float yTexChunk2 = 1 - m_innerRect.bottom() / th;
+ float yTexChunk1 = m_innerRect.top() / th;
+ float yTexChunk2 = m_innerRect.bottom() / th;
- fillRow(v, 0, 1, xChunkCount, xChunkSize);
+ fillRow(v, 0, 0, xChunkCount, xChunkSize);
fillRow(v, m_innerRect.y(), yTexChunk1, xChunkCount, xChunkSize);
for (int yc=0; yc<yChunkCount; ++yc) {
}
fillRow(v, m_targetRect.height() - bottomBorder, yTexChunk2, xChunkCount, xChunkSize);
- fillRow(v, m_targetRect.height(), 0, xChunkCount, xChunkSize);
+ fillRow(v, m_targetRect.height(), 1, xChunkCount, xChunkSize);
// v = m_geometry.vertexDataAsTexturedPoint2D();
bool positionFirst = attributes.at(0) == qtPositionAttributeName();
- QRectF srcRect(0, 1, 1, -1);
+ QRectF srcRect(0, 0, 1, 1);
for (int iy = 0; iy <= vmesh; ++iy) {
float fy = iy / float(vmesh);
float y = float(dstRect.top()) + fy * float(dstRect.height());
const QGLContext *ctx = QGLContext::currentContext();
m_renderer->setDeviceRect(m_size);
m_renderer->setViewportRect(m_size);
- m_renderer->setProjectMatrixToRect(m_rect);
+ QRectF mirrored(m_rect.left(), m_rect.bottom(), m_rect.width(), -m_rect.height());
+ m_renderer->setProjectMatrixToRect(mirrored);
m_renderer->setClearColor(Qt::transparent);
if (m_multisampling) {
node->setHorizontalWrapMode(hWrap);
node->setVerticalWrapMode(vWrap);
node->setTargetRect(QRectF(0, 0, width(), height()));
- node->setSourceRect(QRectF(0, 1, 1, -1));
+ node->setSourceRect(QRectF(0, 0, 1, 1));
node->update();
return node;
markDirty(DirtyMaterial);
}
-
void QSGDefaultImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode)
{
if (m_material.verticalWrapMode() == wrapMode)
int h = m_image.height();
#ifdef QT_OPENGL_ES
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
- for (int i = 0; i < m_image.height(); ++i)
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, w, 1, GL_RGBA, GL_UNSIGNED_BYTE, m_image.constScanLine(h - 1 - i));
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_image.constBits());
#else
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
- for (int i = 0; i < m_image.height(); ++i)
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, w, 1, GL_BGRA, GL_UNSIGNED_BYTE, m_image.constScanLine(h - 1 - i));
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, m_image.constBits());
#endif
if (m_has_mipmaps) {
}
m_texture_size = QSize(w, h);
+ m_texture_rect = QRectF(0, 0, 1, 1);
updateBindOptions(m_dirty_bind_options);
m_dirty_bind_options = false;
GLuint m_texture_id;
QSize m_texture_size;
+ QRectF m_texture_rect;
uint m_has_alpha : 1;
uint m_has_mipmaps : 1;