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

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

源代码1 项目: MediaSDK   文件: EGLSurfaceTexture.java
private static EGLConfig chooseEGLConfig(EGLDisplay display) {
  EGLConfig[] configs = new EGLConfig[1];
  int[] numConfigs = new int[1];
  boolean success =
      EGL14.eglChooseConfig(
          display,
          EGL_CONFIG_ATTRIBUTES,
          /* attrib_listOffset= */ 0,
          configs,
          /* configsOffset= */ 0,
          /* config_size= */ 1,
          numConfigs,
          /* num_configOffset= */ 0);
  if (!success || numConfigs[0] <= 0 || configs[0] == null) {
    throw new GlException(
        Util.formatInvariant(
            /* format= */ "eglChooseConfig failed: success=%b, numConfigs[0]=%d, configs[0]=%s",
            success, numConfigs[0], configs[0]));
  }

  return configs[0];
}
 
源代码2 项目: MediaSDK   文件: EGLSurfaceTexture.java
private static EGLContext createEGLContext(
    EGLDisplay display, EGLConfig config, @SecureMode int secureMode) {
  int[] glAttributes;
  if (secureMode == SECURE_MODE_NONE) {
    glAttributes = new int[] {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE};
  } else {
    glAttributes =
        new int[] {
          EGL14.EGL_CONTEXT_CLIENT_VERSION,
          2,
          EGL_PROTECTED_CONTENT_EXT,
          EGL14.EGL_TRUE,
          EGL14.EGL_NONE
        };
  }
  EGLContext context =
      EGL14.eglCreateContext(
          display, config, EGL14.EGL_NO_CONTEXT, glAttributes, 0);
  if (context == null) {
    throw new GlException("eglCreateContext failed");
  }
  return context;
}
 
源代码3 项目: webrtc_android   文件: EglBase14Impl.java
private static EGLConfig getEglConfig(EGLDisplay eglDisplay, int[] configAttributes) {
  EGLConfig[] configs = new EGLConfig[1];
  int[] numConfigs = new int[1];
  if (!EGL14.eglChooseConfig(
          eglDisplay, configAttributes, 0, configs, 0, configs.length, numConfigs, 0)) {
    throw new RuntimeException(
        "eglChooseConfig failed: 0x" + Integer.toHexString(EGL14.eglGetError()));
  }
  if (numConfigs[0] <= 0) {
    throw new RuntimeException("Unable to find any matching EGL config");
  }
  final EGLConfig eglConfig = configs[0];
  if (eglConfig == null) {
    throw new RuntimeException("eglChooseConfig returned null");
  }
  return eglConfig;
}
 
源代码4 项目: webrtc_android   文件: EglBase14Impl.java
private static EGLContext createEglContext(
      EGLContext sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) {
  if (sharedContext != null && sharedContext == EGL14.EGL_NO_CONTEXT) {
    throw new RuntimeException("Invalid sharedContext");
  }
  int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE};
  EGLContext rootContext = sharedContext == null ? EGL14.EGL_NO_CONTEXT : sharedContext;
  final EGLContext eglContext;
  synchronized (EglBase.lock) {
    eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes, 0);
  }
  if (eglContext == EGL14.EGL_NO_CONTEXT) {
    throw new RuntimeException(
        "Failed to create EGL context: 0x" + Integer.toHexString(EGL14.eglGetError()));
  }
  return eglContext;
}
 
源代码5 项目: TelePlus-Android   文件: EGLSurfaceTexture.java
private static EGLConfig chooseEGLConfig(EGLDisplay display) {
  EGLConfig[] configs = new EGLConfig[1];
  int[] numConfigs = new int[1];
  boolean success =
      EGL14.eglChooseConfig(
          display,
          EGL_CONFIG_ATTRIBUTES,
          /* attrib_listOffset= */ 0,
          configs,
          /* configsOffset= */ 0,
          /* config_size= */ 1,
          numConfigs,
          /* num_configOffset= */ 0);
  if (!success || numConfigs[0] <= 0 || configs[0] == null) {
    throw new GlException(
        Util.formatInvariant(
            /* format= */ "eglChooseConfig failed: success=%b, numConfigs[0]=%d, configs[0]=%s",
            success, numConfigs[0], configs[0]));
  }

  return configs[0];
}
 
