diff options
author | Stefan Wildemann <metalstrolch@users.noreply.github.com> | 2021-09-13 11:36:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-13 11:36:50 +0200 |
commit | 0ed1660858a6b3055077f3b0d245c0316beb621c (patch) | |
tree | 64faca31f26907f3e46cab8622e792839386cec0 | |
parent | da065b411d6bee9e7f9b7424bb615d64c7e4cc54 (diff) | |
download | navit-0ed1660858a6b3055077f3b0d245c0316beb621c.tar.gz |
Fix:core: cancel drawing on resize request (#1142)
* Fix:core: cancel drawing on resize request
This commit causes navit to cancel async drawing in case of resize
request. Drawing is started again after that. this should effectively
cause a redraw on subsequent calls to resize. Some graphics like qt5
call resize for both dimension changes if the wigdet get's resized.
* Fix:graphics:qt5 Clear pixmap on resize
To remove ugly artefacts after resizing the widget until navit completes
to redraw the screen the widgets pixmap is cleared.
-rw-r--r-- | navit/graphics/qt5/QNavitQuick.cpp | 7 | ||||
-rw-r--r-- | navit/graphics/qt5/QNavitWidget.cpp | 7 | ||||
-rw-r--r-- | navit/navit.c | 6 |
3 files changed, 7 insertions, 13 deletions
diff --git a/navit/graphics/qt5/QNavitQuick.cpp b/navit/graphics/qt5/QNavitQuick.cpp index dcd0d2aa5..966072852 100644 --- a/navit/graphics/qt5/QNavitQuick.cpp +++ b/navit/graphics/qt5/QNavitQuick.cpp @@ -181,12 +181,7 @@ void QNavitQuick::geometryChanged(const QRectF& newGeometry, const QRectF& oldGe if (graphics_priv->pixmap == NULL) { graphics_priv->pixmap = new QPixmap(width(), height()); } - painter = new QPainter(graphics_priv->pixmap); - if (painter != NULL) { - QBrush brush; - painter->fillRect(0, 0, width(), height(), brush); - delete painter; - } + graphics_priv->pixmap->fill(Qt::transparent); dbg(lvl_debug, "size %fx%f", width(), height()); dbg(lvl_debug, "pixmap %p %dx%d", graphics_priv->pixmap, graphics_priv->pixmap->width(), graphics_priv->pixmap->height()); diff --git a/navit/graphics/qt5/QNavitWidget.cpp b/navit/graphics/qt5/QNavitWidget.cpp index 869d5f2ec..43c04d87f 100644 --- a/navit/graphics/qt5/QNavitWidget.cpp +++ b/navit/graphics/qt5/QNavitWidget.cpp @@ -105,12 +105,7 @@ void QNavitWidget::resizeEvent(QResizeEvent* event) { if (graphics_priv->pixmap == NULL) { graphics_priv->pixmap = new QPixmap(size()); } - painter = new QPainter(graphics_priv->pixmap); - if (painter != NULL) { - QBrush brush; - painter->fillRect(0, 0, width(), height(), brush); - delete painter; - } + graphics_priv->pixmap->fill(Qt::transparent); dbg(lvl_debug, "size %dx%d", width(), height()); dbg(lvl_debug, "pixmap %p %dx%d", graphics_priv->pixmap, graphics_priv->pixmap->width(), graphics_priv->pixmap->height()); diff --git a/navit/navit.c b/navit/navit.c index f80890e2c..14087c4ed 100644 --- a/navit/navit.c +++ b/navit/navit.c @@ -490,8 +490,12 @@ void navit_handle_resize(struct navit *this_, int w, int h) { graphics_set_rect(this_->gra, &sel.u.p_rect); if (callback) callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_); - if (this_->ready == 3) + if (this_->ready == 3) { + /* About to resize. Cancel drawing whatever it is */ + graphics_draw_cancel(this_->gra, this_->displaylist); + /* draw again even if we did not cancel anything */ navit_draw_async(this_, 1); + } } static void navit_resize(void *data, int w, int h) { |