What you probably want to do is use a plain SurfaceView.
Here's the short version:
SurfaceView
has two parts, theSurface
and a bit of fake stuff in theView
. TheSurface
gets passed directly to the surface compositor (SurfaceFlinger), so when you draw on it with OpenGL there's relatively little overhead. This makes it fast, but it also makes it not play quite right with the View hierarchy, because theSurface
is on one layer and the View-based UI is on a different layer.TextureView
also has two parts, but the part you draw on lives behind the scenes (that's where theSurfaceTexture
comes in). When the frame is complete, the stuff you drew is blitted onto the View layer. The GPU can do this quickly, but "some work" is always slower than "no work".GLSurfaceView
is aSurfaceView
with a wrapper class that does all the EGL setup and inter-thread messaging for you.
Edit: the long version is available here.
If you can do the GL/EGL setup and thread management yourself -- which, if you're now running on a TextureView, you clearly can -- then you should probably use a plain SurfaceView
.
Having said all that, it should be possible to make your original code work with GLSurfaceView
. I expect you want to call eglPresentationTimeANDROID()
on the EGL context that's shared with the GLSurfaceView
, not from within GLSurfaceView
itself, so it doesn't matter that GLSurfaceView
is using EGL10 internally. What matters for sharing the context is the context client version (e.g. GLES2 vs. GLES3), not the EGL interface version used to configure the context.
You can see examples of all of this working in Grafika. In particular:
- "Show + capture camera" uses a
GLSurfaceView
, the camera, and the video encoder. Note the EGL context is shared. The example is convoluted and somewhat painful, mostly because it's deliberately trying to useGLSurfaceView
and a shared EGL context. (Update: note this issue about race conditions with shared contexts.) - "Play video (TextureView)" and "Basic GL in TextureView" show
TextureView
in action. - "Record GL app with FBO" uses a plain
SurfaceView
.