android.opengl.EGLContext#android.opengl.EGLSurface源码实例Demo

下面列出了android.opengl.EGLContext#android.opengl.EGLSurface 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Tok-Android   文件: EGLBase.java
/**
 * change context to draw this window surface
 */
private boolean makeCurrent(final EGLSurface surface) {
    //		if (DEBUG) Log.v(TAG, "makeCurrent:");
    if (mEglDisplay == null) {
        LogUtil.i(TAG, "makeCurrent:eglDisplay not initialized");
    }
    if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
        final int error = EGL14.eglGetError();
        if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
            Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
        }
        return false;
    }
    // attach EGL renderring context to specific EGL window surface
    if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
        Log.w(TAG, "eglMakeCurrent:" + EGL14.eglGetError());
        return false;
    }
    return true;
}
 
源代码2 项目: AudioVideoPlayerSample   文件: EGLBase.java
/**
 * change context to draw this window surface
 * @return
 */
private boolean makeCurrent(EGLSurface surface) {
	if (DEBUG) Log.v(TAG, "makeCurrent:");
       if (mEglDisplay == null) {
           if (DEBUG) Log.d(TAG, "makeCurrent:eglDisplay not initialized");
       }
       if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
           int error = EGL14.eglGetError();
           if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
               Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
           }
           return false;
       }
       // attach EGL renderring context to specific EGL window surface
       if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
           Log.w("TAG", "eglMakeCurrent" + EGL14.eglGetError());
           return false;
       }
       return true;
}
 
源代码3 项目: pause-resume-video-recording   文件: EglCore.java
/**
 * Creates an EGL surface associated with a Surface.
 * <p>
 * If this is destined for MediaCodec, the EGLConfig should have the "recordable" attribute.
 */
public EGLSurface createWindowSurface(Object surface) {
    if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture)) {
        throw new RuntimeException("invalid surface: " + surface);
    }

    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    EGLSurface eglSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, surface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    if (eglSurface == null) {
        throw new RuntimeException("surface was null");
    }
    return eglSurface;
}
 
源代码4 项目: grafika   文件: EglCore.java
/**
 * Creates an EGL surface associated with a Surface.
 * <p>
 * If this is destined for MediaCodec, the EGLConfig should have the "recordable" attribute.
 */
public EGLSurface createWindowSurface(Object surface) {
    if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture)) {
        throw new RuntimeException("invalid surface: " + surface);
    }

    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    EGLSurface eglSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, surface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    if (eglSurface == null) {
        throw new RuntimeException("surface was null");
    }
    return eglSurface;
}
 
public EGLSurface createWindowSurface(EGLDisplay display, EGLConfig config, Object nativeWindow)
{
   EGLSurface result = null;
   try
   {
      result = EGL14.eglCreateWindowSurface(display, config, nativeWindow, s_DEFAULT_SURFACE_ATTRIBS, 0);
   }
   catch (IllegalArgumentException e)
   {
      // This exception indicates that the surface flinger surface
      // is not valid. This can happen if the surface flinger surface has
      // been torn down, but the application has not yet been
      // notified via SurfaceHolder.Callback.surfaceDestroyed.
      // In theory the application should be notified first,
      // but in practice sometimes it is not. See b/4588890
      Log.e(s_TAG, "eglCreateWindowSurface", e);
   }
   return result;
}
 
源代码6 项目: cineio-broadcast-android   文件: EglCore.java
/**
 * Makes our EGL context current, using the supplied "draw" and "read" surfaces.
 */
public void makeCurrent(EGLSurface drawSurface, EGLSurface readSurface) {
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        // called makeCurrent() before create?
        Log.d(TAG, "NOTE: makeCurrent w/o display");
    }
    if (!EGL14.eglMakeCurrent(mEGLDisplay, drawSurface, readSurface, mEGLContext)) {
        throw new RuntimeException("eglMakeCurrent(draw,read) failed");
    }
}
 
