Sped up rendering
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 6 Jun 2019 19:29:45 +0000 (21:29 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 6 Jun 2019 19:29:45 +0000 (21:29 +0200)
net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUIRenderer.java

index a2be5ba..5182a24 100644 (file)
@@ -29,14 +29,19 @@ public class LogicUIRenderer
 
        private static void renderComponent(GeneralGC gc, GUIComponent component, Rectangle visibleRegion)
        {
-               component.render(gc, visibleRegion);
-               if (DRAW_PINS)
+               Rectangle bounds = component.getBounds();
+               double lw = gc.getLineWidth();
+               if (visibleRegion.intersects(bounds.x - lw, bounds.y - lw, bounds.width + lw + lw, bounds.height + lw + lw))
                {
-                       gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_DARK_CYAN));
-                       for (Pin p : component.getPins())
+                       component.render(gc, visibleRegion);
+                       if (DRAW_PINS)
                        {
-                               Point pos = p.getPos();
-                               gc.fillOval(pos.x - 1, pos.y - 1, 2, 2);
+                               gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_DARK_CYAN));
+                               for (Pin p : component.getPins())
+                               {
+                                       Point pos = p.getPos();
+                                       gc.fillOval(pos.x - 1, pos.y - 1, 2, 2);
+                               }
                        }
                }
        }