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
Also fix a bug where Matrix.invertM was not returning false when the
matrix could not be inverted.
Change-Id: I68b172032093d9f257e88c802de936633bb4912c
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
Just use jniThrowException instead. Note that it would be trivial to throw
seemingly more appropriate exceptions (NullPointerException and
OutOfMemoryException in particular), but I'm only attempting to preserve
existing behavior here.
I also found shadowing bugs in some of the special-case functions, which
would previously always have leaked memory.
This also moves an accidental change to a generated file (ActivityThread ->
AppGlobals) into the generator, so it won't be overwritten in future.
Change-Id: Iab570310b568cb406c60dd0e2b8211f8a36ae590
Bug #3461349
Before this change, eglGetCurrent*() could not be used to compare
contexts, displays and surfaces at the Dalvik level.
Change-Id: I442037dae37bc357b64810ab10c779b5754e9153
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.