源代码6 项目: UltraGpuImage   文件: EglBase14.java
private static EGLConfig getEglConfig(EGLDisplay eglDisplay, int[] configAttributes) {
  EGLConfig[] configs = new EGLConfig[1];
  int[] numConfigs = new int[1];
  if (!EGL14.eglChooseConfig(
          eglDisplay, configAttributes, 0, configs, 0, configs.length, numConfigs, 0)) {
    throw new RuntimeException(
        "eglChooseConfig failed: 0x" + Integer.toHexString(EGL14.eglGetError()));
  }
  if (numConfigs[0] <= 0) {
    throw new RuntimeException("Unable to find any matching EGL config");
  }
  final EGLConfig eglConfig = configs[0];
  if (eglConfig == null) {
    throw new RuntimeException("eglChooseConfig returned null");
  }
  return eglConfig;
}
 
源代码7 项目: UltraGpuImage   文件: EglBase14.java
private static EGLContext createEglContext(
    @Nullable EglBase14.Context sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) {
  if (sharedContext != null && sharedContext.egl14Context == EGL14.EGL_NO_CONTEXT) {
    throw new RuntimeException("Invalid sharedContext");
  }
  int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE};
  EGLContext rootContext =
      sharedContext == null ? EGL14.EGL_NO_CONTEXT : sharedContext.egl14Context;
  final EGLContext eglContext;
  synchronized (EglBase.lock) {
    eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes, 0);
  }
  if (eglContext == EGL14.EGL_NO_CONTEXT) {
    throw new RuntimeException(
        "Failed to create EGL context: 0x" + Integer.toHexString(EGL14.eglGetError()));
  }
  return eglContext;
}
 
源代码8 项目: TelePlus-Android   文件: EGLSurfaceTexture.java
private static EGLConfig chooseEGLConfig(EGLDisplay display) {
  EGLConfig[] configs = new EGLConfig[1];
  int[] numConfigs = new int[1];
  boolean success =
      EGL14.eglChooseConfig(
          display,
          EGL_CONFIG_ATTRIBUTES,
          /* attrib_listOffset= */ 0,
          configs,
          /* configsOffset= */ 0,
          /* config_size= */ 1,
          numConfigs,
          /* num_configOffset= */ 0);
  if (!success || numConfigs[0] <= 0 || configs[0] == null) {
    throw new GlException(
        Util.formatInvariant(
            /* format= */ "eglChooseConfig failed: success=%b, numConfigs[0]=%d, configs[0]=%s",
            success, numConfigs[0], configs[0]));
  }

  return configs[0];
}
 
源代码9 项目: TelePlus-Android   文件: EGLSurfaceTexture.java
private static EGLContext createEGLContext(
    EGLDisplay display, EGLConfig config, @SecureMode int secureMode) {
  int[] glAttributes;
  if (secureMode == SECURE_MODE_NONE) {
    glAttributes = new int[] {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE};
  } else {
    glAttributes =
        new int[] {
          EGL14.EGL_CONTEXT_CLIENT_VERSION,
          2,
          EGL_PROTECTED_CONTENT_EXT,
          EGL14.EGL_TRUE,
          EGL14.EGL_NONE
        };
  }
  EGLContext context =
      EGL14.eglCreateContext(
          display, config, android.opengl.EGL14.EGL_NO_CONTEXT, glAttributes, 0);
  if (context == null) {
    throw new GlException("eglCreateContext failed");
  }
  return context;
}
 
源代码10 项目: AAVT   文件: EglHelper.java
public boolean createGLESWithSurface(EGLConfigAttrs attrs,EGLContextAttrs ctxAttrs,Object surface){
    EGLConfig config=getConfig(attrs.surfaceType(EGL14.EGL_WINDOW_BIT).makeDefault(true));
    if(config==null){
        log("getConfig failed : "+EGL14.eglGetError());
        return false;
    }
    mEGLContext=createContext(config,EGL14.EGL_NO_CONTEXT,ctxAttrs.makeDefault(true));
    if(mEGLContext==EGL14.EGL_NO_CONTEXT){
        log("createContext failed : "+EGL14.eglGetError());
        return false;
    }
    mEGLSurface=createWindowSurface(surface);
    if(mEGLSurface==EGL14.EGL_NO_SURFACE){
        log("createWindowSurface failed : "+EGL14.eglGetError());
        return false;
    }
    if(!EGL14.eglMakeCurrent(mEGLDisplay,mEGLSurface,mEGLSurface,mEGLContext)){
        log("eglMakeCurrent failed : "+EGL14.eglGetError());
        return false;
    }
    return true;
}
 
