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 <gunnar@sletta.org>
This commit is contained in:
Allan Sandfeld Jensen 2015-01-13 11:33:22 +01:00 committed by Allan Sandfeld Jensen
parent 89edf43c44
commit 6c117ee4aa

View File

@ -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) {