From 6c117ee4aa4974556c6d6ac3799277a4da67b112 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 13 Jan 2015 11:33:22 +0100 Subject: Correct QPainter's is_brush_transparent 1-bit QImage's should not be considered transparent unless they have use transparent colors in the color table or have no color table. By using hasAlphaChannel we also catch other transparent brush textures. The method is only used in determining emulation specifiers. Change-Id: I120ee1de4dc2df666c3e2acb1e40b53a8de40754 Reviewed-by: Gunnar Sletta --- src/gui/painting/qpainter.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index c923b3b22a..4ff334a6d6 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -112,11 +112,14 @@ extern bool qHasPixmapTexture(const QBrush &); static inline bool is_brush_transparent(const QBrush &brush) { Qt::BrushStyle s = brush.style(); - bool brushBitmap = qHasPixmapTexture(brush) - ? brush.texture().isQBitmap() - : (brush.textureImage().depth() == 1); - return ((s >= Qt::Dense1Pattern && s <= Qt::DiagCrossPattern) - || (s == Qt::TexturePattern && brushBitmap)); + if (s != Qt::TexturePattern) + return s >= Qt::Dense1Pattern && s <= Qt::DiagCrossPattern; + if (qHasPixmapTexture(brush)) + return brush.texture().isQBitmap() || brush.texture().hasAlphaChannel(); + else { + const QImage texture = brush.textureImage(); + return texture.hasAlphaChannel() || (texture.depth() == 1 && texture.colorCount() == 0); + } } static inline bool is_pen_transparent(const QPen &pen) { -- cgit v1.2.3