Package 

Class GlCameraPreview

  • All Implemented Interfaces:
    com.otaliastudios.cameraview.preview.FilterCameraPreview , com.otaliastudios.cameraview.preview.RendererCameraPreview

    
    public class GlCameraPreview
    extends CameraPreview<GLSurfaceView, SurfaceTexture> implements FilterCameraPreview, RendererCameraPreview
                        

    - The android camera will stream image to the given SurfaceTexture. - in the SurfaceTexture constructor we pass the GL texture handle that we have created. - The SurfaceTexture is linked to the Camera1Engine object. The camera will pass down buffers of data with a specified size (that is, the Camera1Engine preview size). For this reason we don't have to specify surfaceTexture.setDefaultBufferSize() (like we do, for example, in Snapshot1PictureRecorder). - When SurfaceTexture.updateTexImage() is called, it will fetch the latest texture image from the camera stream and assign it to the GL texture that was passed. Now the GL texture must be drawn using draw* APIs. The SurfaceTexture will also give us the transformation matrix to be applied. - The easy way to render an OpenGL texture is using the GLSurfaceView class. It manages the GL context, hosts a surface and runs a separated rendering thread that will perform the rendering. - As per docs, we ask the GLSurfaceView to delegate rendering to us, using setRenderer. We request a render on the SurfaceView anytime the SurfaceTexture notifies that it has new data available (see OnFrameAvailableListener below). - So in short: - The SurfaceTexture has buffers of data of mInputStreamSize - The SurfaceView hosts a view (and a surface) of size mOutputSurfaceSize. These are determined by the CameraView.onMeasure method. - We have a GL rich texture to be drawn (in the given method and thread). This class will provide rendering callbacks to anyone who registers a RendererFrameCallback. Callbacks are guaranteed to be called on the renderer thread, which means that we can fetch the GL context that was created and is managed by the GLSurfaceView.