use of android.graphics.SurfaceTexture in project android_frameworks_base by AOSPA.
the class ColorFade method captureScreenshotTextureAndSetViewport.
private boolean captureScreenshotTextureAndSetViewport() {
if (!attachEglContext()) {
return false;
}
try {
if (!mTexNamesGenerated) {
GLES20.glGenTextures(1, mTexNames, 0);
if (checkGlErrors("glGenTextures")) {
return false;
}
mTexNamesGenerated = true;
}
final SurfaceTexture st = new SurfaceTexture(mTexNames[0]);
final Surface s = new Surface(st);
try {
SurfaceControl.screenshot(SurfaceControl.getBuiltInDisplay(SurfaceControl.BUILT_IN_DISPLAY_ID_MAIN), s);
st.updateTexImage();
st.getTransformMatrix(mTexMatrix);
} finally {
s.release();
st.release();
}
// Set up texture coordinates for a quad.
// We might need to change this if the texture ends up being
// a different size from the display for some reason.
mTexCoordBuffer.put(0, 0f);
mTexCoordBuffer.put(1, 0f);
mTexCoordBuffer.put(2, 0f);
mTexCoordBuffer.put(3, 1f);
mTexCoordBuffer.put(4, 1f);
mTexCoordBuffer.put(5, 1f);
mTexCoordBuffer.put(6, 1f);
mTexCoordBuffer.put(7, 0f);
// Set up our viewport.
GLES20.glViewport(0, 0, mDisplayWidth, mDisplayHeight);
ortho(0, mDisplayWidth, 0, mDisplayHeight, -1, 1);
} finally {
detachEglContext();
}
return true;
}
use of android.graphics.SurfaceTexture in project android_frameworks_base by AOSPA.
the class RequestThreadManager method createDummySurface.
/**
* Fake preview for jpeg captures when there is no active preview
*/
private void createDummySurface() {
if (mDummyTexture == null || mDummySurface == null) {
mDummyTexture = new SurfaceTexture(/*ignored*/
0);
// TODO: use smallest default sizes
mDummyTexture.setDefaultBufferSize(640, 480);
mDummySurface = new Surface(mDummyTexture);
}
}
use of android.graphics.SurfaceTexture in project android_frameworks_base by AOSPA.
the class TextureView method getHardwareLayer.
HardwareLayer getHardwareLayer() {
if (mLayer == null) {
if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) {
return null;
}
mLayer = mAttachInfo.mHardwareRenderer.createTextureLayer();
boolean createNewSurface = (mSurface == null);
if (createNewSurface) {
// Create a new SurfaceTexture for the layer.
mSurface = new SurfaceTexture(false);
nCreateNativeWindow(mSurface);
}
mLayer.setSurfaceTexture(mSurface);
mSurface.setDefaultBufferSize(getWidth(), getHeight());
mSurface.setOnFrameAvailableListener(mUpdateListener, mAttachInfo.mHandler);
if (mListener != null && createNewSurface) {
mListener.onSurfaceTextureAvailable(mSurface, getWidth(), getHeight());
}
mLayer.setLayerPaint(mLayerPaint);
}
if (mUpdateSurface) {
// Someone has requested that we use a specific SurfaceTexture, so
// tell mLayer about it and set the SurfaceTexture to use the
// current view size.
mUpdateSurface = false;
// Since we are updating the layer, force an update to ensure its
// parameters are correct (width, height, transform, etc.)
updateLayer();
mMatrixChanged = true;
mLayer.setSurfaceTexture(mSurface);
mSurface.setDefaultBufferSize(getWidth(), getHeight());
}
return mLayer;
}
use of android.graphics.SurfaceTexture in project chromeview by pwnall.
the class ChildProcessService method establishSurfaceTexturePeer.
/**
* Called from native code to share a surface texture with another child process.
* Through using the callback object the browser is used as a proxy to route the
* call to the correct process.
*
* @param pid Process handle of the child process to share the SurfaceTexture with.
* @param surfaceObject The Surface or SurfaceTexture to share with the other child process.
* @param primaryID Used to route the call to the correct client instance.
* @param secondaryID Used to route the call to the correct client instance.
*/
@SuppressWarnings("unused")
@CalledByNative
private void establishSurfaceTexturePeer(int pid, Object surfaceObject, int primaryID, int secondaryID) {
if (mCallback == null) {
Log.e(TAG, "No callback interface has been provided.");
return;
}
Surface surface = null;
boolean needRelease = false;
if (surfaceObject instanceof Surface) {
surface = (Surface) surfaceObject;
} else if (surfaceObject instanceof SurfaceTexture) {
surface = new Surface((SurfaceTexture) surfaceObject);
needRelease = true;
} else {
Log.e(TAG, "Not a valid surfaceObject: " + surfaceObject);
return;
}
try {
mCallback.establishSurfacePeer(pid, surface, primaryID, secondaryID);
} catch (RemoteException e) {
Log.e(TAG, "Unable to call establishSurfaceTexturePeer: " + e);
return;
} finally {
if (needRelease) {
surface.release();
}
}
}
use of android.graphics.SurfaceTexture in project android_frameworks_base by ResurrectionRemix.
the class OnTheGoService method setupViews.
private void setupViews(final boolean isRestarting) {
logDebug("Setup Views, restarting: " + (isRestarting ? "true" : "false"));
final int cameraType = Settings.System.getInt(getContentResolver(), Settings.System.ON_THE_GO_CAMERA, 0);
try {
getCameraInstance(cameraType);
} catch (Exception exc) {
// Well, you cant have all in this life..
logDebug("Exception: " + exc.getMessage());
createNotification(NOTIFICATION_ERROR);
stopOnTheGo(true);
}
final TextureView mTextureView = new TextureView(this);
mTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i2) {
try {
if (mCamera != null) {
mCamera.setDisplayOrientation(90);
mCamera.setPreviewTexture(surfaceTexture);
mCamera.startPreview();
}
} catch (IOException io) {
logDebug("IOException: " + io.getMessage());
}
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i, int i2) {
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
releaseCamera();
return true;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
}
});
mOverlay = new FrameLayout(this);
mOverlay.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mOverlay.addView(mTextureView);
final WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, PixelFormat.TRANSLUCENT);
wm.addView(mOverlay, params);
toggleOnTheGoAlpha();
}
Aggregations