Skip to content

Commit

Permalink
Do not change depth for the backingstore's underlying image
Browse files Browse the repository at this point in the history
The depth cannot change. This means that RGB16 cannot be upgraded
to 8565 for example as that would be a 24 bit format whereas the
backingstores and the underlying platform may expect a 16 bit
format.

Task-number: QTBUG-50869
Change-Id: I648b39287d43a80fae8097a33bbf3b8bbdcb8816
Reviewed-by: Friedemann Kleint <[email protected]>
Reviewed-by: Andreas Holzammer <[email protected]>
Reviewed-by: Allan Sandfeld Jensen <[email protected]>
  • Loading branch information
alpqr authored and Jani Heikkinen committed Feb 5, 2016
1 parent cb6d4d1 commit d482805
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/gui/image/qimage_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ inline QImage::Format qt_alphaVersion(QImage::Format format)
return QImage::Format_ARGB32_Premultiplied;
}

inline QImage::Format qt_maybeAlphaVersionWithSameDepth(QImage::Format format)
{
const QImage::Format toFormat = qt_alphaVersion(format);
return qt_depthForFormat(format) == qt_depthForFormat(toFormat) ? toFormat : format;
}

inline QImage::Format qt_alphaVersionForPainting(QImage::Format format)
{
QImage::Format toFormat = qt_alphaVersion(format);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/platforms/windows/qwindowsbackingstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void QWindowsBackingStore::resize(const QSize &size, const QRegion &region)
if (QImage::toPixelFormat(format).alphaUsage() == QPixelFormat::UsesAlpha)
m_alphaNeedsFill = true;
else // upgrade but here we know app painting does not rely on alpha hence no need to fill
format = qt_alphaVersionForPainting(format);
format = qt_maybeAlphaVersionWithSameDepth(format);

QWindowsNativeImage *oldwni = m_image.data();
QWindowsNativeImage *newwni = new QWindowsNativeImage(size.width(), size.height(), format);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/platforms/xcb/qxcbbackingstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI

m_hasAlpha = QImage::toPixelFormat(format).alphaUsage() == QPixelFormat::UsesAlpha;
if (!m_hasAlpha)
format = qt_alphaVersionForPainting(format);
format = qt_maybeAlphaVersionWithSameDepth(format);

m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, format);
m_graphics_buffer = new QXcbShmGraphicsBuffer(&m_qimage);
Expand Down

0 comments on commit d482805

Please sign in to comment.