summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorCarolina Gomes <ext-carolina.s.gomes@nomovok.com>2010-03-26 15:10:36 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2010-04-14 12:56:40 (GMT)
commit91976b6bde42dd8c939591c01017208aaa670418 (patch)
tree268b3aa1df820f3c8296dad4bddc500a6f50601f /src/opengl
parentb331a74b8fd71ba803e2cf2a9e0c49e1d3538f40 (diff)
downloadQt-91976b6bde42dd8c939591c01017208aaa670418.zip
Qt-91976b6bde42dd8c939591c01017208aaa670418.tar.gz
Qt-91976b6bde42dd8c939591c01017208aaa670418.tar.bz2
QTBUG-6800 patch included, but only for OpenGL 2.0
Merge-request: 2344 Reviewed-by: Tom Cooksey
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp11
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h2
-rw-r--r--src/opengl/qgl.cpp27
3 files changed, 39 insertions, 1 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 0cc7430..0ef9204 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -510,12 +510,19 @@ void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& s
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
+bool QGL2PaintEngineEx::isNativePaintingActive()
+{
+ return nativePaintingActive;
+}
+
void QGL2PaintEngineEx::beginNativePainting()
{
Q_D(QGL2PaintEngineEx);
ensureActive();
d->transferMode(BrushDrawingMode);
+ nativePaintingActive = true;
+
QGLContext *ctx = d->ctx;
glUseProgram(0);
@@ -583,6 +590,7 @@ void QGL2PaintEngineEx::endNativePainting()
{
Q_D(QGL2PaintEngineEx);
d->needsSync = true;
+ nativePaintingActive = false;
}
void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode)
@@ -1101,7 +1109,8 @@ void QGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stops, i
/////////////////////////////////// Public Methods //////////////////////////////////////////
QGL2PaintEngineEx::QGL2PaintEngineEx()
- : QPaintEngineEx(*(new QGL2PaintEngineExPrivate(this)))
+ : QPaintEngineEx(*(new QGL2PaintEngineExPrivate(this))),
+ nativePaintingActive(false)
{
}
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index 34d72d1..e91d7ac 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -154,8 +154,10 @@ public:
void setRenderTextActive(bool);
+ bool isNativePaintingActive();
private:
Q_DISABLE_COPY(QGL2PaintEngineEx)
+ bool nativePaintingActive;
};
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 4e1a63c..848982d 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -2767,6 +2767,19 @@ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum text
return;
}
#else
+
+ if (d_ptr->active_engine->type() == QPaintEngine::OpenGL2) {
+ QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine);
+ //qDebug() << "Paint Engine is OpenGL2";
+ if (eng->isNativePaintingActive() == false) {
+ //qDebug() << "No usage of begin/endNativePainting()";
+ QRectF src = QRectF(0, 0, target.width(), target.height());
+ QSize size = QSize(target.width(), target.height());
+ eng->drawTexture(target, textureId, size, src);
+ return;
+ }
+ }
+
const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D);
GLint oldTexture;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture);
@@ -2817,6 +2830,7 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text
Q_UNUSED(textureTarget);
qWarning("drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) not supported with OpenGL ES, use rect version instead");
#else
+
const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D);
GLint oldTexture;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture);
@@ -2830,6 +2844,19 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text
glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth);
glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight);
+ if (d_ptr->active_engine->type() == QPaintEngine::OpenGL2) {
+ QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine);
+ //qDebug() << "Paint Engine is OpenGL2";
+ if (eng->isNativePaintingActive() == false) {
+ //qDebug() << "No usage of begin/endNativePainting()";
+ QRectF dest = QRectF(point, QSizeF(textureWidth, textureHeight));
+ QRectF src = QRectF(0, 0, textureWidth, textureHeight);
+ QSize size = QSize(textureWidth, textureHeight);
+ eng->drawTexture(dest, textureId, size, src);
+ return;
+ }
+ }
+
qDrawTextureRect(QRectF(point, QSizeF(textureWidth, textureHeight)), textureWidth, textureHeight, textureTarget);
if (!wasEnabled)