diff options
author | Mathias Agopian <mathias@google.com> | 2013-04-18 13:52:58 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2013-04-18 14:47:44 -0700 |
commit | 78bc2033129507f1cf4acb2e3007f89cb2b3f224 (patch) | |
tree | 41adde11412edcce0980968faaf83b9360be2771 /opengl | |
parent | d3f9ffe28d1599e40f8c9a7c0c32465324bb2828 (diff) | |
download | frameworks_base-78bc2033129507f1cf4acb2e3007f89cb2b3f224.zip frameworks_base-78bc2033129507f1cf4acb2e3007f89cb2b3f224.tar.gz frameworks_base-78bc2033129507f1cf4acb2e3007f89cb2b3f224.tar.bz2 |
don't trigger a render when setting the rendermode
also don't cache the rendermode, to mimic the older
behaviour.
Bug: 8656076
Change-Id: Id9383852bed073927db2364f7ac30a1be28b4cd8
Diffstat (limited to 'opengl')
-rw-r--r-- | opengl/java/android/opengl/GLSurfaceView.java | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/opengl/java/android/opengl/GLSurfaceView.java b/opengl/java/android/opengl/GLSurfaceView.java index ab7ceb6..235829e 100644 --- a/opengl/java/android/opengl/GLSurfaceView.java +++ b/opengl/java/android/opengl/GLSurfaceView.java @@ -184,7 +184,6 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback private int mDebugFlags; private int mEGLContextClientVersion; private boolean mPreserveEGLContextOnPause; - private int mUserRenderMode; /** * The renderer only renders @@ -258,7 +257,6 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback // underlying surface is created and destroyed SurfaceHolder holder = getHolder(); holder.addCallback(this); - mUserRenderMode = RENDERMODE_CONTINUOUSLY; } /** @@ -516,7 +514,6 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback default: throw new IllegalArgumentException("renderMode"); } - mUserRenderMode = renderMode; mGLThread.setRenderMode(renderMode); } @@ -528,7 +525,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback * @see #RENDERMODE_WHEN_DIRTY */ public int getRenderMode() { - return mUserRenderMode; + return mGLThread.getRenderMode(); } /** @@ -608,9 +605,13 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback if (LOG_ATTACH_DETACH) { Log.d(TAG, "onAttachedToWindow reattach =" + mDetached); } + + final int renderMode = mGLThread != null ? + mGLThread.mRenderMode : RENDERMODE_CONTINUOUSLY; + if (mDetached && (mRenderer != null)) { mGLThread = new GLThread(mThisWeakRef); - mGLThread.setRenderMode(mUserRenderMode); + mGLThread.setRenderMode(renderMode); mGLThread.start(); } mDetached = false; @@ -1261,6 +1262,17 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback private Handler mGLHandler; private Choreographer mChoreographer; + // this runnable could be called often, so we keep an instance around + class GetRenderModeRunnable implements Runnable { + volatile public int renderMode; + @Override + public void run() { + renderMode = doGetRenderMode(); + } + }; + + private final GetRenderModeRunnable mGetRenderModeRunnable = new GetRenderModeRunnable(); + /* * Set once at thread construction time, nulled out when the parent view is garbage * called. This weak reference allows the GLSurfaceView to be garbage collected while @@ -1511,7 +1523,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback } } - private void doWindowResize(final int width, final int height) { + private void doWindowResize(int width, int height) { // we were not drawing yet. Update the window size and // state and attempt to draw a frame. mSizeChanged = (mWidth != width || mHeight != height); @@ -1522,9 +1534,13 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback executeDraw(); } - private void doSetRenderMode(final int renderMode) { + private void doSetRenderMode(int renderMode) { mRenderMode = renderMode; - requestRender(); + } + + + private int doGetRenderMode() { + return mRenderMode; } /* @@ -1607,6 +1623,11 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback }, 0); } + public int getRenderMode() { + mGLHandler.runWithScissors(mGetRenderModeRunnable, 0); + return mGetRenderModeRunnable.renderMode; + } + public void requestExitAndWait() { getLooper().quit(); try { |