源代码11 项目: AAVT   文件: EglHelper.java
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;
}
 
源代码12 项目: VideoCRE   文件: EglBase14.java
private static EGLConfig getEglConfig(EGLDisplay eglDisplay, int[] configAttributes) {
  EGLConfig[] configs = new EGLConfig[1];
  int[] numConfigs = new int[1];
  if (!EGL14.eglChooseConfig(
          eglDisplay, configAttributes, 0, configs, 0, configs.length, numConfigs, 0)) {
    throw new RuntimeException(
        "eglChooseConfig failed: 0x" + Integer.toHexString(EGL14.eglGetError()));
  }
  if (numConfigs[0] <= 0) {
    throw new RuntimeException("Unable to find any matching EGL config");
  }
  final EGLConfig eglConfig = configs[0];
  if (eglConfig == null) {
    throw new RuntimeException("eglChooseConfig returned null");
  }
  return eglConfig;
}
 
源代码13 项目: VideoCRE   文件: EglBase14.java
private static EGLContext createEglContext(
    EglBase14.Context sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) {
  if (sharedContext != null && sharedContext.egl14Context == EGL14.EGL_NO_CONTEXT) {
    throw new RuntimeException("Invalid sharedContext");
  }
  int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE};
  EGLContext rootContext =
      sharedContext == null ? EGL14.EGL_NO_CONTEXT : sharedContext.egl14Context;
  final EGLContext eglContext;
  synchronized (EglBase.lock) {
    eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes, 0);
  }
  if (eglContext == EGL14.EGL_NO_CONTEXT) {
    throw new RuntimeException(
        "Failed to create EGL context: 0x" + Integer.toHexString(EGL14.eglGetError()));
  }
  return eglContext;
}
 
源代码14 项目: Tok-Android   文件: EGLBase.java
@SuppressWarnings("unused")
private EGLConfig getConfig(final boolean with_depth_buffer, final boolean isRecordable) {
    final int[] attribList = {
        EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL14.EGL_RED_SIZE, 8,
        EGL14.EGL_GREEN_SIZE, 8, EGL14.EGL_BLUE_SIZE, 8, EGL14.EGL_ALPHA_SIZE, 8,
        EGL14.EGL_NONE, EGL14.EGL_NONE,    //EGL14.EGL_STENCIL_SIZE, 8,
        EGL14.EGL_NONE, EGL14.EGL_NONE,
        //EGL_RECORDABLE_ANDROID, 1,	// this flag need to recording of MediaCodec
        EGL14.EGL_NONE, EGL14.EGL_NONE,
        //with_depth_buffer ? EGL14.EGL_DEPTH_SIZE : EGL14.EGL_NONE,
        // with_depth_buffer ? 16 : 0,
        EGL14.EGL_NONE
    };
    int offset = 10;
    if (false) {                // ステンシルバッファ(常時未使用)
        attribList[offset++] = EGL14.EGL_STENCIL_SIZE;
        attribList[offset++] = 8;
    }
    if (with_depth_buffer) {    // デプスバッファ
        attribList[offset++] = EGL14.EGL_DEPTH_SIZE;
        attribList[offset++] = 16;
    }
    if (isRecordable && (Build.VERSION.SDK_INT >= 18)) {// MediaCodecの入力用Surfaceの場合
        attribList[offset++] = EGL_RECORDABLE_ANDROID;
        attribList[offset++] = 1;
    }
    for (int i = attribList.length - 1; i >= offset; i--) {
        attribList[i] = EGL14.EGL_NONE;
    }
    final EGLConfig[] configs = new EGLConfig[1];
    final int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEglDisplay, attribList, 0, configs, 0, configs.length,
        numConfigs, 0)) {
        // XXX it will be better to fallback to RGB565
        LogUtil.i(TAG, "unable to find RGBA8888 / " + " EGLConfig");
        return null;
    }
    return configs[0];
}
 
