// Path: app/src/main/java/com/draabek/fractal/util/Utils.java
// public class Utils {
//     public static final String FRACTALS_PREFERENCE	= "FRACTALS_PREFERENCE";
//     public static final String PREFS_CURRENT_FRACTAL_KEY = "prefs_current_fractal_key";
//     public static final String PREFS_CURRENT_FRACTAL_PATH = "prefs_current_fractal_path";
//     public static final boolean DEBUG = BuildConfig.DEBUG;
// 
//     public static Bitmap getBitmapFromAsset(AssetManager mgr, String path) {
//         InputStream is = null;
//         Bitmap bitmap;
//         try {
//             is = mgr.open(path);
//             bitmap = BitmapFactory.decodeStream(is);
//         } catch (final IOException e) {
//             bitmap = null;
//         } finally {
//             if (is != null) {
//                 try {
//                     is.close();
//                 } catch (IOException ignored) {
//                 }
//             }
//         }
//         return bitmap;
//     }
// }


import android.graphics.Bitmap;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import android.util.Log;
import com.draabek.fractal.util.Utils;
import java.util.Locale;
import java.util.Map;
     * @param settings Map<String, Float> of fractal float settings
     * @param shaderProgram Handle to the compiled shader program to attach the uniforms to
     */
    public static void applyFloatUniforms(Map<String, Float> settings, int shaderProgram) {
        for (String setting : settings.keySet()) {
            int uniformHandle = GLES20.glGetUniformLocation(shaderProgram, setting);
            if (uniformHandle == -1) {
                Log.w(ShaderUtils.class.getName(), "Unable to find uniform for " + setting);
                if (Utils.DEBUG) {
                    throw new RuntimeException("glGetUniformLocation " + setting + " error");
                }
            }
            // For now only support single float uniforms
            Object o = settings.get(setting);
            float f = (float) o;
            GLES20.glUniform1f(uniformHandle, f);
            ShaderUtils.checkGlError("glUniform1f");
        }
    }

    /**
     * Pass current width and height as uniform to the shader
     * @param width Current screen width
     * @param height Current screen height
     * @param shaderProgram Handle to the compiled shader program to attach the uniforms to
     */
    public static void applyResolutionUniform(int width, int height, int shaderProgram) {
        int resolutionHandle = GLES20.glGetUniformLocation(shaderProgram, "resolution");
        if (resolutionHandle == -1) {
            Log.w(ShaderUtils.class.getName(), "Unable to find uniform for resolution");
// Path: app/src/main/java/com/draabek/fractal/util/Utils.java
// public class Utils {
//     public static final String FRACTALS_PREFERENCE	= "FRACTALS_PREFERENCE";
//     public static final String PREFS_CURRENT_FRACTAL_KEY = "prefs_current_fractal_key";
//     public static final String PREFS_CURRENT_FRACTAL_PATH = "prefs_current_fractal_path";
//     public static final boolean DEBUG = BuildConfig.DEBUG;
// 
//     public static Bitmap getBitmapFromAsset(AssetManager mgr, String path) {
//         InputStream is = null;
//         Bitmap bitmap;
//         try {
//             is = mgr.open(path);
//             bitmap = BitmapFactory.decodeStream(is);
//         } catch (final IOException e) {
//             bitmap = null;
//         } finally {
//             if (is != null) {
//                 try {
//                     is.close();
//                 } catch (IOException ignored) {
//                 }
//             }
//         }
//         return bitmap;
//     }
// }


// Path: app/src/main/java/com/draabek/fractal/gl/ShaderUtils.java
import android.graphics.Bitmap;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import android.util.Log;
import com.draabek.fractal.util.Utils;
import java.util.Locale;
import java.util.Map;

     * @param settings Map<String, Float> of fractal float settings
     * @param shaderProgram Handle to the compiled shader program to attach the uniforms to
     */
    public static void applyFloatUniforms(Map<String, Float> settings, int shaderProgram) {
        for (String setting : settings.keySet()) {
            int uniformHandle = GLES20.glGetUniformLocation(shaderProgram, setting);
            if (uniformHandle == -1) {
                Log.w(ShaderUtils.class.getName(), "Unable to find uniform for " + setting);
                if (Utils.DEBUG) {
                    throw new RuntimeException("glGetUniformLocation " + setting + " error");
                }
            }
            // For now only support single float uniforms
            Object o = settings.get(setting);
            float f = (float) o;
            GLES20.glUniform1f(uniformHandle, f);
            ShaderUtils.checkGlError("glUniform1f");
        }
    }

    /**
     * Pass current width and height as uniform to the shader
     * @param width Current screen width
     * @param height Current screen height
     * @param shaderProgram Handle to the compiled shader program to attach the uniforms to
     */
    public static void applyResolutionUniform(int width, int height, int shaderProgram) {
        int resolutionHandle = GLES20.glGetUniformLocation(shaderProgram, "resolution");
        if (resolutionHandle == -1) {
            Log.w(ShaderUtils.class.getName(), "Unable to find uniform for resolution");
            if (Utils.DEBUG) {