174 return "true".equals(System.getProperty("javafx.draw.in.paint", result));}); 175 176 private static boolean singleThreaded = 177 AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> { 178 Boolean result = Boolean.getBoolean("quantum.singlethreaded"); 179 if (/*verbose &&*/ result) { 180 System.out.println("Warning: Single GUI Threadiong is enabled, FPS should be slower"); 181 } 182 return result; 183 }); 184 185 private static boolean noRenderJobs = 186 AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> { 187 Boolean result = Boolean.getBoolean("quantum.norenderjobs"); 188 if (/*verbose &&*/ result) { 189 System.out.println("Warning: Quantum will not submit render jobs, nothing should draw"); 190 } 191 return result; 192 }); 193 194 private AtomicBoolean toolkitRunning = new AtomicBoolean(false); 195 private AtomicBoolean animationRunning = new AtomicBoolean(false); 196 private AtomicBoolean nextPulseRequested = new AtomicBoolean(false); 197 private AtomicBoolean pulseRunning = new AtomicBoolean(false); 198 private int inPulse = 0; 199 private CountDownLatch launchLatch = new CountDownLatch(1); 200 201 final int PULSE_INTERVAL = (int)(TimeUnit.SECONDS.toMillis(1L) / getRefreshRate()); 202 final int FULLSPEED_INTERVAL = 1; // ms 203 boolean nativeSystemVsync = false; 204 private float _maxPixelScale; 205 private Runnable pulseRunnable, userRunnable, timerRunnable; 206 private Timer pulseTimer = null; 207 private Thread shutdownHook = null; 208 private PaintCollector collector; 209 private QuantumRenderer renderer; 210 private GraphicsPipeline pipeline; 211 212 private ClassLoader ccl; 213 214 private HashMap<Object,EventLoop> eventLoopMap = null; 215 216 private final PerformanceTracker perfTracker = new PerformanceTrackerImpl(); 438 } 439 if (listener != null) { 440 try { 441 listener.done(r); 442 } catch (Throwable th) { 443 th.printStackTrace(); 444 } 445 } 446 return null; 447 } 448 // Run the render job in the UI thread (this is for benchmarking only) 449 if (singleThreaded) { 450 r.run(); 451 return null; 452 } 453 return (renderer.submitRenderJob(r)); 454 } 455 456 void postPulse() { 457 if (toolkitRunning.get() && 458 (animationRunning.get() || nextPulseRequested.get() || collector.hasDirty()) && 459 !setPulseRunning()) { 460 461 Application.invokeLater(pulseRunnable); 462 463 if (debug) { 464 System.err.println("QT.postPulse@(" + System.nanoTime() + "): " + pulseString()); 465 } 466 } else if (debug) { 467 System.err.println("QT.postPulse#(" + System.nanoTime() + ") DROP: " + pulseString()); 468 } 469 } 470 471 private String pulseString() { 472 return ((toolkitRunning.get() ? "T" : "t") + 473 (animationRunning.get() ? "A" : "a") + 474 (pulseRunning.get() ? "P" : "p") + 475 (nextPulseRequested.get() ? "N" : "n") + 476 (collector.hasDirty() ? "D" : "d")); 477 } 478 479 private boolean setPulseRunning() { 480 return (pulseRunning.getAndSet(true)); 481 } 482 483 private void endPulseRunning() { 484 pulseRunning.set(false); 485 if (debug) { 486 System.err.println("QT.endPulse: " + System.nanoTime()); 487 } 488 } 489 490 void pulseFromQueue() { 491 try { 492 pulse(); 493 } finally { 494 endPulseRunning(); 495 } 496 } | 174 return "true".equals(System.getProperty("javafx.draw.in.paint", result));}); 175 176 private static boolean singleThreaded = 177 AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> { 178 Boolean result = Boolean.getBoolean("quantum.singlethreaded"); 179 if (/*verbose &&*/ result) { 180 System.out.println("Warning: Single GUI Threadiong is enabled, FPS should be slower"); 181 } 182 return result; 183 }); 184 185 private static boolean noRenderJobs = 186 AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> { 187 Boolean result = Boolean.getBoolean("quantum.norenderjobs"); 188 if (/*verbose &&*/ result) { 189 System.out.println("Warning: Quantum will not submit render jobs, nothing should draw"); 190 } 191 return result; 192 }); 193 194 private class PulseTask { 195 private volatile boolean isRunning; 196 PulseTask(boolean state) { 197 isRunning = state; 198 } 199 200 synchronized void set(boolean state) { 201 isRunning = state; 202 if (isRunning) { 203 pulseTimer.resume(); 204 } 205 } 206 207 boolean get() { 208 return isRunning; 209 } 210 } 211 212 private AtomicBoolean toolkitRunning = new AtomicBoolean(false); 213 private PulseTask animationRunning = new PulseTask(false); 214 private PulseTask nextPulseRequested = new PulseTask(false); 215 private AtomicBoolean pulseRunning = new AtomicBoolean(false); 216 private int inPulse = 0; 217 private CountDownLatch launchLatch = new CountDownLatch(1); 218 219 final int PULSE_INTERVAL = (int)(TimeUnit.SECONDS.toMillis(1L) / getRefreshRate()); 220 final int FULLSPEED_INTERVAL = 1; // ms 221 boolean nativeSystemVsync = false; 222 private float _maxPixelScale; 223 private Runnable pulseRunnable, userRunnable, timerRunnable; 224 private Timer pulseTimer = null; 225 private Thread shutdownHook = null; 226 private PaintCollector collector; 227 private QuantumRenderer renderer; 228 private GraphicsPipeline pipeline; 229 230 private ClassLoader ccl; 231 232 private HashMap<Object,EventLoop> eventLoopMap = null; 233 234 private final PerformanceTracker perfTracker = new PerformanceTrackerImpl(); 456 } 457 if (listener != null) { 458 try { 459 listener.done(r); 460 } catch (Throwable th) { 461 th.printStackTrace(); 462 } 463 } 464 return null; 465 } 466 // Run the render job in the UI thread (this is for benchmarking only) 467 if (singleThreaded) { 468 r.run(); 469 return null; 470 } 471 return (renderer.submitRenderJob(r)); 472 } 473 474 void postPulse() { 475 if (toolkitRunning.get() && 476 (animationRunning.get() || nextPulseRequested.get()) && 477 !setPulseRunning()) { 478 479 Application.invokeLater(pulseRunnable); 480 481 if (debug) { 482 System.err.println("QT.postPulse@(" + System.nanoTime() + "): " + pulseString()); 483 } 484 } else { 485 if (debug) { 486 System.err.println("QT.postPulse#(" + System.nanoTime() + "): DROP : " + pulseString()); 487 } 488 if (!animationRunning.get() && !nextPulseRequested.get() && !pulseRunning.get()) { 489 pulseTimer.pause(); 490 if (debug) { 491 System.err.println("QT.postPulse#(" + System.nanoTime() + "): Pause Timer : " + pulseString()); 492 } 493 } 494 } 495 } 496 497 private String pulseString() { 498 return ((toolkitRunning.get() ? "T" : "t") + 499 (animationRunning.get() ? "A" : "a") + 500 (pulseRunning.get() ? "P" : "p") + 501 (nextPulseRequested.get() ? "N" : "n")); 502 } 503 504 private boolean setPulseRunning() { 505 return (pulseRunning.getAndSet(true)); 506 } 507 508 private void endPulseRunning() { 509 pulseRunning.set(false); 510 if (debug) { 511 System.err.println("QT.endPulse: " + System.nanoTime()); 512 } 513 } 514 515 void pulseFromQueue() { 516 try { 517 pulse(); 518 } finally { 519 endPulseRunning(); 520 } 521 } |