History log of /frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
29e0bd2f5a80fdfe0e5b482a1df86363afcecbfa 19-Sep-2012 Mathias Agopian <mathias@google.com> GLSurfaceView defaults to 888 instead of 565

Change-Id: Ie00fe578136365031e4bb878a04b68dc40e24b9e
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
cee059dc764a57860da6b1574952089680b5ddc6 16-Apr-2012 Jack Palevich <jackpal@google.com> Improve GLSurfaceView Pausing.

When pausing we want to do three separate things, in order:

+ release the EGL surface
+ optionally release the EGL context
+ optionally terminate Egl

Previously we would only do these things if we had an EGL surface. But
it is possible that we don't have an EGL Surface, but still have an EGL
context. And in that situation we still want to release the EGL context.

Now we check the preconditions for the three cases separately.

Bug: 6338235
Change-Id: I804683b3d5c136cc98ea3f5051067eea18152ddf
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
7dee7a38baafcbdd26ff116eeec862ec661dedec 10-Apr-2012 Jack Palevich <jackpal@google.com> Notify monitor waiters when changing mSurfaceIsBad value.

Otherwise the waiters might not wake up, leading to ANRs.

Bug: 6307843
Change-Id: I0646b4e8368f80dbff46342f75709992796973fd
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
7d73df83f9a28950f404e957eb2e4ea1e8525c55 30-Mar-2012 Jack Palevich <jackpal@google.com> Try to survive a failure return from eglMakeCurrent.

Assume a failure in eglMakeCurrent occurs because the SurfaceView
surface has been destroyed.

See b/6257956 for an example of this failure happening during rotation
stress testing.

Change-Id: I4618703b5291aba3a3f0c6bd83c3435a67b97d33
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
db6c78b5bdf264abe8f6de97f67ca5e90fb6a05a 29-Mar-2012 Jack Palevich <jackpal@google.com> Make GLSurfaceView handle eglSwapBuffers errors more robustly.

A careful reading of the EGL spec, as well as experience with many
different EGL drivers, has shown that it is error prone to attempt to
discriminate between different error conditions.

We now treat any error besides EGL_CONTEXT_LOST as an indication that the
EGL context is in a bad state, most likely due to the window manager
having removed the underlying surface flinger surface.

In addition, we changed the way we deal with this kind of error:
Previously we would ignore the error and keep rendering. But if the
EGL context and surface has become invalid, it would be better to
stop drawing. We now stop drawing until the surface view surface is
recreated.

See b/6032663 for an example of this problem affecting the GMM app,
but note that GMM is using their own version of GLSurfaceView, so this
change won't help them directly. They'll have to make a similar change
to their version of GLSurfaceView.

Change-Id: Iffe3e1e3a3c7a91d03140fd34391eadeaecf777e
Signed-off-by: Jack Palevich <jackpal@google.com>
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
f7f4c20605badb95f99e3f1f609458a9e4fe0c1a 22-Mar-2012 Jack Palevich <jackpal@google.com> Merge "Remove EGL context limit for Adreno GPUs."
8b854cd74bd29b6bb0b4c681490a3a97b1739289 19-Mar-2012 Jack Palevich <jackpal@google.com> Remove EGL context limit for Adreno GPUs.

This change allows Adreno GPUs to have multiple EGL contexts. We had
to limit this in earlier versions of Android due to limitations in
the Adreno GPU driver (only 8 EGL contexts allowed system wide.)
That brand of GPU has improved its EGL drivers to support multiple
EGL contexts in more recent versions of their drivers used on more
recent versions of Android.

Bug: 6142005
Change-Id: Id3030466be9a3d9fbe728f1785378c1f05da98fe
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
48a59c3d852867f13da4138ed2de94044febb99e 15-Mar-2012 Jack Palevich <jackpal@google.com> Ignore EGL_BAD_CURRENT_SURFACE errors from eglSwapBuffers

Certain EGL device drivers are generating this error, so we need to
survive it. (It's not clear from the EGL spec whether this is a
legitimate error code, but since it's being generated we need to
handle it.)

Remove logging of expected errors from elSwapBuffers. We expect these
errors to happen, and are handeling them by ignoring them.
No need to clutter the logs.

