/** Queues a texture to be destroyed on the GL thread. */ public void queueDestroyTexture(final int tex) { platform.invokeLater(new Runnable() { public void run() { destroyTexture(tex); } }); }
/** Queues a framebuffer to be destroyed on the GL thread. */ public void queueDeleteFramebuffer(final int fbuf) { platform.invokeLater(new Runnable() { public void run() { deleteFramebuffer(fbuf); } }); }
protected void setImageLater(final AsyncImage<IMG> image, final IMG impl, final Scale scale) { platform.invokeLater(new Runnable() { public void run () { image.setImage(impl, scale); } }); }
/** * Delivers {@code result} to {@code callback} on the next game tick (on the PlayN thread). */ public <T> void notifySuccess(final Callback<T> callback, final T result) { invokeLater(new Runnable() { public void run() { callback.onSuccess(result); } }); }
protected void setErrorLater(final AsyncImage<?> image, final Throwable error) { platform.invokeLater(new Runnable() { public void run () { image.setError(error); } }); }
/** * Delivers {@code error} to {@code callback} on the next game tick (on the PlayN thread). */ public void notifyFailure(final Callback<?> callback, final Throwable error) { invokeLater(new Runnable() { public void run() { callback.onFailure(error); } }); }
/** Queues a custom shader to be cleaned up on the GL thread. */ public void queueClearShader(final GLShader shader) { platform.invokeLater(new Runnable() { public void run() { shader.clearProgram(); } }); }
@Override public void invokeLater(Runnable runnable) { switch (state) { default: case RUNNING: super.invokeLater(runnable); break; case PAUSED: // if we're paused, we need to run these on the main app thread instead of queueing them up // for processing on the run queue, because the run queue isn't processed while we're paused; // the main thread will ensure they're run serially, but also that they don't linger until the // next time the app is resumed (if that happens at all) activity.runOnUiThread(runnable); break; case EXITED: // if our activity has already exited, we have to drop this runnable, because we don't want to // conflict with another instance of our activity which may have already started up // (especially not its GL thread) break; } }
@Override public void invokeLater(Runnable runnable) { switch (state) { default: case RUNNING: super.invokeLater(runnable); break; case PAUSED: // if we're paused, we need to run these on the main app thread instead of queueing them up // for processing on the run queue, because the run queue isn't processed while we're paused; // the main thread will ensure they're run serially, but also that they don't linger until the // next time the app is resumed (if that happens at all) activity.runOnUiThread(runnable); break; case EXITED: // if our activity has already exited, we have to drop this runnable, because we don't want to // conflict with another instance of our activity which may have already started up // (especially not its GL thread) break; } }