From f0b1edca6368701237d83090a75ac61c1c6f2532 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Thu, 28 Apr 2011 15:10:32 +0200 Subject: Revert "Flipped texture coordinates right way up." This reverts commit ffb6fe57ee0ece18b6778889f7602811ab4ca822. Conflicts: src/declarative/scenegraph/qsgdefaultimagenode.cpp --- src/declarative/items/qsgimage.cpp | 4 ++-- src/declarative/items/qsgninepatchnode.cpp | 14 ++++++++------ src/declarative/items/qsgshadereffectmesh.cpp | 2 +- src/declarative/items/qsgshadereffectsource.cpp | 5 +++-- src/declarative/scenegraph/qsgdefaultimagenode.cpp | 1 - src/declarative/scenegraph/util/qsgtexture.cpp | 9 +++------ src/declarative/scenegraph/util/qsgtexture_p.h | 1 + 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/declarative/items/qsgimage.cpp b/src/declarative/items/qsgimage.cpp index 6f63555b81..d24db9f670 100644 --- a/src/declarative/items/qsgimage.cpp +++ b/src/declarative/items/qsgimage.cpp @@ -262,9 +262,9 @@ QSGNode *QSGImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) }; 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); diff --git a/src/declarative/items/qsgninepatchnode.cpp b/src/declarative/items/qsgninepatchnode.cpp index 7858e98190..045dd6c94f 100644 --- a/src/declarative/items/qsgninepatchnode.cpp +++ b/src/declarative/items/qsgninepatchnode.cpp @@ -147,7 +147,8 @@ void QSGNinePatchNode::update() 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; @@ -163,7 +164,8 @@ void QSGNinePatchNode::update() 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; @@ -184,10 +186,10 @@ void QSGNinePatchNode::update() // 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; ycsetDeviceRect(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) { @@ -518,7 +519,7 @@ QSGNode *QSGShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaintNod 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; diff --git a/src/declarative/scenegraph/qsgdefaultimagenode.cpp b/src/declarative/scenegraph/qsgdefaultimagenode.cpp index a705e822c3..aa30d009da 100644 --- a/src/declarative/scenegraph/qsgdefaultimagenode.cpp +++ b/src/declarative/scenegraph/qsgdefaultimagenode.cpp @@ -97,7 +97,6 @@ void QSGDefaultImageNode::setMipmapFiltering(QSGTexture::Filtering filtering) markDirty(DirtyMaterial); } - void QSGDefaultImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode) { if (m_material.verticalWrapMode() == wrapMode) diff --git a/src/declarative/scenegraph/util/qsgtexture.cpp b/src/declarative/scenegraph/util/qsgtexture.cpp index 6112e777e4..9362ba8bf6 100644 --- a/src/declarative/scenegraph/util/qsgtexture.cpp +++ b/src/declarative/scenegraph/util/qsgtexture.cpp @@ -356,13 +356,9 @@ void QSGPlainTexture::bind() 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) { @@ -372,6 +368,7 @@ void QSGPlainTexture::bind() } m_texture_size = QSize(w, h); + m_texture_rect = QRectF(0, 0, 1, 1); updateBindOptions(m_dirty_bind_options); m_dirty_bind_options = false; diff --git a/src/declarative/scenegraph/util/qsgtexture_p.h b/src/declarative/scenegraph/util/qsgtexture_p.h index 8ea0930235..2c142f5746 100644 --- a/src/declarative/scenegraph/util/qsgtexture_p.h +++ b/src/declarative/scenegraph/util/qsgtexture_p.h @@ -97,6 +97,7 @@ protected: GLuint m_texture_id; QSize m_texture_size; + QRectF m_texture_rect; uint m_has_alpha : 1; uint m_has_mipmaps : 1; -- cgit v1.2.3