Drawing optimization: only redraw changed layers

The effect was: when drawing a shape on a single layer, all
layers have been redrawn. This was changed such that only
the affected layer is actually redrawn.
This commit is contained in:
Matthias Koefferlein
2017-02-23 23:33:07 +01:00
parent 83f12382e8
commit 55bac69a4a
11 changed files with 90 additions and 30 deletions
+2 -1
View File
@@ -32,6 +32,7 @@
#include "dbLayoutStateModel.h"
#include <vector>
#include <limits>
namespace lay
{
@@ -351,7 +352,7 @@ public:
private:
void invalidate_state ()
{
invalidate_bboxes ();
invalidate_bboxes (std::numeric_limits<unsigned int>::max ());
}
virtual void do_update ();
+1 -1
View File
@@ -79,7 +79,7 @@ LayoutHandle::LayoutHandle (db::Layout *layout, const std::string &filename)
}
mp_layout->hier_changed_event.add (this, &LayoutHandle::layout_changed);
mp_layout->bboxes_changed_event.add (this, &LayoutHandle::layout_changed);
mp_layout->bboxes_changed_any_event.add (this, &LayoutHandle::layout_changed);
mp_layout->cell_name_changed_event.add (this, &LayoutHandle::layout_changed);
mp_layout->prop_ids_changed_event.add (this, &LayoutHandle::layout_changed);
mp_layout->layer_properties_changed_event.add (this, &LayoutHandle::layout_changed);
+26 -6
View File
@@ -645,7 +645,7 @@ void LayoutView::update_event_handlers ()
for (unsigned int i = 0; i < cellviews (); ++i) {
cellview (i)->layout ().hier_changed_event.add (this, &LayoutView::signal_hier_changed);
cellview (i)->layout ().bboxes_changed_event.add (this, &LayoutView::signal_bboxes_changed);
cellview (i)->layout ().bboxes_changed_event.add (this, &LayoutView::signal_bboxes_from_layer_changed, i);
cellview (i)->layout ().dbu_changed_event.add (this, &LayoutView::signal_bboxes_changed);
cellview (i)->layout ().prop_ids_changed_event.add (this, &LayoutView::signal_prop_ids_changed);
cellview (i)->layout ().layer_properties_changed_event.add (this, &LayoutView::signal_layer_properties_changed);
@@ -653,7 +653,7 @@ void LayoutView::update_event_handlers ()
cellview (i)->apply_technology_with_sender_event.add (this, &LayoutView::signal_apply_technology);
}
annotation_shapes ().bboxes_changed_event.add (this, &LayoutView::signal_annotations_changed);
annotation_shapes ().bboxes_changed_any_event.add (this, &LayoutView::signal_annotations_changed);
mp_canvas->viewport_changed_event.add (this, &LayoutView::viewport_changed);
}
@@ -2066,15 +2066,35 @@ LayoutView::signal_hier_changed ()
hier_changed_event ();
}
void
LayoutView::signal_bboxes_from_layer_changed (unsigned int cv_index, unsigned int layer_index)
{
if (layer_index == std::numeric_limits<unsigned int>::max ()) {
// redraw all
signal_bboxes_changed ();
} else {
// redraw only the layers required for redrawing
for (std::vector<lay::RedrawLayerInfo>::const_iterator l = mp_canvas->get_redraw_layers ().begin (); l != mp_canvas->get_redraw_layers ().end (); ++l) {
if (l->cellview_index == int (cv_index) && (layer_index == std::numeric_limits<unsigned int>::max () || l->layer_index == int (layer_index))) {
redraw_layer ((unsigned int) (l - mp_canvas->get_redraw_layers ().begin ()));
}
}
// forward this event to our observers
geom_changed_event ();
}
}
void
LayoutView::signal_bboxes_changed ()
{
// schedule a redraw request for all layers
// HINT: it could be optimized if we knew which layer to redraw. However, this
// is somewhat difficult to find out: first, we had to identify the layer we need to
// redraw, the the layout which to redraw and then the layer views which need to be
// redrawn ..
redraw ();
// forward this event to our observers
geom_changed_event ();
}
+1
View File
@@ -2494,6 +2494,7 @@ public slots:
// event handlers used to connect to the layout object's events
void signal_hier_changed ();
void signal_bboxes_from_layer_changed (unsigned int cv_index, unsigned int layer_index);
void signal_bboxes_changed ();
void signal_prop_ids_changed ();
void signal_layer_properties_changed ();
+7 -4
View File
@@ -193,6 +193,7 @@ RedrawThread::restart (const std::vector<int> &restart)
{
m_redraw_regions.clear ();
m_redraw_regions.push_back (db::Box (db::Point (0, 0), db::Point (m_width, m_height)));
m_valid_region = m_stored_region = db::DBox ();
do_start (false, 0, 0, restart, -1);
}
@@ -241,13 +242,13 @@ RedrawThread::do_start (bool clear, const db::Vector *shift_vector, const std::v
cv->layout ().update ();
// attach to the layout object to receive change notifications to stop the redraw thread
cv->layout ().hier_changed_event.add (this, &RedrawThread::layout_changed);
cv->layout ().bboxes_changed_event.add (this, &RedrawThread::layout_changed);
cv->layout ().bboxes_changed_any_event.add (this, &RedrawThread::layout_changed);
}
}
mp_view->annotation_shapes ().update ();
// attach to the layout object to receive change notifications to stop the redraw thread
mp_view->annotation_shapes ().hier_changed_event.add (this, &RedrawThread::layout_changed); // not really required, since the shapes have no hierarchy, but for completeness ..
mp_view->annotation_shapes ().bboxes_changed_event.add (this, &RedrawThread::layout_changed);
mp_view->annotation_shapes ().bboxes_changed_any_event.add (this, &RedrawThread::layout_changed);
mp_view->cellviews_about_to_change_event.add (this, &RedrawThread::layout_changed);
mp_view->cellview_about_to_change_event.add (this, &RedrawThread::layout_changed_with_int);
@@ -275,8 +276,10 @@ RedrawThread::do_start (bool clear, const db::Vector *shift_vector, const std::v
if (*l == draw_custom_queue_entry) {
planes_to_init.push_back (-1);
} else if (*l >= 0 && *l < int (m_layers.size ())) {
for (int o = 0; o < planes_per_layer; ++o) {
planes_to_init.push_back (o + *l * planes_per_layer + special_planes_before + special_planes_after);
for (int i = 0; i < planes_per_layer / 3; ++i) {
planes_to_init.push_back (*l * (planes_per_layer / 3) + special_planes_before + i);
planes_to_init.push_back ((*l + m_nlayers) * (planes_per_layer / 3) + special_planes_before + i);
planes_to_init.push_back ((*l + m_nlayers * 2) * (planes_per_layer / 3) + special_planes_before + i);
}
}
}