Add coding style guide.
[platform/core/uifw/coregl.git] / src / modules / fastpath / coregl_fastpath.c
index 85cc12a..5da81fe 100644 (file)
@@ -26,7 +26,7 @@ GLGlueContext      *initial_ctx = NULL;
 Mutex               ctx_list_access_mutex = MUTEX_INITIALIZER;
 
 GLContext_List     *glctx_list = NULL;
-static int          api_gl_version=COREGL_GLAPI_2;
+static int          api_gl_version = COREGL_GLAPI_2;
 
 static void
 _state_get_texture_states(GLenum pname, GLint *params)
@@ -37,8 +37,7 @@ _state_get_texture_states(GLenum pname, GLint *params)
 
        _orig_fastpath_glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint *)&cur_active_tex);
        int i;
-       for (i = 0; i < initial_ctx->gl_num_tex_units[0]; i++)
-       {
+       for (i = 0; i < initial_ctx->gl_num_tex_units[0]; i++) {
                _orig_fastpath_glActiveTexture(GL_TEXTURE0 + i);
                _orig_fastpath_glGetIntegerv(pname, (GLint *)&params[i]);
        }
@@ -51,8 +50,7 @@ _state_get_draw_buffers(GLenum *params)
        AST(initial_ctx != NULL);
 
        int i;
-       for (i = 0; i < initial_ctx->gl_num_draw_buffers[0]; i++)
-       {
+       for (i = 0; i < initial_ctx->gl_num_draw_buffers[0]; i++) {
                _orig_fastpath_glGetIntegerv(GL_DRAW_BUFFER0 + i, (GLint *)&params[i]);
        }
 }
@@ -63,9 +61,10 @@ _state_get_transform_feedback_buffer_bindings(GLuint *params)
        AST(initial_ctx != NULL);
 
        int i;
-       for (i = 0; i < initial_ctx->gl_num_transform_feedback_separate_attribs[0]; i++)
-       {
-               _orig_fastpath_glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, i, (GLint *)&params[i]);
+       for (i = 0; i < initial_ctx->gl_num_transform_feedback_separate_attribs[0];
+            i++) {
+               _orig_fastpath_glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, i,
+                                              (GLint *)&params[i]);
        }
 }
 
@@ -75,9 +74,10 @@ _state_get_transform_feedback_buffer_bindings_offset(GLintptr *params)
        AST(initial_ctx != NULL);
 
        int i;
-       for (i = 0; i < initial_ctx->gl_num_transform_feedback_separate_attribs[0]; i++)
-       {
-               _orig_fastpath_glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_START, i, (GLint *)&params[i]);
+       for (i = 0; i < initial_ctx->gl_num_transform_feedback_separate_attribs[0];
+            i++) {
+               _orig_fastpath_glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_START, i,
+                                              (GLint *)&params[i]);
        }
 }
 
@@ -87,9 +87,10 @@ _state_get_transform_feedback_buffer_bindings_size(GLsizeiptr *params)
        AST(initial_ctx != NULL);
 
        int i;
-       for (i = 0; i < initial_ctx->gl_num_transform_feedback_separate_attribs[0]; i++)
-       {
-               _orig_fastpath_glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_SIZE, i, (GLint *)&params[i]);
+       for (i = 0; i < initial_ctx->gl_num_transform_feedback_separate_attribs[0];
+            i++) {
+               _orig_fastpath_glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_SIZE, i,
+                                              (GLint *)&params[i]);
        }
 }
 
@@ -99,8 +100,7 @@ _state_get_uniform_buffer_bindings(GLuint *params)
        AST(initial_ctx != NULL);
 
        int i;
