Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ abstract class GlassScene implements TKScene {
private volatile boolean entireSceneDirty = true;

private boolean doPresent = true;
private boolean doVSync = false;
private final AtomicBoolean painting = new AtomicBoolean(false);

private final boolean depthBuffer;
Expand Down Expand Up @@ -307,6 +308,14 @@ public final synchronized boolean getDoPresent() {
return doPresent;
}

public final synchronized void setDoVSync(boolean value) {
doVSync = value;
}

public final synchronized boolean getDoVsync() {
return doVSync;
}

protected Color getClearColor() {
WindowStage windowStage = stage instanceof WindowStage ? (WindowStage)stage : null;
if (windowStage != null && windowStage.getPlatformWindow() != null &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,14 @@ final void renderAll() {
if (!needsHint) {
needsHint = gs.isSynchronous();
}
}

for (final GlassScene gs : dirtyScenes) {
// On platforms with a window manager, we always set doPresent = true, because
// we always need to rerender the scene if it's in the dirty list and we do a
// swap on a per-window basis
gs.setDoPresent(true);
gs.setDoVSync(needsHint && dirtyScenes.getLast() == gs);
try {
gs.repaint();
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ final class PresentingPainter extends ViewPainter {

/* present for vsync buffer swap */
if (vs.getDoPresent()) {
if (!presentable.present()) {
if (!presentable.present(vs.getDoVsync())) {
disposePresentable();
sceneState.getScene().entireSceneNeedsRepaint();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public interface Presentable extends RenderTarget {
*/
public boolean present();

public default boolean present(boolean vsync) {
return present();
}

public float getPixelScaleFactorX();
public float getPixelScaleFactorY();
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,16 @@ private void drawTexture(ES2Graphics g, RTTexture src,

@Override
public boolean present() {
boolean presented = drawable.swapBuffers(context.getGLContext());
context.makeCurrent(null);
return drawable.swapBuffers(context.getGLContext());
}

@Override
public boolean present(boolean vsync) {
boolean presented = present();

if (vsync)
context.getGLContext().finish();

return presented;
}

Expand Down Expand Up @@ -308,6 +316,7 @@ public void dispose() {
}

if (drawable != null) {
context.makeCurrent(null);
drawable.dispose();
drawable = null;
}
Expand Down