Revision e52f9d96
Added by Leszek Koltunski over 9 years ago
| src/main/java/org/distorted/examples/plainmonalisa/PlainMonaLisaSurfaceView.java | ||
|---|---|---|
| 31 | 31 |
{
|
| 32 | 32 |
private static final String TAG = "MonaLisaSurface"; |
| 33 | 33 |
private RenderThread mRenderThread; |
| 34 |
private static volatile boolean mPaused = true; |
|
| 34 | 35 |
|
| 35 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 36 | 37 |
|
| ... | ... | |
| 110 | 111 |
|
| 111 | 112 |
public void onPause() |
| 112 | 113 |
{
|
| 114 |
mPaused = true; |
|
| 115 |
|
|
| 113 | 116 |
Log.d(TAG, "onPause unhooking choreographer"); |
| 114 | 117 |
Choreographer.getInstance().removeFrameCallback(this); |
| 115 | 118 |
} |
| ... | ... | |
| 118 | 121 |
|
| 119 | 122 |
public void onResume() |
| 120 | 123 |
{
|
| 124 |
mPaused = false; |
|
| 125 |
|
|
| 121 | 126 |
if (mRenderThread != null) |
| 122 | 127 |
{
|
| 123 | 128 |
Log.d(TAG, "onResume re-hooking choreographer"); |
| ... | ... | |
| 125 | 130 |
} |
| 126 | 131 |
} |
| 127 | 132 |
|
| 133 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 134 |
|
|
| 135 |
public static boolean isPaused() |
|
| 136 |
{
|
|
| 137 |
return mPaused; |
|
| 138 |
} |
|
| 139 |
|
|
| 128 | 140 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 129 | 141 |
|
| 130 | 142 |
@Override |
| src/main/java/org/distorted/examples/plainmonalisa/RenderThread.java | ||
|---|---|---|
| 237 | 237 |
|
| 238 | 238 |
public void doFrame(long frameTimeNs) |
| 239 | 239 |
{
|
| 240 |
Trace.beginSection("doFrame draw");
|
|
| 240 |
if( PlainMonaLisaSurfaceView.isPaused() ) |
|
| 241 |
{
|
|
| 242 |
android.util.Log.e("Thread", "Got here after onPaused- ignoring frame draw call!!");
|
|
| 243 |
return; |
|
| 244 |
} |
|
| 245 |
|
|
| 241 | 246 |
eglCore.makeCurrent(eglSurface); |
| 242 | 247 |
|
| 243 | 248 |
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
| ... | ... | |
| 245 | 250 |
monaLisa.draw(System.currentTimeMillis()); |
| 246 | 251 |
|
| 247 | 252 |
eglCore.swapBuffers(eglSurface); |
| 248 |
Trace.endSection(); |
|
| 249 | 253 |
} |
| 250 | 254 |
|
| 251 | 255 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Fix a bug in PlainMonaLisa - avoid a crash on screen rotate