源代码15 项目: Lassi-Android   文件: EglCore.java
/**
 * Finds a suitable EGLConfig.
 *
 * @param flags   Bit flags from constructor.
 * @param version Must be 2 or 3.
 */
private EGLConfig getConfig(int flags, int version) {
    int renderableType = EGL14.EGL_OPENGL_ES2_BIT;
    if (version >= 3) {
        renderableType |= EGLExt.EGL_OPENGL_ES3_BIT_KHR;
    }

    // The actual surface is generally RGBA or RGBX, so situationally omitting alpha
    // doesn't really help.  It can also lead to a huge performance hit on glReadPixels()
    // when reading into a GL_RGBA buffer.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_ALPHA_SIZE, 8,
            //EGL14.EGL_DEPTH_SIZE, 16,
            //EGL14.EGL_STENCIL_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, renderableType,
            EGL14.EGL_NONE, 0,      // placeholder for recordable [@-3]
            EGL14.EGL_NONE
    };
    if ((flags & FLAG_RECORDABLE) != 0) {
        attribList[attribList.length - 3] = EGL_RECORDABLE_ANDROID;
        attribList[attribList.length - 2] = 1;
    }
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        Log.w(TAG, "unable to find RGB8888 / " + version + " EGLConfig");
        return null;
    }
    return configs[0];
}
 
源代码16 项目: mobile-ar-sensor-logger   文件: EglCore.java
/**
 * Finds a suitable EGLConfig.
 *
 * @param flags Bit flags from constructor.
 * @param version Must be 2 or 3.
 */
private EGLConfig getConfig(int flags, int version) {
    int renderableType = EGL14.EGL_OPENGL_ES2_BIT;
    if (version >= 3) {
        renderableType |= EGLExt.EGL_OPENGL_ES3_BIT_KHR;
    }

    // The actual surface is generally RGBA or RGBX, so situationally omitting alpha
    // doesn't really help.  It can also lead to a huge performance hit on glReadPixels()
    // when reading into a GL_RGBA buffer.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_ALPHA_SIZE, 8,
            //EGL14.EGL_DEPTH_SIZE, 16,
            //EGL14.EGL_STENCIL_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, renderableType,
            EGL14.EGL_NONE, 0,      // placeholder for recordable [@-3]
            EGL14.EGL_NONE
    };
    if ((flags & FLAG_RECORDABLE) != 0) {
        attribList[attribList.length - 3] = EGL_RECORDABLE_ANDROID;
        attribList[attribList.length - 2] = 1;
    }
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        Log.w(TAG, "unable to find RGB8888 / " + version + " EGLConfig");
        return null;
    }
    return configs[0];
}
 
源代码17 项目: android_9.0.0_r45   文件: SurfaceTextureRenderer.java
private void configureEGLContext() {
    mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        throw new IllegalStateException("No EGL14 display");
    }
    int[] version = new int[2];
    if (!EGL14.eglInitialize(mEGLDisplay, version, /*offset*/ 0, version, /*offset*/ 1)) {
        throw new IllegalStateException("Cannot initialize EGL14");
    }

    int[] attribList = {
            EGL14.EGL_RED_SIZE, EGL_COLOR_BITLENGTH,
            EGL14.EGL_GREEN_SIZE, EGL_COLOR_BITLENGTH,
            EGL14.EGL_BLUE_SIZE, EGL_COLOR_BITLENGTH,
            EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
            EGL_RECORDABLE_ANDROID, 1,
            EGL14.EGL_SURFACE_TYPE, EGL14.EGL_PBUFFER_BIT | EGL14.EGL_WINDOW_BIT,
            EGL14.EGL_NONE
    };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    EGL14.eglChooseConfig(mEGLDisplay, attribList, /*offset*/ 0, configs, /*offset*/ 0,
            configs.length, numConfigs, /*offset*/ 0);
    checkEglError("eglCreateContext RGB888+recordable ES2");
    mConfigs = configs[0];
    int[] attrib_list = {
            EGL14.EGL_CONTEXT_CLIENT_VERSION, GLES_VERSION,
            EGL14.EGL_NONE
    };
    mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT,
            attrib_list, /*offset*/ 0);
    checkEglError("eglCreateContext");
    if(mEGLContext == EGL14.EGL_NO_CONTEXT) {
        throw new IllegalStateException("No EGLContext could be made");
    }
}
 
