This source file includes following definitions.
- lockSurface
- handle
- allocNativeYuvBufferT
- close
- finalize
package com.example.helloandroidcamera2;
import android.view.Surface;
public class NativeSurfaceHandle implements AutoCloseable {
private long mHandle;
public static NativeSurfaceHandle lockSurface(Surface surface) {
long handle = AndroidBufferUtilities.lockSurface(surface);
if (handle == 0L) {
return null;
}
return new NativeSurfaceHandle(handle);
}
public NativeSurfaceHandle(long handle) {
mHandle = handle;
}
public long handle() {
return mHandle;
}
public HalideYuvBufferT allocNativeYuvBufferT() {
if (mHandle == 0L){
throw new IllegalStateException("Surface already unlocked.");
}
long yuvHandle = AndroidBufferUtilities.allocNativeYuvBufferTFromSurfaceHandle(mHandle);
return new HalideYuvBufferT(yuvHandle);
}
@Override
public void close() {
if (mHandle != 0L) {
AndroidBufferUtilities.unlockSurface(mHandle);
mHandle = 0L;
}
}
@Override
protected void finalize() {
close();
}
}