summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wildemann <metalstrolch@users.noreply.github.com>2019-09-20 09:28:46 +0200
committerGitHub <noreply@github.com>2019-09-20 09:28:46 +0200
commitdeccb6c4379e135ae45513a7bfef3b4998f24e94 (patch)
treed44e92d33b18d0f106c50c0c7a63976ca60cf9bf
parenta9a1375c7445b2f60bbd0e75cba70f14ca1c64ee (diff)
downloadnavit-deccb6c4379e135ae45513a7bfef3b4998f24e94.tar.gz
fix:graphics/qt5: Allow to draw transparent polygons (#878)
There is a "misconception" in qt5 graphics about how to draw transparent stuff causing transparent items on the map to not correctly work. This PR changes qt5 graphics to force-clear overlays on starting to draw them instead of force clearing the shape of a transparent item. While this imposes the limitation that the content of an overlay cannot be drawn in multiple runs, it allows to draw transparent stuff on the map. Luckily I don't know of any overlay item yet that is not drawn in one run. So this seems to work OK.
-rw-r--r--navit/graphics/qt5/graphics_qt5.cpp28
1 files changed, 5 insertions, 23 deletions
diff --git a/navit/graphics/qt5/graphics_qt5.cpp b/navit/graphics/qt5/graphics_qt5.cpp
index 10784d6b3..cb9b4c456 100644
--- a/navit/graphics/qt5/graphics_qt5.cpp
+++ b/navit/graphics/qt5/graphics_qt5.cpp
@@ -408,13 +408,7 @@ static void draw_polygon(struct graphics_priv* gr, struct graphics_gc_priv* gc,
polygon.putPoints(i, 1, p[i].x, p[i].y);
gr->painter->setPen(*gc->pen);
gr->painter->setBrush(*gc->brush);
- /* if the polygon is transparent, we need to clear it first */
- if (!gc->brush->isOpaque()) {
- QPainter::CompositionMode mode = gr->painter->compositionMode();
- gr->painter->setCompositionMode(QPainter::CompositionMode_Clear);
- gr->painter->drawPolygon(polygon);
- gr->painter->setCompositionMode(mode);
- }
+
gr->painter->drawPolygon(polygon);
}
@@ -446,13 +440,6 @@ static void draw_polygon_with_holes (struct graphics_priv *gr, struct graphics_g
if(hole_count > 0)
path = path.subtracted(inner);
- /* if the polygon is transparent, we need to clear it first */
- if (!gc->brush->isOpaque()) {
- QPainter::CompositionMode mode = gr->painter->compositionMode();
- gr->painter->setCompositionMode(QPainter::CompositionMode_Clear);
- gr->painter->drawPath(path);
- gr->painter->setCompositionMode(mode);
- }
gr->painter->drawPath(path);
}
@@ -460,13 +447,6 @@ static void draw_rectangle(struct graphics_priv* gr, struct graphics_gc_priv* gc
// dbg(lvl_debug,"gr=%p gc=%p %d,%d,%d,%d", gr, gc, p->x, p->y, w, h);
if (gr->painter == NULL)
return;
- /* if the rectangle is transparent, we need to clear it first */
- if (!gc->brush->isOpaque()) {
- QPainter::CompositionMode mode = gr->painter->compositionMode();
- gr->painter->setCompositionMode(QPainter::CompositionMode_Clear);
- gr->painter->fillRect(p->x, p->y, w, h, *gc->brush);
- gr->painter->setCompositionMode(mode);
- }
gr->painter->fillRect(p->x, p->y, w, h, *gc->brush);
}
@@ -647,9 +627,11 @@ static void draw_mode(struct graphics_priv* gr, enum draw_mode_num mode) {
case draw_mode_begin:
dbg(lvl_debug, "Begin drawing on context %p (use == %d)", gr, gr->use_count);
gr->use_count++;
- if (gr->painter == NULL)
+ if (gr->painter == NULL) {
+ if(gr->parent != NULL)
+ gr->pixmap->fill(QColor(0,0,0,0));
gr->painter = new QPainter(gr->pixmap);
- else
+ } else
dbg(lvl_debug, "drawing on %p already active", gr);
break;
case draw_mode_end: