javax.microedition.khronos.egl.EGLDisplay Java Examples

The following examples show how to use javax.microedition.khronos.egl.EGLDisplay. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EConfigChooser.java    From SimpleVideoEdit with Apache License 2.0 6 votes vote down vote up
@Override
public EGLConfig chooseConfig(final EGL10 egl, final EGLDisplay display) {
    final int[] num_config = new int[1];
    if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) {
        throw new IllegalArgumentException("eglChooseConfig failed");
    }
    final int config_size = num_config[0];
    if (config_size <= 0) {
        throw new IllegalArgumentException("No configs match configSpec");
    }

    final EGLConfig[] configs = new EGLConfig[config_size];
    if (!egl.eglChooseConfig(display, configSpec, configs, config_size, num_config)) {
        throw new IllegalArgumentException("eglChooseConfig#2 failed");
    }
    final EGLConfig config = chooseConfig(egl, display, configs);
    if (config == null) {
        throw new IllegalArgumentException("No config chosen");
    }
    return config;
}
 
Example #2
Source File: GLThread.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public android.opengl.EGLSurface createWindowSurface(android.opengl.EGLDisplay display, android.opengl.EGLConfig config, Object nativeWindow) {
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    android.opengl.EGLSurface result = null;
    try {
        result = EGL14.eglCreateWindowSurface(display, config, nativeWindow, surfaceAttribs, 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("DefaultWindow", "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #3
Source File: GLTextureView.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 6 votes vote down vote up
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
                              EGLConfig[] configs) {
    for (EGLConfig config : configs) {
        int d = findConfigAttrib(egl, display, config,
                EGL10.EGL_DEPTH_SIZE, 0);
        int s = findConfigAttrib(egl, display, config,
                EGL10.EGL_STENCIL_SIZE, 0);
        if ((d >= mDepthSize) && (s >= mStencilSize)) {
            int r = findConfigAttrib(egl, display, config,
                    EGL10.EGL_RED_SIZE, 0);
            int g = findConfigAttrib(egl, display, config,
                    EGL10.EGL_GREEN_SIZE, 0);
            int b = findConfigAttrib(egl, display, config,
                    EGL10.EGL_BLUE_SIZE, 0);
            int a = findConfigAttrib(egl, display, config,
                    EGL10.EGL_ALPHA_SIZE, 0);
            if ((r == mRedSize) && (g == mGreenSize)
                    && (b == mBlueSize) && (a == mAlphaSize)) {
                return config;
            }
        }
    }
    return null;
}
 
Example #4
Source File: GLTextureView.java    From VideoRecorder with Apache License 2.0 6 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
        EGLConfig config, Object nativeWindow) {
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
    } 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(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #5
Source File: GLThread.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
                              EGLConfig[] configs) {
    for (EGLConfig config : configs) {
        int d = findConfigAttrib(egl, display, config,
                EGL10.EGL_DEPTH_SIZE, 0);
        int s = findConfigAttrib(egl, display, config,
                EGL10.EGL_STENCIL_SIZE, 0);
        if ((d >= mDepthSize) && (s >= mStencilSize)) {
            int r = findConfigAttrib(egl, display, config,
                    EGL10.EGL_RED_SIZE, 0);
            int g = findConfigAttrib(egl, display, config,
                    EGL10.EGL_GREEN_SIZE, 0);
            int b = findConfigAttrib(egl, display, config,
                    EGL10.EGL_BLUE_SIZE, 0);
            int a = findConfigAttrib(egl, display, config,
                    EGL10.EGL_ALPHA_SIZE, 0);
            if ((r == mRedSize) && (g == mGreenSize)
                    && (b == mBlueSize) && (a == mAlphaSize)) {
                return config;
            }
        }
    }
    return null;
}
 
Example #6
Source File: GLTextureView.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 6 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
    } 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(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #7
Source File: GLThread.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
@Override
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {

    int[] surfaceAttribs = {
            EGL10.EGL_NONE
    };
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, surfaceAttribs);
    } 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("DefaultWindow", "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #8
Source File: EglBase10Impl.java    From webrtc_android with MIT License 6 votes vote down vote up
private EGLContext createEglContext(
      EGLContext sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) {
  if (sharedContext != null && sharedContext == EGL10.EGL_NO_CONTEXT) {
    throw new RuntimeException("Invalid sharedContext");
  }
  int[] contextAttributes = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};
  EGLContext rootContext = sharedContext == null ? EGL10.EGL_NO_CONTEXT : sharedContext;
  final EGLContext eglContext;
  synchronized (EglBase.lock) {
    eglContext = egl.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes);
  }
  if (eglContext == EGL10.EGL_NO_CONTEXT) {
    throw new RuntimeException(
        "Failed to create EGL context: 0x" + Integer.toHexString(egl.eglGetError()));
  }
  return eglContext;
}
 
