summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp5
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h2
-rw-r--r--src/opengl/qgl.cpp8
-rw-r--r--src/opengl/qgl_p.h10
-rw-r--r--src/opengl/qpaintengine_opengl.cpp16
5 files changed, 29 insertions, 12 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index e24539b..0ad454f 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -423,8 +423,9 @@ void QGL2PaintEngineExPrivate::updateBrushTexture()
const QPixmap& texPixmap = currentBrush->texture();
glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT);
- ctx->d_func()->bindTexture(texPixmap, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption);
+ QGLTexture *tex = ctx->d_func()->bindTexture(texPixmap, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption);
updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, q->state()->renderHints & QPainter::SmoothPixmapTransform);
+ textureInvertedY = tex->options & QGLContext::InvertedYBindOption ? -1 : 1;
}
brushTextureDirty = false;
}
@@ -517,7 +518,7 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms()
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col);
}
- QSizeF invertedTextureSize( 1.0 / texPixmap.width(), 1.0 / texPixmap.height() );
+ QSizeF invertedTextureSize(1.0 / texPixmap.width(), 1.0 * textureInvertedY / texPixmap.height());
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::InvertedTextureSize), invertedTextureSize);
QVector2D halfViewportSize(width*0.5, height*0.5);
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index cb23b11..2b16019 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -261,6 +261,8 @@ public:
bool needsSync;
bool inRenderText;
+
+ float textureInvertedY;
};
QT_END_NAMESPACE
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 9e0c5f8..3c23149 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -4851,7 +4851,7 @@ QGLFormat QGLDrawable::format() const
return QGLFormat();
}
-GLuint QGLDrawable::bindTexture(const QImage &image, GLenum target, GLint format,
+QGLTexture *QGLDrawable::bindTexture(const QImage &image, GLenum target, GLint format,
QGLContext::BindOptions options)
{
QGLTexture *texture = 0;
@@ -4866,10 +4866,10 @@ GLuint QGLDrawable::bindTexture(const QImage &image, GLenum target, GLint format
else if (wsurf)
texture = wsurf->context()->d_func()->bindTexture(image, target, format, options);
#endif
- return texture->id;
+ return texture;
}
-GLuint QGLDrawable::bindTexture(const QPixmap &pixmap, GLenum target, GLint format,
+QGLTexture *QGLDrawable::bindTexture(const QPixmap &pixmap, GLenum target, GLint format,
QGLContext::BindOptions options)
{
QGLTexture *texture = 0;
@@ -4883,7 +4883,7 @@ GLuint QGLDrawable::bindTexture(const QPixmap &pixmap, GLenum target, GLint form
else if (wsurf)
texture = wsurf->context()->d_func()->bindTexture(pixmap, target, format, options);
#endif
- return texture->id;
+ return texture;
}
QColor QGLDrawable::backgroundColor() const
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index d4b7597..2eb4aa5 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -358,10 +358,12 @@ public:
void doneCurrent();
QSize size() const;
QGLFormat format() const;
- GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA,
- QGLContext::BindOptions = QGLContext::InternalBindOption);
- GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA,
- QGLContext::BindOptions = QGLContext::InternalBindOption);
+ QGLTexture *bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D,
+ GLint format = GL_RGBA,
+ QGLContext::BindOptions = QGLContext::InternalBindOption);
+ QGLTexture *bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D,
+ GLint format = GL_RGBA,
+ QGLContext::BindOptions = QGLContext::InternalBindOption);
QColor backgroundColor() const;
QGLContext *context() const;
bool autoFillBackground() const;
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index bf4d4b9..8c545d2 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -4335,10 +4335,11 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con
} else {
d->flushDrawQueue();
+ QGLTexture *tex;
if (scaled.isNull())
- d->drawable.bindTexture(pm);
+ tex = d->drawable.bindTexture(pm);
else
- d->drawable.bindTexture(scaled);
+ tex = d->drawable.bindTexture(scaled);
updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, d->use_smooth_pixmap_transform);
#ifndef QT_OPENGL_ES
@@ -4351,6 +4352,15 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con
GLdouble tc_w = r.width()/pm.width();
GLdouble tc_h = r.height()/pm.height();
+ // Rotate the texture so that it is aligned correctly and the
+ // wrapping is done correctly
+ if (tex->options & QGLContext::InvertedYBindOption) {
+ glMatrixMode(GL_TEXTURE);
+ glPushMatrix();
+ glRotatef(180.0, 0.0, 1.0, 0.0);
+ glRotatef(180.0, 0.0, 0.0, 1.0);
+ }
+
q_vertexType vertexArray[4*2];
q_vertexType texCoordArray[4*2];
@@ -4369,6 +4379,8 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
+ if (tex->options & QGLContext::InvertedYBindOption)
+ glPopMatrix();
glDisable(GL_TEXTURE_2D);
#ifndef QT_OPENGL_ES