use of android.graphics.SurfaceTexture in project android_frameworks_base by AOSPA.
the class SurfaceTextureRenderer method configureSurfaces.
/**
* Set a collection of output {@link Surface}s that can be drawn to.
*
* @param surfaces a {@link Collection} of surfaces.
*/
public void configureSurfaces(Collection<Pair<Surface, Size>> surfaces) {
releaseEGLContext();
if (surfaces == null || surfaces.size() == 0) {
Log.w(TAG, "No output surfaces configured for GL drawing.");
return;
}
for (Pair<Surface, Size> p : surfaces) {
Surface s = p.first;
Size surfaceSize = p.second;
// If pixel conversions aren't handled by egl, use a pbuffer
try {
EGLSurfaceHolder holder = new EGLSurfaceHolder();
holder.surface = s;
holder.width = surfaceSize.getWidth();
holder.height = surfaceSize.getHeight();
if (LegacyCameraDevice.needsConversion(s)) {
mConversionSurfaces.add(holder);
// LegacyCameraDevice is the producer of surfaces if it's not handled by EGL,
// so LegacyCameraDevice needs to connect to the surfaces.
LegacyCameraDevice.connectSurface(s);
} else {
mSurfaces.add(holder);
}
} catch (LegacyExceptionUtils.BufferQueueAbandonedException e) {
Log.w(TAG, "Surface abandoned, skipping configuration... ", e);
}
}
// Set up egl display
configureEGLContext();
// Set up regular egl surfaces if needed
if (mSurfaces.size() > 0) {
configureEGLOutputSurfaces(mSurfaces);
}
// Set up pbuffer surface if needed
if (mConversionSurfaces.size() > 0) {
configureEGLPbufferSurfaces(mConversionSurfaces);
}
makeCurrent((mSurfaces.size() > 0) ? mSurfaces.get(0).eglSurface : mConversionSurfaces.get(0).eglSurface);
initializeGLState();
mSurfaceTexture = new SurfaceTexture(getTextureId());
// Set up performance tracking if enabled
if (SystemProperties.getBoolean(LEGACY_PERF_PROPERTY, false)) {
setupGlTiming();
}
}
use of android.graphics.SurfaceTexture in project android_frameworks_base by crdroidandroid.
the class CameraSource method open.
@Override
public void open(FilterContext context) {
if (mLogVerbose)
Log.v(TAG, "Opening");
// Open camera
mCamera = Camera.open(mCameraId);
// Set parameters
getCameraParameters();
mCamera.setParameters(mCameraParameters);
// Create frame formats
createFormats();
// Bind it to our camera frame
mCameraFrame = (GLFrame) context.getFrameManager().newBoundFrame(mOutputFormat, GLFrame.EXTERNAL_TEXTURE, 0);
mSurfaceTexture = new SurfaceTexture(mCameraFrame.getTextureId());
try {
mCamera.setPreviewTexture(mSurfaceTexture);
} catch (IOException e) {
throw new RuntimeException("Could not bind camera surface texture: " + e.getMessage() + "!");
}
// Connect SurfaceTexture to callback
mSurfaceTexture.setOnFrameAvailableListener(onCameraFrameAvailableListener);
// Start the preview
mNewFrameAvailable = false;
mCamera.startPreview();
}
use of android.graphics.SurfaceTexture in project android_frameworks_base by crdroidandroid.
the class SurfaceTextureSource method open.
@Override
public void open(FilterContext context) {
if (mLogVerbose)
Log.v(TAG, "Opening SurfaceTextureSource");
// Create SurfaceTexture anew each time - it can use substantial memory.
mSurfaceTexture = new SurfaceTexture(mMediaFrame.getTextureId());
// Connect SurfaceTexture to callback
mSurfaceTexture.setOnFrameAvailableListener(onFrameAvailableListener);
// Connect SurfaceTexture to source
mSourceListener.onSurfaceTextureSourceReady(mSurfaceTexture);
mFirstFrame = true;
}
use of android.graphics.SurfaceTexture in project android_packages_apps_Camera by CyanogenMod.
the class EffectsRecorder method invokeOnSurfaceTextureSourceReady.
private void invokeOnSurfaceTextureSourceReady(Object[] args) {
SurfaceTexture source = (SurfaceTexture) args[0];
if (mLogVerbose)
Log.v(TAG, "SurfaceTexture ready callback received");
synchronized (EffectsRecorder.this) {
mTextureSource = source;
if (mState == STATE_CONFIGURE) {
// Rest of cleanup will happen in onRunnerDone
if (mLogVerbose)
Log.v(TAG, "Ready callback: Already stopped, skipping.");
return;
}
if (mState == STATE_RELEASED) {
// or anything else
if (mLogVerbose)
Log.v(TAG, "Ready callback: Already released, skipping.");
return;
}
if (source == null) {
if (mLogVerbose) {
Log.v(TAG, "Ready callback: source null! Looks like graph was closed!");
}
if (mState == STATE_PREVIEW || mState == STATE_STARTING_PREVIEW || mState == STATE_RECORD) {
// the surface texture goes away.
if (mLogVerbose) {
Log.v(TAG, "Ready callback: State: " + mState + ". stopCameraPreview");
}
stopCameraPreview();
}
return;
}
// Lock AE/AWB to reduce transition flicker
tryEnable3ALocks(true);
mCameraDevice.stopPreview();
if (mLogVerbose)
Log.v(TAG, "Runner active, connecting effects preview");
mCameraDevice.setPreviewTextureAsync(mTextureSource);
mCameraDevice.startPreviewAsync();
// Unlock AE/AWB after preview started
tryEnable3ALocks(false);
mState = STATE_PREVIEW;
if (mLogVerbose)
Log.v(TAG, "Start preview/effect switch complete");
// Sending a message to listener that preview is complete
sendMessage(mCurrentEffect, EFFECT_MSG_PREVIEW_RUNNING);
}
}
use of android.graphics.SurfaceTexture in project android_packages_apps_Camera by CyanogenMod.
the class Util method newSurfaceLayer.
public static SurfaceTexture newSurfaceLayer(int mCameraDisplayOrientation, Parameters mParameters, CameraActivity mActivity) {
CameraScreenNail screenNail = (CameraScreenNail) mActivity.mCameraScreenNail;
if (mSurfaceTexture == null || mSwitchCamera) {
mSwitchCamera = false;
Size size = mParameters.getPreviewSize();
if (mCameraDisplayOrientation % 180 == 0) {
screenNail.setSize(size.width, size.height);
} else {
screenNail.setSize(size.height, size.width);
}
screenNail.enableAspectRatioClamping();
mActivity.notifyScreenNailChanged();
screenNail.acquireSurfaceTexture();
mSurfaceTexture = screenNail.getSurfaceTexture();
}
return (SurfaceTexture) mSurfaceTexture;
}
Aggregations