Example #9
Source File: EglBase10Impl.java    From webrtc_android with MIT License 6 votes vote down vote up
private EGLConfig getEglConfig(EGLDisplay eglDisplay, int[] configAttributes) {
  EGLConfig[] configs = new EGLConfig[1];
  int[] numConfigs = new int[1];
  if (!egl.eglChooseConfig(eglDisplay, configAttributes, configs, configs.length, numConfigs)) {
    throw new RuntimeException(
        "eglChooseConfig failed: 0x" + Integer.toHexString(egl.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;
}
 
Example #10
Source File: DefaultConfigChooser.java    From CameraRecorder-android with MIT License 6 votes vote down vote up
@Override
public EGLConfig chooseConfig(final EGL10 egl, final EGLDisplay display) {
    // 要求されている仕様から使用可能な構成の数を抽出します。
    final int[] num_config = new int[1];
    if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) {
        throw new IllegalArgumentException("eglChooseConfig failed");
    }
    final int config_size = num_config[0];
    if (config_size <= 0) {
        throw new IllegalArgumentException("No configs match configSpec");
    }

    // 実際の構成を抽出します。
    final EGLConfig[] configs = new EGLConfig[config_size];
    if (!egl.eglChooseConfig(display, configSpec, configs, config_size, num_config)) {
        throw new IllegalArgumentException("eglChooseConfig#2 failed");
    }
    final EGLConfig config = chooseConfig(egl, display, configs);
    if (config == null) {
        throw new IllegalArgumentException("No config chosen");
    }
    return config;
}
 
Example #11
Source File: DefaultConfigChooser.java    From CameraRecorder-android with MIT License 6 votes vote down vote up
private EGLConfig chooseConfig(final EGL10 egl, final EGLDisplay display, final EGLConfig[] configs) {
    for (final EGLConfig config : configs) {
        final int d = findConfigAttrib(egl, display, config, EGL_DEPTH_SIZE, 0);
        final int s = findConfigAttrib(egl, display, config, EGL_STENCIL_SIZE, 0);
        if ((d >= depthSize) && (s >= stencilSize)) {
            final int r = findConfigAttrib(egl, display, config, EGL_RED_SIZE, 0);
            final int g = findConfigAttrib(egl, display, config, EGL_GREEN_SIZE, 0);
            final int b = findConfigAttrib(egl, display, config, EGL_BLUE_SIZE, 0);
            final int a = findConfigAttrib(egl, display, config, EGL_ALPHA_SIZE, 0);
            if ((r == redSize) && (g == greenSize) && (b == blueSize) && (a == alphaSize)) {
                return config;
            }
        }
    }
    return null;
}
 
Example #12
Source File: DefaultConfigChooser.java    From GPUVideo-android with MIT License 6 votes vote down vote up
private EGLConfig chooseConfig(final EGL10 egl, final EGLDisplay display, final EGLConfig[] configs) {
    for (final EGLConfig config : configs) {
        final int d = findConfigAttrib(egl, display, config, EGL_DEPTH_SIZE, 0);
        final int s = findConfigAttrib(egl, display, config, EGL_STENCIL_SIZE, 0);
        if ((d >= depthSize) && (s >= stencilSize)) {
            final int r = findConfigAttrib(egl, display, config, EGL_RED_SIZE, 0);
            final int g = findConfigAttrib(egl, display, config, EGL_GREEN_SIZE, 0);
            final int b = findConfigAttrib(egl, display, config, EGL_BLUE_SIZE, 0);
            final int a = findConfigAttrib(egl, display, config, EGL_ALPHA_SIZE, 0);
            if ((r == redSize) && (g == greenSize) && (b == blueSize) && (a == alphaSize)) {
                return config;
            }
        }
    }
    return null;
}
 
Example #13
Source File: GLTextureView.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
    int[] num_config = new int[1];
    if (!egl.eglChooseConfig(display, mConfigSpec, null, 0,
            num_config)) {
        throw new IllegalArgumentException("eglChooseConfig failed");
    }

    int numConfigs = num_config[0];

    if (numConfigs <= 0) {
        throw new IllegalArgumentException(
                "No configs match configSpec");
    }

    EGLConfig[] configs = new EGLConfig[numConfigs];
    if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs,
            num_config)) {
        throw new IllegalArgumentException("eglChooseConfig#2 failed");
    }
    EGLConfig config = chooseConfig(egl, display, configs);
    if (config == null) {
        throw new IllegalArgumentException("No config chosen");
    }
    return config;
}
 
