public static void postUpdate() { if (!idleHandlerActive) { queue.addIdleHandler(glView); idleHandlerActive = true; // Log.i(logTag, "start idle handler"); } }
@Override public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { /*Log.i(logTag, "surfaceChanged " + Integer.toString(w) + " " + Integer.toString(h) + " " + getHolder().getSurfaceFrame().toString());*/ if (mEglHelper.mEglContext == null) { // Log.i(logTag, "context lost"); return; } if (!initNative) { handler = new Handler(); nativeInit(w, h); queue = Looper.myQueue(); queue.addIdleHandler(this); idleHandlerActive = true; initNative = true; } else { nativeResize(w, h); postUpdate(); if (initSurface == true && android.os.Build.VERSION.SDK_INT >= 11) // HACK: resize is from a screen rotation, do swap() again or display may not // render, Android bug? Custom rotation animation in pre 3.0 redraws the screen // at least one more time anyway { // Log.i(logTag, "extra swap after rotation"); mEglHelper.swap(); } } initSurface = true; }
/** * Processes pending events on the input connection thread before returning. Must be called on * the input connection thread during a test. */ protected void processInputConnectionEvents() { fAssertSame( "Should be called on input connection thread", Looper.myLooper(), inputConnectionHandler.getLooper()); // Adapted from GeckoThread.pumpMessageLoop. MessageQueue queue = Looper.myQueue(); queue.addIdleHandler( new MessageQueue.IdleHandler() { @Override public boolean queueIdle() { final Message msg = Message.obtain(inputConnectionHandler); msg.obj = inputConnectionHandler; inputConnectionHandler.sendMessageAtFrontOfQueue(msg); return false; // Remove this idle handler. } }); final Method getNextMessage; try { getNextMessage = queue.getClass().getDeclaredMethod("next"); } catch (final NoSuchMethodException e) { throw new UnsupportedOperationException(e); } getNextMessage.setAccessible(true); while (true) { final Message msg; try { msg = (Message) getNextMessage.invoke(queue); } catch (final IllegalAccessException | InvocationTargetException e) { throw new UnsupportedOperationException(e); } if (msg.obj == inputConnectionHandler && msg.getTarget() == inputConnectionHandler) { // Our idle signal break; } else if (msg.getTarget() == null) { Looper.myLooper().quit(); break; } msg.getTarget().dispatchMessage(msg); } }
void scheduleNextLocked() { if (mQueue.size() > 0) { Runnable peek = mQueue.getFirst(); if (peek instanceof IdleRunnable) { mMessageQueue.addIdleHandler(mHandler); } else { mHandler.sendEmptyMessage(1); } } }
public static void stopUpdate() { // Log.i(logTag, "stop idle handler"); queue.removeIdleHandler(glView); idleHandlerActive = false; }