[aseprite] 235/308: Fix artifacts when scrolling on widgets with sub-children (fix #963)

Tobias Hansen thansen at moszumanska.debian.org
Tue Mar 8 02:45:15 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 1588e834c3838ffda630abc21bb70c2d4fd75d4d
Author: David Capello <davidcapello at gmail.com>
Date:   Mon Feb 15 15:54:54 2016 -0300

    Fix artifacts when scrolling on widgets with sub-children (fix #963)
    
    This bug was introduced in b0650f6afea1b860a8593fd4614ca272f8edbfac
    To fix this issue we've to remove kPaintMessages from the message queue
    for widgets that were moved. Those pending paint messages aren't valid
    anymore because the widget was invalidated again.
---
 src/ui/manager.cpp | 24 +++++++++++++++---------
 src/ui/manager.h   |  1 +
 src/ui/view.cpp    | 11 ++---------
 src/ui/widget.cpp  |  9 +++++++++
 4 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp
index 1ab31dd..f7a1ba1 100644
--- a/src/ui/manager.cpp
+++ b/src/ui/manager.cpp
@@ -835,21 +835,27 @@ void Manager::freeWidget(Widget* widget)
 
 void Manager::removeMessage(Message* msg)
 {
-  Messages::iterator it = std::find(msg_queue.begin(), msg_queue.end(), msg);
+  auto it = std::find(msg_queue.begin(), msg_queue.end(), msg);
   ASSERT(it != msg_queue.end());
   msg_queue.erase(it);
 }
 
 void Manager::removeMessagesFor(Widget* widget)
 {
-  for (Messages::iterator it=msg_queue.begin(), end=msg_queue.end();
-       it != end; ++it)
-    removeWidgetFromRecipients(widget, *it);
+  for (Message* msg : msg_queue)
+    removeWidgetFromRecipients(widget, msg);
+}
+
+void Manager::removeMessagesFor(Widget* widget, MessageType type)
+{
+  for (Message* msg : msg_queue)
+    if (msg->type() == type)
+      removeWidgetFromRecipients(widget, msg);
 }
 
 void Manager::removeMessagesForTimer(Timer* timer)
 {
-  for (Messages::iterator it=msg_queue.begin(); it != msg_queue.end(); ) {
+  for (auto it=msg_queue.begin(); it != msg_queue.end(); ) {
     Message* msg = *it;
 
     if (!msg->isUsed() &&
@@ -1269,11 +1275,11 @@ void Manager::pumpQueue()
             // Restore clip region for paint messages.
             surface->setClipBounds(oldClip);
           }
-
-          // As this kPaintMessage's rectangle was updated, we can
-          // remove it from "m_invalidRegion".
-          m_invalidRegion -= gfx::Region(paintMsg->rect());
         }
+
+        // As this kPaintMessage's rectangle was updated, we can
+        // remove it from "m_invalidRegion".
+        m_invalidRegion -= gfx::Region(paintMsg->rect());
       }
       else {
         // Call the message handler
diff --git a/src/ui/manager.h b/src/ui/manager.h
index 0b603cc..14f26c1 100644
--- a/src/ui/manager.h
+++ b/src/ui/manager.h
@@ -74,6 +74,7 @@ namespace ui {
     void freeWidget(Widget* widget);
     void removeMessage(Message* msg);
     void removeMessagesFor(Widget* widget);
+    void removeMessagesFor(Widget* widget, MessageType type);
     void removeMessagesForTimer(Timer* timer);
 
     void addMessageFilter(int message, Widget* widget);
diff --git a/src/ui/view.cpp b/src/ui/view.cpp
index b625dca..d9b4c82 100644
--- a/src/ui/view.cpp
+++ b/src/ui/view.cpp
@@ -336,21 +336,14 @@ void View::onSetViewScroll(const gfx::Point& pt)
   }
 #endif
 
-  // Don't re-invalidate the already invalid region.
-  if (manager)
-    invalidRegion -= manager->getInvalidRegion();
-
   // Invalidate viewport's children regions
   m_viewport.invalidateRegion(invalidRegion);
 
   // Notify about the new scroll position
   onScrollChange();
 
-  // Generate PaintMessages right now when the invalid region is too
-  // disaggregated. This is useful to avoid a lot of PaintMessage with
-  // small rectangles.
-  if (manager->getInvalidRegion().size() > 4)
-    flushRedraw();
+  // Generate PaintMessages right now.
+  flushRedraw();
 }
 
 void View::onScrollRegion(ScrollRegionEvent& ev)
diff --git a/src/ui/widget.cpp b/src/ui/widget.cpp
index 231ff13..6fcb431 100644
--- a/src/ui/widget.cpp
+++ b/src/ui/widget.cpp
@@ -618,6 +618,11 @@ void Widget::setBounds(const Rect& rc)
 void Widget::setBoundsQuietly(const gfx::Rect& rc)
 {
   m_bounds = rc;
+
+  // Remove all paint messages for this widget.
+  if (Manager* manager = this->manager())
+    manager->removeMessagesFor(this, kPaintMessage);
+
   invalidate();
 }
 
@@ -1457,6 +1462,10 @@ void Widget::offsetWidgets(int dx, int dy)
   m_updateRegion.offset(dx, dy);
   m_bounds.offset(dx, dy);
 
+  // Remove all paint messages for this widget.
+  if (Manager* manager = this->manager())
+    manager->removeMessagesFor(this, kPaintMessage);
+
   for (auto child : m_children)
     child->offsetWidgets(dx, dy);
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list