diff options
author | Kenneth Russel <[email protected]> | 2005-02-27 21:30:24 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-02-27 21:30:24 +0000 |
commit | ef5917630fb25e28ff6e2465dddce6af00015711 (patch) | |
tree | 759343a8b136e40677dfd574cece572ac126faa6 /src | |
parent | 2758428e509e39ad307e9722b7d4609954ddbef2 (diff) |
Made GLJPanel.display() use paintImmediately all the time; removed
now-unnecessary semaphore and heuristics
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@247 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rw-r--r-- | src/net/java/games/jogl/GLJPanel.java | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/net/java/games/jogl/GLJPanel.java b/src/net/java/games/jogl/GLJPanel.java index 425160494..6b9b52ec7 100644 --- a/src/net/java/games/jogl/GLJPanel.java +++ b/src/net/java/games/jogl/GLJPanel.java @@ -78,7 +78,6 @@ public final class GLJPanel extends JPanel implements GLDrawable { private int neededOffscreenImageHeight; private DataBufferByte dbByte; private DataBufferInt dbInt; - private Object semaphore = new Object(); private int panelWidth = 0; private int panelHeight = 0; private Updater updater; @@ -127,26 +126,9 @@ public final class GLJPanel extends JPanel implements GLDrawable { // Multithreaded redrawing of Swing components is not allowed, // so do everything on the event dispatch thread try { - // Wait a reasonable period of time for the repaint to - // complete, so that we don't swamp the AWT event queue thread - // with repaint requests. We used to have an explicit flag to - // detect when the repaint completed; unfortunately, under - // some circumstances, the top-level window can be torn down - // while we're waiting for the repaint to complete, which will - // never happen. It doesn't look like there's enough - // information in the EventQueue to figure out whether there - // are pending events without posting to the queue, which we - // don't want to do during shutdown, and adding a - // HierarchyListener and watching for displayability events - // might be fragile since we don't know exactly how this - // component will be used in users' applications. For these - // reasons we simply wait up to a brief period of time for the - // repaint to complete. - synchronized(semaphore) { - repaint(); - semaphore.wait(100); - } - } catch (InterruptedException e) { + EventQueue.invokeAndWait(paintImmediatelyAction); + } catch (Exception e) { + throw new GLException(e); } } } @@ -177,9 +159,6 @@ public final class GLJPanel extends JPanel implements GLDrawable { } else { offscreenContext.invokeGL(displayAction, false, initAction); } - synchronized(semaphore) { - semaphore.notifyAll(); - } } /** Overridden from Canvas; causes {@link GLDrawableHelper#reshape} @@ -594,6 +573,13 @@ public final class GLJPanel extends JPanel implements GLDrawable { } private SwapBuffersAction swapBuffersAction = new SwapBuffersAction(); + class PaintImmediatelyAction implements Runnable { + public void run() { + paintImmediately(0, 0, getWidth(), getHeight()); + } + } + private PaintImmediatelyAction paintImmediatelyAction = new PaintImmediatelyAction(); + private int getNextPowerOf2(int number) { if (((number-1) & number) == 0) { //ex: 8 -> 0b1000; 8-1=7 -> 0b0111; 0b1000&0b0111 == 0 |