Example #14
Source File: DefaultConfigChooser.java    From GPUVideo-android with MIT License 6 votes vote down vote up
@Override
public EGLConfig chooseConfig(final EGL10 egl, final EGLDisplay display) {
    // 要求されている仕様から使用可能な構成の数を抽出します。
    final int[] num_config = new int[1];
    if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) {
        throw new IllegalArgumentException("eglChooseConfig failed");
    }
    final int config_size = num_config[0];
    if (config_size <= 0) {
        throw new IllegalArgumentException("No configs match configSpec");
    }

    // 実際の構成を抽出します。
    final EGLConfig[] configs = new EGLConfig[config_size];
    if (!egl.eglChooseConfig(display, configSpec, configs, config_size, num_config)) {
        throw new IllegalArgumentException("eglChooseConfig#2 failed");
    }
    final EGLConfig config = chooseConfig(egl, display, configs);
    if (config == null) {
        throw new IllegalArgumentException("No config chosen");
    }
    return config;
}
 
Example #15
Source File: EGLLogWrapper.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
public boolean eglChooseConfig(EGLDisplay display, int[] attrib_list,
                               EGLConfig[] configs, int config_size, int[] num_config) {
    begin("eglChooseConfig");
    arg("display", display);
    arg("attrib_list", attrib_list);
    arg("config_size", config_size);
    end();

    boolean result = mEgl10.eglChooseConfig(display, attrib_list, configs,
            config_size, num_config);
    arg("configs", configs);
    arg("num_config", num_config);
    returns(result);
    checkError();
    return result;
}
 
Example #16
Source File: GLTextureView.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
                              EGLConfig[] configs) {
    for (EGLConfig config : configs) {
        int d = findConfigAttrib(egl, display, config,
                EGL10.EGL_DEPTH_SIZE, 0);
        int s = findConfigAttrib(egl, display, config,
                EGL10.EGL_STENCIL_SIZE, 0);
        if ((d >= mDepthSize) && (s >= mStencilSize)) {
            int r = findConfigAttrib(egl, display, config,
                    EGL10.EGL_RED_SIZE, 0);
            int g = findConfigAttrib(egl, display, config,
                    EGL10.EGL_GREEN_SIZE, 0);
            int b = findConfigAttrib(egl, display, config,
                    EGL10.EGL_BLUE_SIZE, 0);
            int a = findConfigAttrib(egl, display, config,
                    EGL10.EGL_ALPHA_SIZE, 0);
            if ((r == mRedSize) && (g == mGreenSize)
                    && (b == mBlueSize) && (a == mAlphaSize)) {
                return config;
            }
        }
    }
    return null;
}
 
