Search in sources :

Example 1 with EGLConfig

use of javax.microedition.khronos.egl.EGLConfig in project TextJustify-Android by bluejamesbond.

the class DocumentView method getMaxTextureSize.

private static int getMaxTextureSize() {
    // Code from
    // http://stackoverflow.com/a/26823209/1100536
    // Safe minimum default size
    final int GL_MAX_TEXTURE_SIZE = 2048;
    // Get EGL Display
    EGL10 egl = (EGL10) EGLContext.getEGL();
    EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    // Initialise
    int[] version = new int[2];
    egl.eglInitialize(display, version);
    // Query total number of configurations
    int[] totalConfigurations = new int[1];
    egl.eglGetConfigs(display, null, 0, totalConfigurations);
    // Query actual list configurations
    EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]];
    egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations);
    int[] textureSize = new int[1];
    int maximumTextureSize = 0;
    // Iterate through all the configurations to located the maximum texture size
    for (int i = 0; i < totalConfigurations[0]; i++) {
        // Only need to check for width since opengl textures are always squared
        egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize);
        // Keep track of the maximum texture size
        if (maximumTextureSize < textureSize[0])
            maximumTextureSize = textureSize[0];
    }
    // Release
    egl.eglTerminate(display);
    // Return largest texture size found, or default
    return Math.max(maximumTextureSize, GL_MAX_TEXTURE_SIZE);
}
Also used : EGL10(javax.microedition.khronos.egl.EGL10) EGLDisplay(javax.microedition.khronos.egl.EGLDisplay) SuppressLint(android.annotation.SuppressLint) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) EGLConfig(javax.microedition.khronos.egl.EGLConfig)

Example 2 with EGLConfig

use of javax.microedition.khronos.egl.EGLConfig in project platform_frameworks_base by android.

the class RenderTarget method forSurfaceTexture.

@TargetApi(11)
public RenderTarget forSurfaceTexture(SurfaceTexture surfaceTexture) {
    EGLConfig eglConfig = chooseEglConfig(mEgl, mDisplay);
    EGLSurface eglSurf = null;
    synchronized (mSurfaceSources) {
        eglSurf = mSurfaceSources.get(surfaceTexture);
        if (eglSurf == null) {
            eglSurf = mEgl.eglCreateWindowSurface(mDisplay, eglConfig, surfaceTexture, null);
            mSurfaceSources.put(surfaceTexture, eglSurf);
        }
    }
    checkEglError(mEgl, "eglCreateWindowSurface");
    checkSurface(mEgl, eglSurf);
    RenderTarget result = new RenderTarget(mDisplay, mContext, eglSurf, 0, false, true);
    result.setSurfaceSource(surfaceTexture);
    result.addReferenceTo(eglSurf);
    return result;
}
Also used : EGLSurface(javax.microedition.khronos.egl.EGLSurface) EGLConfig(javax.microedition.khronos.egl.EGLConfig) TargetApi(android.annotation.TargetApi)

Example 3 with EGLConfig

use of javax.microedition.khronos.egl.EGLConfig in project platform_frameworks_base by android.

the class RenderTarget method forSurfaceHolder.

public RenderTarget forSurfaceHolder(SurfaceHolder surfaceHolder) {
    EGLConfig eglConfig = chooseEglConfig(mEgl, mDisplay);
    EGLSurface eglSurf = null;
    synchronized (mSurfaceSources) {
        eglSurf = mSurfaceSources.get(surfaceHolder);
        if (eglSurf == null) {
            eglSurf = mEgl.eglCreateWindowSurface(mDisplay, eglConfig, surfaceHolder, null);
            mSurfaceSources.put(surfaceHolder, eglSurf);
        }
    }
    checkEglError(mEgl, "eglCreateWindowSurface");
    checkSurface(mEgl, eglSurf);
    RenderTarget result = new RenderTarget(mDisplay, mContext, eglSurf, 0, false, true);
    result.addReferenceTo(eglSurf);
    result.setSurfaceSource(surfaceHolder);
    return result;
}
Also used : EGLSurface(javax.microedition.khronos.egl.EGLSurface) EGLConfig(javax.microedition.khronos.egl.EGLConfig)

Example 4 with EGLConfig

use of javax.microedition.khronos.egl.EGLConfig in project platform_frameworks_base by android.

the class RenderTarget method newTarget.

public static RenderTarget newTarget(int width, int height) {
    EGL10 egl = (EGL10) EGLContext.getEGL();
    EGLDisplay eglDisplay = createDefaultDisplay(egl);
    EGLConfig eglConfig = chooseEglConfig(egl, eglDisplay);
    EGLContext eglContext = createContext(egl, eglDisplay, eglConfig);
    EGLSurface eglSurface = createSurface(egl, eglDisplay, width, height);
    RenderTarget result = new RenderTarget(eglDisplay, eglContext, eglSurface, 0, true, true);
    result.addReferenceTo(eglSurface);
    return result;
}
Also used : EGLSurface(javax.microedition.khronos.egl.EGLSurface) EGL10(javax.microedition.khronos.egl.EGL10) EGLDisplay(javax.microedition.khronos.egl.EGLDisplay) EGLContext(javax.microedition.khronos.egl.EGLContext) EGLConfig(javax.microedition.khronos.egl.EGLConfig)

Example 5 with EGLConfig

use of javax.microedition.khronos.egl.EGLConfig in project libgdx by libgdx.

the class GdxEglConfigChooser method chooseConfig.

public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
    // get (almost) all configs available by using r=g=b=4 so we
    // can chose with big confidence :)
    int[] num_config = new int[1];
    egl.eglChooseConfig(display, mConfigAttribs, null, 0, num_config);
    int numConfigs = num_config[0];
    if (numConfigs <= 0) {
        throw new IllegalArgumentException("No configs match configSpec");
    }
    // now actually read the configurations.
    EGLConfig[] configs = new EGLConfig[numConfigs];
    egl.eglChooseConfig(display, mConfigAttribs, configs, numConfigs, num_config);
    // FIXME remove this.
    // printConfigs(egl, display, configs);
    // chose the best one, taking into account multi sampling.
    EGLConfig config = chooseConfig(egl, display, configs);
    // printConfigs(egl, display, new EGLConfig[] { config });
    return config;
}
Also used : EGLConfig(javax.microedition.khronos.egl.EGLConfig)

Aggregations

EGLConfig (javax.microedition.khronos.egl.EGLConfig)42 EGLSurface (javax.microedition.khronos.egl.EGLSurface)20 EGL10 (javax.microedition.khronos.egl.EGL10)12 EGLDisplay (javax.microedition.khronos.egl.EGLDisplay)12 TargetApi (android.annotation.TargetApi)9 EGLContext (javax.microedition.khronos.egl.EGLContext)8 SuppressLint (android.annotation.SuppressLint)1 Paint (android.graphics.Paint)1 TextPaint (android.text.TextPaint)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1