Bug: 6083241

Change-Id: If17dcfbb68d3009b92cf95a448728ccb47023b51
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
80b3cd6bc608c5929096e3407de2b157be925d3e 15-Nov-2011 Jack Palevich <jackpal@google.com> Fix potential GLThread / GLSurfaceView memory leak.

Until now a leak was possible under the following scenario:

Create a GLSurfaceView
Register a renderer (this automatically starts a GLThread).
Discard the GLSurfaceView without installing it in the view system.

This scenario can occur when a device is rotated rapidly from
orientation A to orientation B to orientation C. In that scenario,
orientation B's GLSurfaceView might be discarded without ever being
attached to a window.

If this issue had been identified before GLSurfaceView had clients, one
possible fix would have been to delay the construction of the GLThread
until the GLSurfaceView was attached to a window. Unfortunately, it's
too late, and so making that change would lead to observable changes in
behavior, possibly breaking some clients.

Instead, fixed by making GLThread and EGLHelper static classes that hold
onto a weak reference to the GLSurfaceView. This allows the GLSurfaceView
to be garbage collected when it is no longer used, even if the GLThread
is active. GLSurfaceView's finalize method will manually stop the GLThread
if it is still running when the GLSurfaceView exits.

Part of this change was to remove the Renderer reference from GLThread,
because Renderer is a user-supplied class that could contain a reference
chain that points back to the GLSurfaceView.

Fixes b/5606613 "GLSurfaceView that's never added to a window will
leak threads and views, can leak activities"

Change-Id: Iafdc329eb6e9e40062358e7c119f5547ffe23d5e
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
eba186448ff048f8fc1ba596c9779e8069a93128 31-Oct-2011 Joe Fernandez <joefernandez@google.com> am 74b2b954: am 09848bc8: Merge "docs: add developer guide cross references, Project ACRE, round 3" into ics-mr0

* commit '74b2b9547329a0b05e0bd5701057696007b854bb':
docs: add developer guide cross references, Project ACRE, round 3
74b2b9547329a0b05e0bd5701057696007b854bb 29-Oct-2011 Joe Fernandez <joefernandez@google.com> am 09848bc8: Merge "docs: add developer guide cross references, Project ACRE, round 3" into ics-mr0

* commit '09848bc89de999416e2de82a7693b2deec6bf802':
docs: add developer guide cross references, Project ACRE, round 3
b50e2afd6782e9b877f52844bec106c12ff9a9ef 28-Oct-2011 Jack Palevich <jackpal@google.com> Destroy and recreate the EGL surface when the surface size changes.

Details:
+ Split EGLHelper.createSurface into two methods.
+ Add a separate flag for specifying when to create the GlInterface.
+ destroy and recreate the EGL surface when the surface size changes
+ Remove no-longer-needed work-around for b/2263168.

This fixes b/2263168

Change-Id: I0d2596527e3c8dabacdd8a8e427531eaefe7d266
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
61fd1e8d8c3ccf2d6b7d4af1c19e8f0988d5a1ec 26-Oct-2011 Joe Fernandez <joefernandez@google.com> docs: add developer guide cross references, Project ACRE, round 3

Change-Id: I6125315ecdf0f78dd947c514a9944729d723e95d
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
a35c120d8fafa7dded606a25bc100b13f48ab9e3 14-Oct-2011 Jack Palevich <jackpal@google.com> Work around race condition when shutting down a surface flinger surface.

Works around b/4588890

Change-Id: Ie0cf1f212686aec93cda85bf112f4b7ab4197256
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
3ab88557947d708cc36d60ce6566509ceff944e4 02-Aug-2011 Mathias Agopian <mathias@google.com> fix an issue where the screen could be stale after a surface size change

some GLES drivers dequeue buffers before a frame is started
(which is allowed), which can cause a that frame to be rendered
into a buffer of the wrong size. Such buffer will be ignored
by the compositor. If the application draws only once after a
size change, the screen might stay in this stale state.

this can be avoided by telling the GL driver to purge all its
pending buffers, which is done by making the surface not current
and then current again.

this solution is specific to android, but acceptable because
handled solely in the framework.