Example #17
Source File: SurfaceTextureRenderer.java    From Camera2 with Apache License 2.0 6 votes vote down vote up
private static EGLConfig chooseConfig(EGL10 egl, EGLDisplay display)
{
    int[] numConfig = new int[1];
    if (!egl.eglChooseConfig(display, CONFIG_SPEC, null, 0, numConfig))
    {
        throw new IllegalArgumentException("eglChooseConfig failed");
    }

    int numConfigs = numConfig[0];
    if (numConfigs <= 0)
    {
        throw new IllegalArgumentException("No configs match configSpec");
    }

    EGLConfig[] configs = new EGLConfig[numConfigs];
    if (!egl.eglChooseConfig(
            display, CONFIG_SPEC, configs, numConfigs, numConfig))
    {
        throw new IllegalArgumentException("eglChooseConfig#2 failed");
    }

    return configs[0];
}
 
Example #18
Source File: EConfigChooser.java    From SimpleVideoEdit with Apache License 2.0 6 votes vote down vote up
private EGLConfig chooseConfig(final EGL10 egl, final EGLDisplay display, final EGLConfig[] configs) {
    for (final EGLConfig config : configs) {
        final int d = findConfigAttrib(egl, display, config, EGL_DEPTH_SIZE, 0);
        final int s = findConfigAttrib(egl, display, config, EGL_STENCIL_SIZE, 0);
        if ((d >= depthSize) && (s >= stencilSize)) {
            final int r = findConfigAttrib(egl, display, config, EGL_RED_SIZE, 0);
            final int g = findConfigAttrib(egl, display, config, EGL_GREEN_SIZE, 0);
            final int b = findConfigAttrib(egl, display, config, EGL_BLUE_SIZE, 0);
            final int a = findConfigAttrib(egl, display, config, EGL_ALPHA_SIZE, 0);
            if ((r == redSize) && (g == greenSize) && (b == blueSize) && (a == alphaSize)) {
                return config;
            }
        }
    }
    return null;
}
 
Example #19
Source File: EGLLogWrapper.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public boolean eglDestroySurface(EGLDisplay display, EGLSurface surface) {
    begin("eglDestroySurface");
    arg("display", display);
    arg("surface", surface);
    end();

    boolean result = mEgl10.eglDestroySurface(display, surface);
    returns(result);
    checkError();
    return result;
}
 
Example #20
Source File: EGLLogWrapper.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public boolean eglGetConfigAttrib(EGLDisplay display, EGLConfig config,
                                  int attribute, int[] value) {
    begin("eglGetConfigAttrib");
    arg("display", display);
    arg("config", config);
    arg("attribute", attribute);
    end();
    boolean result = mEgl10.eglGetConfigAttrib(display, config, attribute,
            value);
    arg("value", value);
    returns(result);
    checkError();
    return false;
}
 
Example #21
Source File: EGLLogWrapper.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public boolean eglCopyBuffers(EGLDisplay display, EGLSurface surface,
                              Object native_pixmap) {
    begin("eglCopyBuffers");
    arg("display", display);
    arg("surface", surface);
    arg("native_pixmap", native_pixmap);
    end();

    boolean result = mEgl10.eglCopyBuffers(display, surface, native_pixmap);
    returns(result);
    checkError();
    return result;
}
 