-       for (i = 0; i < initial_ctx->gl_num_uniform_buffer_bindings[0]; i++)
-       {
+       for (i = 0; i < initial_ctx->gl_num_uniform_buffer_bindings[0]; i++) {
 /////////////////////////////////////////////////////////////////////////////////
 // XXXX : AVOID SEGFAULT in ADRENO
                ((GLint *)params)[i] = 0;
@@ -115,8 +115,7 @@ _state_get_uniform_buffer_bindings_offset(GLintptr *params)
        AST(initial_ctx != NULL);
 
        int i;
-       for (i = 0; i < initial_ctx->gl_num_uniform_buffer_bindings[0]; i++)
-       {
+       for (i = 0; i < initial_ctx->gl_num_uniform_buffer_bindings[0]; i++) {
                _orig_fastpath_glGetIntegeri_v(GL_UNIFORM_BUFFER_START, i, (GLint *)&params[i]);
        }
 }
@@ -127,8 +126,7 @@ _state_get_uniform_buffer_bindings_size(GLsizeiptr *params)
        AST(initial_ctx != NULL);
 
        int i;
-       for (i = 0; i < initial_ctx->gl_num_uniform_buffer_bindings[0]; i++)
-       {
+       for (i = 0; i < initial_ctx->gl_num_uniform_buffer_bindings[0]; i++) {
                _orig_fastpath_glGetIntegeri_v(GL_UNIFORM_BUFFER_SIZE, i, (GLint *)&params[i]);
        }
 }
@@ -150,22 +148,20 @@ init_modules_fastpath()
        fastpath_opt = atoi(get_env_setting("COREGL_FASTPATH"));
        fastpath_force_off_opt = atoi(get_env_setting("COREGL_FASTPATH_FORCE_OFF"));
 
-       if (fastpath_force_off_opt == 1)
-       {
+       if (fastpath_force_off_opt == 1) {
                COREGL_LOG("\E[40;31;1m(DISABLED by force option)\E[0m ");
                fastpath_opt = 0;
        }
 
-       switch (fastpath_opt)
-       {
-               case 1:
-                       COREGL_LOG("(%d) Fastpath enabled...\n", fastpath_opt);
-                       fp_opt = FP_FAST_PATH;
-                       break;
-               default:
-                       COREGL_LOG("(%d) Default API path enabled...\n", fastpath_opt);
-                       fp_opt = FP_NORMAL_PATH;
-                       break;
+       switch (fastpath_opt) {
+       case 1:
+               COREGL_LOG("(%d) Fastpath enabled...\n", fastpath_opt);
+               fp_opt = FP_FAST_PATH;
+               break;
+       default:
+               COREGL_LOG("(%d) Default API path enabled...\n", fastpath_opt);
+               fp_opt = FP_NORMAL_PATH;
+               break;
        }
 
        debug_nofp = atoi(get_env_setting("COREGL_DEBUG_NOFP"));
@@ -182,17 +178,16 @@ deinit_modules_fastpath()
        // Destroy remained context & Detect leaks
        int retry_destroy = 0;
 
-       while (1)
-       {
+       while (1) {
                retry_destroy = 0;
                current = glctx_list;
-               while (current)
-               {
-                       if (current->cstate != NULL)
-                       {
-                               COREGL_WRN("\E[40;31;1mContext attached to [dpy=%p|rctx=%p] has not been completely destroyed.(leak)\E[0m\n", current->cstate->rdpy, current->cstate->rctx);
+               while (current) {
+                       if (current->cstate != NULL) {
+                               COREGL_WRN("\E[40;31;1mContext attached to [dpy=%p|rctx=%p] has not been completely destroyed.(leak)\E[0m\n",
+                                          current->cstate->rdpy, current->cstate->rctx);
 
-                               _orig_fastpath_eglMakeCurrent(current->cstate->rdpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+                               _orig_fastpath_eglMakeCurrent(current->cstate->rdpy, EGL_NO_SURFACE,
+                                                             EGL_NO_SURFACE, EGL_NO_CONTEXT);
                                _orig_fastpath_eglDestroyContext(current->cstate->rdpy, current->cstate->rctx);
 
                                fastpath_remove_context_states_from_list(current->cstate, NULL);
@@ -227,8 +222,7 @@ init_modules_tstate_fastpath(GLThreadState *tstate)
 void
 deinit_modules_tstate_fastpath(GLThreadState *tstate)
 {
-       if (tstate->module_data[MY_MODULE_ID] != NULL)
-       {
+       if (tstate->module_data[MY_MODULE_ID] != NULL) {
                free(tstate->module_data[MY_MODULE_ID]);
                tstate->module_data[MY_MODULE_ID] = NULL;
        }
@@ -237,17 +231,16 @@ deinit_modules_tstate_fastpath(GLThreadState *tstate)
 void
 fastpath_apply_overrides()
 {
-       switch(fp_opt)
-       {
-               case FP_FAST_PATH:
-                       fastpath_apply_overrides_egl(1);
-                       fastpath_apply_overrides_gl(1);
-                       break;
-               case FP_NORMAL_PATH:
-                       break;
-               default:
-                       COREGL_ERR("Invalide GL Override Option!!!\n");
-                       break;
+       switch (fp_opt) {
+       case FP_FAST_PATH:
+               fastpath_apply_overrides_egl(1);
+               fastpath_apply_overrides_gl(1);
+               break;
+       case FP_NORMAL_PATH:
+               break;
+       default:
+               COREGL_ERR("Invalide GL Override Option!!!\n");
+               break;
        }
 }
 
@@ -290,8 +283,7 @@ fastpath_apply_overrides_gl(int enable)
 #undef _COREGL_START_API
 #undef _COREGL_END_API
 
-       if (debug_nofp != 1)
-       {
+       if (debug_nofp != 1) {
                COREGL_OVERRIDE(fastpath_, glGetError);
                COREGL_OVERRIDE(fastpath_, glGetString);
 
@@ -463,7 +455,7 @@ fastpath_apply_overrides_gl(int enable)
                COREGL_OVERRIDE(fastpath_, glClearDepthfOES );
                COREGL_OVERRIDE(fastpath_, glClearDepthxOES );
                /* Start overriding GLES 3.0 */
-               if(driver_gl_version >= COREGL_GLAPI_3) {
+               if (driver_gl_version >= COREGL_GLAPI_3) {
                        COREGL_OVERRIDE(fastpath_, glReadBuffer);
 
                        COREGL_OVERRIDE(fastpath_, glGenQueries);
@@ -523,8 +515,7 @@ fastpath_apply_overrides_gl(int enable)
                        COREGL_OVERRIDE(fastpath_, glProgramParameteri);
                } // End of GLES 3.0
 
-               if(driver_gl_version >= COREGL_GLAPI_31)
-               {
+               if (driver_gl_version >= COREGL_GLAPI_31) {
                        COREGL_OVERRIDE(fastpath_, glCreateShaderProgramv);
                        COREGL_OVERRIDE(fastpath_, glGenProgramPipelines);
                        COREGL_OVERRIDE(fastpath_, glGetProgramPipelineiv);
@@ -590,9 +581,7 @@ fastpath_apply_overrides_gl(int enable)
                        COREGL_OVERRIDE(fastpath_, glVertexAttribBinding);
                        COREGL_OVERRIDE(fastpath_, glVertexBindingDivisor);
                }
-       }
-       else
-       {
+       } else {
                COREGL_LOG("\E[40;35;1m[CoreGL] SKIP GL FASTPATH...\E[0m\n");
        }
 }
@@ -602,112 +591,109 @@ fastpath_apply_overrides_gl(int enable)
 static inline GL_Object_Hash_Base *
 _lock_gl_object_hash(GL_Object_State *ostate, GL_Object_Type type)
 {
-       switch (type)
-       {
-               case GL_OBJECT_TYPE_QUERY:
-                       return &ostate->query;
-               case GL_OBJECT_TYPE_TEXTURE:
-                       AST(mutex_lock(&ostate->shared->access_mutex) == 1);
-                       return &ostate->shared->texture;
-               case GL_OBJECT_TYPE_BUFFER:
-                       AST(mutex_lock(&ostate->shared->access_mutex) == 1);
-                       return &ostate->shared->buffer;
-               case GL_OBJECT_TYPE_FRAMEBUFFER:
-                       return &ostate->framebuffer;
-               case GL_OBJECT_TYPE_RENDERBUFFER:
-                       AST(mutex_lock(&ostate->shared->access_mutex) == 1);
-                       return &ostate->shared->renderbuffer;
-               case GL_OBJECT_TYPE_PROGRAM:
-                       AST(mutex_lock(&ostate->shared->access_mutex) == 1);
-                       return &ostate->shared->program;
-               case GL_OBJECT_TYPE_VERTEXARRAY:
-                       return &ostate->vertexarray;
-               case GL_OBJECT_TYPE_SAMPLER:
-                       AST(mutex_lock(&ostate->shared->access_mutex) == 1);
-                       return &ostate->shared->sampler;
-               case GL_OBJECT_TYPE_TRANSFORMFEEDBACK:
-                       return &ostate->transformfeedback;
-               case GL_OBJECT_TYPE_PROGRAMPIPELINE:
-                       AST(mutex_lock(&ostate->shared->access_mutex) == 1);
-                       return &ostate->shared->programpipeline;
-               default:
-                       return NULL;
+       switch (type) {
+       case GL_OBJECT_TYPE_QUERY:
+               return &ostate->query;
+       case GL_OBJECT_TYPE_TEXTURE:
+               AST(mutex_lock(&ostate->shared->access_mutex) == 1);
+               return &ostate->shared->texture;
+       case GL_OBJECT_TYPE_BUFFER:
+               AST(mutex_lock(&ostate->shared->access_mutex) == 1);
+               return &ostate->shared->buffer;
+       case GL_OBJECT_TYPE_FRAMEBUFFER:
+               return &ostate->framebuffer;
+       case GL_OBJECT_TYPE_RENDERBUFFER:
+               AST(mutex_lock(&ostate->shared->access_mutex) == 1);
+               return &ostate->shared->renderbuffer;
+       case GL_OBJECT_TYPE_PROGRAM:
+               AST(mutex_lock(&ostate->shared->access_mutex) == 1);
+               return &ostate->shared->program;
+       case GL_OBJECT_TYPE_VERTEXARRAY:
+               return &ostate->vertexarray;
+       case GL_OBJECT_TYPE_SAMPLER:
+               AST(mutex_lock(&ostate->shared->access_mutex) == 1);
+               return &ostate->shared->sampler;
+       case GL_OBJECT_TYPE_TRANSFORMFEEDBACK:
+               return &ostate->transformfeedback;
+       case GL_OBJECT_TYPE_PROGRAMPIPELINE:
+               AST(mutex_lock(&ostate->shared->access_mutex) == 1);
+               return &ostate->shared->programpipeline;
+       default:
+               return NULL;
        }
 }
 
 static inline void
 _unlock_gl_object_hash(GL_Object_State *ostate, GL_Object_Type type)
 {
-       switch (type)
-       {
-               case GL_OBJECT_TYPE_TEXTURE:
-               case GL_OBJECT_TYPE_BUFFER:
-               case GL_OBJECT_TYPE_RENDERBUFFER:
-               case GL_OBJECT_TYPE_PROGRAM:
-               case GL_OBJECT_TYPE_SAMPLER:
-               case GL_OBJECT_TYPE_PROGRAMPIPELINE:
-                       AST(mutex_unlock(&ostate->shared->access_mutex) == 1);
-               default:
-                       break;
+       switch (type) {
+       case GL_OBJECT_TYPE_TEXTURE:
+       case GL_OBJECT_TYPE_BUFFER:
+       case GL_OBJECT_TYPE_RENDERBUFFER:
+       case GL_OBJECT_TYPE_PROGRAM:
+       case GL_OBJECT_TYPE_SAMPLER:
+       case GL_OBJECT_TYPE_PROGRAMPIPELINE:
+               AST(mutex_unlock(&ostate->shared->access_mutex) == 1);
+       default:
+               break;
        }
 }
 
 static inline GL_Object_Hash_Base *
 _lock_gl_object_hash_real(GL_Object_State *ostate, GL_Object_Type type)
 {
-       switch (type)
-       {
-               case GL_OBJECT_TYPE_QUERY:
-                       return &ostate->query_real;
-               case GL_OBJECT_TYPE_TEXTURE:
-                       AST(mutex_lock(&ostate->shared->real_access_mutex) == 1);
-                       return &ostate->shared->texture_real;
-               case GL_OBJECT_TYPE_BUFFER:
-                       AST(mutex_lock(&ostate->shared->real_access_mutex) == 1);
-                       return &ostate->shared->buffer_real;
-               case GL_OBJECT_TYPE_FRAMEBUFFER:
-                       return &ostate->framebuffer_real;
-               case GL_OBJECT_TYPE_RENDERBUFFER:
-                       AST(mutex_lock(&ostate->shared->real_access_mutex) == 1);
-                       return &ostate->shared->renderbuffer_real;
-               case GL_OBJECT_TYPE_PROGRAM:
-                       AST(mutex_lock(&ostate->shared->real_access_mutex) == 1);
-                       return &ostate->shared->program_real;
-               case GL_OBJECT_TYPE_VERTEXARRAY:
-                       return &ostate->vertexarray_real;
-               case GL_OBJECT_TYPE_SAMPLER:
-                       AST(mutex_lock(&ostate->shared->real_access_mutex) == 1);
-                       return &ostate->shared->sampler_real;
-               case GL_OBJECT_TYPE_TRANSFORMFEEDBACK:
-                       return &ostate->transformfeedback_real;
-               case GL_OBJECT_TYPE_PROGRAMPIPELINE:
-                       AST(mutex_lock(&ostate->shared->real_access_mutex) == 1);
-                       return &ostate->shared->programpipeline_real;
-               default:
-                       return NULL;
+       switch (type) {
+       case GL_OBJECT_TYPE_QUERY:
+               return &ostate->query_real;
+       case GL_OBJECT_TYPE_TEXTURE:
+               AST(mutex_lock(&ostate->shared->real_access_mutex) == 1);
+               return &ostate->shared->texture_real;
+       case GL_OBJECT_TYPE_BUFFER:
+               AST(mutex_lock(&ostate->shared->real_access_mutex) == 1);
+               return &ostate->shared->buffer_real;
+       case GL_OBJECT_TYPE_FRAMEBUFFER:
+               return &ostate->framebuffer_real;
+       case GL_OBJECT_TYPE_RENDERBUFFER:
+               AST(mutex_lock(&ostate->shared->real_access_mutex) == 1);
+               return &ostate->shared->renderbuffer_real;
+       case GL_OBJECT_TYPE_PROGRAM:
+               AST(mutex_lock(&ostate->shared->real_access_mutex) == 1);
+               return &ostate->shared->program_real;
+       case GL_OBJECT_TYPE_VERTEXARRAY:
+               return &ostate->vertexarray_real;
+       case GL_OBJECT_TYPE_SAMPLER:
+               AST(mutex_lock(&ostate->shared->real_access_mutex) == 1);
+               return &ostate->shared->sampler_real;
+       case GL_OBJECT_TYPE_TRANSFORMFEEDBACK:
+               return &ostate->transformfeedback_real;
+       case GL_OBJECT_TYPE_PROGRAMPIPELINE:
+               AST(mutex_lock(&ostate->shared->real_access_mutex) == 1);
+               return &ostate->shared->programpipeline_real;
+       default:
+               return NULL;
        }
 }
 
 static inline void
 _unlock_gl_object_hash_real(GL_Object_State *ostate, GL_Object_Type type)
 {
-       switch (type)
-       {
-               case GL_OBJECT_TYPE_TEXTURE:
-               case GL_OBJECT_TYPE_BUFFER:
-               case GL_OBJECT_TYPE_RENDERBUFFER:
-               case GL_OBJECT_TYPE_PROGRAM:
-               case GL_OBJECT_TYPE_SAMPLER:
-               case GL_OBJECT_TYPE_PROGRAMPIPELINE:
-                       AST(mutex_unlock(&ostate->shared->real_access_mutex) == 1);
-                       break;
-               default:
-                       break;
+       switch (type) {
+       case GL_OBJECT_TYPE_TEXTURE:
+       case GL_OBJECT_TYPE_BUFFER:
+       case GL_OBJECT_TYPE_RENDERBUFFER:
+       case GL_OBJECT_TYPE_PROGRAM:
+       case GL_OBJECT_TYPE_SAMPLER:
+       case GL_OBJECT_TYPE_PROGRAMPIPELINE:
+               AST(mutex_unlock(&ostate->shared->real_access_mutex) == 1);
+               break;
+       default:
+               break;
        }
 }
 
 int
-fastpath_add_context_state_to_list(const void *option, const int option_len, GLContextState *cstate, Mutex *mtx)
+fastpath_add_context_state_to_list(const void *option, const int option_len,
+                                  GLContextState *cstate, Mutex *mtx)
 {
        int ret = 0;
        int tid = 0;
@@ -721,12 +707,10 @@ fastpath_add_context_state_to_list(const void *option, const int option_len, GLC
        tid = get_current_thread();
 
        current = glctx_list;
-       while (current != NULL)
-       {
+       while (current != NULL) {
                if (current->option_len == option_len &&
                    memcmp(current->option, option, option_len) == 0 &&
-                   current->thread_id == tid)
-               {
+                   current->thread_id == tid) {
                        AST(current->cstate == cstate);
                        goto finish;
                }
@@ -734,8 +718,7 @@ fastpath_add_context_state_to_list(const void *option, const int option_len, GLC
        }
 
        newitm = (GLContext_List *)calloc(1, sizeof(GLContext_List));
-       if (newitm == NULL)
-       {
+       if (newitm == NULL) {
                COREGL_ERR("Failed to create context list.\n");
                goto finish;
        }
@@ -755,15 +738,12 @@ fastpath_add_context_state_to_list(const void *option, const int option_len, GLC
        goto finish;
 
 finish:
-       if (ret != 1)
-       {
-               if (newitm != NULL)
-               {
+       if (ret != 1) {
+               if (newitm != NULL) {
                        free(newitm);
                        newitm = NULL;
                }
-               if (cstate != NULL)
-               {
+               if (cstate != NULL) {
                        free(cstate);
                        cstate = NULL;
                }
@@ -774,7 +754,8 @@ finish:
 }
 
 GLContextState *
-fastpath_get_context_state_from_list(const void *option, const int option_len, Mutex *mtx)
+fastpath_get_context_state_from_list(const void *option, const int option_len,
+                                    Mutex *mtx)
 {
        GLContextState *ret = NULL;
        GLContext_List *current = NULL;
@@ -785,12 +766,10 @@ fastpath_get_context_state_from_list(const void *option, const int option_len, M
        tid = get_current_thread();
 
        current = glctx_list;
-       while (current != NULL)
-       {
+       while (current != NULL) {
                if (current->option_len == option_len &&
                    memcmp(current->option, option, option_len) == 0 &&
-                   current->thread_id == tid)
-               {
+                   current->thread_id == tid) {
                        ret = current->cstate;
                        goto finish;
                }
@@ -816,23 +795,17 @@ fastpath_remove_context_states_from_list(GLContextState *cstate, Mutex *mtx)
 
        current = glctx_list;
 
-       while (current != NULL)
-       {
-               if (current->cstate == cstate)
-               {
+       while (current != NULL) {
+               if (current->cstate == cstate) {
                        GLContext_List *nextitm = NULL;
-                       if (olditm != NULL)
-                       {
+                       if (olditm != NULL) {
                                olditm->next = current->next;
                                nextitm = olditm->next;
-                       }
-                       else
-                       {
+                       } else {
                                glctx_list = current->next;
                                nextitm = glctx_list;
                        }
-                       if (current->option != NULL)
-                       {
+                       if (current->option != NULL) {
                                AST(current->option_len > 0);
                                free(current->option);
                                current->option = NULL;
@@ -900,15 +873,11 @@ static void
 _add_hash(GL_Object_Hash_Base *hash_base, GL_Object_Hash *data)
 {
        int array_idx = data->hash_key & (hash_base->hash_size - 1);
-       if (hash_base->hash_field[array_idx] == NULL)
-       {
+       if (hash_base->hash_field[array_idx] == NULL) {
                hash_base->hash_field[array_idx] = data;
-       }
-       else
-       {
+       } else {
                GL_Object_Hash *current = hash_base->hash_field[array_idx];
-               while(current->next)
-               {
+               while (current->next) {
                        AST(current->hash_key != data->hash_key);
                        current = current->next;
                }
@@ -927,10 +896,8 @@ _remove_hash(GL_Object_Hash_Base *hash_base, GLuint hash)
        GL_Object_Hash *current = hash_base->hash_field[array_idx];
        GL_Object_Hash *prev = NULL;
 
-       while(current)
-       {
-               if (current->hash_key == hash)
-               {
+       while (current) {
+               if (current->hash_key == hash) {
                        if (prev != NULL)
                                prev->next = current->next;
                        else
@@ -951,18 +918,14 @@ _free_hash_list(GL_Object_Hash_Base *hash_base, int free_data)
 {
        if (hash_base->item_size == 0) return;
 
-       for (int i = 0; i < hash_base->hash_size; i++)
-       {
-               if (hash_base->hash_field[i] != NULL)
-               {
+       for (int i = 0; i < hash_base->hash_size; i++) {
+               if (hash_base->hash_field[i] != NULL) {
                        GL_Object_Hash *current = hash_base->hash_field[i];
 
-                       while (current != NULL)
-                       {
+                       while (current != NULL) {
                                GL_Object_Hash *current_next = current->next;
 
-                               if (free_data == 1 && current->item != NULL)
-                               {
+                               if (free_data == 1 && current->item != NULL) {
                                        free(current->item);
                                }
 
@@ -1042,17 +1005,15 @@ _ostate_hash_check(GL_Object_Hash_Base *hash_base)
        GL_Object_Hash **oldfield = hash_base->hash_field;
 
        hash_base->hash_size = oldsize << 1;
-       hash_base->hash_field = (GL_Object_Hash **)calloc(1, sizeof(GL_Object_Hash *) * hash_base->hash_size);
+       hash_base->hash_field = (GL_Object_Hash **)calloc(1,
+                               sizeof(GL_Object_Hash *) * hash_base->hash_size);
        AST(hash_base->hash_field != NULL);
 
-       for (int i = 0; i < oldsize; i++)
-       {
-               if (oldfield[i] != NULL)
-               {
+       for (int i = 0; i < oldsize; i++) {
+               if (oldfield[i] != NULL) {
                        GL_Object_Hash *current = oldfield[i];
 
-                       while (current != NULL)
-                       {
+                       while (current != NULL) {
                                GL_Object_Hash *current_next = current->next;
                                _add_hash(hash_base, current);
                                hash_base->item_size--;
@@ -1065,7 +1026,8 @@ _ostate_hash_check(GL_Object_Hash_Base *hash_base)
 }
 
 GLuint
-fastpath_ostate_create_object(GL_Object_State *ostate, GL_Object_Type type, GLuint real_name)
+fastpath_ostate_create_object(GL_Object_State *ostate, GL_Object_Type type,
+                             GLuint real_name)
 {
        GLuint ret = _COREGL_INT_INIT_VALUE;
 
@@ -1077,24 +1039,20 @@ fastpath_ostate_create_object(GL_Object_State *ostate, GL_Object_Type type, GLui
        hash_base_real = _lock_gl_object_hash_real(ostate, type);
 
        newid = hash_base->last_id + 1;
-       if (newid >= hash_base->hash_size)
-       {
+       if (newid >= hash_base->hash_size) {
                hash_base->is_looped = 1;
                newid = 1;
                hash_base->last_id = 1;
        }
 
-       if (hash_base->is_looped != 0)
-       {
+       if (hash_base->is_looped != 0) {
                int i;
                int findingid = newid;
                newid = -1;
-               for (i = 0; i < hash_base->hash_size; i++)
-               {
+               for (i = 0; i < hash_base->hash_size; i++) {
                        GL_Object_Hash *exist_hash = NULL;
                        FIND_HASH(hash_base, findingid, exist_hash);
-                       if (exist_hash == NULL)
-                       {
+                       if (exist_hash == NULL) {
                                newid = findingid;
                                break;
                        }
@@ -1114,9 +1072,9 @@ fastpath_ostate_create_object(GL_Object_State *ostate, GL_Object_Type type, GLui
                newobj->ref_count = 1;
 
 
-               GL_Object_Hash *newobj_hash = (GL_Object_Hash *)calloc(1, sizeof(GL_Object_Hash));
-               if (newobj_hash == NULL)
-               {
+               GL_Object_Hash *newobj_hash = (GL_Object_Hash *)calloc(1,
+                                             sizeof(GL_Object_Hash));
+               if (newobj_hash == NULL) {
                        free(newobj);
                        goto finish;
                }
@@ -1124,9 +1082,9 @@ fastpath_ostate_create_object(GL_Object_State *ostate, GL_Object_Type type, GLui
                newobj_hash->hash_key = newid;
                _add_hash(hash_base, newobj_hash);
 
-               GL_Object_Hash *newobj_hash_real = (GL_Object_Hash *)calloc(1, sizeof(GL_Object_Hash));
-               if (newobj_hash_real == NULL)
-               {
+               GL_Object_Hash *newobj_hash_real = (GL_Object_Hash *)calloc(1,
+                                                  sizeof(GL_Object_Hash));
+               if (newobj_hash_real == NULL) {
                        free(newobj);
                        free(newobj_hash);
                        goto finish;
@@ -1160,7 +1118,8 @@ finish:
        }
 
 GLuint
-fastpath_ostate_remove_object(GL_Object_State *ostate, GL_Object_Type type, GLuint glue_name)
+fastpath_ostate_remove_object(GL_Object_State *ostate, GL_Object_Type type,
+                             GLuint glue_name)
 {
        GLuint ret = _COREGL_INT_INIT_VALUE;
 
@@ -1175,8 +1134,7 @@ fastpath_ostate_remove_object(GL_Object_State *ostate, GL_Object_Type type, GLui
 
        object->ref_count--;
 
-       if (object->ref_count <= 0)
-       {
+       if (object->ref_count <= 0) {
                GL_Object_Hash *object_hash = NULL;
 
                FIND_HASH(hash_base, object->id - (int)type, object_hash);
@@ -1205,7 +1163,8 @@ finish:
 }
 
 GLuint
-fastpath_ostate_get_object(GL_Object_State *ostate, GL_Object_Type type, GLuint glue_name)
+fastpath_ostate_get_object(GL_Object_State *ostate, GL_Object_Type type,
+                          GLuint glue_name)
 {
        GLuint ret = _COREGL_INT_INIT_VALUE;
 
@@ -1234,8 +1193,7 @@ fastpath_ostate_has_object_type(GL_Object_State *ostate, GL_Object_Type type)
        GL_Object *object = NULL;
        hash_base = _lock_gl_object_hash(ostate, type);
 
-       if(hash_base->hash_field == 0)
-       {
+       if (hash_base->hash_field == 0) {
                ret = 0;
                goto finish;
        }
@@ -1252,7 +1210,8 @@ finish:
 
 
 GLint
-fastpath_ostate_set_object_tag(GL_Object_State *ostate, GL_Object_Type type, GLuint glue_name, GLvoid *tag)
+fastpath_ostate_set_object_tag(GL_Object_State *ostate, GL_Object_Type type,
+                              GLuint glue_name, GLvoid *tag)
 {
        GLint ret = _COREGL_INT_INIT_VALUE;
 
@@ -1277,7 +1236,8 @@ finish:
 }
 
 GLvoid *
-fastpath_ostate_get_object_tag(GL_Object_State *ostate, GL_Object_Type type, GLuint glue_name)
+fastpath_ostate_get_object_tag(GL_Object_State *ostate, GL_Object_Type type,
+                              GLuint glue_name)
 {
        GLvoid *ret = NULL;
 
@@ -1297,7 +1257,8 @@ finish:
 }
 
 GLuint
-fastpath_ostate_find_object(GL_Object_State *ostate, GL_Object_Type type, GLuint real_name)
+fastpath_ostate_find_object(GL_Object_State *ostate, GL_Object_Type type,
+                           GLuint real_name)
 {
        GLuint ret = _COREGL_INT_INIT_VALUE;
 
@@ -1317,7 +1278,8 @@ finish:
 }
 
 GLint
-fastpath_ostate_use_object(GL_Object_State *ostate, GL_Object_Type type, GLuint glue_name)
+fastpath_ostate_use_object(GL_Object_State *ostate, GL_Object_Type type,
+                          GLuint glue_name)
 {
        GLint ret = _COREGL_INT_INIT_VALUE;
 
@@ -1344,12 +1306,10 @@ fastpath_dump_context_states(GLGlueContext *ctx, int force_output)
 
        if (unlikely(trace_state_flag != 1)) return;
 
-       if (!force_output)
-       {
+       if (!force_output) {
                struct timeval tv_now = { 0, 0 };
                AST(gettimeofday(&tv_now, NULL) == 0);
-               if (tv_now.tv_sec - tv_last.tv_sec < _COREGL_TRACE_OUTPUT_INTERVAL_SEC)
-               {
+               if (tv_now.tv_sec - tv_last.tv_sec < _COREGL_TRACE_OUTPUT_INTERVAL_SEC) {
                        goto finish;
                }
                tv_last = tv_now;
@@ -1357,7 +1317,8 @@ fastpath_dump_context_states(GLGlueContext *ctx, int force_output)
 
        TRACE("\n");
        TRACE("\E[0;40;34m========================================================================================================================\E[0m\n");
-       TRACE("\E[40;32;1m  State info \E[1;37;1m: <PID = %d> GlueCTX = %p\E[0m\n", getpid(), ctx);
+       TRACE("\E[40;32;1m  State info \E[1;37;1m: <PID = %d> GlueCTX = %p\E[0m\n",
+             getpid(), ctx);
        TRACE("\E[0;40;34m========================================================================================================================\E[0m\n");
 
 #define PRINTF_CHAR_GLenum "0x%8X"
@@ -1424,8 +1385,7 @@ fastpath_init_context_states(GLGlueContext *ctx)
 
        AST(mutex_lock(&init_context_mutex) == 1);
 
-       if (ctx == NULL)
-       {
+       if (ctx == NULL) {
                COREGL_ERR("Context NULL\n");
                ret = 0;
                goto finish;
@@ -1434,8 +1394,7 @@ fastpath_init_context_states(GLGlueContext *ctx)
        AST(ctx->initialized == 0);
        AST(ctx->ostate.shared != NULL);
 
-       if (initial_ctx == NULL)
-       {
+       if (initial_ctx == NULL) {
                initial_ctx = (GLGlueContext *)calloc(1, sizeof(GLGlueContext));
                AST(initial_ctx != NULL);
 
@@ -1543,21 +1502,24 @@ fastpath_init_context_states(GLGlueContext *ctx)
 # undef _COREGL_END_API
 # undef _COREGL_START_API
 
-               if (initial_ctx->gl_num_vertex_attribs[0] > MAX_VERTEX_ATTRIBS)
-               {
-                       COREGL_WRN("\E[40;31;1mNumber of vertex attrib is too big! (%d-%d)\E[0m\n", MAX_VERTEX_ATTRIBS, initial_ctx->gl_num_vertex_attribs[0]);
+               if (initial_ctx->gl_num_vertex_attribs[0] > MAX_VERTEX_ATTRIBS) {
+                       COREGL_WRN("\E[40;31;1mNumber of vertex attrib is too big! (%d-%d)\E[0m\n",
+                                  MAX_VERTEX_ATTRIBS, initial_ctx->gl_num_vertex_attribs[0]);
                }
-               if (initial_ctx->gl_num_tex_units[0] > MAX_TEXTURE_UNITS)
-               {
-                       COREGL_WRN("\E[40;31;1mNumber of texture unit is too big! (%d-%d)\E[0m\n", MAX_TEXTURE_UNITS, initial_ctx->gl_num_tex_units[0]);
+               if (initial_ctx->gl_num_tex_units[0] > MAX_TEXTURE_UNITS) {
+                       COREGL_WRN("\E[40;31;1mNumber of texture unit is too big! (%d-%d)\E[0m\n",
+                                  MAX_TEXTURE_UNITS, initial_ctx->gl_num_tex_units[0]);
                }
-               if (initial_ctx->gl_num_transform_feedback_separate_attribs[0] > MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS)
-               {
-                       COREGL_WRN("\E[40;31;1mNumber of transform feedback separate attrib is too big! (%d-%d)\E[0m\n", MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, initial_ctx->gl_num_transform_feedback_separate_attribs[0]);
+               if (initial_ctx->gl_num_transform_feedback_separate_attribs[0] >
+                   MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS) {
+                       COREGL_WRN("\E[40;31;1mNumber of transform feedback separate attrib is too big! (%d-%d)\E[0m\n",
+                                  MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,
+                                  initial_ctx->gl_num_transform_feedback_separate_attribs[0]);
                }
-               if (initial_ctx->gl_num_uniform_buffer_bindings[0] > MAX_UNIFORM_BUFFER_BINDINGS)
-               {
-                       COREGL_WRN("\E[40;31;1mNumber of uniform buffer binding is too big! (%d-%d)\E[0m\n", MAX_UNIFORM_BUFFER_BINDINGS, initial_ctx->gl_num_uniform_buffer_bindings[0]);
+               if (initial_ctx->gl_num_uniform_buffer_bindings[0] >
+                   MAX_UNIFORM_BUFFER_BINDINGS) {
+                       COREGL_WRN("\E[40;31;1mNumber of uniform buffer binding is too big! (%d-%d)\E[0m\n",
+                                  MAX_UNIFORM_BUFFER_BINDINGS, initial_ctx->gl_num_uniform_buffer_bindings[0]);
                }
        }
 
@@ -1592,8 +1554,10 @@ finish:
 }
 
 #ifdef COREGL_USE_MODULE_TRACEPATH
-extern void *tracepath_api_trace_begin(const char *name, void *hint, int trace_total_time);
-extern void *tracepath_api_trace_end(const char *name, void *hint, int trace_total_time);
+extern void *tracepath_api_trace_begin(const char *name, void *hint,
+                                      int trace_total_time);
+extern void *tracepath_api_trace_end(const char *name, void *hint,
+                                    int trace_total_time);
 #endif
 
 #define CHECK_GL_ERROR(func) \
@@ -1614,15 +1578,13 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx)
        unsigned char flag = 0;
        int i = 0;
 
-       if (debug_nofp == 1)
-       {
+       if (debug_nofp == 1) {
                ret = 1;
                goto finish;
        }
 
        // Return if they're the same
-       if (oldctx == newctx)
-       {
+       if (oldctx == newctx) {
                ret = 1;
                goto finish;
        }
@@ -1636,7 +1598,8 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx)
 
 #ifdef COREGL_USE_MODULE_TRACEPATH
        static void *trace_hint_glfinish = NULL;
-       trace_hint_glfinish = tracepath_api_trace_begin("eglMakeCurrent(FP glFinish)", trace_hint_glfinish, 0);
+       trace_hint_glfinish = tracepath_api_trace_begin("eglMakeCurrent(FP glFinish)",
+                             trace_hint_glfinish, 0);
 #endif // COREGL_USE_MODULE_TRACEPATH
 
        {
@@ -1654,62 +1617,51 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx)
        // _varray_flag
 #ifdef COREGL_USE_MODULE_TRACEPATH
        static void *trace_hint_vertex_attrib = NULL;
-       trace_hint_vertex_attrib = tracepath_api_trace_begin("eglMakeCurrent(FP vertex attrib)", trace_hint_vertex_attrib, 0);
+       trace_hint_vertex_attrib =
+               tracepath_api_trace_begin("eglMakeCurrent(FP vertex attrib)",
+                                         trace_hint_vertex_attrib, 0);
 #endif // COREGL_USE_MODULE_TRACEPATH
 
        flag = oldctx->_vattrib_flag | newctx->_vattrib_flag;
-       if (flag)
-       {
-               for (i = 0; i < oldctx->gl_num_vertex_attribs[0]; i++)
-               {
-                       if (newctx->gl_vertex_array_buf_id[i] != oldctx->gl_vertex_array_buf_id[i])
-                       {
-                               CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_ARRAY_BUFFER, newctx->gl_vertex_array_buf_id[i]))
-                       }
-                       else
-                       {
+       if (flag) {
+               for (i = 0; i < oldctx->gl_num_vertex_attribs[0]; i++) {
+                       if (newctx->gl_vertex_array_buf_id[i] != oldctx->gl_vertex_array_buf_id[i]) {
+                               CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_ARRAY_BUFFER,
+                                               newctx->gl_vertex_array_buf_id[i]))
+                       } else {
                                CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_ARRAY_BUFFER, 0))
                        }
 
-                       STATE_COMPARE(gl_vertex_array_divisor[i])
-                       {
-                               CHECK_GL_ERROR(_orig_fastpath_glVertexAttribDivisor(i, newctx->gl_vertex_array_divisor[i]))
+                       STATE_COMPARE(gl_vertex_array_divisor[i]) {
+                               CHECK_GL_ERROR(_orig_fastpath_glVertexAttribDivisor(i,
+                                               newctx->gl_vertex_array_divisor[i]))
                        }
 
-                       if (newctx->gl_vertex_array_size[i] != 0)
-                       {
+                       if (newctx->gl_vertex_array_size[i] != 0) {
                                CHECK_GL_ERROR(_orig_fastpath_glVertexAttribPointer(i,
-                                              newctx->gl_vertex_array_size[i],
-                                              newctx->gl_vertex_array_type[i],
-                                              newctx->gl_vertex_array_normalized[i],
-                                              newctx->gl_vertex_array_stride[i],
-                                              newctx->gl_vertex_array_pointer[i]))
-                       }
-                       else
-                       {
-                               if (newctx->gl_vertex_array_integer[0] == GL_TRUE)
-                               {
-                                       if (newctx->gl_vertex_array_type[0] == GL_UNSIGNED_INT)
-                                       {
-                                               CHECK_GL_ERROR(_orig_fastpath_glVertexAttribI4uiv(i, &newctx->gl_vertex_attrib_value_unsigned_integer[4 * i]))
-                                       }
-                                       else
-                                       {
-                                               CHECK_GL_ERROR(_orig_fastpath_glVertexAttribI4iv(i, &newctx->gl_vertex_attrib_value_integer[4 * i]))
+                                               newctx->gl_vertex_array_size[i],
+                                               newctx->gl_vertex_array_type[i],
+                                               newctx->gl_vertex_array_normalized[i],
+                                               newctx->gl_vertex_array_stride[i],
+                                               newctx->gl_vertex_array_pointer[i]))
+                       } else {
+                               if (newctx->gl_vertex_array_integer[0] == GL_TRUE) {
+                                       if (newctx->gl_vertex_array_type[0] == GL_UNSIGNED_INT) {
+                                               CHECK_GL_ERROR(_orig_fastpath_glVertexAttribI4uiv(i,
+                                                               &newctx->gl_vertex_attrib_value_unsigned_integer[4 * i]))
+                                       } else {
+                                               CHECK_GL_ERROR(_orig_fastpath_glVertexAttribI4iv(i,
+                                                               &newctx->gl_vertex_attrib_value_integer[4 * i]))
                                        }
-                               }
-                               else
-                               {
-                                       CHECK_GL_ERROR(_orig_fastpath_glVertexAttrib4fv(i, &newctx->gl_vertex_attrib_value[4 * i]))
+                               } else {
+                                       CHECK_GL_ERROR(_orig_fastpath_glVertexAttrib4fv(i,
+                                                       &newctx->gl_vertex_attrib_value[4 * i]))
                                }
                        }
 
-                       if (newctx->gl_vertex_array_enabled[i] == GL_TRUE)
-                       {
+                       if (newctx->gl_vertex_array_enabled[i] == GL_TRUE) {
                                CHECK_GL_ERROR(_orig_fastpath_glEnableVertexAttribArray(i))
-                       }
-                       else
-                       {
+                       } else {
                                CHECK_GL_ERROR(_orig_fastpath_glDisableVertexAttribArray(i))
                        }
                }
@@ -1717,98 +1669,100 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx)
        }
 
 #ifdef COREGL_USE_MODULE_TRACEPATH
-       tracepath_api_trace_end("eglMakeCurrent(FP vertex attrib)", trace_hint_vertex_attrib, 0);
+       tracepath_api_trace_end("eglMakeCurrent(FP vertex attrib)",
+                               trace_hint_vertex_attrib, 0);
 #endif // COREGL_USE_MODULE_TRACEPATH
 
 
 #ifdef COREGL_USE_MODULE_TRACEPATH
        static void *trace_hint_bindbuffers = NULL;
-       trace_hint_bindbuffers = tracepath_api_trace_begin("eglMakeCurrent(FP bind buffers)", trace_hint_bindbuffers, 0);
+       trace_hint_bindbuffers =
+               tracepath_api_trace_begin("eglMakeCurrent(FP bind buffers)",
+                                         trace_hint_bindbuffers, 0);
 #endif // COREGL_USE_MODULE_TRACEPATH
 
        //------------------//
        // _bind_flag1
        flag = oldctx->_bind_flag1 | newctx->_bind_flag1;
-       if (flag)
-       {
-               STATE_COMPARE(gl_array_buffer_binding[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_ARRAY_BUFFER, newctx->gl_array_buffer_binding[0]))
-               }
-               STATE_COMPARE(gl_element_array_buffer_binding[0])
-               {
-                       STATE_COMPARE(gl_vertex_array_binding[0])
-                       {
-                               CHECK_GL_ERROR(_orig_fastpath_glBindVertexArray(newctx->gl_vertex_array_binding[0]))
+       if (flag) {
+               STATE_COMPARE(gl_array_buffer_binding[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_ARRAY_BUFFER,
+                                       newctx->gl_array_buffer_binding[0]))
+               }
+               STATE_COMPARE(gl_element_array_buffer_binding[0]) {
+                       STATE_COMPARE(gl_vertex_array_binding[0]) {
+                               CHECK_GL_ERROR(_orig_fastpath_glBindVertexArray(
+                                                      newctx->gl_vertex_array_binding[0]))
                        }
-                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, newctx->gl_element_array_buffer_binding[0]))
+                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
+                                       newctx->gl_element_array_buffer_binding[0]))
                }
 
-               if (newctx->gl_framebuffer_binding_read_used == 1)
-               {
-                       STATE_COMPARE(gl_framebuffer_binding_read[0])
-                       {
-                               if(driver_gl_version >=2)
-                                       CHECK_GL_ERROR(_orig_fastpath_glBindFramebuffer(GL_READ_FRAMEBUFFER, newctx->gl_framebuffer_binding_read[0]))
-                               else
-                                       CHECK_GL_ERROR(_orig_fastpath_glBindFramebufferOES(GL_READ_FRAMEBUFFER, newctx->gl_framebuffer_binding_read[0]))
-                       }
-                       STATE_COMPARE(gl_framebuffer_binding_draw[0])
-                       {
-                               if(driver_gl_version >=2)
-                                       CHECK_GL_ERROR(_orig_fastpath_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, newctx->gl_framebuffer_binding_draw[0]))
-                               else
-                                       CHECK_GL_ERROR(_orig_fastpath_glBindFramebufferOES(GL_DRAW_FRAMEBUFFER, newctx->gl_framebuffer_binding_draw[0]))
-                       }
-               }
-               else
-               {
-                       STATE_COMPARE(gl_framebuffer_binding[0])
-                       {
-                               if(driver_gl_version >=2)
-                                       CHECK_GL_ERROR(_orig_fastpath_glBindFramebuffer(GL_FRAMEBUFFER, newctx->gl_framebuffer_binding[0]))
-                               else
-                                       CHECK_GL_ERROR(_orig_fastpath_glBindFramebufferOES(GL_FRAMEBUFFER, newctx->gl_framebuffer_binding[0]))
-                       }
+               if (newctx->gl_framebuffer_binding_read_used == 1) {
+                       STATE_COMPARE(gl_framebuffer_binding_read[0]) {
+                               if (driver_gl_version >= 2)
+                                       CHECK_GL_ERROR(_orig_fastpath_glBindFramebuffer(GL_READ_FRAMEBUFFER,
+                                                       newctx->gl_framebuffer_binding_read[0]))
+                                       else
+                                               CHECK_GL_ERROR(_orig_fastpath_glBindFramebufferOES(GL_READ_FRAMEBUFFER,
+                                                               newctx->gl_framebuffer_binding_read[0]))
+                                       }
+                       STATE_COMPARE(gl_framebuffer_binding_draw[0]) {
+                               if (driver_gl_version >= 2)
+                                       CHECK_GL_ERROR(_orig_fastpath_glBindFramebuffer(GL_DRAW_FRAMEBUFFER,
+                                                       newctx->gl_framebuffer_binding_draw[0]))
+                                       else
+                                               CHECK_GL_ERROR(_orig_fastpath_glBindFramebufferOES(GL_DRAW_FRAMEBUFFER,
+                                                               newctx->gl_framebuffer_binding_draw[0]))
+                                       }
+               } else {
+                       STATE_COMPARE(gl_framebuffer_binding[0]) {
+                               if (driver_gl_version >= 2)
+                                       CHECK_GL_ERROR(_orig_fastpath_glBindFramebuffer(GL_FRAMEBUFFER,
+                                                       newctx->gl_framebuffer_binding[0]))
+                                       else
+                                               CHECK_GL_ERROR(_orig_fastpath_glBindFramebufferOES(GL_FRAMEBUFFER,
+                                                               newctx->gl_framebuffer_binding[0]))
+                                       }
                }
-               STATE_COMPARE(gl_renderbuffer_binding[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glBindRenderbuffer(GL_RENDERBUFFER, newctx->gl_renderbuffer_binding[0]))
+               STATE_COMPARE(gl_renderbuffer_binding[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glBindRenderbuffer(GL_RENDERBUFFER,
+                                       newctx->gl_renderbuffer_binding[0]))
                }
        }
 
        //------------------//
        // _bind_flag2
        flag = oldctx->_bind_flag2 | newctx->_bind_flag2;
-       if (flag)
-       {
-               STATE_COMPARE(gl_copy_read_buffer_binding[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_COPY_READ_BUFFER, newctx->gl_copy_read_buffer_binding[0]))
+       if (flag) {
+               STATE_COMPARE(gl_copy_read_buffer_binding[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_COPY_READ_BUFFER,
+                                       newctx->gl_copy_read_buffer_binding[0]))
                }
-               STATE_COMPARE(gl_copy_write_buffer_binding[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_COPY_WRITE_BUFFER, newctx->gl_copy_write_buffer_binding[0]))
+               STATE_COMPARE(gl_copy_write_buffer_binding[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_COPY_WRITE_BUFFER,
+                                       newctx->gl_copy_write_buffer_binding[0]))
                }
-               STATE_COMPARE(gl_pixel_pack_buffer_binding[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_PIXEL_PACK_BUFFER, newctx->gl_pixel_pack_buffer_binding[0]))
+               STATE_COMPARE(gl_pixel_pack_buffer_binding[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_PIXEL_PACK_BUFFER,
+                                       newctx->gl_pixel_pack_buffer_binding[0]))
                }
-               STATE_COMPARE(gl_pixel_unpack_buffer_binding[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_PIXEL_UNPACK_BUFFER, newctx->gl_pixel_unpack_buffer_binding[0]))
+               STATE_COMPARE(gl_pixel_unpack_buffer_binding[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_PIXEL_UNPACK_BUFFER,
+                                       newctx->gl_pixel_unpack_buffer_binding[0]))
                }
-               STATE_COMPARE(gl_transform_feedback_buffer_binding[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, newctx->gl_transform_feedback_buffer_binding[0]))
+               STATE_COMPARE(gl_transform_feedback_buffer_binding[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER,
+                                       newctx->gl_transform_feedback_buffer_binding[0]))
                }
-               STATE_COMPARE(gl_uniform_buffer_binding[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_UNIFORM_BUFFER, newctx->gl_uniform_buffer_binding[0]))
+               STATE_COMPARE(gl_uniform_buffer_binding[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_UNIFORM_BUFFER,
+                                       newctx->gl_uniform_buffer_binding[0]))
                }
        }
 #ifdef COREGL_USE_MODULE_TRACEPATH
-       tracepath_api_trace_end("eglMakeCurrent(FP bind buffers)", trace_hint_bindbuffers, 0);
+       tracepath_api_trace_end("eglMakeCurrent(FP bind buffers)",
+                               trace_hint_bindbuffers, 0);
 #endif // COREGL_USE_MODULE_TRACEPATH
 
 
@@ -1817,283 +1771,241 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx)
        // _enable_flag1
 #ifdef COREGL_USE_MODULE_TRACEPATH
        static void *trace_hint_enable_states = NULL;
-       trace_hint_enable_states = tracepath_api_trace_begin("eglMakeCurrent(FP enable states)", trace_hint_enable_states, 0);
+       trace_hint_enable_states =
+               tracepath_api_trace_begin("eglMakeCurrent(FP enable states)",
+                                         trace_hint_enable_states, 0);
 #endif // COREGL_USE_MODULE_TRACEPATH
 
        flag = oldctx->_enable_flag1 | newctx->_enable_flag1;
-       if (flag)
-       {
-               STATE_COMPARE(gl_blend[0])
-               {
-                       if (newctx->gl_blend[0])
-                       {
+       if (flag) {
+               STATE_COMPARE(gl_blend[0]) {
+                       if (newctx->gl_blend[0]) {
                                CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_BLEND))
-                       }
-                       else
+                       } else
                                CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_BLEND))
-               }
-               STATE_COMPARE(gl_cull_face[0])
-               {
-                       if (newctx->gl_cull_face[0])
-                       {
-                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_CULL_FACE))
                        }
-                       else
+               STATE_COMPARE(gl_cull_face[0]) {
+                       if (newctx->gl_cull_face[0]) {
+                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_CULL_FACE))
+                       } else
                                CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_CULL_FACE))
-               }
-               STATE_COMPARE(gl_depth_test[0])
-               {
-                       if (newctx->gl_depth_test[0])
-                       {
-                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_DEPTH_TEST))
                        }
-                       else
+               STATE_COMPARE(gl_depth_test[0]) {
+                       if (newctx->gl_depth_test[0]) {
+                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_DEPTH_TEST))
+                       } else
                                CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_DEPTH_TEST))
-               }
-               STATE_COMPARE(gl_dither[0])
-               {
-                       if (newctx->gl_dither[0])
-                       {
-                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_DITHER))
                        }
-                       else
+               STATE_COMPARE(gl_dither[0]) {
+                       if (newctx->gl_dither[0]) {
+                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_DITHER))
+                       } else
                                CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_DITHER))
-               }
+                       }
        }
 
        // _enable_flag2
        flag = oldctx->_enable_flag2 | newctx->_enable_flag2;
-       if (flag)
-       {
-               STATE_COMPARE(gl_polygon_offset_fill[0])
-               {
-                       if (newctx->gl_polygon_offset_fill[0])
-                       {
+       if (flag) {
+               STATE_COMPARE(gl_polygon_offset_fill[0]) {
+                       if (newctx->gl_polygon_offset_fill[0]) {
                                CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_POLYGON_OFFSET_FILL))
-                       }
-                       else
+                       } else
                                CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_POLYGON_OFFSET_FILL))
-               }
-               STATE_COMPARE(gl_sample_alpha_to_coverage[0])
-               {
-                       if (newctx->gl_sample_alpha_to_coverage[0])
-                       {
-                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE))
                        }
-                       else
+               STATE_COMPARE(gl_sample_alpha_to_coverage[0]) {
+                       if (newctx->gl_sample_alpha_to_coverage[0]) {
+                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE))
+                       } else
                                CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE))
-               }
-               STATE_COMPARE(gl_sample_coverage[0])
-               {
-                       if (newctx->gl_sample_coverage[0])
-                       {
-                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_SAMPLE_COVERAGE))
                        }
-                       else
+               STATE_COMPARE(gl_sample_coverage[0]) {
+                       if (newctx->gl_sample_coverage[0]) {
+                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_SAMPLE_COVERAGE))
+                       } else
                                CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_SAMPLE_COVERAGE))
-               }
-               STATE_COMPARE(gl_scissor_test[0])
-               {
-                       if (newctx->gl_scissor_test[0])
-                       {
-                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_SCISSOR_TEST))
                        }
-                       else
+               STATE_COMPARE(gl_scissor_test[0]) {
+                       if (newctx->gl_scissor_test[0]) {
+                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_SCISSOR_TEST))
+                       } else
                                CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_SCISSOR_TEST))
-               }
-               STATE_COMPARE(gl_stencil_test[0])
-               {
-                       if (newctx->gl_stencil_test[0])
-                       {
-                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_STENCIL_TEST))
                        }
-                       else
+               STATE_COMPARE(gl_stencil_test[0]) {
+                       if (newctx->gl_stencil_test[0]) {
+                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_STENCIL_TEST))
+                       } else
                                CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_STENCIL_TEST))
-               }
+                       }
        }
 
        // _enable_flag3
        flag = oldctx->_enable_flag3 | newctx->_enable_flag3;
-       if (flag)
-       {
-               STATE_COMPARE(gl_primitive_restart_fixed_index[0])
-               {
-                       if (newctx->gl_primitive_restart_fixed_index[0])
-                       {
+       if (flag) {
+               STATE_COMPARE(gl_primitive_restart_fixed_index[0]) {
+                       if (newctx->gl_primitive_restart_fixed_index[0]) {
                                CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX))
-                       }
-                       else
+                       } else
                                CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_PRIMITIVE_RESTART_FIXED_INDEX))
-               }
-               STATE_COMPARE(gl_rasterizer_discard[0])
-               {
-                       if (newctx->gl_rasterizer_discard[0])
-                       {
-                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_RASTERIZER_DISCARD))
                        }
-                       else
+               STATE_COMPARE(gl_rasterizer_discard[0]) {
+                       if (newctx->gl_rasterizer_discard[0]) {
+                               CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_RASTERIZER_DISCARD))
+                       } else
                                CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_RASTERIZER_DISCARD))
-               }
+                       }
        }
 
 #ifdef COREGL_USE_MODULE_TRACEPATH
-       tracepath_api_trace_end("eglMakeCurrent(FP enable states)", trace_hint_enable_states, 0);
+       tracepath_api_trace_end("eglMakeCurrent(FP enable states)",
+                               trace_hint_enable_states, 0);
 #endif // COREGL_USE_MODULE_TRACEPATH
 
        //------------------//
        // _clear_flag1
 #ifdef COREGL_USE_MODULE_TRACEPATH
        static void *trace_hint_clear_viewport = NULL;
-       trace_hint_clear_viewport = tracepath_api_trace_begin("eglMakeCurrent(FP clear/viewport)", trace_hint_clear_viewport, 0);
+       trace_hint_clear_viewport =
+               tracepath_api_trace_begin("eglMakeCurrent(FP clear/viewport)",
+                                         trace_hint_clear_viewport, 0);
 #endif // COREGL_USE_MODULE_TRACEPATH
 
        flag = oldctx->_clear_flag1 | newctx->_clear_flag1;
-       if (flag)
-       {
+       if (flag) {
                // Viewport.
-               STATES_COMPARE(gl_viewport, 4 * sizeof(GLint))
-               {
+               STATES_COMPARE(gl_viewport, 4 * sizeof(GLint)) {
                        CHECK_GL_ERROR(_orig_fastpath_glViewport(newctx->gl_viewport[0],
-                                      newctx->gl_viewport[1],
-                                      newctx->gl_viewport[2],
-                                      newctx->gl_viewport[3]))
+                                       newctx->gl_viewport[1],
+                                       newctx->gl_viewport[2],
+                                       newctx->gl_viewport[3]))
                }
 
-               STATE_COMPARE(gl_current_program[0])
-               {
+               STATE_COMPARE(gl_current_program[0]) {
                        CHECK_GL_ERROR(_orig_fastpath_glUseProgram(newctx->gl_current_program[0]))
                }
-               STATES_COMPARE(gl_color_clear_value, 4 * sizeof(GLclampf))
-               {
+               STATES_COMPARE(gl_color_clear_value, 4 * sizeof(GLclampf)) {
                        CHECK_GL_ERROR(_orig_fastpath_glClearColor(newctx->gl_color_clear_value[0],
-                                      newctx->gl_color_clear_value[1],
-                                      newctx->gl_color_clear_value[2],
-                                      newctx->gl_color_clear_value[3]))
+                                       newctx->gl_color_clear_value[1],
+                                       newctx->gl_color_clear_value[2],
+                                       newctx->gl_color_clear_value[3]))
                }
        }
 
 
        // _clear_flag2
        flag = oldctx->_clear_flag2 | newctx->_clear_flag2;
-       if (flag)
-       {
-               STATES_COMPARE(gl_color_writemask, 4 * sizeof(GLboolean))
-               {
+       if (flag) {
+               STATES_COMPARE(gl_color_writemask, 4 * sizeof(GLboolean)) {
                        CHECK_GL_ERROR(_orig_fastpath_glColorMask(newctx->gl_color_writemask[0],
-                                      newctx->gl_color_writemask[1],
-                                      newctx->gl_color_writemask[2],
-                                      newctx->gl_color_writemask[3]))
+                                       newctx->gl_color_writemask[1],
+                                       newctx->gl_color_writemask[2],
+                                       newctx->gl_color_writemask[3]))
                }
-               STATES_COMPARE(gl_depth_range, 2 * sizeof(GLclampf))
-               {
+               STATES_COMPARE(gl_depth_range, 2 * sizeof(GLclampf)) {
                        CHECK_GL_ERROR(_orig_fastpath_glDepthRangef(newctx->gl_depth_range[0],
-                                      newctx->gl_depth_range[1]))
+                                       newctx->gl_depth_range[1]))
                }
-               STATE_COMPARE(gl_depth_clear_value[0])
-               {
+               STATE_COMPARE(gl_depth_clear_value[0]) {
                        CHECK_GL_ERROR(_orig_fastpath_glClearDepthf(newctx->gl_depth_clear_value[0]))
                }
-               STATE_COMPARE(gl_depth_func[0])
-               {
+               STATE_COMPARE(gl_depth_func[0]) {
                        CHECK_GL_ERROR(_orig_fastpath_glDepthFunc(newctx->gl_depth_func[0]))
                }
-               STATE_COMPARE(gl_depth_writemask[0])
-               {
+               STATE_COMPARE(gl_depth_writemask[0]) {
                        CHECK_GL_ERROR(_orig_fastpath_glDepthMask(newctx->gl_depth_writemask[0]))
                }
-               STATE_COMPARE(gl_cull_face_mode[0])
-               {
+               STATE_COMPARE(gl_cull_face_mode[0]) {
                        CHECK_GL_ERROR(_orig_fastpath_glCullFace(newctx->gl_cull_face_mode[0]))
                }
 
        }
 
 #ifdef COREGL_USE_MODULE_TRACEPATH
-       tracepath_api_trace_end("eglMakeCurrent(FP clear/viewport)", trace_hint_clear_viewport, 0);
+       tracepath_api_trace_end("eglMakeCurrent(FP clear/viewport)",
+                               trace_hint_clear_viewport, 0);
 #endif // COREGL_USE_MODULE_TRACEPATH
 
        //------------------//
        // Texture here...
 #ifdef COREGL_USE_MODULE_TRACEPATH
        static void *trace_hint_bind_textures = NULL;
-       trace_hint_bind_textures = tracepath_api_trace_begin("eglMakeCurrent(FP bind textures)", trace_hint_bind_textures, 0);
+       trace_hint_bind_textures =
+               tracepath_api_trace_begin("eglMakeCurrent(FP bind textures)",
+                                         trace_hint_bind_textures, 0);
 #endif // COREGL_USE_MODULE_TRACEPATH
 
        flag = oldctx->_tex_flag1 | newctx->_tex_flag1;
-       if (flag)
-       {
+       if (flag) {
 
-               for (i = 0; i < oldctx->gl_num_tex_units[0]; i++)
-               {
-                       STATE_COMPARE(gl_tex_2d_state[i])
-                       {
+               for (i = 0; i < oldctx->gl_num_tex_units[0]; i++) {
+                       STATE_COMPARE(gl_tex_2d_state[i]) {
                                CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i))
-                               CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_2D, newctx->gl_tex_2d_state[i]))
+                               CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_2D,
+                                               newctx->gl_tex_2d_state[i]))
                        }
-                       STATE_COMPARE(gl_tex_3d_state[i])
-                       {
+                       STATE_COMPARE(gl_tex_3d_state[i]) {
                                CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i))
-                               CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_3D, newctx->gl_tex_3d_state[i]))
+                               CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_3D,
+                                               newctx->gl_tex_3d_state[i]))
                        }
-                       STATE_COMPARE(gl_tex_2d_array_state[i])
-                       {
+                       STATE_COMPARE(gl_tex_2d_array_state[i]) {
                                CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i))
-                               CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_2D_ARRAY, newctx->gl_tex_2d_array_state[i]))
+                               CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_2D_ARRAY,
+                                               newctx->gl_tex_2d_array_state[i]))
                        }
-                       STATE_COMPARE(gl_tex_cube_state[i])
-                       {
+                       STATE_COMPARE(gl_tex_cube_state[i]) {
                                CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i))
-                               CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_CUBE_MAP, newctx->gl_tex_cube_state[i]))
+                               CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_CUBE_MAP,
+                                               newctx->gl_tex_cube_state[i]))
                        }
-                       STATE_COMPARE(gl_tex_external_oes_state[i])
-                       {
+                       STATE_COMPARE(gl_tex_external_oes_state[i]) {
                                CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i))
-                               CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_EXTERNAL_OES, newctx->gl_tex_external_oes_state[i]))
+                               CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_EXTERNAL_OES,
+                                               newctx->gl_tex_external_oes_state[i]))
                        }
                }
 
                // Restore active texture
                CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(newctx->gl_active_texture[0]))
 
-               STATE_COMPARE(gl_generate_mipmap_hint[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glHint(GL_GENERATE_MIPMAP_HINT, newctx->gl_generate_mipmap_hint[0]))
+               STATE_COMPARE(gl_generate_mipmap_hint[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glHint(GL_GENERATE_MIPMAP_HINT,
+                                                            newctx->gl_generate_mipmap_hint[0]))
                }
        }
 #ifdef COREGL_USE_MODULE_TRACEPATH
-       tracepath_api_trace_end("eglMakeCurrent(FP bind textures)", trace_hint_bind_textures, 0);
+       tracepath_api_trace_end("eglMakeCurrent(FP bind textures)",
+                               trace_hint_bind_textures, 0);
 #endif // COREGL_USE_MODULE_TRACEPATH
 
        //------------------//
 #ifdef COREGL_USE_MODULE_TRACEPATH
        static void *trace_hint_etc = NULL;
-       trace_hint_etc = tracepath_api_trace_begin("eglMakeCurrent(FP etc.)", trace_hint_etc, 0);
+       trace_hint_etc = tracepath_api_trace_begin("eglMakeCurrent(FP etc.)",
+                        trace_hint_etc, 0);
 #endif // COREGL_USE_MODULE_TRACEPATH
 
        flag = oldctx->_blend_flag | newctx->_blend_flag;
-       if (flag)
-       {
-               STATES_COMPARE(gl_blend_color, 4 * sizeof(GLclampf))
-               {
+       if (flag) {
+               STATES_COMPARE(gl_blend_color, 4 * sizeof(GLclampf)) {
                        CHECK_GL_ERROR(_orig_fastpath_glBlendColor(newctx->gl_blend_color[0],
-                                      newctx->gl_blend_color[1],
-                                      newctx->gl_blend_color[2],
-                                      newctx->gl_blend_color[3]))
+                                       newctx->gl_blend_color[1],
+                                       newctx->gl_blend_color[2],
+                                       newctx->gl_blend_color[3]))
                }
                if ((oldctx->gl_blend_src_rgb[0] != newctx->gl_blend_src_rgb[0]) ||
                    (oldctx->gl_blend_dst_rgb[0] != newctx->gl_blend_dst_rgb[0]) ||
                    (oldctx->gl_blend_src_alpha[0] != newctx->gl_blend_src_alpha[0]) ||
-                   (oldctx->gl_blend_dst_alpha[0] != newctx->gl_blend_dst_alpha[0]))
-               {
+                   (oldctx->gl_blend_dst_alpha[0] != newctx->gl_blend_dst_alpha[0])) {
                        CHECK_GL_ERROR(_orig_fastpath_glBlendFuncSeparate(newctx->gl_blend_src_rgb[0],
-                                      newctx->gl_blend_dst_rgb[0],
-                                      newctx->gl_blend_src_alpha[0],
-                                      newctx->gl_blend_dst_alpha[0]))
+                                       newctx->gl_blend_dst_rgb[0],
+                                       newctx->gl_blend_src_alpha[0],
+                                       newctx->gl_blend_dst_alpha[0]))
                }
                if ((oldctx->gl_blend_equation_rgb[0] != newctx->gl_blend_equation_rgb[0]) ||
-                   (oldctx->gl_blend_equation_alpha[0] != newctx->gl_blend_equation_alpha[0]))
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glBlendEquationSeparate(newctx->gl_blend_equation_rgb[0], newctx->gl_blend_equation_alpha[0]))
+                   (oldctx->gl_blend_equation_alpha[0] != newctx->gl_blend_equation_alpha[0])) {
+                       CHECK_GL_ERROR(_orig_fastpath_glBlendEquationSeparate(
+                                              newctx->gl_blend_equation_rgb[0], newctx->gl_blend_equation_alpha[0]))
                }
 
        }
@@ -2101,63 +2013,61 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx)
        //------------------//
        // _stencil_flag1
        flag = oldctx->_stencil_flag1 | newctx->_stencil_flag1;
-       if (flag)
-       {
+       if (flag) {
                if ((oldctx->gl_stencil_func[0] != newctx->gl_stencil_func[0]) ||
                    (oldctx->gl_stencil_ref[0]  != newctx->gl_stencil_ref[0])  ||
-                   (oldctx->gl_stencil_value_mask[0] != newctx->gl_stencil_value_mask[0]))
-               {
+                   (oldctx->gl_stencil_value_mask[0] != newctx->gl_stencil_value_mask[0])) {
                        CHECK_GL_ERROR(_orig_fastpath_glStencilFuncSeparate(GL_FRONT,
-                                      newctx->gl_stencil_func[0],
-                                      newctx->gl_stencil_ref[0],
-                                      newctx->gl_stencil_value_mask[0]))
+                                       newctx->gl_stencil_func[0],
+                                       newctx->gl_stencil_ref[0],
+                                       newctx->gl_stencil_value_mask[0]))
                }
                if ((oldctx->gl_stencil_fail[0] != newctx->gl_stencil_fail[0]) ||
-                   (oldctx->gl_stencil_pass_depth_fail[0] != newctx->gl_stencil_pass_depth_fail[0]) ||
-                   (oldctx->gl_stencil_pass_depth_pass[0] != newctx->gl_stencil_pass_depth_pass[0]))
-               {
+                   (oldctx->gl_stencil_pass_depth_fail[0] != newctx->gl_stencil_pass_depth_fail[0])
+                   ||
+                   (oldctx->gl_stencil_pass_depth_pass[0] !=
+                    newctx->gl_stencil_pass_depth_pass[0])) {
                        CHECK_GL_ERROR(_orig_fastpath_glStencilOpSeparate(GL_FRONT,
-                                      newctx->gl_stencil_fail[0],
-                                      newctx->gl_stencil_pass_depth_fail[0],
-                                      newctx->gl_stencil_pass_depth_pass[0]))
+                                       newctx->gl_stencil_fail[0],
+                                       newctx->gl_stencil_pass_depth_fail[0],
+                                       newctx->gl_stencil_pass_depth_pass[0]))
                }
 
-               STATE_COMPARE(gl_stencil_writemask[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glStencilMaskSeparate(GL_FRONT, newctx->gl_stencil_writemask[0]))
+               STATE_COMPARE(gl_stencil_writemask[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glStencilMaskSeparate(GL_FRONT,
+                                       newctx->gl_stencil_writemask[0]))
                }
        }
 
 
        // _stencil_flag1
        flag = oldctx->_stencil_flag2 | newctx->_stencil_flag2;
-       if (flag)
-       {
+       if (flag) {
                if ((oldctx->gl_stencil_back_func[0] != newctx->gl_stencil_back_func[0]) ||
                    (oldctx->gl_stencil_back_ref[0]  != newctx->gl_stencil_back_ref[0])  ||
-                   (oldctx->gl_stencil_back_value_mask[0] != newctx->gl_stencil_back_value_mask[0]))
-               {
+                   (oldctx->gl_stencil_back_value_mask[0] !=
+                    newctx->gl_stencil_back_value_mask[0])) {
                        CHECK_GL_ERROR(_orig_fastpath_glStencilFuncSeparate(GL_BACK,
-                                      newctx->gl_stencil_back_func[0],
-                                      newctx->gl_stencil_back_ref[0],
-                                      newctx->gl_stencil_back_value_mask[0]))
+                                       newctx->gl_stencil_back_func[0],
+                                       newctx->gl_stencil_back_ref[0],
+                                       newctx->gl_stencil_back_value_mask[0]))
                }
                if ((oldctx->gl_stencil_back_fail[0] != newctx->gl_stencil_back_fail[0]) ||
-                   (oldctx->gl_stencil_back_pass_depth_fail[0] != newctx->gl_stencil_back_pass_depth_fail[0]) ||
-                   (oldctx->gl_stencil_back_pass_depth_pass[0] != newctx->gl_stencil_back_pass_depth_pass[0]))
-               {
+                   (oldctx->gl_stencil_back_pass_depth_fail[0] !=
+                    newctx->gl_stencil_back_pass_depth_fail[0]) ||
+                   (oldctx->gl_stencil_back_pass_depth_pass[0] !=
+                    newctx->gl_stencil_back_pass_depth_pass[0])) {
                        CHECK_GL_ERROR(_orig_fastpath_glStencilOpSeparate(GL_BACK,
-                                      newctx->gl_stencil_back_fail[0],
-                                      newctx->gl_stencil_back_pass_depth_fail[0],
-                                      newctx->gl_stencil_back_pass_depth_pass[0]))
+                                       newctx->gl_stencil_back_fail[0],
+                                       newctx->gl_stencil_back_pass_depth_fail[0],
+                                       newctx->gl_stencil_back_pass_depth_pass[0]))
                }
 
-               STATE_COMPARE(gl_stencil_back_writemask[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glStencilMaskSeparate(GL_BACK, newctx->gl_stencil_back_writemask[0]))
+               STATE_COMPARE(gl_stencil_back_writemask[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glStencilMaskSeparate(GL_BACK,
+                                       newctx->gl_stencil_back_writemask[0]))
                }
-               STATE_COMPARE(gl_stencil_clear_value[0])
-               {
+               STATE_COMPARE(gl_stencil_clear_value[0]) {
                        CHECK_GL_ERROR(_orig_fastpath_glClearStencil(newctx->gl_stencil_clear_value[0]))
                }
        }
@@ -2165,129 +2075,124 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx)
        //------------------//
        // _pixel_flag1
        flag = oldctx->_pixel_flag1 | newctx->_pixel_flag1;
-       if (flag)
-       {
-               STATE_COMPARE(gl_pack_row_length[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_ROW_LENGTH, newctx->gl_pack_row_length[0]))
+       if (flag) {
+               STATE_COMPARE(gl_pack_row_length[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_ROW_LENGTH,
+                                       newctx->gl_pack_row_length[0]))
                }
-               STATE_COMPARE(gl_pack_skip_rows[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_SKIP_ROWS, newctx->gl_pack_skip_rows[0]))
+               STATE_COMPARE(gl_pack_skip_rows[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_SKIP_ROWS,
+                                       newctx->gl_pack_skip_rows[0]))
                }
-               STATE_COMPARE(gl_pack_skip_pixels[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_SKIP_PIXELS, newctx->gl_pack_skip_pixels[0]))
+               STATE_COMPARE(gl_pack_skip_pixels[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_SKIP_PIXELS,
+                                       newctx->gl_pack_skip_pixels[0]))
                }
