本文整理匯總了Java中android.opengl.EGLSurface類的典型用法代碼示例。如果您正苦於以下問題:Java EGLSurface類的具體用法?Java EGLSurface怎麽用?Java EGLSurface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EGLSurface類屬於android.opengl包,在下文中一共展示了EGLSurface類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: SurfaceEncoder
import android.opengl.EGLSurface; //導入依賴的package包/類
public SurfaceEncoder(){
super.setOnDrawEndListener(new OnDrawEndListener() {
@Override
public void onDrawEnd(EGLSurface surface, RenderBean bean) {
AvLog.d(TAG,"onDrawEnd start-->");
if(bean.timeStamp!=-1){
bean.egl.setPresentationTime(surface,bean.timeStamp*1000);
}else{
if(startTime==-1){
startTime=bean.textureTime;
}
bean.egl.setPresentationTime(surface,bean.textureTime-startTime);
}
videoEncodeStep(false);
AvLog.e(TAG,"onDrawEnd end-->");
if(mListener!=null){
mListener.onDrawEnd(surface,bean);
}
}
});
}
示例2: createGLESWithPBuffer
import android.opengl.EGLSurface; //導入依賴的package包/類
public EGLSurface createGLESWithPBuffer(EGLConfigAttrs attrs,EGLContextAttrs ctxAttrs,int width,int height){
EGLConfig config=getConfig(attrs.surfaceType(EGL14.EGL_PBUFFER_BIT));
if(config==null){
log("getConfig failed : "+EGL14.eglGetError());
return null;
}
EGLContext eglContext=createContext(config,EGL14.EGL_NO_CONTEXT,ctxAttrs);
if(eglContext==EGL14.EGL_NO_CONTEXT){
log("createContext failed : "+EGL14.eglGetError());
return null;
}
EGLSurface eglSurface=createPBufferSurface(config,width,height);
if(eglSurface==EGL14.EGL_NO_SURFACE){
log("createWindowSurface failed : "+EGL14.eglGetError());
return null;
}
if(!EGL14.eglMakeCurrent(mEGLDisplay,eglSurface,eglSurface,eglContext)){
log("eglMakeCurrent failed : "+EGL14.eglGetError());
return null;
}
return eglSurface;
}
示例3: makeCurrent
import android.opengl.EGLSurface; //導入依賴的package包/類
/**
* change context to draw this window surface
* @return
*/
private boolean makeCurrent(final 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) {
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;
}
示例4: testSetPresentationTime
import android.opengl.EGLSurface; //導入依賴的package包/類
/**
* Test for {@link GLTools#setPresentationTime(EGLDisplay, EGLSurface, long)} .
* @throws Exception by some fails
*/
@Test
public final void testSetPresentationTime() throws Exception {
final EGLDisplay eglDisplay = GLTools.newDisplay();
final EGLConfig eglConfig = GLTools.newConfig(eglDisplay, true);
final EGLContext eglContext = GLTools.newContext(eglDisplay, eglConfig);
final EGLSurface eglSurface =
GLTools.newSurface(eglDisplay, eglConfig, FRAME_SIZE, FRAME_SIZE);
GLTools.makeCurrent(eglDisplay, eglSurface, eglContext);
final int txt = GLTools.newTexture(TEXTURE_LEVEL);
final SurfaceTexture surfaceTexture = new SurfaceTexture(txt, true);
final Surface surface = new Surface(surfaceTexture);
final EGLSurface window = GLTools.newSurface(eglDisplay, eglConfig, surface);
GLTools.setPresentationTime(eglDisplay, window, PRESENTATION_TIME);
GLTools.closeSurface(eglDisplay, window);
surface.release();
surfaceTexture.release();
GLTools.closeTexture(txt, TEXTURE_LEVEL);
GLTools.closeSurface(eglDisplay, eglSurface);
GLTools.closeContext(eglDisplay, eglContext);
GLTools.closeDisplay(eglDisplay);
}
示例5: testTexture
import android.opengl.EGLSurface; //導入依賴的package包/類
/**
* Test for {@link GLTools#newTexture(int)} and {@link GLTools#closeTexture(int, int)}.
* @throws Exception by some fails
*/
@Test
public final void testTexture() throws Exception {
final EGLDisplay eglDisplay = GLTools.newDisplay();
final EGLConfig eglConfig = GLTools.newConfig(eglDisplay, true);
final EGLContext eglContext = GLTools.newContext(eglDisplay, eglConfig);
final EGLSurface eglSurface =
GLTools.newSurface(eglDisplay, eglConfig, FRAME_SIZE, FRAME_SIZE);
GLTools.makeCurrent(eglDisplay, eglSurface, eglContext);
GLTools.closeTexture(GLTools.newTexture(TEXTURE_LEVEL), TEXTURE_LEVEL);
GLTools.closeSurface(eglDisplay, eglSurface);
GLTools.closeContext(eglDisplay, eglContext);
GLTools.closeDisplay(eglDisplay);
}
示例6: testShader
import android.opengl.EGLSurface; //導入依賴的package包/類
/**
* Test for {@link GLTools#newShader(int[])} and {@link GLTools#closeShader(int[])}.
* @throws Exception by some fails
*/
@Test
public final void testShader() throws Exception {
final EGLDisplay eglDisplay = GLTools.newDisplay();
final EGLConfig eglConfig = GLTools.newConfig(eglDisplay, true);
final EGLContext eglContext = GLTools.newContext(eglDisplay, eglConfig);
final EGLSurface eglSurface =
GLTools.newSurface(eglDisplay, eglConfig, FRAME_SIZE, FRAME_SIZE);
GLTools.makeCurrent(eglDisplay, eglSurface, eglContext);
final int[] attrs = new int[5];
GLTools.newShader(attrs);
GLTools.closeShader(attrs);
GLTools.closeSurface(eglDisplay, eglSurface);
GLTools.closeContext(eglDisplay, eglContext);
GLTools.closeDisplay(eglDisplay);
}
示例7: createWindowSurface
import android.opengl.EGLSurface; //導入依賴的package包/類
/**
* 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;
}
示例8: createEGLSurface
import android.opengl.EGLSurface; //導入依賴的package包/類
public EGLSurface createEGLSurface(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[] surfaceAttributes = {
EGL14.EGL_NONE
};
EGLSurface eglSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, surface,
surfaceAttributes, 0);
if (eglSurface == null) {
throw new RuntimeException("surface was null");
}
return eglSurface;
}
示例9: cameraInit
import android.opengl.EGLSurface; //導入依賴的package包/類
private void cameraInit(){
mShower=new SurfaceShower();
mProvider=new CameraProvider();
mProcessor=new VideoSurfaceProcessor();
mProcessor.setTextureProvider(mProvider);
mProcessor.addObserver(mShower);
mFb=new FrameBuffer();
mShower.setOnDrawEndListener(new SurfaceShower.OnDrawEndListener() {
@Override
public void onDrawEnd(EGLSurface surface, RenderBean bean) {
if(exportFlag){
if(mOutputFilter==null){
mOutputFilter=new YuvOutputFilter(YuvOutputFilter.EXPORT_TYPE_NV21);
mOutputFilter.create();
mOutputFilter.sizeChanged(picX,picY);
mOutputFilter.setInputTextureSize(bean.sourceWidth,bean.sourceHeight);
tempBuffer=new byte[picX*picY*3/2];
}
mOutputFilter.drawToTexture(bean.textureId);
mOutputFilter.getOutput(tempBuffer,0,picX*picY*3/2);
runOnUiThread(new Runnable() {
@Override
public void run() {
if(mBitmap!=null){
mBitmap.recycle();
mBitmap=null;
}
mBitmap=rawByteArray2RGBABitmap2(tempBuffer,picX,picY);
mImage.setImageBitmap(mBitmap);
mImage.setVisibility(View.VISIBLE);
}
});
exportFlag=false;
}
}
});
}
示例10: logCurrent
import android.opengl.EGLSurface; //導入依賴的package包/類
/**
* 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);
}
示例11: destroyGLES
import android.opengl.EGLSurface; //導入依賴的package包/類
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;
}
示例12: swap
import android.opengl.EGLSurface; //導入依賴的package包/類
private int swap(final EGLSurface surface) {
// if (DEBUG) Log.v(TAG, "swap:");
if (!EGL14.eglSwapBuffers(mEglDisplay, surface)) {
final int err = EGL14.eglGetError();
if (DEBUG) Log.w(TAG, "swap:err=" + err);
return err;
}
return EGL14.EGL_SUCCESS;
}
示例13: createWindowSurface
import android.opengl.EGLSurface; //導入依賴的package包/類
private EGLSurface createWindowSurface(final Object nativeWindow) {
if (DEBUG) Log.v(TAG, "createWindowSurface:nativeWindow=" + nativeWindow);
final int[] surfaceAttribs = {
EGL14.EGL_NONE
};
EGLSurface result = null;
try {
result = EGL14.eglCreateWindowSurface(mEglDisplay, mEglConfig, nativeWindow, surfaceAttribs, 0);
} catch (final IllegalArgumentException e) {
Log.e(TAG, "eglCreateWindowSurface", e);
}
return result;
}
示例14: destroyWindowSurface
import android.opengl.EGLSurface; //導入依賴的package包/類
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");
}
示例15: createOffscreenSurface
import android.opengl.EGLSurface; //導入依賴的package包/類
/**
* 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;
}