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
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
- Move PackageInfo out of ActivityThread, renaming to LoadedApk.
- Rename some of the other PacakgeInfo inner classes to better
represent what they are.
- Rename HistoryRecord to ActivityRecord.
- Introduce AppGlobals, to eventually let ActivityThread become
package scoped.
Change-Id: Ib714c54ceb3cdbb525dce3db9505f31042e88cf0
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.
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.
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.
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.
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.
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.
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.
Adds support for formerly-unimplemented methods:
glCurrentPaletteMatrixOES
glLoadPaletteFromModelViewMatrixOES
glMatrixIndexPointerOES
glWeightPointerOES
The bulk of the changes are related to implementing the two PointerOES
methods, which are implemented pretty much the same way as the existing
Pointer methods were implemented.
This change also changes the way glPointSizePointerOES is implemented,
making it act like all the other Pointer methods. (Previously it was
not handling non-direct-buffer arguments correctly.)
Fixes bug 2308625 "Support matrix palette skinning
in JSR239 and related APIs"
Also updated GLLogWraper to fix two bugs in GLLogWrapper that were
discovered while testing matrix palette skinning support:
a) Handle trying to print the contents of null-but-enabled buffers.
(It's not legal to draw with null-but-enabled buffers, and
in fact some OpenGL drivers will crash if you try to render in this
state, but there's no reason the GLLogWrapper should crash while trying
to debug this situation.
b) Don't read off the end of a vertex buffer with non-zero position when
printing the entire contents of the vertex buffer. Now we only print from
the current position to the end of the buffer.
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.
Adds support for formerly-unimplemented methods:
glCurrentPaletteMatrixOES
glLoadPaletteFromModelViewMatrixOES
glMatrixIndexPointerOES
glWeightPointerOES
The bulk of the changes are related to implementing the two PointerOES
methods, which are implemented pretty much the same way as the existing
Pointer methods were implemented.
This change also changes the way glPointSizePointerOES is implemented,
making it act like all the other Pointer methods. (Previously it was
not handling non-direct-buffer arguments correctly.)
Fixes bug 2308625 "Support matrix palette skinning
in JSR239 and related APIs"
Also updated GLLogWraper to fix two bugs in GLLogWrapper that were
discovered while testing matrix palette skinning support:
a) Handle trying to print the contents of null-but-enabled buffers.
(It's not legal to draw with null-but-enabled buffers, and
in fact some OpenGL drivers will crash if you try to render in this
state, but there's no reason the GLLogWrapper should crash while trying
to debug this situation.
b) Don't read off the end of a vertex buffer with non-zero position when
printing the entire contents of the vertex buffer. Now we only print from
the current position to the end of the buffer.
EGL10.EGL_NO_XXX objects for displays, surfaces, and contexts.
This allows clients to compare the returned object against
the public EGL10.EGL_NO_XXX object using a simple == operation.
This fixes bug 2303947 "Java layer EGL API makes it difficult
to tell when certain methods have failed"
Merge commit '85a9498a2f33d62a4313a3561b5468456974696e'
* commit '85a9498a2f33d62a4313a3561b5468456974696e':
Improve the exception message text by including eglGetError().
Merge commit '9c0b39c47efade5ee2303a8f8ffbd9cf87c2c841' into eclair-mr2-plus-aosp
* commit '9c0b39c47efade5ee2303a8f8ffbd9cf87c2c841':
Improve the exception message text by including eglGetError().
Merge commit 'ca00dee21425882619aef4ecbe3e0d08de0544e5' into eclair-mr2
* commit 'ca00dee21425882619aef4ecbe3e0d08de0544e5':
Improve the exception message text by including eglGetError().
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.