use of android.view.Surface in project platform_frameworks_base by android.
the class RenderScriptGL method setSurface.
/**
* @deprecated in API 16
* Bind an os surface
*
*
* @param w
* @param h
* @param sur
*/
public void setSurface(SurfaceHolder sur, int w, int h) {
validate();
Surface s = null;
if (sur != null) {
s = sur.getSurface();
}
mWidth = w;
mHeight = h;
nContextSetSurface(w, h, s);
}
use of android.view.Surface in project platform_frameworks_base by android.
the class ColorFade method createSurface.
private boolean createSurface() {
if (mSurfaceSession == null) {
mSurfaceSession = new SurfaceSession();
}
SurfaceControl.openTransaction();
try {
if (mSurfaceControl == null) {
try {
int flags;
if (mMode == MODE_FADE) {
flags = SurfaceControl.FX_SURFACE_DIM | SurfaceControl.HIDDEN;
} else {
flags = SurfaceControl.OPAQUE | SurfaceControl.HIDDEN;
}
mSurfaceControl = new SurfaceControl(mSurfaceSession, "ColorFade", mDisplayWidth, mDisplayHeight, PixelFormat.OPAQUE, flags);
} catch (OutOfResourcesException ex) {
Slog.e(TAG, "Unable to create surface.", ex);
return false;
}
mSurfaceControl.setLayerStack(mDisplayLayerStack);
mSurfaceControl.setSize(mDisplayWidth, mDisplayHeight);
mSurface = new Surface();
mSurface.copyFrom(mSurfaceControl);
mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManagerInternal, mDisplayId, mSurfaceControl);
mSurfaceLayout.onDisplayTransaction();
}
} finally {
SurfaceControl.closeTransaction();
}
return true;
}
use of android.view.Surface in project platform_frameworks_base by android.
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.view.Surface in project platform_frameworks_base by android.
the class MediaRecorderTest method testPersistentSurfaceRecording.
public void testPersistentSurfaceRecording() {
boolean success = false;
int noOfFailure = 0;
Surface surface = null;
try {
int codec = MediaRecorder.VideoEncoder.H264;
int frameRate = MediaProfileReader.getMaxFrameRateForCodec(codec);
surface = MediaCodec.createPersistentInputSurface();
for (int k = 0; k < 2; k++) {
String filename = "/sdcard/surface_persistent" + k + ".3gp";
Log.v(TAG, "test persistent surface - round " + k);
success = recordVideoFromSurface(frameRate, 0, 352, 288, codec, MediaRecorder.OutputFormat.THREE_GPP, filename, true, /* videoOnly */
surface);
if (success) {
success = validateVideo(filename, 352, 288);
}
if (!success) {
noOfFailure++;
}
}
} catch (Exception e) {
Log.v(TAG, e.toString());
} finally {
if (surface != null) {
Log.v(TAG, "releasing persistent surface");
surface.release();
surface = null;
}
}
assertTrue("testPersistentSurfaceRecording", noOfFailure == 0);
}
use of android.view.Surface in project platform_frameworks_base by android.
the class Camera2ReprocessCaptureTest method doMixedReprocessBurstCapture.
/**
* Do a burst of captures that are mixed with regular and reprocess captures.
*
* @param isReprocessCaptures An array whose elements indicate whether it's a reprocess capture
* request. If the element is true, it represents a reprocess capture
* request. If the element is false, it represents a regular capture
* request. The size of the array is the number of capture requests
* in the burst.
*/
private ImageResultHolder[] doMixedReprocessBurstCapture(boolean[] isReprocessCaptures) throws Exception {
if (isReprocessCaptures == null || isReprocessCaptures.length <= 0) {
throw new IllegalArgumentException("isReprocessCaptures must have at least 1 capture.");
}
boolean hasReprocessRequest = false;
boolean hasRegularRequest = false;
TotalCaptureResult[] results = new TotalCaptureResult[isReprocessCaptures.length];
for (int i = 0; i < isReprocessCaptures.length; i++) {
// submit a capture and get the result if this entry is a reprocess capture.
if (isReprocessCaptures[i]) {
results[i] = submitCaptureRequest(mFirstImageReader.getSurface(), /*inputResult*/
null);
mImageWriter.queueInputImage(mFirstImageReaderListener.getImage(CAPTURE_TIMEOUT_MS));
hasReprocessRequest = true;
} else {
hasRegularRequest = true;
}
}
Surface[] outputSurfaces = new Surface[isReprocessCaptures.length];
for (int i = 0; i < isReprocessCaptures.length; i++) {
outputSurfaces[i] = getReprocessOutputImageReader().getSurface();
}
TotalCaptureResult[] finalResults = submitMixedCaptureBurstRequest(outputSurfaces, results);
ImageResultHolder[] holders = new ImageResultHolder[isReprocessCaptures.length];
for (int i = 0; i < isReprocessCaptures.length; i++) {
Image image = getReprocessOutputImageReaderListener().getImage(CAPTURE_TIMEOUT_MS);
if (hasReprocessRequest && hasRegularRequest) {
// If there are mixed requests, images and results may not be in the same order.
for (int j = 0; j < finalResults.length; j++) {
if (finalResults[j] != null && finalResults[j].get(CaptureResult.SENSOR_TIMESTAMP) == image.getTimestamp()) {
holders[i] = new ImageResultHolder(image, finalResults[j]);
finalResults[j] = null;
break;
}
}
assertNotNull("Cannot find a result matching output image's timestamp: " + image.getTimestamp(), holders[i]);
} else {
// If no mixed requests, images and results should be in the same order.
holders[i] = new ImageResultHolder(image, finalResults[i]);
}
}
return holders;
}
Aggregations