experimental drawing optimization.
authorRobin Gareus <robin@gareus.org>
Fri, 5 Dec 2014 21:40:26 +0000 (22:40 +0100)
committerRobin Gareus <robin@gareus.org>
Fri, 5 Dec 2014 21:40:26 +0000 (22:40 +0100)
Q: is bounding_box(); etc more complex than queuing draw?

either way, canvas should eventually switch to
use an optimized OptimizingLookupTable.

libs/canvas/lookup_table.cc

index 2396f596354504798f0cdbc625da9c3c8bccd0b5..c50f010dc8b3b5bc4971cfd07bea560249bde618 100644 (file)
@@ -41,11 +41,22 @@ DumbLookupTable::DumbLookupTable (Item const & item)
 }
 
 vector<Item *>
-DumbLookupTable::get (Rect const &)
+DumbLookupTable::get (Rect const &area)
 {
        list<Item *> const & items = _item.items ();
        vector<Item *> vitems;
+#if 1
+       for (list<Item *>::const_iterator i = items.begin(); i != items.end(); ++i) {
+               boost::optional<Rect> item_bbox = (*i)->bounding_box ();
+               if (!item_bbox) continue;
+               Rect item = (*i)->item_to_window (item_bbox.get());
+               if (item.intersection (area)) {
+                       vitems.push_back (*i);
+               }
+       }
+#else
        copy (items.begin(), items.end(), back_inserter (vitems));
+#endif
        return vitems;
 }