Bug: 2263168
Change-Id: I3d3c9a019979a9186e329d3160fa54adac78d3f7
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
43dd61e08a726fbc3695b1cbfdef6bdd4ddd34be 12-Jul-2011 Mathias Agopian <mathias@google.com> fix typo in a comment

Change-Id: If913611a65e8b578021e9f9a9546f05e0ce6ef44
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
75f2bc04df11c67d7074186432278f182381b9f2 19-Jan-2011 Jack Palevich <jackpal@google.com> Unhide GLSurfaceView.get/setPreserveEGLContextOnPause

Change-Id: I882b8fa7888e2baae41c81b75af7fc1f639d38d6
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
8432b3f98a22d5cdfcc0183d134770597e44d412 14-Jan-2011 Jack Palevich <jackpal@google.com> Add support for preserving EGL contexts when pausing / resuming.

Hidden for now.

Change-Id: I350576c11960a1aa232da7aebc5c6ec60ff796b5
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
1396afb73047c402db5af98e8f6b442ecbfa98d4 27-Oct-2010 Jack Palevich <jackpal@google.com> Preserve the render mode when recreating the render thread.

Change-Id: I67a12a9598d3ef099bef8727411891614b1bc3f7
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
2ff6a824619ac6849ba9f36d97590acf74f62518 27-Oct-2010 Jack Palevich <jackpal@google.com> Allow a GLSurfaceView to be reattached to a window.

This approach is more backwards-compatible than the previous attempt.

The onDetachedFromWindow case is unchanged from the "classic"
GLSurfaceView behavior, except that we don't throw a NPE if the
renderer has never been set.

Change-Id: Ia8103a73366ddb13be44f16b789c929e75ddc792
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
fc5508bc994174bc4d1b1d028cfa25eb70ea8203 26-Oct-2010 Jack Palevich <jackpal@google.com> Do not exit the GLSurfaceView thread when detached from a window.

Allows a GLSurfaceView to be removed from a window and later reattached
to a window.

Change-Id: I2b44f35d0c95404b13912782df8877953609a5d0
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
1b4ecc63c4eceb7c125d4e749fd5f747d99d6ec6 14-Jul-2010 Jack Palevich <jackpal@google.com> Fix deadlock when switching between two GLSurfaceViews

Some devices only support a single active EGL context.

On those devices, when a second activity that uses a GLSurfaceView
is started in the same process, the second activity can potentially
hang in GLSurfaceView.onWindowResize waiting for its GLSurfaceView
render thread to draw a frame. The second activity's render thread
is waiting to acquire an EGL context, but the first activity's render
thread doesn't know it should release the EGL context.

The fix is to detect the potential hang, and ask the first activity's
render thread to release the EGL context.

Change-Id: Ibb342c68772297744c973bcf5010581cd132db67
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
d6ddcb7f00a7af95b452233d965b922632f78f21 25-May-2010 Mathias Agopian <mathias@google.com> fix [2677468] some 3rd party GL ES apps get a 32-bits surface by default and fail

force all SurfaceView to 565

Change-Id: I8ebfa1239d8e4fa097c2e544677fb92fa20b39bd
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
0e4aa37872810e46775374596e0beb11f7123727 19-Apr-2010 Jack Palevich <jackpal@google.com> Quietly handle EGL_BAD_NATIVE_WINDOW errors

We believe these errors happen when the window
manager has told surface flinger to close the
native window.

If this error happens while we are creating the
EGL surface we exit the render loop (and
therefore exit the render thread.)

If the error happens while swapping the surface
we ignore it.

In either situation, we expect that the
application is about to be shut down by the
window manager, so it should not be necessary
to try and recover from the error.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
4a65900cd69b79e6e47d275575eaeb5bb2487f9f 27-Mar-2010 Jack Palevich <jackpal@google.com> Turn off logging.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
451a224c46c297bd6b25e3570b45f5053b4788be 26-Mar-2010 Jack Palevich <jackpal@google.com> GLSurfaceView pause and resume now synchronize
with the GLThread.

We used to just set the mPaused state and return,
now we wait until the rendering thread signals
that it has noticed the change in pause state.

This makes Pause/Resume more consistent with
other UI-thread-to-GLThread event communication.