源代码18 项目: TelePlus-Android   文件: EGLSurfaceTexture.java
/**
 * Initializes required EGL parameters and creates the {@link SurfaceTexture}.
 *
 * @param secureMode The {@link SecureMode} to be used for EGL surface.
 */
public void init(@SecureMode int secureMode) {
  display = getDefaultDisplay();
  EGLConfig config = chooseEGLConfig(display);
  context = createEGLContext(display, config, secureMode);
  surface = createEGLSurface(display, config, context, secureMode);
  generateTextureIds(textureIdHolder);
  texture = new SurfaceTexture(textureIdHolder[0]);
  texture.setOnFrameAvailableListener(this);
}
 
源代码19 项目: RtmpPublisher   文件: EglCore.java
/**
 * Finds a suitable EGLConfig.
 *
 * @param flags Bit flags from constructor.
 * @param version Must be 2 or 3.
 */
private EGLConfig getConfig(int flags, int version) {
    int renderableType = EGL14.EGL_OPENGL_ES2_BIT;
    if (version >= 3) {
        renderableType |= EGLExt.EGL_OPENGL_ES3_BIT_KHR;
    }

    // The actual surface is generally RGBA or RGBX, so situationally omitting alpha
    // doesn't really help.  It can also lead to a huge performance hit on glReadPixels()
    // when reading into a GL_RGBA buffer.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_ALPHA_SIZE, 8,
            //EGL14.EGL_DEPTH_SIZE, 16,
            //EGL14.EGL_STENCIL_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, renderableType,
            EGL14.EGL_NONE, 0,      // placeholder for recordable [@-3]
            EGL14.EGL_NONE
    };
    if ((flags & FLAG_RECORDABLE) != 0) {
        attribList[attribList.length - 3] = EGL_RECORDABLE_ANDROID;
        attribList[attribList.length - 2] = 1;
    }
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        Log.w(TAG, "unable to find RGB8888 / " + version + " EGLConfig");
        return null;
    }
    return configs[0];
}
 
源代码20 项目: PhotoMovie   文件: EglCore.java
/**
 * Finds a suitable EGLConfig.
 *
 * @param flags Bit flags from constructor.
 * @param version Must be 2 or 3.
 */
private EGLConfig getConfig(int flags, int version) {
    int renderableType = EGL14.EGL_OPENGL_ES2_BIT;
    if (version >= 3) {
        renderableType |= EGLExt.EGL_OPENGL_ES3_BIT_KHR;
    }

    // The actual surface is generally RGBA or RGBX, so situationally omitting alpha
    // doesn't really help.  It can also lead to a huge performance hit on glReadPixels()
    // when reading into a GL_RGBA buffer.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_ALPHA_SIZE, 8,
            //EGL14.EGL_DEPTH_SIZE, 16,
            //EGL14.EGL_STENCIL_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, renderableType,
            EGL14.EGL_NONE, 0,      // placeholder for recordable [@-3]
            EGL14.EGL_NONE
    };
    if ((flags & FLAG_RECORDABLE) != 0) {
        attribList[attribList.length - 3] = EGL_RECORDABLE_ANDROID;
        attribList[attribList.length - 2] = 1;
    }
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        Log.w(TAG, "unable to find RGB8888 / " + version + " EGLConfig");
        return null;
    }
    return configs[0];
}
 
源代码21 项目: TikTok   文件: EglCore.java
/**
 * Finds a suitable EGLConfig.
 *
 * @param flags Bit flags from constructor.
 * @param version Must be 2 or 3.
 */
