src/opengl/qpixmapdata_gl.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
child 5 d3bac044e0f0
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the QtOpenGL module of the Qt Toolkit.
     7 ** This file is part of the QtOpenGL module of the Qt Toolkit.
     8 **
     8 **
   250     , m_hasFillColor(false)
   250     , m_hasFillColor(false)
   251     , m_hasAlpha(false)
   251     , m_hasAlpha(false)
   252 {
   252 {
   253     setSerialNumber(++qt_gl_pixmap_serial);
   253     setSerialNumber(++qt_gl_pixmap_serial);
   254     m_glDevice.setPixmapData(this);
   254     m_glDevice.setPixmapData(this);
       
   255 
       
   256     // Set InteralBindOptions minus the memory managed, since this
       
   257     // QGLTexture is not managed as part of the internal texture cache
       
   258     m_texture.options = QGLContext::PremultipliedAlphaBindOption;
   255 }
   259 }
   256 
   260 
   257 QGLPixmapData::~QGLPixmapData()
   261 QGLPixmapData::~QGLPixmapData()
   258 {
   262 {
   259     QGLWidget *shareWidget = qt_gl_share_widget();
   263     QGLWidget *shareWidget = qt_gl_share_widget();
   338         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
   342         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
   339         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   343         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   340     }
   344     }
   341 
   345 
   342     if (!m_source.isNull()) {
   346     if (!m_source.isNull()) {
       
   347         glBindTexture(target, m_texture.id);
   343         if (external_format == GL_RGB) {
   348         if (external_format == GL_RGB) {
   344             const QImage tx = m_source.convertToFormat(QImage::Format_RGB888);
   349             const QImage tx = m_source.convertToFormat(QImage::Format_RGB888);
   345 
       
   346             glBindTexture(target, m_texture.id);
       
   347             glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
   350             glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
   348                             GL_UNSIGNED_BYTE, tx.bits());
   351                             GL_UNSIGNED_BYTE, tx.bits());
   349         } else {
   352         } else {
   350             const QImage tx = ctx->d_func()->convertToGLFormat(m_source, true, external_format);
   353             const QImage tx = ctx->d_func()->convertToGLFormat(m_source, true, external_format);
   351 
       
   352             glBindTexture(target, m_texture.id);
       
   353             glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
   354             glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
   354                             GL_UNSIGNED_BYTE, tx.bits());
   355                             GL_UNSIGNED_BYTE, tx.bits());
       
   356             // convertToGLFormat will flip the Y axis, so it needs to
       
   357             // be drawn upside down
       
   358             m_texture.options |= QGLContext::InvertedYBindOption;
   355         }
   359         }
   356 
   360 
   357         if (useFramebufferObjects())
   361         if (useFramebufferObjects())
   358             m_source = QImage();
   362             m_source = QImage();
   359     }
   363     }