android.opengl.GLSurfaceView.EGLConfigChooser Java Examples

The following examples show how to use android.opengl.GLSurfaceView.EGLConfigChooser. 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: CompositeConfigChooser.java    From ParticlesDrawable with Apache License 2.0 6 votes vote down vote up
@Override
public final EGLConfig chooseConfig(@NonNull final EGL10 egl, final EGLDisplay display) {
    for (final EGLConfigChooser chooser : choosers) {
        try {
            final EGLConfig config = chooser.chooseConfig(egl, display);
            if (config == null) {
                throw new IllegalArgumentException("Returned config is null");
            }
            return config;
        } catch (@NonNull final RuntimeException e) {
            if (log) {
                Log.w(TAG, "Chooser failed", e);
            }
        }
    }

    throw new NoMatchingConfigsException();
}
 
Example #2
Source File: FailsafeMultisamplingConfigChooser.java    From ParticlesDrawable with Apache License 2.0 6 votes vote down vote up
@NonNull
private static EGLConfigChooser[] makeChoosers(
        final int samples,
        @Nullable final EGLConfigChooserCallback callback
) {
    final int fixedConfigChoosersCount = 3;
    final int dynamicConfigChoosersCount = (int) Math.ceil(Math.log(samples) / Math.log(2));

    final EGLConfigChooser[] choosers = new EGLConfigChooser[
            dynamicConfigChoosersCount + fixedConfigChoosersCount];

    int chooserPosition = 0;
    for (int i = samples; i >= 2; i /= 2) {
        choosers[chooserPosition++] = new MultisamplingConfigChooser(i, callback);
    }
    choosers[chooserPosition++] = new CoverageMultisamplingConfigChooser(samples, callback);
    choosers[chooserPosition++] = new RGB888ConfigChooser(callback);
    choosers[chooserPosition] = new AnyConfigChooser(callback);
    return choosers;
}
 
Example #3
Source File: FailsafeEGLConfigChooserFactory.java    From ParticlesDrawable with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an {@link EGLConfigChooser} for given multisampling value.
 * Will fallback to lower multisampling mode or no multisampling mode at all if unsupported.
 *
 * @param samples  multisampling mode. Must be a positive number and a power of two. May be 0 for
 *                 no multisampling.
 * @param callback the {@link EGLConfigChooserCallback} to notify with the chosen config
 * @return new {@link EGLConfigChooser}  for the given parameters.
 */
@NonNull
public static EGLConfigChooser newFailsafeEGLConfigChooser(
        final int samples,
        @Nullable final EGLConfigChooserCallback callback) {
    if (samples < 0) {
        throw new IllegalArgumentException("samples must not be negative");
    }

    if (samples == 0) {
        return new FailsafeRGB888ConfigChooser(callback);
    } else {
        return new FailsafeMultisamplingConfigChooser(samples, callback);
    }
}
 
Example #4
Source File: CompositeConfigChooser.java    From ParticlesDrawable with Apache License 2.0 4 votes vote down vote up
CompositeConfigChooser(@NonNull final EGLConfigChooser... choosers) {
    if (choosers == null || choosers.length == 0) {
        throw new IllegalArgumentException("Must pass at least one chooser");
    }
    this.choosers = choosers;
}
 
Example #5
Source File: GLConfiguration.java    From document-viewer with GNU General Public License v3.0 4 votes vote down vote up
public static EGLConfigChooser getConfigChooser() {
    if (chooser == null) {
        chooser = new BaseEGLConfigChooser();
    }
    return chooser;
}