private EGLConfig getConfig(int flags, int version) {
    int renderableType = EGL14.EGL_OPENGL_ES2_BIT;
    if (version >= 3) {
        renderableType |= EGLExt.EGL_OPENGL_ES3_BIT_KHR;
    }

    // The actual surface is generally RGBA or RGBX, so situationally omitting alpha
    // doesn't really help.  It can also lead to a huge performance hit on glReadPixels()
    // when reading into a GL_RGBA buffer.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_ALPHA_SIZE, 8,
            //EGL14.EGL_DEPTH_SIZE, 16,
            //EGL14.EGL_STENCIL_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, renderableType,
            EGL14.EGL_NONE, 0,      // placeholder for recordable [@-3]
            EGL14.EGL_NONE
    };
    if ((flags & FLAG_RECORDABLE) != 0) {
        attribList[attribList.length - 3] = EGL_RECORDABLE_ANDROID;
        attribList[attribList.length - 2] = 1;
    }
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        Log.w(TAG, "unable to find RGB8888 / " + version + " EGLConfig");
        return null;
    }
    return configs[0];
}
 
源代码22 项目: VideoRecorder   文件: EglCore.java
/**
 * Finds a suitable EGLConfig.
 *
 * @param flags Bit flags from constructor.
 * @param version Must be 2 or 3.
 */
private EGLConfig getConfig(int flags, int version) {
    int renderableType = EGL14.EGL_OPENGL_ES2_BIT;
    if (version >= 3) {
        renderableType |= EGLExt.EGL_OPENGL_ES3_BIT_KHR;
    }

    // The actual surface is generally RGBA or RGBX, so situationally omitting alpha
    // doesn't really help.  It can also lead to a huge performance hit on glReadPixels()
    // when reading into a GL_RGBA buffer.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_ALPHA_SIZE, 8,
            //EGL14.EGL_DEPTH_SIZE, 16,
            //EGL14.EGL_STENCIL_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, renderableType,
            EGL14.EGL_NONE, 0,      // placeholder for recordable [@-3]
            EGL14.EGL_NONE
    };
    if ((flags & FLAG_RECORDABLE) != 0) {
        attribList[attribList.length - 3] = EGL_RECORDABLE_ANDROID;
        attribList[attribList.length - 2] = 1;
    }
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        Log.w(TAG, "unable to find RGB8888 / " + version + " EGLConfig");
        return null;
    }
    return configs[0];
}
 
源代码23 项目: sealrtc-android   文件: EglCore.java
/**
 * Finds a suitable EGLConfig.
 *
 * @param flags Bit flags from constructor.
 * @param version Must be 2 or 3.
 */
private EGLConfig getConfig(int flags, int version) {
    int renderableType = EGL14.EGL_OPENGL_ES2_BIT;
    if (version >= 3) {
        renderableType |= EGLExt.EGL_OPENGL_ES3_BIT_KHR;
    }

    // The actual surface is generally RGBA or RGBX, so situationally omitting alpha
    // doesn't really help.  It can also lead to a huge performance hit on glReadPixels()
    // when reading into a GL_RGBA buffer.
    int[] attribList = {
        EGL14.EGL_RED_SIZE, 8,
        EGL14.EGL_GREEN_SIZE, 8,
        EGL14.EGL_BLUE_SIZE, 8,
        EGL14.EGL_ALPHA_SIZE, 8,
        // EGL14.EGL_DEPTH_SIZE, 16,
        // EGL14.EGL_STENCIL_SIZE, 8,
        EGL14.EGL_RENDERABLE_TYPE, renderableType,
        EGL14.EGL_NONE, 0, // placeholder for recordable [@-3]
        EGL14.EGL_NONE
    };
    if ((flags & FLAG_RECORDABLE) != 0) {
        attribList[attribList.length - 3] = EGL_RECORDABLE_ANDROID;
        attribList[attribList.length - 2] = 1;
    }
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(
            mEGLDisplay, attribList, 0, configs, 0, configs.length, numConfigs, 0)) {
        Log.w(TAG, "unable to find RGB8888 / " + version + " EGLConfig");
        return null;
    }
    return configs[0];
}
 