-               STATE_COMPARE(gl_pack_alignment[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_ALIGNMENT, newctx->gl_pack_alignment[0]))
+               STATE_COMPARE(gl_pack_alignment[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_ALIGNMENT,
+                                       newctx->gl_pack_alignment[0]))
                }
        }
 
        // _pixel_flag2
        flag = oldctx->_pixel_flag2 | newctx->_pixel_flag2;
-       if (flag)
-       {
-               STATE_COMPARE(gl_unpack_row_length[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_ROW_LENGTH, newctx->gl_unpack_row_length[0]))
+       if (flag) {
+               STATE_COMPARE(gl_unpack_row_length[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_ROW_LENGTH,
+                                       newctx->gl_unpack_row_length[0]))
                }
-               STATE_COMPARE(gl_unpack_skip_rows[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_SKIP_ROWS, newctx->gl_unpack_skip_rows[0]))
+               STATE_COMPARE(gl_unpack_skip_rows[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_SKIP_ROWS,
+                                       newctx->gl_unpack_skip_rows[0]))
                }
-               STATE_COMPARE(gl_unpack_skip_pixels[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_SKIP_PIXELS, newctx->gl_unpack_skip_pixels[0]))
+               STATE_COMPARE(gl_unpack_skip_pixels[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_SKIP_PIXELS,
+                                       newctx->gl_unpack_skip_pixels[0]))
                }
