Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/opengl/qgl.cpp

    r651 r769  
    103103#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
    104104QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs;
     105#endif
     106
     107#ifdef Q_WS_X11
     108extern const QX11Info *qt_x11Info(const QPaintDevice *pd);
    105109#endif
    106110
     
    15311535            for (int x=0; x < w; ++x) {
    15321536                const uint pixel = *q;
    1533                 *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00);
     1537                if (alpha_format && include_alpha) {
     1538                    *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff)
     1539                         | (pixel & 0xff00ff00);
     1540                } else {
     1541                    *q = 0xff000000 | ((pixel << 16) & 0xff0000)
     1542                         | ((pixel >> 16) & 0xff) | (pixel & 0x00ff00);
     1543                }
     1544
    15341545                q++;
    15351546            }
     
    15421553QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha)
    15431554{
    1544     QImage img(size, alpha_format ? QImage::Format_ARGB32 : QImage::Format_RGB32);
     1555    QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32
     1556                                                     : QImage::Format_RGB32);
    15451557    int w = size.width();
    15461558    int h = size.height();
     
    15911603    qt_gl_texture_cache = this;
    15921604
    1593     QImagePixmapCleanupHooks::instance()->addPixmapDataModificationHook(cleanupTextures);
     1605    QImagePixmapCleanupHooks::instance()->addPixmapDataModificationHook(cleanupTexturesForPixampData);
    15941606    QImagePixmapCleanupHooks::instance()->addPixmapDataDestructionHook(cleanupBeforePixmapDestruction);
    1595     QImagePixmapCleanupHooks::instance()->addImageHook(imageCleanupHook);
     1607    QImagePixmapCleanupHooks::instance()->addImageHook(cleanupTexturesForCacheKey);
    15961608}
    15971609
     
    16001612    qt_gl_texture_cache = 0;
    16011613
    1602     QImagePixmapCleanupHooks::instance()->removePixmapDataModificationHook(cleanupTextures);
     1614    QImagePixmapCleanupHooks::instance()->removePixmapDataModificationHook(cleanupTexturesForPixampData);
    16031615    QImagePixmapCleanupHooks::instance()->removePixmapDataDestructionHook(cleanupBeforePixmapDestruction);
    1604     QImagePixmapCleanupHooks::instance()->removeImageHook(imageCleanupHook);
     1616    QImagePixmapCleanupHooks::instance()->removeImageHook(cleanupTexturesForCacheKey);
    16051617}
    16061618
     
    16581670  is deref'ed
    16591671*/
    1660 void QGLTextureCache::imageCleanupHook(qint64 cacheKey)
    1661 {
    1662     // ### remove when the GL texture cache becomes thread-safe
    1663     if (qApp->thread() != QThread::currentThread())
    1664         return;
    1665     QGLTexture *texture = instance()->getTexture(cacheKey);
    1666     if (texture && texture->options & QGLContext::MemoryManagedBindOption)
    1667         instance()->remove(cacheKey);
    1668 }
    1669 
    1670 
    1671 void QGLTextureCache::cleanupTextures(QPixmapData* pmd)
     1672void QGLTextureCache::cleanupTexturesForCacheKey(qint64 cacheKey)
    16721673{
    16731674    // ### remove when the GL texture cache becomes thread-safe
    16741675    if (qApp->thread() == QThread::currentThread()) {
    1675         const qint64 cacheKey = pmd->cacheKey();
    1676         QGLTexture *texture = instance()->getTexture(cacheKey);
    1677         if (texture && texture->options & QGLContext::MemoryManagedBindOption)
    1678             instance()->remove(cacheKey);
    1679     }
     1676        instance()->remove(cacheKey);
     1677        Q_ASSERT(instance()->getTexture(cacheKey) == 0);
     1678    }
     1679}
     1680
     1681
     1682void QGLTextureCache::cleanupTexturesForPixampData(QPixmapData* pmd)
     1683{
     1684    cleanupTexturesForCacheKey(pmd->cacheKey());
    16801685}
    16811686
     
    16831688{
    16841689    // Remove any bound textures first:
    1685     cleanupTextures(pmd);
    1686     Q_ASSERT(instance()->getTexture(pmd->cacheKey()) == 0);
     1690    cleanupTexturesForPixampData(pmd);
    16871691
    16881692#if defined(Q_WS_X11)
     
    20852089    Q_ASSERT(texture);
    20862090
    2087     if (texture->id > 0)
    2088         QImagePixmapCleanupHooks::enableCleanupHooks(image);
     2091    // Enable the cleanup hooks for this image so that the texture cache entry is removed when the
     2092    // image gets deleted:
     2093    QImagePixmapCleanupHooks::enableCleanupHooks(image);
    20892094
    20902095    return texture;
     
    21402145
    21412146    QImage img = image;
     2147
    21422148    if (!(QGLExtensions::glExtensions() & QGLExtensions::NPOTTextures)
    21432149        && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0)
     
    23082314    QGLTexture *texture = new QGLTexture(q, tx_id, target, options);
    23092315    QGLTextureCache::instance()->insert(q, key, texture, cost);
     2316
    23102317    return texture;
    23112318}
     
    23522359#if defined(Q_WS_X11)
    23532360    // Try to use texture_from_pixmap
    2354     if (pd->classId() == QPixmapData::X11Class && pd->pixelType() == QPixmapData::PixmapType) {
     2361    const QX11Info *xinfo = qt_x11Info(paintDevice);
     2362    if (pd->classId() == QPixmapData::X11Class && pd->pixelType() == QPixmapData::PixmapType
     2363        && xinfo && xinfo->screen() == pixmap.x11Info().screen())
     2364    {
    23552365        texture = bindTextureFromNativePixmap(pd, key, options);
    23562366        if (texture) {
     
    24212431
    24222432    Q_D(QGLContext);
    2423     QGLTexture *texture = d->bindTexture(image, target, format, false, DefaultBindOption);
     2433    QGLTexture *texture = d->bindTexture(image, target, format, DefaultBindOption);
    24242434    return texture->id;
    24252435}
     
    25612571        GLuint texture = dds_cache->value(ddsKeys.at(i));
    25622572        if (id == texture) {
    2563             glDeleteTextures(1, &texture);
    25642573            dds_cache->remove(ddsKeys.at(i));
    2565             return;
     2574            break;
    25662575        }
    25672576    }
     2577
     2578    // Finally, actually delete the texture ID
     2579    glDeleteTextures(1, &id);
    25682580}
    25692581
     
    44164428
    44174429    QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine();
     4430
     4431    QPaintEngine *engine = paintEngine();
     4432    if (engine && (oldEngineType == QPaintEngine::OpenGL2) && engine->isActive()) {
     4433        qWarning("QGLWidget::renderText(): Calling renderText() while a GL 2 paint engine is"
     4434                 " active on the same device is not allowed.");
     4435        return;
     4436    }
     4437
     4438    // this changes what paintEngine() returns
    44184439    qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL);
    4419     QPaintEngine *engine = paintEngine();
     4440    engine = paintEngine();
    44204441    QPainter *p;
    44214442    bool reuse_painter = false;
     
    45104531
    45114532    QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine();
     4533    QPaintEngine *engine = paintEngine();
     4534
     4535    if (engine && (oldEngineType == QPaintEngine::OpenGL2) && engine->isActive()) {
     4536        qWarning("QGLWidget::renderText(): Calling renderText() while a GL 2 paint engine is"
     4537                 " active on the same device is not allowed.");
     4538        return;
     4539    }
     4540
     4541    // this changes what paintEngine() returns
    45124542    qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL);
    4513     QPaintEngine *engine = paintEngine();
     4543    engine = paintEngine();
    45144544    QPainter *p;
    45154545    bool reuse_painter = false;
     
    54305460    quint32 width = pvrHeader->width;
    54315461    quint32 height = pvrHeader->height;
    5432     while (bufferSize > 0 && level < pvrHeader->mipMapCount) {
     5462    while (bufferSize > 0 && level <= pvrHeader->mipMapCount) {
    54335463        quint32 size =
    54345464            (qMax(width, minWidth) * qMax(height, minHeight) *
Note: See TracChangeset for help on using the changeset viewer.