源代码24 项目: In77Camera   文件: EGLBase.java
@SuppressWarnings("unused")
private EGLConfig getConfig(final boolean with_depth_buffer, final boolean isRecordable) {
    final int[] attribList = {
            EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_ALPHA_SIZE, 8,
            EGL14.EGL_NONE, EGL14.EGL_NONE,	//EGL14.EGL_STENCIL_SIZE, 8,
            EGL14.EGL_NONE, EGL14.EGL_NONE,	//EGL_RECORDABLE_ANDROID, 1,	// this flag need to recording of MediaCodec
            EGL14.EGL_NONE,	EGL14.EGL_NONE,	//	with_depth_buffer ? EGL14.EGL_DEPTH_SIZE : EGL14.EGL_NONE,
								// with_depth_buffer ? 16 : 0,
            EGL14.EGL_NONE
    };
    int offset = 10;
    if (false) {				// ステンシルバッファ(常時未使用)
    	attribList[offset++] = EGL14.EGL_STENCIL_SIZE;
    	attribList[offset++] = 8;
    }
    if (with_depth_buffer) {	// デプスバッファ
    	attribList[offset++] = EGL14.EGL_DEPTH_SIZE;
    	attribList[offset++] = 16;
    }
    if (isRecordable && (Build.VERSION.SDK_INT >= 18)) {// MediaCodecの入力用Surfaceの場合
    	attribList[offset++] = EGL_RECORDABLE_ANDROID;
    	attribList[offset++] = 1;
    }
    for (int i = attribList.length - 1; i >= offset; i--) {
    	attribList[i] = EGL14.EGL_NONE;
    }
    final EGLConfig[] configs = new EGLConfig[1];
    final int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEglDisplay, attribList, 0, configs, 0, configs.length, numConfigs, 0)) {
    	// XXX it will be better to fallback to RGB565
        Log.w(TAG, "unable to find RGBA8888 / " + " EGLConfig");
        return null;
    }
    return configs[0];
}
 
源代码25 项目: SimpleVideoEditor   文件: EglUtil.java
static EGLConfig getEglConfig(EGLDisplay eglDisplay, int version) {
    // Get an EGLConfig.
    int renderableType = EGL14.EGL_OPENGL_ES2_BIT;
    if (version == 3) {
        renderableType = EGLExt.EGL_OPENGL_ES3_BIT_KHR;
    }
    final int RED_SIZE = 8;
    final int GREEN_SIZE = 8;
    final int BLUE_SIZE = 8;
    final int ALPHA_SIZE = 8;
    final int DEPTH_SIZE = 0;
    final int STENCIL_SIZE = 0;
    final int[] DEFAULT_CONFIGURATION = new int[]{
            EGL14.EGL_RENDERABLE_TYPE, renderableType,
            EGL14.EGL_RED_SIZE, RED_SIZE,
            EGL14.EGL_GREEN_SIZE, GREEN_SIZE,
            EGL14.EGL_BLUE_SIZE, BLUE_SIZE,
            EGL14.EGL_ALPHA_SIZE, ALPHA_SIZE,
            EGL14.EGL_DEPTH_SIZE, DEPTH_SIZE,
            EGL14.EGL_STENCIL_SIZE, STENCIL_SIZE,
            EGL14.EGL_NONE};
    int[] configsCount = new int[1];
    EGLConfig[] eglConfigs = new EGLConfig[1];
    if (!EGL14.eglChooseConfig(
            eglDisplay, DEFAULT_CONFIGURATION, 0, eglConfigs, 0, 1, configsCount, 0)) {
        throw new RuntimeException("eglChooseConfig failed");
    }
    return eglConfigs[0];
}
 
源代码26 项目: TelePlus-Android   文件: EGLSurfaceTexture.java
/**
 * Initializes required EGL parameters and creates the {@link SurfaceTexture}.
 *
 * @param secureMode The {@link SecureMode} to be used for EGL surface.
 */
public void init(@SecureMode int secureMode) {
  display = getDefaultDisplay();
  EGLConfig config = chooseEGLConfig(display);
  context = createEGLContext(display, config, secureMode);
  surface = createEGLSurface(display, config, context, secureMode);
  generateTextureIds(textureIdHolder);
  texture = new SurfaceTexture(textureIdHolder[0]);
  texture.setOnFrameAvailableListener(this);
}
 
