summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-02-17 15:36:59 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-02-17 15:36:59 (GMT)
commit54b20c491f7e182f6b98f65b7e9e8e68286d6109 (patch)
tree7f17d6b2540ea226eb7d8d1b830f31f1a032316a /src/opengl
parentdcb2678f39345b66c5303e74c156654a8d13fe83 (diff)
parent17a0a50a101fc9863d0dffd0dcb887ba68a99622 (diff)
downloadQt-54b20c491f7e182f6b98f65b7e9e8e68286d6109.zip
Qt-54b20c491f7e182f6b98f65b7e9e8e68286d6109.tar.gz
Qt-54b20c491f7e182f6b98f65b7e9e8e68286d6109.tar.bz2
Merge branch '4.6' into qt-master-from-4.6
Conflicts: mkspecs/common/symbian/symbian.conf src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp tools/assistant/tools/assistant/helpviewer.cpp
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp2
-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_x11.cpp7
-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
15 files changed, 63 insertions, 64 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index d2fb925..8468102 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1334,7 +1334,7 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem
if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
- if (d->deviceHasAlpha || txtype > QTransform::TxTranslate
+ if (d->device->alphaRequested() || txtype > QTransform::TxTranslate
|| (state()->composition_mode != QPainter::CompositionMode_Source
&& state()->composition_mode != QPainter::CompositionMode_SourceOver))
{
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index cfcbbf8..5f5941b 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1692,18 +1692,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)
@@ -1759,32 +1759,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) {
@@ -2185,8 +2178,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;
}
@@ -2240,6 +2234,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())))
@@ -2408,6 +2403,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;
}
@@ -2524,7 +2520,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;
}
@@ -2664,11 +2660,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 efd2090..0491db9 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -538,8 +538,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_x11.cpp b/src/opengl/qgl_x11.cpp
index 61a16be..f0b06ef5 100644
--- a/src/opengl/qgl_x11.cpp
+++ b/src/opengl/qgl_x11.cpp
@@ -1656,8 +1656,11 @@ static bool qt_resolveTextureFromPixmap(QPaintDevice *paintDevice)
Display *display = xinfo ? xinfo->display() : X11->display;
int screen = xinfo ? xinfo->screen() : X11->defaultScreen;
- QGLExtensionMatcher extensions(glXQueryExtensionsString(display, screen));
- if (extensions.match("GLX_EXT_texture_from_pixmap")) {
+ QGLExtensionMatcher serverExtensions(glXQueryExtensionsString(display, screen));
+ QGLExtensionMatcher clientExtensions(glXGetClientString(display, GLX_EXTENSIONS));
+ if (serverExtensions.match("GLX_EXT_texture_from_pixmap")
+ && clientExtensions.match("GLX_EXT_texture_from_pixmap"))
+ {
glXBindTexImageEXT = (qt_glXBindTexImageEXT) qglx_getProcAddress("glXBindTexImageEXT");
glXReleaseTexImageEXT = (qt_glXReleaseTexImageEXT) qglx_getProcAddress("glXReleaseTexImageEXT");
}
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 f1d2325..2d0711b 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -325,6 +325,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 a0b1a79..2d82222 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -124,6 +124,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 1e3223e..954049d 100644
--- a/src/opengl/qglpixelbuffer_egl.cpp
+++ b/src/opengl/qglpixelbuffer_egl.cpp
@@ -61,13 +61,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)
@@ -211,7 +204,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 edce56a..6a1d030 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);