-               STATE_COMPARE(gl_unpack_alignment[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_ALIGNMENT, newctx->gl_unpack_alignment[0]))
+               STATE_COMPARE(gl_unpack_alignment[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_ALIGNMENT,
+                                       newctx->gl_unpack_alignment[0]))
                }
-               STATE_COMPARE(gl_unpack_image_height[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, newctx->gl_unpack_image_height[0]))
+               STATE_COMPARE(gl_unpack_image_height[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_IMAGE_HEIGHT,
+                                       newctx->gl_unpack_image_height[0]))
                }
-               STATE_COMPARE(gl_unpack_skip_images[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_SKIP_IMAGES, newctx->gl_unpack_skip_images[0]))
+               STATE_COMPARE(gl_unpack_skip_images[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_SKIP_IMAGES,
+                                       newctx->gl_unpack_skip_images[0]))
                }
        }
 
        //------------------//
        // _misc_flag1
        flag = oldctx->_misc_flag1 | newctx->_misc_flag1;
-       if (flag)
-       {
-               STATE_COMPARE(gl_front_face[0])
-               {
+       if (flag) {
+               STATE_COMPARE(gl_front_face[0]) {
                        CHECK_GL_ERROR(_orig_fastpath_glFrontFace(newctx->gl_front_face[0]))
                }
-               STATE_COMPARE(gl_line_width[0])
-               {
+               STATE_COMPARE(gl_line_width[0]) {
                        CHECK_GL_ERROR(_orig_fastpath_glLineWidth(newctx->gl_line_width[0]))
                }
-               if ((oldctx->gl_polygon_offset_factor[0] != newctx->gl_polygon_offset_factor[0]) ||
-                   (oldctx->gl_polygon_offset_units[0]  != newctx->gl_polygon_offset_units[0]))
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glPolygonOffset(newctx->gl_polygon_offset_factor[0],
-                                      newctx->gl_polygon_offset_units[0]))
-               }
-               if ((oldctx->gl_sample_coverage_value[0]  != newctx->gl_sample_coverage_value[0]) ||
-                   (oldctx->gl_sample_coverage_invert[0] != newctx->gl_sample_coverage_invert[0]))
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glSampleCoverage(newctx->gl_sample_coverage_value[0],
-                                      newctx->gl_sample_coverage_invert[0]))
-               }
-               STATE_COMPARE(gl_fragment_shader_derivative_hint[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES, newctx->gl_fragment_shader_derivative_hint[0]))
+               if ((oldctx->gl_polygon_offset_factor[0] != newctx->gl_polygon_offset_factor[0])
+                   ||
+                   (oldctx->gl_polygon_offset_units[0]  != newctx->gl_polygon_offset_units[0])) {
+                       CHECK_GL_ERROR(_orig_fastpath_glPolygonOffset(
+                                              newctx->gl_polygon_offset_factor[0],
+                                              newctx->gl_polygon_offset_units[0]))
+               }
+               if ((oldctx->gl_sample_coverage_value[0]  !=
+                    newctx->gl_sample_coverage_value[0]) ||
+                   (oldctx->gl_sample_coverage_invert[0] !=
+                    newctx->gl_sample_coverage_invert[0])) {
+                       CHECK_GL_ERROR(_orig_fastpath_glSampleCoverage(
+                                              newctx->gl_sample_coverage_value[0],
+                                              newctx->gl_sample_coverage_invert[0]))
+               }
+               STATE_COMPARE(gl_fragment_shader_derivative_hint[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
+                                                            newctx->gl_fragment_shader_derivative_hint[0]))
                }
        }
 
        // _misc_flag2
        flag = oldctx->_misc_flag2 | newctx->_misc_flag2;