源代码27 项目: CameraRecorder-android   文件: EGLBase.java
@SuppressWarnings("unused")
private EGLConfig getConfig(final boolean with_depth_buffer, final boolean isRecordable) {
    final int[] attribList = {
            EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_ALPHA_SIZE, 8,
            EGL14.EGL_NONE, EGL14.EGL_NONE,    //EGL14.EGL_STENCIL_SIZE, 8,
            EGL14.EGL_NONE, EGL14.EGL_NONE,    //EGL_RECORDABLE_ANDROID, 1,	// this flag need to recording of MediaCodec
            EGL14.EGL_NONE, EGL14.EGL_NONE,    //	with_depth_buffer ? EGL14.EGL_DEPTH_SIZE : EGL14.EGL_NONE,
            // with_depth_buffer ? 16 : 0,
            EGL14.EGL_NONE
    };
    int offset = 10;
    if (false) {
        attribList[offset++] = EGL14.EGL_STENCIL_SIZE;
        attribList[offset++] = 8;
    }
    if (with_depth_buffer) {
        attribList[offset++] = EGL14.EGL_DEPTH_SIZE;
        attribList[offset++] = 16;
    }
    if (isRecordable && (Build.VERSION.SDK_INT >= 18)) {// MediaCodecの入力用Surfaceの場合
        attribList[offset++] = EGL_RECORDABLE_ANDROID;
        attribList[offset++] = 1;
    }
    for (int i = attribList.length - 1; i >= offset; i--) {
        attribList[i] = EGL14.EGL_NONE;
    }
    final EGLConfig[] configs = new EGLConfig[1];
    final int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(eglDisplay, attribList, 0, configs, 0, configs.length, numConfigs, 0)) {
        // XXX it will be better to fallback to RGB565
        Log.w(TAG, "unable to find RGBA8888 / " + " EGLConfig");
        return null;
    }
    return configs[0];
}
 
源代码28 项目: PLDroidShortVideo   文件: EglCore.java
/**
 * Finds a suitable EGLConfig.
 *
 * @param flags   Bit flags from constructor.
 * @param version Must be 2 or 3.
 */
private EGLConfig getConfig(int flags, int version) {
    int renderableType = EGL14.EGL_OPENGL_ES2_BIT;
    if (version >= 3) {
        renderableType |= EGLExt.EGL_OPENGL_ES3_BIT_KHR;
    }

    // The actual surface is generally RGBA or RGBX, so situationally omitting alpha
    // doesn't really help.  It can also lead to a huge performance hit on glReadPixels()
    // when reading into a GL_RGBA buffer.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_ALPHA_SIZE, 8,
            //EGL14.EGL_DEPTH_SIZE, 16,
            //EGL14.EGL_STENCIL_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, renderableType,
            EGL14.EGL_NONE, 0,      // placeholder for recordable [@-3]
            EGL14.EGL_NONE
    };
    if ((flags & FLAG_RECORDABLE) != 0) {
        attribList[attribList.length - 3] = EGL_RECORDABLE_ANDROID;
        attribList[attribList.length - 2] = 1;
    }
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        Log.w(TAG, "unable to find RGB8888 / " + version + " EGLConfig");
        return null;
    }
    return configs[0];
}
 
源代码29 项目: AAVT   文件: EglHelper.java
public EGLConfig getConfig(EGLConfigAttrs attrs){
    EGLConfig[] configs = new EGLConfig[1];
    int[] configNum = new int[1];
    EGL14.eglChooseConfig(mEGLDisplay,attrs.build(),0,configs,0,1,configNum,0);
    //选择的过程可能出现多个,也可能一个都没有,这里只用一个
    if(configNum[0]>0){
        if(attrs.isDefault()){
            mEGLConfig=configs[0];
        }
        return configs[0];
    }
    return null;
}
 
源代码30 项目: AAVT   文件: EglHelper.java
public EGLContext createContext(EGLConfig config,EGLContext share,EGLContextAttrs attrs){
    EGLContext context= EGL14.eglCreateContext(mEGLDisplay,config,share,attrs.build(),0);
    if(attrs.isDefault()){
        mEGLContext=context;
    }
    return context;
}