Search in sources :

Example 31 with SurfaceTexture

use of android.graphics.SurfaceTexture in project android_frameworks_base by DirtyUnicorns.

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 32 with SurfaceTexture

use of android.graphics.SurfaceTexture in project android_frameworks_base by DirtyUnicorns.

the class EGLImpl method eglCreateWindowSurface.

public EGLSurface eglCreateWindowSurface(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list) {
    Surface sur = null;
    if (native_window instanceof SurfaceView) {
        SurfaceView surfaceView = (SurfaceView) native_window;
        sur = surfaceView.getHolder().getSurface();
    } else if (native_window instanceof SurfaceHolder) {
        SurfaceHolder holder = (SurfaceHolder) native_window;
        sur = holder.getSurface();
    } else if (native_window instanceof Surface) {
        sur = (Surface) native_window;
    }
    long eglSurfaceId;
    if (sur != null) {
        eglSurfaceId = _eglCreateWindowSurface(display, config, sur, attrib_list);
    } else if (native_window instanceof SurfaceTexture) {
        eglSurfaceId = _eglCreateWindowSurfaceTexture(display, config, native_window, attrib_list);
    } else {
        throw new java.lang.UnsupportedOperationException("eglCreateWindowSurface() can only be called with an instance of " + "Surface, SurfaceView, SurfaceHolder or SurfaceTexture at the moment.");
    }
    if (eglSurfaceId == 0) {
        return EGL10.EGL_NO_SURFACE;
    }
    return new EGLSurfaceImpl(eglSurfaceId);
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SurfaceTexture(android.graphics.SurfaceTexture) SurfaceView(android.view.SurfaceView) Surface(android.view.Surface)

Example 33 with SurfaceTexture

use of android.graphics.SurfaceTexture in project android_frameworks_base by ParanoidAndroid.

the class HTML5VideoInline method decideDisplayMode.

@Override
public void decideDisplayMode() {
    SurfaceTexture surfaceTexture = getSurfaceTexture(getVideoLayerId());
    Surface surface = new Surface(surfaceTexture);
    mPlayer.setSurface(surface);
    surface.release();
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) Surface(android.view.Surface)

Example 34 with SurfaceTexture

use of android.graphics.SurfaceTexture in project android_frameworks_base by ParanoidAndroid.

the class HTML5VideoInline method getSurfaceTexture.

// Inline Video specific FUNCTIONS:
public static SurfaceTexture getSurfaceTexture(int videoLayerId) {
    // Create the surface texture.
    if (videoLayerId != mVideoLayerUsingSurfaceTexture || mSurfaceTexture == null || mTextureNames == null) {
        // The GL texture will store in the VideoLayerManager at native side.
        // They will be clean up when requested.
        // The reason we recreated GL texture name is for screen shot support.
        mTextureNames = new int[1];
        GLES20.glGenTextures(1, mTextureNames, 0);
        mSurfaceTexture = new SurfaceTexture(mTextureNames[0]);
    }
    mVideoLayerUsingSurfaceTexture = videoLayerId;
    return mSurfaceTexture;
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture)

Example 35 with SurfaceTexture

use of android.graphics.SurfaceTexture in project android_frameworks_base by AOSPA.

the class EGL14 method eglCreateWindowSurface.

public static EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, Object win, int[] attrib_list, int offset) {
    Surface sur = null;
    if (win instanceof SurfaceView) {
        SurfaceView surfaceView = (SurfaceView) win;
        sur = surfaceView.getHolder().getSurface();
    } else if (win instanceof SurfaceHolder) {
        SurfaceHolder holder = (SurfaceHolder) win;
        sur = holder.getSurface();
    } else if (win instanceof Surface) {
        sur = (Surface) win;
    }
    EGLSurface surface;
    if (sur != null) {
        surface = _eglCreateWindowSurface(dpy, config, sur, attrib_list, offset);
    } else if (win instanceof SurfaceTexture) {
        surface = _eglCreateWindowSurfaceTexture(dpy, config, win, attrib_list, offset);
    } else {
        throw new java.lang.UnsupportedOperationException("eglCreateWindowSurface() can only be called with an instance of " + "Surface, SurfaceView, SurfaceTexture or SurfaceHolder at the moment, " + "this will be fixed later.");
    }
    return surface;
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SurfaceTexture(android.graphics.SurfaceTexture) SurfaceView(android.view.SurfaceView) Surface(android.view.Surface)

Aggregations

SurfaceTexture (android.graphics.SurfaceTexture)159 Surface (android.view.Surface)97 SurfaceView (android.view.SurfaceView)18 IOException (java.io.IOException)17 Test (org.junit.Test)16 EGLSurface (android.opengl.EGLSurface)14 SurfaceHolder (android.view.SurfaceHolder)14 Context (android.content.Context)13 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)13 FakeClock (com.google.android.exoplayer2.testutil.FakeClock)13 TextureView (android.view.TextureView)12 PlaybackOutput (com.google.android.exoplayer2.robolectric.PlaybackOutput)12 CapturingRenderersFactory (com.google.android.exoplayer2.testutil.CapturingRenderersFactory)12 Uri (android.net.Uri)9 MediaPlayer (android.media.MediaPlayer)8 OnInfoListener (android.media.MediaPlayer.OnInfoListener)8 OnPreparedListener (android.media.MediaPlayer.OnPreparedListener)8 ImageView (android.widget.ImageView)6 ApplicationProvider (androidx.test.core.app.ApplicationProvider)6 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)6