This change was made in the hope of fixing some
race conditions observed in monkey testing.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
57c6a46bd0c84c4b349d49f8df12f30a8cfcdaa2 25-Mar-2010 Jack Palevich <jackpal@google.com> Turn off thread logging (too many messages.)

Leave some other logging on for the monkey test.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
e6c9448eb3228887c49f6ba9c4be2345443286e9 25-Mar-2010 Jack Palevich <jackpal@google.com> Add logging of GLSurfaceView pause/resume calls.

Turn on GLSurfaceView logging, so we can get better
information in the monkey tests.

Change-Id: Ifec0101f8a00ab09037dc9f7a1496fa1a374cc08
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
b1768998f14e03bd69cf049783d6cbeccf6d5839 24-Mar-2010 Jack Palevich <jackpal@google.com> Improve our EGL management when pausing / resuming.

We now release the EGL context when pausing. This
is required to reduce the chance of running out of
contexts on devices which support a limited number
of active EGL contexts.

Someday we may implement a global EGL context
manager that will allow us to let EGL contexts
persist until another activity needs an EGL
context. But for now, without such a manager,
we take the conservative approach.

Separately, we now terminate EGL when
pausing on Sapphire. This is a requirement of the
Sapphire OpenGL driver.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
07353a1e8598b1e2993b8b6763f630379ae6e8bb 23-Mar-2010 Jack Palevich <jackpal@google.com> GLSurfaceView: Log egl failures

Decode the EGL error code when throwing exceptions.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
04b17ab7b4a17a28f541f746c3d55046c5b87596 15-Mar-2010 Jack Palevich <jackpal@google.com> Improve eglSwapBuffers error handling.

We now distinguish EGL_CONTEXT_LOST errors from
other kinds of errors. We return "true" if
the swap completes successfully, "false" if
the swap fails due to EGL_CONTEXT_LOST, and
throw a RuntimeException if the swap fails due
to any other cause.

If eglSwapBuffers succeeds, we now avoid calling
eglGetError at all, which means we avoid clearing
any EGL errors that might already have been
pending before eglSwapBuffers is called.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
83835359e51ddb8be37cea9bf4bb32f9390d82b7 05-Mar-2010 Jack Palevich <jackpal@google.com> Clarify the default algorithm used to choose an EGLConfig.

Explicitly default to an RGB_565 android.view.Surface.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
4a2221ec4a929976be570ad096252c8dea326e19 06-Mar-2010 Jack Palevich <jackpal@google.com> Fix inverted release-EGLContext-on-pause logic.

This works around a bug in the
"Q3Dimension MSM7500" driver. That driver only
supports a single active EGLContext, so we must
release and restore the EGLContext when pausing
and unpausing.

Unfortunately the test for deciding whether to
release the context was inverted. We were
releasing the context on every device besides
the MSM7500 devices, which was a performance
drain, and we were not releasing the context on
the MSM7500, which meant the underlying driver
bug was not worked around.

Now we release the EGL context when pausing only
on the devices that have the bug.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
840e958847f31f835dbf17ce539c9f8317251cc9 18-Jan-2010 Jack Palevich <jackpal@google.com> Decouple the EGL context lifetime from the EGL surface lifetime.

The EGL context is now preserved when possible. Previously we would
destroy it whenever the EGL surface was destroyed. Preserving the
EGL context preserves loaded textures and VBO resources.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
66a4a6e45f59f72f24d710221c27db1bd233e154 21-Dec-2009 Jack Palevich <jackpal@google.com> Fix merge conflict markers that accidentally got checked in.

