Search in sources :

Example 6 with EglCore

use of com.android.grafika.gles.EglCore in project grafika by google.

the class PlayMovieSurfaceActivity method clearSurface.

/**
     * Clears the playback surface to black.
     */
private void clearSurface(Surface surface) {
    // We need to do this with OpenGL ES (*not* Canvas -- the "software render" bits
    // are sticky).  We can't stay connected to the Surface after we're done because
    // that'd prevent the video encoder from attaching.
    //
    // If the Surface is resized to be larger, the new portions will be black, so
    // clearing to something other than black may look weird unless we do the clear
    // post-resize.
    EglCore eglCore = new EglCore();
    WindowSurface win = new WindowSurface(eglCore, surface, false);
    win.makeCurrent();
    GLES20.glClearColor(0, 0, 0, 0);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
    win.swapBuffers();
    win.release();
    eglCore.release();
}
Also used : EglCore(com.android.grafika.gles.EglCore) WindowSurface(com.android.grafika.gles.WindowSurface)

Example 7 with EglCore

use of com.android.grafika.gles.EglCore in project grafika by google.

the class TextureMovieEncoder method handleUpdateSharedContext.

/**
     * Tears down the EGL surface and context we've been using to feed the MediaCodec input
     * surface, and replaces it with a new one that shares with the new context.
     * <p>
     * This is useful if the old context we were sharing with went away (maybe a GLSurfaceView
     * that got torn down) and we need to hook up with the new one.
     */
private void handleUpdateSharedContext(EGLContext newSharedContext) {
    Log.d(TAG, "handleUpdatedSharedContext " + newSharedContext);
    // Release the EGLSurface and EGLContext.
    mInputWindowSurface.releaseEglSurface();
    mFullScreen.release(false);
    mEglCore.release();
    // Create a new EGLContext and recreate the window surface.
    mEglCore = new EglCore(newSharedContext, EglCore.FLAG_RECORDABLE);
    mInputWindowSurface.recreate(mEglCore);
    mInputWindowSurface.makeCurrent();
    // Create new programs and such for the new context.
    mFullScreen = new FullFrameRect(new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));
}
Also used : FullFrameRect(com.android.grafika.gles.FullFrameRect) Texture2dProgram(com.android.grafika.gles.Texture2dProgram) EglCore(com.android.grafika.gles.EglCore)

Aggregations

EglCore (com.android.grafika.gles.EglCore)7 WindowSurface (com.android.grafika.gles.WindowSurface)5 FullFrameRect (com.android.grafika.gles.FullFrameRect)3 Texture2dProgram (com.android.grafika.gles.Texture2dProgram)3 IOException (java.io.IOException)2 Paint (android.graphics.Paint)1 SurfaceTexture (android.graphics.SurfaceTexture)1 MediaCodec (android.media.MediaCodec)1 MediaFormat (android.media.MediaFormat)1 MediaMuxer (android.media.MediaMuxer)1 Surface (android.view.Surface)1 OffscreenSurface (com.android.grafika.gles.OffscreenSurface)1