Search in sources :

Example 6 with Surface

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);
}
Also used : Surface(android.view.Surface)

Example 7 with Surface

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;
}
Also used : OutOfResourcesException(android.view.Surface.OutOfResourcesException) SurfaceSession(android.view.SurfaceSession) SurfaceControl(android.view.SurfaceControl) EGLSurface(android.opengl.EGLSurface) Surface(android.view.Surface)

Example 8 with Surface

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;
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) EGLSurface(android.opengl.EGLSurface) Surface(android.view.Surface)

Example 9 with Surface

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);
}
Also used : Paint(android.graphics.Paint) Surface(android.view.Surface)

Example 10 with Surface

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;
}
Also used : TotalCaptureResult(android.hardware.camera2.TotalCaptureResult) CameraTestUtils.getDataFromImage(com.android.mediaframeworktest.helpers.CameraTestUtils.getDataFromImage) Image(android.media.Image) Surface(android.view.Surface)

Aggregations

Surface (android.view.Surface)300 ArrayList (java.util.ArrayList)100 SurfaceTexture (android.graphics.SurfaceTexture)49 BlockingSessionCallback (com.android.ex.camera2.blocking.BlockingSessionCallback)44 Size (android.util.Size)35 CaptureRequest (android.hardware.camera2.CaptureRequest)34 OutputConfiguration (android.hardware.camera2.params.OutputConfiguration)30 IOException (java.io.IOException)27 EGLSurface (android.opengl.EGLSurface)19 Paint (android.graphics.Paint)16 StreamConfigurationMap (android.hardware.camera2.params.StreamConfigurationMap)15 SurfaceHolder (android.view.SurfaceHolder)15 Rect (android.graphics.Rect)13 SurfaceView (android.view.SurfaceView)13 Canvas (android.graphics.Canvas)12 CameraAccessException (android.hardware.camera2.CameraAccessException)12 WifiDisplay (android.hardware.display.WifiDisplay)12 MediaRecorder (android.media.MediaRecorder)11 SurfaceControl (android.view.SurfaceControl)11 Image (android.media.Image)10