(They were in a comment, so it wasn't detected by the compiler.)
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
21799450ec751fd3c41c7e66e69fefb094b3050b 21-Dec-2009 Jack Palevich <jackpal@google.com> Fix bug 2325244 screen turns black for a brief period of time

The problem was a black first frame when creating a surface, or a
garbage frame when the surface was resized.

The cause was lack of synchronization between the render thread and the
UI thread. The UI thread would typically return before the render thread
had a chance to draw its first frame.

The fix was to make the UI thread wait until at least one frame had been
rendered by the rendering thread.

The waiting is done in the surfaceChanged method because we know
that surfaceChanged will be called in both the surface created
and surface changed cases.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
c373edbf1c7066668b8bf5fe90edd3fedd94c78b 07-Dec-2009 Jack Palevich <jackpal@google.com> am 9196034b: am 30d90523: Merge changes Id682ab72,I9bb4dbae into eclair-mr2

Merge commit '9196034b84c48844799a2904ef3ce31f18ee748e'

* commit '9196034b84c48844799a2904ef3ce31f18ee748e':
Improve error message thrown when eglCreateContext fails.
Improve error reporting by always returning the public
9bb4dbae91df0971038e955ef49c5d9a64d4a428 04-Dec-2009 Jack Palevich <jackpal@google.com> Improve error message thrown when eglCreateContext fails.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
355c20cb9276148fd9b7074c5199aedeb497406e 27-Nov-2009 Jack Palevich <jackpal@google.com> Unhide the Android OpenGL ES 2.0 API

Add a Matrix.setLookAtM method for computing a look-at viewing transform.

Change GLU.lookAt to use Matrix.setLook.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
6a9a87da47bcfb032d0585f41d77abb6300ea63c 25-Nov-2009 Jack Palevich <jackpal@google.com> am 85a9498a: am 9c0b39c4: am ca00dee2: Merge change I5aa3adcf into eclair

Merge commit '85a9498a2f33d62a4313a3561b5468456974696e'

* commit '85a9498a2f33d62a4313a3561b5468456974696e':
Improve the exception message text by including eglGetError().
9c0b39c47efade5ee2303a8f8ffbd9cf87c2c841 25-Nov-2009 Jack Palevich <jackpal@google.com> am ca00dee2: Merge change I5aa3adcf into eclair

Merge commit 'ca00dee21425882619aef4ecbe3e0d08de0544e5' into eclair-mr2

* commit 'ca00dee21425882619aef4ecbe3e0d08de0544e5':
Improve the exception message text by including eglGetError().
5aa3adcf304ec3767b3c22128acb23240d8d0bab 25-Nov-2009 Jack Palevich <jackpal@google.com> Improve the exception message text by including eglGetError().

Should help us track down the cause of bug 2285187
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
6ae4da75422bbb31c3e0a09f616cdaee1d465946 19-Nov-2009 Jack Palevich <jackpal@google.com> Extend GLSurfaceView to make it easy to create an OpenGL ES 2.0 context

Provide a new method, GLSurfaceView.setEGLContextClientVersion. Clients
call this method to define which level of OpenGL ES support they want.

This method only affects the default behavior of GLSurfaceView. If clients
have supplied their own EGLContextFactory or EGLConfigChooser then they
are on their own if they want to create an OpenGL ES 2.0 context.

This API is currently hidden.

Update the gl2_java test to use this new API.

Update the gl2_java test's AndroidManifest.xml file to indicate that
it requires OpenGL ES 2.0.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
a822f02bb9c7f5bf2e3fa3cb63effc391be158c5 17-Nov-2009 Jack Palevich <jackpal@google.com> resolved conflicts for merge of dc49acb0 to eclair-mr2
a08d46d8aaabb53eef4d5dc47272565d50f23c19 16-Nov-2009 Jack Palevich <jackpal@google.com> More GLSurfaceView cleanup.

+ The mDone flag is now a pair of flags: mShouldExit and mExited. The
problem with mDone was that it meant "had been asked to exit", but was
being used by some observers as "had exited". Using two variables means
that observers can observe either "had been asked to exit" or "had exited",
as they prefer.

+ Simplyify where we check for mShouldExit. We now check for it at the
top of our innermost guardedRun while loop.

+ requestExitAndWait now waits for mExited to be set to true to know
that a thread has exited, rather than using join(). This means we can use
wait() for the check, which releases the sGLThreadManager
monitor, avoiding a potential deadlock.

+ move the event queue into the sGLThreadManager monitor. This avoids
having to acquire two locks in order to enque/deque events, which also
avoids the potential for lock ordering deadlocks.

+ Simplify the event dequeueing code. We now deque one event each time
through the main GLSurfaceView loop. Events still have priority over
rendering, so there isn't any semantic change, it just cleans up the code.

+ Avoid trying to acquire an egl Surface if we're paused.

+ To simplify reasoning about the code, call sGLThreadManager.notifyAll()
in every case where we modify one of the variables that's protected by
the sGLThreadManager monitor. It would be slightly more efficient to only
notify when we change variables that could cause a thread to wait(), but
then we would have to redo our analysis every time we change any code.

+ Clean up the logic for creating the EGL surface and then calling the
renderer's onSurfaceCreated / onSurfaceChanged methods.

+ Implement work-around for bug 2263168 "Need to draw twice after
screen rotation..."
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
1179efbb3b8856eb8160e2dd67a300a5d64e8e98 11-Nov-2009 Jack Palevich <jackpal@google.com> resolved conflicts for merge of ba56915a to eclair-mr2
67dcd6c2392caf3ff98f35a3d1ec550d229c167b 10-Nov-2009 Jack Palevich <jackpal@google.com> Fix multi-lock ordering issues in GLSurfaceView

There were potential deadlocks between the per-GLThread monitors and the
GLThreadManager monitor.

To avoid these deadlocks we now use a single monitor for
both the GLThreadManager state and the per-GLThread state.

Converted GLThreadManager's semaphore into the equivalent
synchronized-wait-notifyAll code. This enables us to wait for
either mDone, or user events, or the EGL surface with a single "wait()".

Simplified the logic used to acquire and release the EGL surface. The
EGL surface is now only requested while the surfaceFlinger surface
is acquired.

Removed the "egl surface stealing" policy we had recently inserted.
It's not needed now that we reliably quit when requested.

Pulled user event processing outside of the GLThreadManager monitor
so that we don't call any potentially-long-running code while
inside the monitor.

This should help with bug 2228262.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
8da3ac92a6a6247ef06de4d4b684f8635d8fc003 10-Nov-2009 Jack Palevich <jackpal@google.com> resolved conflicts for merge of 3f857b78 to eclair-mr2
32d416518473f3bf5323d660e5910ca5633ffed6 08-Nov-2009 Jack Palevich <jackpal@google.com> Allow a GLThread to release and reacquire the EGL Surface as needed.

We currently only allow one GLThread to have an active EGL Surface at a
time.(This may be lifted in the future, when EGL and GL are reentrant.)

Prior to this change we would enforce this rule by having older GLThreads
quit when a new GLThread started. That had the drawback of leaving the
older GLSurfaceViews in a zombie state -- their GLThreads would be
gone.

We now enforce this rule by just releasing and reacquiring the EGL surface
context as needed.

Specific changes to the code:

created private helper methods - startEgl and stopEgl to help manage
starting and stopping EGL.

Move the calls to sGLThreadManager start and end from the outermost run
method into the startEgl / stopEgl methods.

Reworked the wait loop to handle starting and stopping EGL as needed.

needToWait() gets simpler -- just looks at current status.

sGLThreadManager.shouldQuit was replaced by shouldHaveEgl.


This is another step in fixing bug 2228262.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
a3a351e5d164d0c8b461ae7af86edc0227654a76 07-Nov-2009 Jack Palevich <jackpal@google.com> resolved conflicts for merge of 4e3fadd0 to eclair-mr2
a44249500f6c1c7a75b5c420fa2e81c2aa317a10 07-Nov-2009 Jack Palevich <jackpal@google.com> Fix stupid bug in GLThreadManager implementation.

The code intended to copy the old value of a field, before the
field was updated. However, what the code was actually doing was
copying the new value of the field, after the field was updated.

The fix was to move the copy to before the update.

This is work towards fixing bug 2228262
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
79447b2087c8c820d742185dda7305101f9656f0 06-Nov-2009 Jack Palevich <jackpal@google.com> resolved conflicts for merge of 84872738 to eclair-mr2
8b2c9c9ecb08d25244fa97fb42c2c315ae3cf03d 06-Nov-2009 Jack Palevich <jackpal@google.com> Improve GLSurfaceView to avoid deadlocks and race conditions.

This is work towards fixing bug 2228262

Specific issues fixed by this change:

+ GLThread names now include the thread id, making it easier to tell one
GLThread from another.

+ A private final static boolean LOG_THREADS can be set to true at compile
time to print out thread-related trace information, helpful for debugging
GLSurfaceView behavior. This static defaults to "false".

+ Changed calls to "notify" to "notifyAll" to make the code more
robust in case more than two threads are blocked on the same monitor.

+ Add a GLThreadManager to help manage the transition to
a new GLThread. Currently only one GLThread can be active in an address
space. When the second thread starts up, the GLThreadManager helps the old
GLThread to shut down,

+ Make sure we stop waiting for dead GLThreads. This is done by adding
checks for a variable mDone being true to our monitor wait loops. And
we use a "finally" clause at the end of GLThread.run() method to set mDone
and notifyAll any wait loops.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
28023911a4b572f0ca640e7a3e3f9a0dd6f535e9 14-Oct-2009 Jack Palevich <jackpal@google.com> Add additional error checking of EGL function calls.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
c52ba78cab001ff68b4823f4769c129b8acfddee 14-Oct-2009 Jack Palevich <jackpal@google.com> Allow multiple OpenGL contexts on systems that support them.

Previously we always restricted the number of OpenGL contexts to 1.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
2e26fc08aa1939c19e939d983bd608cdec050024 26-Sep-2009 Jack Palevich <jackpal@google.com> Check for failure to create EGL surfaces and contexts.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
d40dfbbbff81219258ca36b762a89ff503154345 24-Sep-2009 Jack Palevich <jackpal@google.com> Fix broken Javadoc link for GLSurfaceView.EGLWindowSurfaceFactory.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
82cbaab450d3c5d9f3d52c49881212f250d7cd97 24-Sep-2009 Jack Palevich <jackpal@google.com> Publish minor additions to GLSurfaceView API.

Clients can now modify the way that the EGL context and the EGL window
surface are created and destroyed.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
a8fecb87c5eaaefc9ca6272e3b59ef88d293dd6d 23-Sep-2009 Jack Palevich <jackpal@google.com> Create samples showing how to call OpenGL from JNI libraries.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
15e1c6dc7a778590068b1cad55beea2bc6159509 22-Sep-2009 Jack Palevich <jackpal@google.com> Allow GLSurfaceView clients to customize EGL Surfaces and Contexts.

This API is hidden for now, will expose once it's been tested more.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
1bd888ba2e0976a179258cfa65ef07be31602a0a 22-Sep-2009 Jack Palevich <jackpal@google.com> Fix GLSurfaceView to sync surfaceDestroyed with GL rendering thread

Until now we had a race condition where the GL rendering thread could
continue rendering a frame after we have returned from the
SurfaceHolder.Callback.surfaceDestroyed notification.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
82fd4fce16b9bbde25d044acc86ddf7306ebdd10 21-Aug-2009 Mathias Agopian <mathias@google.com> fix a bug in ComponentSizeChooser where it could pick a software EGLConfig instead of a better h/w one.

We now just try to honor the stencil / depth buffer "at least", while doing a "shortest distance" on the colors.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
317a6280cc109e873646e4652be1582d870eedfd 14-Aug-2009 Mathias Agopian <mathias@google.com> Surface::GPU and Surface::HARDWARE are now deprecated; they will be set automatically if needed.

this also ripples into the window manager API by making some constant there deprecated as well.
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
3e832dbe966c2ca0fde2f4bd87ad9c974a93a7cf 10-Apr-2009 Jack Palevich <> AI 145534: am: CL 145526 am: CL 145249 Correct misspelling of constant RENDERMODE_CONTUOUSLY --> RENDERMODE_CONTINUOUSLY
Original author: jackpal
Merged from: //branches/cupcake/...
Original author: android-build

Automated import of CL 145534
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
b47c641fe8330fc68dbed91163ff07015068d0ce 09-Apr-2009 Jack Palevich <> AI 145531: am: CL 145523 am: CL 145244 Fully document GLSurfaceView and related classes.
Original author: jackpal
Merged from: //branches/cupcake/...
Original author: android-build

Automated import of CL 145531
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
a605a51e63de2e7dc99ed085639a6f12b7f85af7 25-Mar-2009 Jack Palevich <> Automated import from //branches/master/...@142658,142658
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
9066cfe9886ac131c34d59ed0e2d287b0e3c0087 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java
f013e1afd1e68af5e3b868c26a653bbfb39538f8 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
/frameworks/base/opengl/java/android/opengl/GLSurfaceView.java