summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-02-15 07:20:23 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-02-15 07:20:23 (GMT)
commitb649ca564a66cc905276f27d2d77cc3bff88d788 (patch)
tree1e38c2f0b41cfec304f611eb0e884711df130e31 /src/opengl
parent34761e25b13bb2af27e9701a04ce0bf31d84c489 (diff)
parent6bee2674184d4c808cebb46e86b4faad6fc1e94e (diff)
downloadQt-b649ca564a66cc905276f27d2d77cc3bff88d788.zip
Qt-b649ca564a66cc905276f27d2d77cc3bff88d788.tar.gz
Qt-b649ca564a66cc905276f27d2d77cc3bff88d788.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Fixed compile for maemo6. Cleanup QEglContext & EGLDisplays Moved 'hasAlpha' property from GL2 engine to GL paint device. Remove useless qDebug in QTextCodec autotest QTextCodec: Symbian has codec for UCS2, only fallback to UTF16 if UCS2 codec cannot be loaded Add caching to QTextCodec::codecForName and QTextCodec::codecForMib Add benchmark for QTextCodec Fix several bugs with GL texture cache Compile fix for OpenGL ES. Fix missing/outdated license headers. Turned off subpixel AA text on surface with alpha in GL2 engine. Add functional Graphics View benchmarks. Make QCUPSSupport::printerHasPPD() clean up after itself. document the slowness of QPixmap::hasAlpha() Speed up custom bitmap brushes on X11 without Xrender support.
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp14
-rw-r--r--src/opengl/qgl.cpp44
-rw-r--r--src/opengl/qgl_p.h4
-rw-r--r--src/opengl/qgl_qws.cpp5
-rw-r--r--src/opengl/qgl_wince.cpp5
-rw-r--r--src/opengl/qgl_x11egl.cpp13
-rw-r--r--src/opengl/qglframebufferobject.cpp7
-rw-r--r--src/opengl/qglframebufferobject_p.h4
-rw-r--r--src/opengl/qglpaintdevice.cpp5
-rw-r--r--src/opengl/qglpaintdevice_p.h1
-rw-r--r--src/opengl/qglpixelbuffer_egl.cpp9
-rw-r--r--src/opengl/qpixmapdata_gl.cpp5
-rw-r--r--src/opengl/qpixmapdata_gl_p.h1
-rw-r--r--src/opengl/qpixmapdata_x11gl_egl.cpp15
14 files changed, 64 insertions, 68 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 07f3159..8235a5c 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1231,14 +1231,14 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem
? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat)
: d->glyphCacheType;
- if (txtype > QTransform::TxTranslate)
- glyphType = QFontEngineGlyphCache::Raster_A8;
- if (glyphType == QFontEngineGlyphCache::Raster_RGBMask
- && state()->composition_mode != QPainter::CompositionMode_Source
- && state()->composition_mode != QPainter::CompositionMode_SourceOver)
- {
- drawCached = false;
+ if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
+ if (d->device->alphaRequested() || txtype > QTransform::TxTranslate
+ || (state()->composition_mode != QPainter::CompositionMode_Source
+ && state()->composition_mode != QPainter::CompositionMode_SourceOver))
+ {
+ glyphType = QFontEngineGlyphCache::Raster_A8;
+ }
}
if (drawCached) {
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 0a89412..22b0602 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1594,18 +1594,18 @@ QGLTextureCache::QGLTextureCache()
Q_ASSERT(qt_gl_texture_cache == 0);
qt_gl_texture_cache = this;
- QImagePixmapCleanupHooks::instance()->addPixmapDataModificationHook(cleanupTextures);
+ QImagePixmapCleanupHooks::instance()->addPixmapDataModificationHook(cleanupTexturesForPixampData);
QImagePixmapCleanupHooks::instance()->addPixmapDataDestructionHook(cleanupBeforePixmapDestruction);
- QImagePixmapCleanupHooks::instance()->addImageHook(imageCleanupHook);
+ QImagePixmapCleanupHooks::instance()->addImageHook(cleanupTexturesForCacheKey);
}
QGLTextureCache::~QGLTextureCache()
{
qt_gl_texture_cache = 0;
- QImagePixmapCleanupHooks::instance()->removePixmapDataModificationHook(cleanupTextures);
+ QImagePixmapCleanupHooks::instance()->removePixmapDataModificationHook(cleanupTexturesForPixampData);
QImagePixmapCleanupHooks::instance()->removePixmapDataDestructionHook(cleanupBeforePixmapDestruction);
- QImagePixmapCleanupHooks::instance()->removeImageHook(imageCleanupHook);
+ QImagePixmapCleanupHooks::instance()->removeImageHook(cleanupTexturesForCacheKey);
}
void QGLTextureCache::insert(QGLContext* ctx, qint64 key, QGLTexture* texture, int cost)
@@ -1661,32 +1661,25 @@ QGLTextureCache* QGLTextureCache::instance()
a hook that removes textures from the cache when a pixmap/image
is deref'ed
*/
-void QGLTextureCache::imageCleanupHook(qint64 cacheKey)
+void QGLTextureCache::cleanupTexturesForCacheKey(qint64 cacheKey)
{
// ### remove when the GL texture cache becomes thread-safe
- if (qApp->thread() != QThread::currentThread())
- return;
- QGLTexture *texture = instance()->getTexture(cacheKey);
- if (texture && texture->options & QGLContext::MemoryManagedBindOption)
+ if (qApp->thread() == QThread::currentThread()) {
instance()->remove(cacheKey);
+ Q_ASSERT(instance()->getTexture(cacheKey) == 0);
+ }
}
-void QGLTextureCache::cleanupTextures(QPixmapData* pmd)
+void QGLTextureCache::cleanupTexturesForPixampData(QPixmapData* pmd)
{
- // ### remove when the GL texture cache becomes thread-safe
- if (qApp->thread() == QThread::currentThread()) {
- const qint64 cacheKey = pmd->cacheKey();
- QGLTexture *texture = instance()->getTexture(cacheKey);
- if (texture && texture->options & QGLContext::MemoryManagedBindOption)
- instance()->remove(cacheKey);
- }
+ cleanupTexturesForCacheKey(pmd->cacheKey());
}
void QGLTextureCache::cleanupBeforePixmapDestruction(QPixmapData* pmd)
{
// Remove any bound textures first:
- cleanupTextures(pmd);
+ cleanupTexturesForPixampData(pmd);
#if defined(Q_WS_X11)
if (pmd->classId() == QPixmapData::X11Class) {
@@ -2087,8 +2080,9 @@ QGLTexture *QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
// NOTE: bindTexture(const QImage&, GLenum, GLint, const qint64, bool) should never return null
Q_ASSERT(texture);
- if (texture->id > 0)
- QImagePixmapCleanupHooks::enableCleanupHooks(image);
+ // Enable the cleanup hooks for this image so that the texture cache entry is removed when the
+ // image gets deleted:
+ QImagePixmapCleanupHooks::enableCleanupHooks(image);
return texture;
}
@@ -2142,6 +2136,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
int tx_h = qt_next_power_of_two(image.height());
QImage img = image;
+
if (!(QGLExtensions::glExtensions() & QGLExtensions::NPOTTextures)
&& !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0)
&& (target == GL_TEXTURE_2D && (tx_w != image.width() || tx_h != image.height())))
@@ -2310,6 +2305,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
int cost = img.width()*img.height()*4/1024;
QGLTexture *texture = new QGLTexture(q, tx_id, target, options);
QGLTextureCache::instance()->insert(q, key, texture, cost);
+
return texture;
}
@@ -2426,7 +2422,7 @@ GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format)
return 0;
Q_D(QGLContext);
- QGLTexture *texture = d->bindTexture(image, target, format, false, DefaultBindOption);
+ QGLTexture *texture = d->bindTexture(image, target, format, DefaultBindOption);
return texture->id;
}
@@ -2566,11 +2562,13 @@ void QGLContext::deleteTexture(GLuint id)
for (int i = 0; i < ddsKeys.size(); ++i) {
GLuint texture = dds_cache->value(ddsKeys.at(i));
if (id == texture) {
- glDeleteTextures(1, &texture);
dds_cache->remove(ddsKeys.at(i));
- return;
+ break;
}
}
+
+ // Finally, actually delete the texture ID
+ glDeleteTextures(1, &id);
}
#ifdef Q_MAC_COMPAT_GL_FUNCTIONS
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index da0887e..0d5a54a 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -540,8 +540,8 @@ public:
static QGLTextureCache *instance();
static void deleteIfEmpty();
- static void imageCleanupHook(qint64 cacheKey);
- static void cleanupTextures(QPixmapData* pixmap);
+ static void cleanupTexturesForCacheKey(qint64 cacheKey);
+ static void cleanupTexturesForPixampData(QPixmapData* pixmap);
static void cleanupBeforePixmapDestruction(QPixmapData* pixmap);
private:
diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp
index d4adc8b..fd17a27 100644
--- a/src/opengl/qgl_qws.cpp
+++ b/src/opengl/qgl_qws.cpp
@@ -198,11 +198,6 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// Get the display and initialize it.
d->eglContext = new QEglContext();
d->eglContext->setApi(QEgl::OpenGL);
- if (!d->eglContext->openDisplay(device())) {
- delete d->eglContext;
- d->eglContext = 0;
- return false;
- }
// Construct the configuration we need for this surface.
QEglProperties configProps;
diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp
index 00a125a..f81115c 100644
--- a/src/opengl/qgl_wince.cpp
+++ b/src/opengl/qgl_wince.cpp
@@ -155,11 +155,6 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// Get the display and initialize it.
d->eglContext = new QEglContext();
d->eglContext->setApi(QEgl::OpenGL);
- if (!d->eglContext->openDisplay(device())) {
- delete d->eglContext;
- d->eglContext = 0;
- return false;
- }
// Construct the configuration we need for this surface.
QEglProperties configProps;
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index 572834b..3d183ee 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -190,11 +190,6 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
if (d->eglContext == 0) {
d->eglContext = new QEglContext();
d->eglContext->setApi(QEgl::OpenGL);
- if (!d->eglContext->openDisplay(device())) {
- delete d->eglContext;
- d->eglContext = 0;
- return false;
- }
// Construct the configuration we need for this surface.
QEglProperties configProps;
@@ -614,7 +609,7 @@ EGLConfig Q_OPENGL_EXPORT qt_chooseEGLConfigForPixmap(bool hasAlpha, bool readOn
EGLint configCount = 0;
do {
- eglChooseConfig(QEglContext::defaultDisplay(0), configAttribs.properties(), targetConfig, 1, &configCount);
+ eglChooseConfig(QEglContext::display(), configAttribs.properties(), targetConfig, 1, &configCount);
if (configCount > 0) {
// Got one
qDebug() << "Found an" << (hasAlpha ? "ARGB" : "RGB") << (readOnly ? "readonly" : "target" )
@@ -653,7 +648,7 @@ bool Q_OPENGL_EXPORT qt_createEGLSurfaceForPixmap(QPixmapData* pmd, bool readOnl
pixmapAttribs.setValue(EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB);
EGLSurface pixmapSurface;
- pixmapSurface = eglCreatePixmapSurface(QEglContext::defaultDisplay(0),
+ pixmapSurface = eglCreatePixmapSurface(QEglContext::display(),
pixmapConfig,
(EGLNativePixmapType) pixmapData->handle(),
pixmapAttribs.properties());
@@ -762,7 +757,7 @@ void QGLContextPrivate::destroyGlSurfaceForPixmap(QPixmapData* pmd)
QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
if (pixmapData->gl_surface) {
EGLBoolean success;
- success = eglDestroySurface(QEglContext::defaultDisplay(0), (EGLSurface)pixmapData->gl_surface);
+ success = eglDestroySurface(QEglContext::display(), (EGLSurface)pixmapData->gl_surface);
if (success == EGL_FALSE) {
qWarning() << "destroyGlSurfaceForPixmap() - Error deleting surface: "
<< QEglContext::errorString(eglGetError());
@@ -777,7 +772,7 @@ void QGLContextPrivate::unbindPixmapFromTexture(QPixmapData* pmd)
QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
if (pixmapData->gl_surface) {
EGLBoolean success;
- success = eglReleaseTexImage(QEglContext::defaultDisplay(0),
+ success = eglReleaseTexImage(QEglContext::display(),
(EGLSurface)pixmapData->gl_surface,
EGL_BACK_BUFFER);
if (success == EGL_FALSE) {
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index ce80796..dd6a3d5 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -329,6 +329,13 @@ void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f,
} else if (attachment == QGLFramebufferObject::Depth) {
fboFormat.setDepth(true);
}
+
+ GLenum format = f->format().internalTextureFormat();
+ reqAlpha = (format != GL_RGB
+#ifndef QT_OPENGL_ES
+ && format != GL_RGB5 && format != GL_RGB8
+#endif
+ );
}
QGLContext *QGLFBOGLPaintDevice::context() const
diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h
index d7f96a5..d8ff012 100644
--- a/src/opengl/qglframebufferobject_p.h
+++ b/src/opengl/qglframebufferobject_p.h
@@ -111,14 +111,16 @@ public:
virtual QSize size() const {return fbo->size();}
virtual QGLContext* context() const;
virtual QGLFormat format() const {return fboFormat;}
+ virtual bool alphaRequested() const { return reqAlpha; }
void setFBO(QGLFramebufferObject* f,
QGLFramebufferObject::Attachment attachment);
private:
- bool wasBound;
QGLFramebufferObject* fbo;
QGLFormat fboFormat;
+ bool wasBound;
+ bool reqAlpha;
};
class QGLFramebufferObjectPrivate
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
index 7697570..8ba0108 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -128,6 +128,11 @@ QGLFormat QGLPaintDevice::format() const
return context()->format();
}
+bool QGLPaintDevice::alphaRequested() const
+{
+ return context()->d_func()->reqFormat.alpha();
+}
+
diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h
index 9815467..3d669da 100644
--- a/src/opengl/qglpaintdevice_p.h
+++ b/src/opengl/qglpaintdevice_p.h
@@ -75,6 +75,7 @@ public:
virtual QGLContext* context() const = 0;
virtual QGLFormat format() const;
virtual QSize size() const = 0;
+ virtual bool alphaRequested() const;
// returns the QGLPaintDevice for the given QPaintDevice
static QGLPaintDevice* getDevice(QPaintDevice*);
diff --git a/src/opengl/qglpixelbuffer_egl.cpp b/src/opengl/qglpixelbuffer_egl.cpp
index ca19011..dbe919d 100644
--- a/src/opengl/qglpixelbuffer_egl.cpp
+++ b/src/opengl/qglpixelbuffer_egl.cpp
@@ -65,13 +65,6 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge
ctx = new QEglContext();
ctx->setApi(QEgl::OpenGL);
- // Open the EGL display.
- if (!ctx->openDisplay(0)) {
- delete ctx;
- ctx = 0;
- return false;
- }
-
// Find the shared context.
QEglContext *shareContext = 0;
if (shareWidget && shareWidget->d_func()->glcx)
@@ -215,7 +208,7 @@ GLuint QGLPixelBuffer::generateDynamicTexture() const
bool QGLPixelBuffer::hasOpenGLPbuffers()
{
// See if we have at least 1 configuration that matches the default format.
- EGLDisplay dpy = QEglContext::defaultDisplay(0);
+ EGLDisplay dpy = QEglContext::display();
if (dpy == EGL_NO_DISPLAY)
return false;
QEglProperties configProps;
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp
index aa80664..653e805 100644
--- a/src/opengl/qpixmapdata_gl.cpp
+++ b/src/opengl/qpixmapdata_gl.cpp
@@ -234,6 +234,11 @@ QSize QGLPixmapGLPaintDevice::size() const
return data->size();
}
+bool QGLPixmapGLPaintDevice::alphaRequested() const
+{
+ return data->m_hasAlpha;
+}
+
void QGLPixmapGLPaintDevice::setPixmapData(QGLPixmapData* d)
{
data = d;
diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h
index e3ba5f8..c239bcb 100644
--- a/src/opengl/qpixmapdata_gl_p.h
+++ b/src/opengl/qpixmapdata_gl_p.h
@@ -88,6 +88,7 @@ public:
void endPaint();
QGLContext* context() const;
QSize size() const;
+ bool alphaRequested() const;
void setPixmapData(QGLPixmapData*);
private:
diff --git a/src/opengl/qpixmapdata_x11gl_egl.cpp b/src/opengl/qpixmapdata_x11gl_egl.cpp
index 55aa1d0..229f75a 100644
--- a/src/opengl/qpixmapdata_x11gl_egl.cpp
+++ b/src/opengl/qpixmapdata_x11gl_egl.cpp
@@ -96,14 +96,14 @@ bool QX11GLPixmapData::hasX11GLPixmaps()
#endif
EGL_NONE
};
- qPixmapARGBSharedEglContext = eglCreateContext(QEglContext::defaultDisplay(0),
+ qPixmapARGBSharedEglContext = eglCreateContext(QEglContext::display(),
argbConfig, 0, contextAttribs);
if (argbConfig == rgbConfig) {
// If the configs are the same, we can re-use the same context.
qPixmapRGBSharedEglContext = qPixmapARGBSharedEglContext;
} else {
- qPixmapRGBSharedEglContext = eglCreateContext(QEglContext::defaultDisplay(0),
+ qPixmapRGBSharedEglContext = eglCreateContext(QEglContext::display(),
rgbConfig, 0, contextAttribs);
}
@@ -114,7 +114,7 @@ bool QX11GLPixmapData::hasX11GLPixmaps()
if (!qt_createEGLSurfaceForPixmap(argbPixmapData, false))
break;
- haveX11Pixmaps = eglMakeCurrent(QEglContext::defaultDisplay(0),
+ haveX11Pixmaps = eglMakeCurrent(QEglContext::display(),
(EGLSurface)argbPixmapData->gl_surface,
(EGLSurface)argbPixmapData->gl_surface,
qPixmapARGBSharedEglContext);
@@ -134,7 +134,7 @@ bool QX11GLPixmapData::hasX11GLPixmaps()
if (!qt_createEGLSurfaceForPixmap(rgbPixmapData, false))
break;
- haveX11Pixmaps = eglMakeCurrent(QEglContext::defaultDisplay(0),
+ haveX11Pixmaps = eglMakeCurrent(QEglContext::display(),
(EGLSurface)rgbPixmapData->gl_surface,
(EGLSurface)rgbPixmapData->gl_surface,
qPixmapRGBSharedEglContext);
@@ -147,7 +147,7 @@ bool QX11GLPixmapData::hasX11GLPixmaps()
} while (0);
if (qPixmapARGBSharedEglContext || qPixmapRGBSharedEglContext) {
- eglMakeCurrent(QEglContext::defaultDisplay(0),
+ eglMakeCurrent(QEglContext::display(),
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
@@ -167,12 +167,12 @@ bool QX11GLPixmapData::hasX11GLPixmaps()
if (!haveX11Pixmaps) {
// Clean up the context(s) if we can't use X11GL pixmaps
if (qPixmapARGBSharedEglContext != EGL_NO_CONTEXT)
- eglDestroyContext(QEglContext::defaultDisplay(0), qPixmapARGBSharedEglContext);
+ eglDestroyContext(QEglContext::display(), qPixmapARGBSharedEglContext);
if (qPixmapRGBSharedEglContext != qPixmapARGBSharedEglContext &&
qPixmapRGBSharedEglContext != EGL_NO_CONTEXT)
{
- eglDestroyContext(QEglContext::defaultDisplay(0), qPixmapRGBSharedEglContext);
+ eglDestroyContext(QEglContext::display(), qPixmapRGBSharedEglContext);
}
qPixmapRGBSharedEglContext = EGL_NO_CONTEXT;
qPixmapARGBSharedEglContext = EGL_NO_CONTEXT;
@@ -212,7 +212,6 @@ QPaintEngine* QX11GLPixmapData::paintEngine() const
ctx = new QGLContext(glFormat());
if (ctx->d_func()->eglContext == 0)
ctx->d_func()->eglContext = new QEglContext();
- ctx->d_func()->eglContext->openDisplay(0); // ;-)
ctx->d_func()->eglContext->setApi(QEgl::OpenGL);
ctx->d_func()->eglContext->setContext(hasAlphaChannel() ? qPixmapARGBSharedEglContext
: qPixmapRGBSharedEglContext);