diff options
author | Gunnar Sletta <gunnar@trolltech.com> | 2009-10-02 07:35:56 (GMT) |
---|---|---|
committer | Gunnar Sletta <gunnar@trolltech.com> | 2009-10-02 08:02:13 (GMT) |
commit | b39ff3af6a784cae14f90d22fe83fa8ed78b231e (patch) | |
tree | aa03ed47872499bc192a62d7931888e7794ef28f /src/opengl/qpixmapdata_gl.cpp | |
parent | 6a9cf6717abbe1a76557d6c3eb2910b658af24d7 (diff) | |
download | Qt-b39ff3af6a784cae14f90d22fe83fa8ed78b231e.zip Qt-b39ff3af6a784cae14f90d22fe83fa8ed78b231e.tar.gz Qt-b39ff3af6a784cae14f90d22fe83fa8ed78b231e.tar.bz2 |
Explicitely check for alpha pixels before creating an alpha GL pixnmap
Reviewed-by: Samuel
Diffstat (limited to 'src/opengl/qpixmapdata_gl.cpp')
-rw-r--r-- | src/opengl/qpixmapdata_gl.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 2331c6d..dc7aa81 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -48,9 +48,12 @@ #include <private/qgl_p.h> #include <private/qdrawhelper_p.h> +#include <private/qimage_p.h> #include <private/qpaintengineex_opengl2_p.h> +#include <qdesktopwidget.h> + QT_BEGIN_NAMESPACE extern QGLWidget* qt_gl_share_widget(); @@ -315,7 +318,7 @@ void QGLPixmapData::ensureCreated() const } void QGLPixmapData::fromImage(const QImage &image, - Qt::ImageConversionFlags) + Qt::ImageConversionFlags flags) { if (image.size() == QSize(w, h)) setSerialNumber(++qt_gl_pixmap_serial); @@ -323,20 +326,26 @@ void QGLPixmapData::fromImage(const QImage &image, if (pixelType() == BitmapType) { m_source = image.convertToFormat(QImage::Format_MonoLSB); + } else { - m_source = image.hasAlphaChannel() - ? image.convertToFormat(QImage::Format_ARGB32_Premultiplied) - : image.convertToFormat(QImage::Format_RGB32); + QImage::Format format = QImage::Format_RGB32; + if (qApp->desktop()->depth() == 16) + format = QImage::Format_RGB16; + + if (image.hasAlphaChannel() && const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()) + format = QImage::Format_ARGB32_Premultiplied;; + + m_source = image.convertToFormat(format); } m_dirty = true; m_hasFillColor = false; - m_hasAlpha = image.hasAlphaChannel(); + m_hasAlpha = m_source.hasAlphaChannel(); w = image.width(); h = image.height(); is_null = (w <= 0 || h <= 0); - d = pixelType() == QPixmapData::PixmapType ? 32 : 1; + d = m_source.depth(); if (m_texture.id) { QGLShareContextScope ctx(qt_gl_share_widget()->context()); |