Better screen updates optimization

master
Marco Maccaferri 2020-05-09 10:53:10 +02:00
rodzic e2e08d9592
commit 1ec3a1151e
1 zmienionych plików z 14 dodań i 3 usunięć

Wyświetl plik

@ -10,6 +10,8 @@
package com.maccasoft.tools; package com.maccasoft.tools;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.TextTransfer;
@ -92,6 +94,7 @@ public class Terminal {
@Override @Override
public void run() { public void run() {
pendingRunnable.set(null);
if (canvas.isDisposed() || bounds == null) { if (canvas.isDisposed() || bounds == null) {
return; return;
} }
@ -99,6 +102,8 @@ public class Terminal {
} }
}; };
final AtomicReference<Runnable> pendingRunnable = new AtomicReference<Runnable>();
Terminal() { Terminal() {
// For JUnit tests // For JUnit tests
} }
@ -422,7 +427,9 @@ public class Terminal {
} finally { } finally {
gc.dispose(); gc.dispose();
} }
display.timerExec(REDRAW_MS, redrawRunnable); if (pendingRunnable.compareAndSet(null, redrawRunnable)) {
display.timerExec(REDRAW_MS, redrawRunnable);
}
} }
}); });
} }
@ -705,7 +712,9 @@ public class Terminal {
} finally { } finally {
gc.dispose(); gc.dispose();
} }
display.timerExec(REDRAW_MS, redrawRunnable); if (pendingRunnable.compareAndSet(null, redrawRunnable)) {
display.timerExec(REDRAW_MS, redrawRunnable);
}
} }
}); });
} }
@ -723,7 +732,9 @@ public class Terminal {
} finally { } finally {
gc.dispose(); gc.dispose();
} }
display.timerExec(REDRAW_MS, redrawRunnable); if (pendingRunnable.compareAndSet(null, redrawRunnable)) {
display.timerExec(REDRAW_MS, redrawRunnable);
}
} }
}); });
} }