Changeset 769 for trunk/src/opengl/qgl.cpp
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/opengl/qgl.cpp
r651 r769 103 103 #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) 104 104 QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs; 105 #endif 106 107 #ifdef Q_WS_X11 108 extern const QX11Info *qt_x11Info(const QPaintDevice *pd); 105 109 #endif 106 110 … … 1531 1535 for (int x=0; x < w; ++x) { 1532 1536 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 1534 1545 q++; 1535 1546 } … … 1542 1553 QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha) 1543 1554 { 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); 1545 1557 int w = size.width(); 1546 1558 int h = size.height(); … … 1591 1603 qt_gl_texture_cache = this; 1592 1604 1593 QImagePixmapCleanupHooks::instance()->addPixmapDataModificationHook(cleanupTextures );1605 QImagePixmapCleanupHooks::instance()->addPixmapDataModificationHook(cleanupTexturesForPixampData); 1594 1606 QImagePixmapCleanupHooks::instance()->addPixmapDataDestructionHook(cleanupBeforePixmapDestruction); 1595 QImagePixmapCleanupHooks::instance()->addImageHook( imageCleanupHook);1607 QImagePixmapCleanupHooks::instance()->addImageHook(cleanupTexturesForCacheKey); 1596 1608 } 1597 1609 … … 1600 1612 qt_gl_texture_cache = 0; 1601 1613 1602 QImagePixmapCleanupHooks::instance()->removePixmapDataModificationHook(cleanupTextures );1614 QImagePixmapCleanupHooks::instance()->removePixmapDataModificationHook(cleanupTexturesForPixampData); 1603 1615 QImagePixmapCleanupHooks::instance()->removePixmapDataDestructionHook(cleanupBeforePixmapDestruction); 1604 QImagePixmapCleanupHooks::instance()->removeImageHook( imageCleanupHook);1616 QImagePixmapCleanupHooks::instance()->removeImageHook(cleanupTexturesForCacheKey); 1605 1617 } 1606 1618 … … 1658 1670 is deref'ed 1659 1671 */ 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) 1672 void QGLTextureCache::cleanupTexturesForCacheKey(qint64 cacheKey) 1672 1673 { 1673 1674 // ### remove when the GL texture cache becomes thread-safe 1674 1675 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 1682 void QGLTextureCache::cleanupTexturesForPixampData(QPixmapData* pmd) 1683 { 1684 cleanupTexturesForCacheKey(pmd->cacheKey()); 1680 1685 } 1681 1686 … … 1683 1688 { 1684 1689 // Remove any bound textures first: 1685 cleanupTextures(pmd); 1686 Q_ASSERT(instance()->getTexture(pmd->cacheKey()) == 0); 1690 cleanupTexturesForPixampData(pmd); 1687 1691 1688 1692 #if defined(Q_WS_X11) … … 2085 2089 Q_ASSERT(texture); 2086 2090 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); 2089 2094 2090 2095 return texture; … … 2140 2145 2141 2146 QImage img = image; 2147 2142 2148 if (!(QGLExtensions::glExtensions() & QGLExtensions::NPOTTextures) 2143 2149 && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0) … … 2308 2314 QGLTexture *texture = new QGLTexture(q, tx_id, target, options); 2309 2315 QGLTextureCache::instance()->insert(q, key, texture, cost); 2316 2310 2317 return texture; 2311 2318 } … … 2352 2359 #if defined(Q_WS_X11) 2353 2360 // 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 { 2355 2365 texture = bindTextureFromNativePixmap(pd, key, options); 2356 2366 if (texture) { … … 2421 2431 2422 2432 Q_D(QGLContext); 2423 QGLTexture *texture = d->bindTexture(image, target, format, false,DefaultBindOption);2433 QGLTexture *texture = d->bindTexture(image, target, format, DefaultBindOption); 2424 2434 return texture->id; 2425 2435 } … … 2561 2571 GLuint texture = dds_cache->value(ddsKeys.at(i)); 2562 2572 if (id == texture) { 2563 glDeleteTextures(1, &texture);2564 2573 dds_cache->remove(ddsKeys.at(i)); 2565 return;2574 break; 2566 2575 } 2567 2576 } 2577 2578 // Finally, actually delete the texture ID 2579 glDeleteTextures(1, &id); 2568 2580 } 2569 2581 … … 4416 4428 4417 4429 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 4418 4439 qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); 4419 QPaintEngine *engine = paintEngine();4440 engine = paintEngine(); 4420 4441 QPainter *p; 4421 4442 bool reuse_painter = false; … … 4510 4531 4511 4532 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 4512 4542 qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); 4513 QPaintEngine *engine = paintEngine();4543 engine = paintEngine(); 4514 4544 QPainter *p; 4515 4545 bool reuse_painter = false; … … 5430 5460 quint32 width = pvrHeader->width; 5431 5461 quint32 height = pvrHeader->height; 5432 while (bufferSize > 0 && level < pvrHeader->mipMapCount) {5462 while (bufferSize > 0 && level <= pvrHeader->mipMapCount) { 5433 5463 quint32 size = 5434 5464 (qMax(width, minWidth) * qMax(height, minHeight) *
Note:
See TracChangeset
for help on using the changeset viewer.