summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpainter.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2015-01-13 11:33:22 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-02-04 19:37:33 +0000
commit6c117ee4aa4974556c6d6ac3799277a4da67b112 (patch)
treeedb8462a04d2ec6762b9a267d4dd142b312d5a58 /src/gui/painting/qpainter.cpp
parent89edf43c44294888781c308d9b1f1d9bab63645b (diff)
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>
Diffstat (limited to 'src/gui/painting/qpainter.cpp')
-rw-r--r--src/gui/painting/qpainter.cpp13
1 files changed, 8 insertions, 5 deletions
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) {