Make CameraPreview faster (#403)

pull/433/head
Mattia Iavarone 6 years ago committed by GitHub
parent 36d073b197
commit fc4a75a24b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      cameraview/src/main/views/com/otaliastudios/cameraview/GlCameraPreview.java

@ -158,25 +158,12 @@ class GlCameraPreview extends CameraPreview<GLSurfaceView, SurfaceTexture> imple
@SuppressWarnings("StatementWithEmptyBody")
@Override
public void onSurfaceChanged(GL10 gl, final int width, final int height) {
gl.glViewport(0, 0, width, height);
if (!mDispatched) {
dispatchOnSurfaceAvailable(width, height);
mDispatched = true;
} else if (mOutputSurfaceWidth == width && mOutputSurfaceHeight == height) {
// I was experimenting and this was happening.
// Not sure if it is stil needed now.
} else {
// With other CameraPreview implementation we could just dispatch the 'size changed' event
// to the controller and everything would go straight. In case of GL, apparently we have to
// force recreate the EGLContext by calling onPause and onResume in the UI thread.
dispatchOnSurfaceDestroyed();
getView().post(new Runnable() {
@Override
public void run() {
getView().onPause();
getView().onResume();
dispatchOnSurfaceAvailable(width, height);
}
});
} else if (width != mOutputSurfaceWidth || height != mOutputSurfaceHeight){
dispatchOnSurfaceSizeChanged(width, height);
}
}

Loading…
Cancel
Save