summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-02-18 13:54:51 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2009-04-01 14:32:51 (GMT)
commitd903f379470fb9f9159fbf37f2cfc02638cd05f6 (patch)
tree2c3211bb9f8492337601303c7420a424ae4fbf59
parent6513e4b9513dfc591c53744517f05aa3c522ace3 (diff)
downloadQt-d903f379470fb9f9159fbf37f2cfc02638cd05f6.zip
Qt-d903f379470fb9f9159fbf37f2cfc02638cd05f6.tar.gz
Qt-d903f379470fb9f9159fbf37f2cfc02638cd05f6.tar.bz2
Fixes: Enable use of the GL pixmap backend in the GL 2 paint engine.
-rw-r--r--src/opengl/qgl.cpp10
-rw-r--r--src/opengl/qgl_p.h4
-rw-r--r--src/opengl/qpixmapdata_gl.cpp13
-rw-r--r--src/opengl/qpixmapdata_gl_p.h1
4 files changed, 20 insertions, 8 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 7c42039..558897d 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1888,14 +1888,14 @@ GLuint QGLContextPrivate::bindTexture(const QImage &image, GLenum target, GLint
/*! \internal */
GLuint QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, bool clean)
{
-#if !defined(QT_OPENGL_ES_2)
- if (target == qt_gl_preferredTextureTarget() && pixmap.pixmapData()->classId() == QPixmapData::OpenGLClass) {
- const QGLPixmapData *data = static_cast<const QGLPixmapData *>(pixmap.pixmapData());
+ Q_Q(QGLContext);
+ QPixmapData *pd = pixmap.pixmapData();
+ if (target == qt_gl_preferredTextureTarget() && pd->classId() == QPixmapData::OpenGLClass) {
+ const QGLPixmapData *data = static_cast<const QGLPixmapData *>(pd);
- if (data->isValidContext(QGLContext::currentContext()))
+ if (data->isValidContext(q))
return data->bind();
}
-#endif
const qint64 key = pixmap.cacheKey();
GLuint id;
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 2eccc23..76f3812 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -418,9 +418,13 @@ inline GLenum qt_gl_preferredTextureFormat()
inline GLenum qt_gl_preferredTextureTarget()
{
+#if 1 || defined(QT_OPENGL_ES_2)
+ return GL_TEXTURE_2D;
+#else
return (QGLExtensions::glExtensions & QGLExtensions::TextureRectangle)
? GL_TEXTURE_RECTANGLE_NV
: GL_TEXTURE_2D;
+#endif
}
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp
index b079557..ec71fa6 100644
--- a/src/opengl/qpixmapdata_gl.cpp
+++ b/src/opengl/qpixmapdata_gl.cpp
@@ -57,12 +57,14 @@ class QGLShareContextScope
public:
QGLShareContextScope(const QGLContext *ctx)
: m_oldContext(0)
- , m_ctx(const_cast<QGLContext *>(ctx))
{
- const QGLContext *currentContext = QGLContext::currentContext();
+ QGLContext *currentContext = const_cast<QGLContext *>(QGLContext::currentContext());
if (currentContext != ctx && !qgl_share_reg()->checkSharing(ctx, currentContext)) {
- m_oldContext = const_cast<QGLContext *>(currentContext);
+ m_oldContext = currentContext;
+ m_ctx = const_cast<QGLContext *>(ctx);
m_ctx->makeCurrent();
+ } else {
+ m_ctx = currentContext;
}
}
@@ -127,6 +129,7 @@ QGLPixmapData::QGLPixmapData(PixelType type)
: QPixmapData(type, OpenGLClass)
, m_width(0)
, m_height(0)
+ , m_ctx(0)
, m_texture(0)
, m_dirty(false)
{
@@ -148,6 +151,9 @@ bool QGLPixmapData::isValid() const
bool QGLPixmapData::isValidContext(const QGLContext *ctx) const
{
+ if (ctx == m_ctx)
+ return true;
+
const QGLContext *share_ctx = qt_gl_share_widget()->context();
return ctx == share_ctx || qgl_share_reg()->checkSharing(ctx, share_ctx);
}
@@ -173,6 +179,7 @@ void QGLPixmapData::ensureCreated() const
m_dirty = false;
QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ m_ctx = ctx;
const GLenum format = qt_gl_preferredTextureFormat();
const GLenum target = qt_gl_preferredTextureTarget();
diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h
index e450f01..97f4959 100644
--- a/src/opengl/qpixmapdata_gl_p.h
+++ b/src/opengl/qpixmapdata_gl_p.h
@@ -97,6 +97,7 @@ private:
int m_width;
int m_height;
+ mutable QGLContext *m_ctx;
mutable GLuint m_texture;
mutable bool m_dirty;
mutable QImage m_source;