MCPcopy Index your code
hub / github.com/processing/processing / handleDraw

Method handleDraw

core/src/processing/core/PApplet.java:2393–2517  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2391
2392
2393 public void handleDraw() {
2394 //debug("handleDraw() " + g + " " + looping + " " + redraw + " valid:" + this.isValid() + " visible:" + this.isVisible());
2395
2396 // canDraw = g != null && (looping || redraw);
2397 if (g == null) return;
2398 if (!looping && !redraw) return;
2399// System.out.println("looping/redraw = " + looping + " " + redraw);
2400
2401 // no longer in use by any of our renderers
2402// if (!g.canDraw()) {
2403// debug("g.canDraw() is false");
2404// // Don't draw if the renderer is not yet ready.
2405// // (e.g. OpenGL has to wait for a peer to be on screen)
2406// return;
2407// }
2408
2409 // Store the quality setting in case it's changed during draw and the
2410 // drawing context needs to be re-built before the next frame.
2411// int pquality = g.smooth;
2412
2413 if (insideDraw) {
2414 System.err.println("handleDraw() called before finishing");
2415 System.exit(1);
2416 }
2417
2418 insideDraw = true;
2419 g.beginDraw();
2420 if (recorder != null) {
2421 recorder.beginDraw();
2422 }
2423
2424 long now = System.nanoTime();
2425
2426 if (frameCount == 0) {
2427 // 3.0a5 should be no longer needed; handled by PSurface
2428 //surface.checkDisplaySize();
2429
2430// try {
2431 //println("Calling setup()");
2432 setup();
2433 //println("Done with setup()");
2434
2435// } catch (RendererChangeException e) {
2436// // Give up, instead set the new renderer and re-attempt setup()
2437// return;
2438// }
2439// defaultSize = false;
2440
2441 } else { // frameCount > 0, meaning an actual draw()
2442 // update the current frameRate
2443
2444 // Calculate frameRate through average frame times, not average fps, e.g.:
2445 //
2446 // Alternating 2 ms and 20 ms frames (JavaFX or JOGL sometimes does this)
2447 // is around 90.91 fps (two frames in 22 ms, one frame 11 ms).
2448 //
2449 // However, averaging fps gives us: (500 fps + 50 fps) / 2 = 275 fps.
2450 // This is because we had 500 fps for 2 ms and 50 fps for 20 ms, but we

Callers 4

displayMethod · 0.80
callDrawMethod · 0.80
handleMethod · 0.80
callDrawMethod · 0.80

Calls 8

setupMethod · 0.95
handleMethodsMethod · 0.95
drawMethod · 0.95
dequeueEventsMethod · 0.95
exitMethod · 0.80
printlnMethod · 0.45
beginDrawMethod · 0.45
endDrawMethod · 0.45

Tested by

no test coverage detected