Example #22
Source File: EGLLogWrapper.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public EGLSurface eglCreatePixmapSurface(EGLDisplay display,
                                         EGLConfig config, Object native_pixmap, int[] attrib_list) {
    begin("eglCreatePixmapSurface");
    arg("display", display);
    arg("config", config);
    arg("native_pixmap", native_pixmap);
    arg("attrib_list", attrib_list);
    end();

    EGLSurface result = mEgl10.eglCreatePixmapSurface(display, config,
            native_pixmap, attrib_list);
    returns(result);
    checkError();
    return result;
}
 
Example #23
Source File: EGLLogWrapper.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public EGLSurface eglCreatePbufferSurface(EGLDisplay display,
                                          EGLConfig config, int[] attrib_list) {
    begin("eglCreatePbufferSurface");
    arg("display", display);
    arg("config", config);
    arg("attrib_list", attrib_list);
    end();

    EGLSurface result = mEgl10.eglCreatePbufferSurface(display, config,
            attrib_list);
    returns(result);
    checkError();
    return result;
}
 
Example #24
Source File: GLThread.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
private int findConfigAttrib(EGL10 egl, EGLDisplay display,
                             EGLConfig config, int attribute, int defaultValue) {

    if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
        return mValue[0];
    }
    return defaultValue;
}
 
Example #25
Source File: GLThread.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public void destroyContext(android.opengl.EGLDisplay display, android.opengl.EGLContext context) {
    if (!EGL14.eglDestroyContext(display, context)) {
        Log.e("DefaultContextFactory", "display:" + display + " context: " + context);
        if (LOG_THREADS) {
            Log.i("DefaultContextFactory", "tid=" + Thread.currentThread().getId());
        }
        EglHelper.throwEglException("eglDestroyContext", EGL14.eglGetError());
    }
}
 
Example #26
Source File: GLTextureView.java    From VideoRecorder with Apache License 2.0 5 votes vote down vote up
private int findConfigAttrib(EGL10 egl, EGLDisplay display,
        EGLConfig config, int attribute, int defaultValue) {

    if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
        return mValue[0];
    }
    return defaultValue;
}
 
Example #27
Source File: EConfigChooser.java    From SimpleVideoEdit with Apache License 2.0 5 votes vote down vote up
private int findConfigAttrib(final EGL10 egl, final EGLDisplay display, final EGLConfig config, final int attribute, final int defaultValue) {
    final int[] value = new int[1];
    if (egl.eglGetConfigAttrib(display, config, attribute, value)) {
        return value[0];
    }
    return defaultValue;
}
 
Example #28
Source File: GLThread.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
@Override
public void destroyContext(EGL10 egl, EGLDisplay display,
                           EGLContext context) {
    if (!egl.eglDestroyContext(display, context)) {
        Log.e("DefaultContextFactory", "display:" + display + " context: " + context);
        if (LOG_THREADS) {
            Log.i("DefaultContextFactory", "tid=" + Thread.currentThread().getId());
        }
        EglHelper.throwEglException("eglDestroyContext", egl.eglGetError());
    }
}
 
Example #29
Source File: GLTextureView.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 5 votes vote down vote up
public void destroyContext(EGL10 egl, EGLDisplay display,
                           EGLContext context) {
    if (!egl.eglDestroyContext(display, context)) {
        Log.e("DefaultContextFactory", "display:" + display + " context: " + context);
        if (LOG_THREADS) {
            Log.i("DefaultContextFactory", "tid=" + Thread.currentThread().getId());
        }
        EglHelper.throwEglException("eglDestroyContex", egl.eglGetError());
    }
}
 
Example #30
Source File: EGLLogWrapper.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public boolean eglQuerySurface(EGLDisplay display, EGLSurface surface,
                               int attribute, int[] value) {
    begin("eglQuerySurface");
    arg("display", display);
    arg("surface", surface);
    arg("attribute", attribute);
    end();
    boolean result = mEgl10.eglQuerySurface(display, surface, attribute,
            value);
    returns(value[0]);
    returns(result);
    checkError();
    return result;
}