Changeset 846 for trunk/src/opengl/qpixmapdata_gl.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/opengl/qpixmapdata_gl.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 368 368 369 369 void QGLPixmapData::fromImage(const QImage &image, 370 Qt::ImageConversionFlags /*flags*/)370 Qt::ImageConversionFlags flags) 371 371 { 372 372 if (image.size() == QSize(w, h)) … … 382 382 format = QImage::Format_RGB16; 383 383 384 if (image.hasAlphaChannel() && const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()) 384 if (image.hasAlphaChannel() 385 && ((flags & Qt::NoOpaqueDetection) 386 || const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels())) 385 387 format = QImage::Format_ARGB32_Premultiplied;; 386 388 … … 471 473 void QGLPixmapData::copy(const QPixmapData *data, const QRect &rect) 472 474 { 473 if (data->classId() != QPixmapData::OpenGLClass ) {475 if (data->classId() != QPixmapData::OpenGLClass || !static_cast<const QGLPixmapData *>(data)->useFramebufferObjects()) { 474 476 QPixmapData::copy(data, rect); 475 477 return; 476 478 } 477 479 478 // can be optimized to do a framebuffer blit or similar ... 479 QPixmapData::copy(data, rect); 480 const QGLPixmapData *other = static_cast<const QGLPixmapData *>(data); 481 if (other->m_renderFbo) { 482 QGLShareContextScope ctx(qt_gl_share_widget()->context()); 483 484 resize(rect.width(), rect.height()); 485 m_hasAlpha = other->m_hasAlpha; 486 ensureCreated(); 487 488 if (!ctx->d_ptr->fbo) 489 glGenFramebuffers(1, &ctx->d_ptr->fbo); 490 491 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, ctx->d_ptr->fbo); 492 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, 493 GL_TEXTURE_2D, m_texture.id, 0); 494 495 if (!other->m_renderFbo->isBound()) 496 glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, other->m_renderFbo->handle()); 497 498 glDisable(GL_SCISSOR_TEST); 499 if (ctx->d_ptr->active_engine && ctx->d_ptr->active_engine->type() == QPaintEngine::OpenGL2) 500 static_cast<QGL2PaintEngineEx *>(ctx->d_ptr->active_engine)->invalidateState(); 501 502 glBlitFramebufferEXT(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height(), 503 0, 0, w, h, 504 GL_COLOR_BUFFER_BIT, 505 GL_NEAREST); 506 507 glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo); 508 } else { 509 QPixmapData::copy(data, rect); 510 } 480 511 } 481 512 … … 622 653 } 623 654 624 bool QGLPixmapData::useFramebufferObjects() 655 bool QGLPixmapData::useFramebufferObjects() const 625 656 { 626 657 return QGLFramebufferObject::hasOpenGLFramebufferObjects() 627 658 && QGLFramebufferObject::hasOpenGLFramebufferBlit() 628 && qt_gl_preferGL2Engine(); 659 && qt_gl_preferGL2Engine() 660 && (w * h > 32*32); // avoid overhead of FBOs for small pixmaps 629 661 } 630 662 … … 708 740 } 709 741 710 extern int qt_defaultDpiX();711 extern int qt_defaultDpiY();742 Q_DECL_IMPORT extern int qt_defaultDpiX(); 743 Q_DECL_IMPORT extern int qt_defaultDpiY(); 712 744 713 745 int QGLPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
Note:
See TracChangeset
for help on using the changeset viewer.