|
|
@ -158,25 +158,12 @@ class GlCameraPreview extends CameraPreview<GLSurfaceView, SurfaceTexture> imple |
|
|
|
@SuppressWarnings("StatementWithEmptyBody") |
|
|
|
@SuppressWarnings("StatementWithEmptyBody") |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSurfaceChanged(GL10 gl, final int width, final int height) { |
|
|
|
public void onSurfaceChanged(GL10 gl, final int width, final int height) { |
|
|
|
|
|
|
|
gl.glViewport(0, 0, width, height); |
|
|
|
if (!mDispatched) { |
|
|
|
if (!mDispatched) { |
|
|
|
dispatchOnSurfaceAvailable(width, height); |
|
|
|
dispatchOnSurfaceAvailable(width, height); |
|
|
|
mDispatched = true; |
|
|
|
mDispatched = true; |
|
|
|
} else if (mOutputSurfaceWidth == width && mOutputSurfaceHeight == height) { |
|
|
|
} else if (width != mOutputSurfaceWidth || height != mOutputSurfaceHeight){ |
|
|
|
// I was experimenting and this was happening.
|
|
|
|
dispatchOnSurfaceSizeChanged(width, height); |
|
|
|
// 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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|