源代码7 项目: sealrtc-android   文件: EglCore.java
/** Makes our EGL context current, using the supplied surface for both "draw" and "read". */
public void makeCurrent(EGLSurface eglSurface) {
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        // called makeCurrent() before create?
        Log.d(TAG, "NOTE: makeCurrent w/o display");
    }
    if (!EGL14.eglMakeCurrent(mEGLDisplay, eglSurface, eglSurface, mEGLContext)) {
        throw new RuntimeException("eglMakeCurrent failed");
    }
}
 
源代码8 项目: PLDroidShortVideo   文件: EglCore.java
/**
 * Makes our EGL context current, using the supplied surface for both "draw" and "read".
 */
public void makeCurrent(EGLSurface eglSurface) {
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        // called makeCurrent() before create?
        Log.d(TAG, "NOTE: makeCurrent w/o display");
    }
    if (!EGL14.eglMakeCurrent(mEGLDisplay, eglSurface, eglSurface, mEGLContext)) {
        throw new RuntimeException("eglMakeCurrent failed");
    }
}
 
源代码9 项目: cineio-broadcast-android   文件: EglCore.java
/**
 * Writes the current display, context, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
            ", surface=" + surface);
}
 
源代码10 项目: VIA-AI   文件: EglCore.java
/**
 * Makes our EGL context current, using the supplied surface for both "draw" and "read".
 */
public void makeCurrent(EGLSurface eglSurface) {
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        // called makeCurrent() before create?
        Log.d(TAG, "NOTE: makeCurrent w/o display");
    }
    if (!EGL14.eglMakeCurrent(mEGLDisplay, eglSurface, eglSurface, mEGLContext)) {
        throw new RuntimeException("eglMakeCurrent failed");
    }
}
 
源代码11 项目: kickflip-android-sdk   文件: EglCore.java
/**
 * Writes the current display, context, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
            ", surface=" + surface);
}
 
源代码12 项目: AudioVideoRecordingSample   文件: EGLBase.java
private void destroyWindowSurface(EGLSurface surface) {
	if (DEBUG) Log.v(TAG, "destroySurface:");

       if (surface != EGL14.EGL_NO_SURFACE) {
       	EGL14.eglMakeCurrent(mEglDisplay,
       		EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
       	EGL14.eglDestroySurface(mEglDisplay, surface);
       }
       surface = EGL14.EGL_NO_SURFACE;
       if (DEBUG) Log.v(TAG, "destroySurface:finished");
}
 
源代码13 项目: PLDroidShortVideo   文件: EglCore.java
/**
 * Makes our EGL context current, using the supplied "draw" and "read" surfaces.
 */
public void makeCurrent(EGLSurface drawSurface, EGLSurface readSurface) {
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        // called makeCurrent() before create?
        Log.d(TAG, "NOTE: makeCurrent w/o display");
    }
    if (!EGL14.eglMakeCurrent(mEGLDisplay, drawSurface, readSurface, mEGLContext)) {
        throw new RuntimeException("eglMakeCurrent(draw,read) failed");
    }
}
 