-       if (flag)
-       {
-               STATES_COMPARE(gl_scissor_box, 4 * sizeof(GLint))
-               {
+       if (flag) {
+               STATES_COMPARE(gl_scissor_box, 4 * sizeof(GLint)) {
                        CHECK_GL_ERROR(_orig_fastpath_glScissor(newctx->gl_scissor_box[0],
-                                                               newctx->gl_scissor_box[1],
-                                                               newctx->gl_scissor_box[2],
-                                                               newctx->gl_scissor_box[3]))
+                                                               newctx->gl_scissor_box[1],
+                                                               newctx->gl_scissor_box[2],
+                                                               newctx->gl_scissor_box[3]))
                }
        }
 
        // _misc_flag3
        flag = oldctx->_misc_flag3 | newctx->_misc_flag3;
-       if (flag)
-       {
-               STATE_COMPARE(gl_read_buffer[0])
-               {
+       if (flag) {
+               STATE_COMPARE(gl_read_buffer[0]) {
                        CHECK_GL_ERROR(_orig_fastpath_glReadBuffer(newctx->gl_read_buffer[0]))
                }
-               STATES_COMPARE(gl_draw_buffers, 16 * sizeof(GLenum))
-               {
+               STATES_COMPARE(gl_draw_buffers, 16 * sizeof(GLenum)) {
                        int drawBuffSize = 16;
                        /* If the  context has only default framebuffer, then size of glDrawBuffers can only be 1 */
-                       if(fastpath_ostate_has_object_type(&newctx->ostate, GL_OBJECT_TYPE_FRAMEBUFFER) == 0) {
+                       if (fastpath_ostate_has_object_type(&newctx->ostate,
+                                                           GL_OBJECT_TYPE_FRAMEBUFFER) == 0) {
                                drawBuffSize = 1;
                        }
 
-                       CHECK_GL_ERROR(_orig_fastpath_glDrawBuffers(drawBuffSize, newctx->gl_draw_buffers))
+                       CHECK_GL_ERROR(_orig_fastpath_glDrawBuffers(drawBuffSize,
+                                       newctx->gl_draw_buffers))
                }
 
-               if (oldctx->gl_transform_feedback_active[0] == GL_TRUE && oldctx->gl_transform_feedback_paused[0] == GL_FALSE)
-               {
+               if (oldctx->gl_transform_feedback_active[0] == GL_TRUE &&
+                   oldctx->gl_transform_feedback_paused[0] == GL_FALSE) {
                        CHECK_GL_ERROR(_orig_fastpath_glPauseTransformFeedback())
                }
-               STATE_COMPARE(gl_transform_feedback_binding[0])
-               {
-                       CHECK_GL_ERROR(_orig_fastpath_glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, newctx->gl_transform_feedback_binding[0]))
+               STATE_COMPARE(gl_transform_feedback_binding[0]) {
+                       CHECK_GL_ERROR(_orig_fastpath_glBindTransformFeedback(GL_TRANSFORM_FEEDBACK,
+                                       newctx->gl_transform_feedback_binding[0]))
                }
-               if (newctx->gl_transform_feedback_active[0] == GL_TRUE && newctx->gl_transform_feedback_paused[0] == GL_FALSE)
-               {
+               if (newctx->gl_transform_feedback_active[0] == GL_TRUE &&
+                   newctx->gl_transform_feedback_paused[0] == GL_FALSE) {
                        CHECK_GL_ERROR(_orig_fastpath_glResumeTransformFeedback())
                }
        }