源代码14 项目: EZFilter   文件: EGLEnvironment.java
private EGLSurface createWindowSurface(final Object nativeWindow) {
    final int[] surfaceAttributes = {
            EGL14.EGL_NONE
    };
    EGLSurface result = null;
    try {
        result = EGL14.eglCreateWindowSurface(mEglDisplay, mEglConfig, nativeWindow, surfaceAttributes, 0);
    } catch (final IllegalArgumentException e) {
        Log.e(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
源代码15 项目: FuAgoraDemoDroid   文件: EglCore.java
/**
 * Makes our EGL context current, using the supplied surface for both "draw" and "read".
 */
public void makeCurrent(EGLSurface eglSurface) {
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        // called makeCurrent() before create?
        Log.d(TAG, "NOTE: makeCurrent w/o display");
    }
    if (!EGL14.eglMakeCurrent(mEGLDisplay, eglSurface, eglSurface, mEGLContext)) {
        throw new RuntimeException("eglMakeCurrent failed");
    }
}
 
源代码16 项目: Lassi-Android   文件: EglCore.java
/**
 * Makes our EGL context current, using the supplied "draw" and "read" surfaces.
 */
public void makeCurrent(EGLSurface drawSurface, EGLSurface readSurface) {
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        // called makeCurrent() before create?
        Log.d(TAG, "NOTE: makeCurrent w/o display");
    }
    if (!EGL14.eglMakeCurrent(mEGLDisplay, drawSurface, readSurface, mEGLContext)) {
        throw new RuntimeException("eglMakeCurrent(draw,read) failed");
    }
}
 
源代码17 项目: AAVT   文件: EglHelper.java
public boolean destroyGLES(EGLSurface surface,EGLContext context){
    EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
    if(surface!=null){
        EGL14.eglDestroySurface(mEGLDisplay,surface);
    }
    if(context!=null){
        EGL14.eglDestroyContext(mEGLDisplay,context);
    }
    EGL14.eglTerminate(mEGLDisplay);
    log("gl destroy gles");
    return true;
}
 
源代码18 项目: CameraRecorder-android   文件: EGLBase.java
int swap(final EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "swap:");
        if (!EGL14.eglSwapBuffers(eglDisplay, surface)) {
            final int err = EGL14.eglGetError();
            if (DEBUG) Log.w(TAG, "swap:err=" + err);
            return err;
        }
        return EGL14.EGL_SUCCESS;
    }
 
源代码19 项目: AudioVideoPlayerSample   文件: EGLBase.java
private EGLSurface createWindowSurface(Object nativeWindow) {
	if (DEBUG) Log.v(TAG, "createWindowSurface:");

       final int[] surfaceAttribs = {
               EGL14.EGL_NONE
       };
	EGLSurface result = null;
	try {
		result = EGL14.eglCreateWindowSurface(mEglDisplay, mEglConfig, nativeWindow, surfaceAttribs, 0);
	} catch (IllegalArgumentException e) {
		Log.e(TAG, "eglCreateWindowSurface", e);
	}
	return result;
}
 
源代码20 项目: MegviiFacepp-Android-SDK   文件: EGLBase.java
private void destroyWindowSurface(EGLSurface surface) {
	if (DEBUG) Log.v(TAG, "destroySurface:");

       if (surface != EGL14.EGL_NO_SURFACE) {
       	EGL14.eglMakeCurrent(mEglDisplay,
       		EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
       	EGL14.eglDestroySurface(mEglDisplay, surface);
       }
       surface = EGL14.EGL_NO_SURFACE;
       if (DEBUG) Log.v(TAG, "destroySurface:finished");
}
 
源代码21 项目: pause-resume-video-recording   文件: EglCore.java
/**
 * Creates an EGL surface associated with an offscreen buffer.
 */
public EGLSurface createOffscreenSurface(int width, int height) {
    int[] surfaceAttribs = {
            EGL14.EGL_WIDTH, width,
            EGL14.EGL_HEIGHT, height,
            EGL14.EGL_NONE
    };
    EGLSurface eglSurface = EGL14.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig,
            surfaceAttribs, 0);
    checkEglError("eglCreatePbufferSurface");
    if (eglSurface == null) {
        throw new RuntimeException("surface was null");
    }
    return eglSurface;
}
 
源代码22 项目: libcommon   文件: EGLBase14.java
/**
 * 現在のスレッドの既存のレンダリングコンテキストがあればそれを共有して
 * 新しいレンダリングコンテキストを生成する
 * 既存のレンダリングコンテキストが存在していなければ独立したレンダリングコンテキストを
 * 生成する
 * @param maxClientVersion
 * @param withDepthBuffer
 * @param stencilBits
 * @param isRecordable
 * @return
 */
/*package*/ static EGLBase createFromCurrentImpl(final int maxClientVersion,
	final boolean withDepthBuffer, final int stencilBits, final boolean isRecordable) {

	Context context = null;
	final EGLContext currentContext = EGL14.eglGetCurrentContext();
	final EGLSurface currentSurface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
	if ((currentContext != null) && (currentSurface != null)) {
		context = wrap(currentContext);
	}
	return new EGLBase14(maxClientVersion, context, withDepthBuffer, stencilBits, isRecordable);
}
 
源代码23 项目: In77Camera   文件: EGLBase.java
private void destroyWindowSurface(EGLSurface surface) {
	if (DEBUG) Log.v(TAG, "destroySurface:");

       if (surface != EGL14.EGL_NO_SURFACE) {
       	EGL14.eglMakeCurrent(mEglDisplay,
       		EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
       	EGL14.eglDestroySurface(mEglDisplay, surface);
       }
       surface = EGL14.EGL_NO_SURFACE;
       if (DEBUG) Log.v(TAG, "destroySurface:finished");
}
 
源代码24 项目: DeviceConnect-Android   文件: CodecInputSurface.java
@Override
EGLSurface createEGLSurface(EGLDisplay display, EGLConfig[] configs) {
    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };

    EGLSurface surface = EGL14.eglCreateWindowSurface(display, configs[0], mSurface, surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    return surface;
}
 
源代码25 项目: libcommon   文件: EGLBase14.java
private void destroyWindowSurface(EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "destroySurface:");

        if (surface != EGL14.EGL_NO_SURFACE) {
        	EGL14.eglMakeCurrent(mEglDisplay,
        		EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
        	EGL14.eglDestroySurface(mEglDisplay, surface);
        }
//		if (DEBUG) Log.v(TAG, "destroySurface:finished");
	}
 
源代码26 项目: RtmpPublisher   文件: EglCore.java
/**
 * Writes the current display, context, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
            ", surface=" + surface);
}
 
源代码27 项目: CameraRecorder-android   文件: EGLBase.java
EGLSurface createWindowSurface(final Object surface) {
    if (DEBUG) Log.v(TAG, "createWindowSurface:nativeWindow=" + surface);

    final int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    EGLSurface result = null;
    try {
        result = EGL14.eglCreateWindowSurface(eglDisplay, eglConfig, surface, surfaceAttribs, 0);
    } catch (final IllegalArgumentException e) {
        Log.e(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
源代码28 项目: AudioVideoPlayerSample   文件: EGLBase.java
private void destroyWindowSurface(EGLSurface surface) {
	if (DEBUG) Log.v(TAG, "destroySurface:");

       if (surface != EGL14.EGL_NO_SURFACE) {
       	EGL14.eglMakeCurrent(mEglDisplay,
       		EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
       	EGL14.eglDestroySurface(mEglDisplay, surface);
       }
       surface = EGL14.EGL_NO_SURFACE;
}
 
源代码29 项目: MockCamera   文件: EglCore.java
/**
 * Makes our EGL context current, using the supplied surface for both "draw" and "read".
 */
public void makeCurrent(EGLSurface eglSurface) {
    if (eGLDisplay == EGL14.EGL_NO_DISPLAY) {
        // called makeCurrent() before create?
        Log.d(TAG,"NOTE: makeCurrent w/o display");
    }
    if (!EGL14.eglMakeCurrent(eGLDisplay, eglSurface, eglSurface, eGLContext)) {
        throw new RuntimeException("eglMakeCurrent failed");
    }
}
 
源代码30 项目: PhotoMovie   文件: EglCore.java
/**
 * Makes our EGL context current, using the supplied "draw" and "read" surfaces.
 */
public void makeCurrent(EGLSurface drawSurface, EGLSurface readSurface) {
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        // called makeCurrent() before create?
        Log.d(TAG, "NOTE: makeCurrent w/o display");
    }
    if (!EGL14.eglMakeCurrent(mEGLDisplay, drawSurface, readSurface, mEGLContext)) {
        throw new RuntimeException("eglMakeCurrent(draw,read) failed");
    }
}