evas: refactorize OpenGL engine.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 24 Aug 2011 16:20:15 +0000 (16:20 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 24 Aug 2011 16:20:15 +0000 (16:20 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@62752 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/modules/engines/gl_common/evas_gl_common.h
src/modules/engines/gl_common/evas_gl_context.c
src/modules/engines/gl_common/evas_gl_shader.c

index be677fe..64adfa5 100644 (file)
@@ -118,9 +118,44 @@ typedef struct _Evas_GL_Font_Texture                 Evas_GL_Font_Texture;
 typedef struct _Evas_GL_Polygon                      Evas_GL_Polygon;
 typedef struct _Evas_GL_Polygon_Point                Evas_GL_Polygon_Point;
 
+typedef enum {
+  SHADER_RECT,
+  SHADER_FONT,
+  SHADER_IMG,
+  SHADER_IMG_NOMUL,
+  SHADER_IMG_BGRA,
+  SHADER_IMG_BGRA_NOMUL,
+  SHADER_IMG_MASK,
+  SHADER_YUV,
+  SHADER_YUV_NOMUL,
+  SHADER_YUY2,
+  SHADER_YUY2_NOMUL,
+  SHADER_TEX,
+  SHADER_TEX_NOMUL,
+  SHADER_FILTER_INVERT,
+  SHADER_FILTER_INVERT_NOMUL,
+  SHADER_FILTER_INVERT_BGRA,
+  SHADER_FILTER_INVERT_BGRA_NOMUL,
+  SHADER_FILTER_GREYSCALE,
+  SHADER_FILTER_GREYSCALE_NOMUL,
+  SHADER_FILTER_GREYSCALE_BGRA,
+  SHADER_FILTER_GREYSCALE_BGRA_NOMUL,
+  SHADER_FILTER_SEPIA,
+  SHADER_FILTER_SEPIA_NOMUL,
+  SHADER_FILTER_SEPIA_BGRA,
+  SHADER_FILTER_SEPIA_BGRA_NOMUL,
+  /* SHADER_FILTER_BLUR, */
+  /* SHADER_FILTER_BLUR_NOMUL, */
+  /* SHADER_FILTER_BLUR_BGRA, */
+  /* SHADER_FILTER_BLUR_BGRA_NOMUL, */
+  SHADER_LAST
+} Evas_GL_Shader;
+
 struct _Evas_GL_Program
 {
    GLuint vert, frag, prog;
+
+   int tex_count;
 };
 
 struct _Evas_GL_Program_Source
@@ -200,29 +235,8 @@ struct _Evas_GL_Shared
    Eina_Hash          *native_pm_hash;
    Eina_Hash          *native_tex_hash;
 
-   struct {
-      Evas_GL_Program  rect;
-      Evas_GL_Program  font;
-
-      Evas_GL_Program  img,            img_nomul;
-      Evas_GL_Program  img_bgra,       img_bgra_nomul;
-      Evas_GL_Program  img_mask;
-      Evas_GL_Program  yuv,            yuv_nomul;
-      Evas_GL_Program  yuy2,           yuy2_nomul;
-      Evas_GL_Program  tex,            tex_nomul;
-
-      Evas_GL_Program  filter_invert,         filter_invert_nomul;
-      Evas_GL_Program  filter_invert_bgra,    filter_invert_bgra_nomul;
-      Evas_GL_Program  filter_greyscale,      filter_greyscale_nomul;
-      Evas_GL_Program  filter_greyscale_bgra, filter_greyscale_bgra_nomul;
-      Evas_GL_Program  filter_sepia,          filter_sepia_nomul;
-      Evas_GL_Program  filter_sepia_bgra,     filter_sepia_bgra_nomul;
-#if 0
-      Evas_GL_Program  filter_blur_vert;
-      Evas_GL_Program  filter_blur,           filter_blur_nomul;
-      Evas_GL_Program  filter_blur_bgra,      filter_blur_bgra_nomul;
-#endif
-   } shader;
+   Evas_GL_Program     shader[SHADER_LAST];
+
    int references;
    int w, h;
    int rot;
@@ -410,6 +424,7 @@ struct _Evas_GL_Polygon_Point
    int x, y;
 };
 
+#if 0
 extern Evas_GL_Program_Source shader_rect_frag_src;
 extern Evas_GL_Program_Source shader_rect_vert_src;
 extern Evas_GL_Program_Source shader_font_frag_src;
@@ -453,7 +468,6 @@ extern Evas_GL_Program_Source shader_filter_greyscale_frag_src;
 extern Evas_GL_Program_Source shader_filter_greyscale_nomul_frag_src;
 extern Evas_GL_Program_Source shader_filter_greyscale_bgra_frag_src;
 extern Evas_GL_Program_Source shader_filter_greyscale_bgra_nomul_frag_src;
-#if 0
 /* blur (annoyingly) needs (aka is faster with) a vertex shader */
 extern Evas_GL_Program_Source shader_filter_blur_vert_src;
 extern Evas_GL_Program_Source shader_filter_blur_frag_src;
index 0cb3f85..f6bab86 100644 (file)
@@ -324,6 +324,7 @@ static void
 _evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc)
 {
    GLfloat proj[16];
+   unsigned int i;
    int w = 1, h = 1, m = 1, rot = 1, foc = 0;
 
    EINA_SAFETY_ON_NULL_RETURN(gc);
@@ -445,162 +446,13 @@ _evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc)
         gc->shared->ay = ay;
      }
 
-   glUseProgram(gc->shared->shader.rect.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.rect.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.font.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.font.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
-   glUseProgram(gc->shared->shader.yuv.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.yuv.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.yuv_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.yuv_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
-   glUseProgram(gc->shared->shader.yuy2.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.yuy2.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.yuy2_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.yuy2_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
-   glUseProgram(gc->shared->shader.tex.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.tex.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.tex_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.tex_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
-   glUseProgram(gc->shared->shader.img.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.img.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.img_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.img_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
-   glUseProgram(gc->shared->shader.img_bgra.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.img_bgra.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.img_bgra_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.img_bgra_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.img_mask.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.img_mask.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.filter_invert.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_invert.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.filter_invert_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_invert_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.filter_invert_bgra.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_invert_bgra.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.filter_invert_bgra_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_invert_bgra_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
-   glUseProgram(gc->shared->shader.filter_greyscale.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_greyscale.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.filter_greyscale_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_greyscale_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.filter_greyscale_bgra.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_greyscale_bgra.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.filter_greyscale_bgra_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_greyscale_bgra_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
-   glUseProgram(gc->shared->shader.filter_sepia.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_sepia.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.filter_sepia_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_sepia_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.filter_sepia_bgra.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_sepia_bgra.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.filter_sepia_bgra_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_sepia_bgra_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
-#if 0
-   glUseProgram(gc->shared->shader.filter_blur_bgra_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_blur_bgra_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.filter_blur_bgra_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_blur_bgra_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.filter_blur_bgra_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_blur_bgra_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUseProgram(gc->shared->shader.filter_blur_bgra_nomul.prog);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.filter_blur_bgra_nomul.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-#endif
-
+   for (i = 0; i < SHADER_LAST; ++i)
+     {
+        glUseProgram(gc->shared->shader[i].prog);
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+        glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader[i].prog, "mvp"), 1, GL_FALSE, proj);
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+     }
 
    glUseProgram(gc->pipe[0].shader.cur_prog);
    GLERR(__FUNCTION__, __FILE__, __LINE__, "");
@@ -822,46 +674,28 @@ evas_gl_common_context_new(void)
 
        if (!evas_gl_common_shader_program_init(shared)) goto error;
 
-        glUseProgram(shared->shader.yuv.prog);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glUniform1i(glGetUniformLocation(shared->shader.yuv.prog, "tex"), 0);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glUniform1i(glGetUniformLocation(shared->shader.yuv.prog, "texu"), 1);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glUniform1i(glGetUniformLocation(shared->shader.yuv.prog, "texv"), 2);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
-        glUseProgram(shared->shader.yuy2.prog);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glUniform1i(glGetUniformLocation(shared->shader.yuy2.prog, "tex"), 0);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glUniform1i(glGetUniformLocation(shared->shader.yuy2.prog, "texuv"), 1);
+#define SHADER_TEXTURE_ADD(Shared, Shader, Name)                        \
+        glUseProgram(Shared->shader[SHADER_##Shader].prog);             \
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");                    \
+        glUniform1i(glGetUniformLocation(Shared->shader[SHADER_##Shader].prog, #Name), Shared->shader[SHADER_##Shader].tex_count++); \
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
 
-        glUseProgram(shared->shader.yuv_nomul.prog);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glUniform1i(glGetUniformLocation(shared->shader.yuv_nomul.prog, "tex"), 0);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glUniform1i(glGetUniformLocation(shared->shader.yuv_nomul.prog, "texu"), 1);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glUniform1i(glGetUniformLocation(shared->shader.yuv_nomul.prog, "texv"), 2);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+        SHADER_TEXTURE_ADD(shared, YUV, tex);
+        SHADER_TEXTURE_ADD(shared, YUV, texu);
+        SHADER_TEXTURE_ADD(shared, YUV, texv);
 
-        glUseProgram(shared->shader.yuy2_nomul.prog);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glUniform1i(glGetUniformLocation(shared->shader.yuy2_nomul.prog, "tex"), 0);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glUniform1i(glGetUniformLocation(shared->shader.yuy2_nomul.prog, "texuv"), 1);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+        SHADER_TEXTURE_ADD(shared, YUY2, tex);
+        SHADER_TEXTURE_ADD(shared, YUY2, texuv);
 
-       glUseProgram(shared->shader.img_mask.prog);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glUniform1i(glGetUniformLocation(shared->shader.img_mask.prog, "tex"), 0);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-        glUniform1i(glGetUniformLocation(shared->shader.img_mask.prog, "texm"), 1);
-        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+        SHADER_TEXTURE_ADD(shared, YUV_NOMUL, tex);
+        SHADER_TEXTURE_ADD(shared, YUV_NOMUL, texu);
+        SHADER_TEXTURE_ADD(shared, YUV_NOMUL, texv);
 
+        SHADER_TEXTURE_ADD(shared, YUY2_NOMUL, tex);
+        SHADER_TEXTURE_ADD(shared, YUY2_NOMUL, texuv);
 
+        SHADER_TEXTURE_ADD(shared, IMG_MASK, tex);
+        SHADER_TEXTURE_ADD(shared, IMG_MASK, texm);
 
         glUseProgram(gc->pipe[0].shader.cur_prog);
         GLERR(__FUNCTION__, __FILE__, __LINE__, "");
@@ -918,22 +752,10 @@ evas_gl_common_context_free(Evas_Engine_GL_Context *gc)
    if ((gc->shared) && (gc->shared->references == 0))
      {
         Evas_GL_Texture_Pool *pt;
+        int i;
 
-        evas_gl_common_shader_program_shutdown(&(gc->shared->shader.rect));
-        evas_gl_common_shader_program_shutdown(&(gc->shared->shader.font));
-        evas_gl_common_shader_program_shutdown(&(gc->shared->shader.img));
-        evas_gl_common_shader_program_shutdown(&(gc->shared->shader.img_nomul));
-        evas_gl_common_shader_program_shutdown(&(gc->shared->shader.img_bgra));
-        evas_gl_common_shader_program_shutdown(&(gc->shared->shader.img_bgra_nomul));
-        evas_gl_common_shader_program_shutdown(&(gc->shared->shader.img_mask));
-        evas_gl_common_shader_program_shutdown(&(gc->shared->shader.yuv));
-        evas_gl_common_shader_program_shutdown(&(gc->shared->shader.yuv_nomul));
-        evas_gl_common_shader_program_shutdown(&(gc->shared->shader.yuy2));
-        evas_gl_common_shader_program_shutdown(&(gc->shared->shader.yuy2_nomul));
-        evas_gl_common_shader_program_shutdown(&(gc->shared->shader.tex));
-        evas_gl_common_shader_program_shutdown(&(gc->shared->shader.tex_nomul));
-
-       evas_gl_common_shader_program_shutdown(&(gc->shared->shader.filter_invert));
+        for (i = 0; i < SHADER_LAST; ++i)
+          evas_gl_common_shader_program_shutdown(&(gc->shared->shader[i]));
 
         while (gc->shared->images)
           {
@@ -1269,7 +1091,7 @@ evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc,
 {
    int pnum, nv, nc, nu, nt, i;
    Eina_Bool blend = 0;
-   GLuint prog = gc->shared->shader.rect.prog;
+   GLuint prog = gc->shared->shader[SHADER_RECT].prog;
    int pn = 0;
 
    if (a < 255) blend = 1;
@@ -1324,7 +1146,7 @@ evas_gl_common_context_rectangle_push(Evas_Engine_GL_Context *gc,
 {
    int pnum, nv, nc, nu, nt, i;
    Eina_Bool blend = 0;
-   GLuint prog = gc->shared->shader.rect.prog;
+   GLuint prog = gc->shared->shader[SHADER_RECT].prog;
    int pn = 0;
 
    if (gc->dc->mask.mask)
@@ -1475,7 +1297,7 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
    int pnum, nv, nc, nu, nu2, nt, i;
    GLfloat tx1, tx2, ty1, ty2;
    Eina_Bool blend = 1;
-   GLuint prog = gc->shared->shader.img.prog;
+   GLuint prog = gc->shared->shader[SHADER_IMG].prog;
    int pn = 0;
 
    if (!tex->alpha) blend = 0;
@@ -1490,16 +1312,16 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
         if (tex->pt->dyn.img)
           {
              if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
-                prog = gc->shared->shader.img_nomul.prog;
+                prog = gc->shared->shader[SHADER_IMG_NOMUL].prog;
              else
-                prog = gc->shared->shader.img.prog;
+                prog = gc->shared->shader[SHADER_IMG].prog;
           }
         else
           {
              if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
-                prog = gc->shared->shader.tex_nomul.prog;
+                prog = gc->shared->shader[SHADER_TEX_NOMUL].prog;
              else
-                prog = gc->shared->shader.tex.prog;
+                prog = gc->shared->shader[SHADER_TEX].prog;
           }
      }
    else
@@ -1507,16 +1329,16 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
         if (tex->gc->shared->info.bgra)
           {
              if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
-               prog = gc->shared->shader.img_bgra_nomul.prog;
+               prog = gc->shared->shader[SHADER_IMG_BGRA_NOMUL].prog;
              else
-               prog = gc->shared->shader.img_bgra.prog;
+               prog = gc->shared->shader[SHADER_IMG_BGRA].prog;
           }
         else
           {
              if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
-               prog = gc->shared->shader.img_nomul.prog;
+               prog = gc->shared->shader[SHADER_IMG_NOMUL].prog;
              else
-               prog = gc->shared->shader.img.prog;
+               prog = gc->shared->shader[SHADER_IMG].prog;
           }
      }
 
@@ -1724,19 +1546,19 @@ evas_gl_common_context_image_mask_push(Evas_Engine_GL_Context *gc,
    GLfloat tx1, tx2, ty1, ty2;
    GLfloat txm1, txm2, tym1, tym2;
    Eina_Bool blend = 1;
-   GLuint prog = gc->shared->shader.img_mask.prog;
+   GLuint prog = gc->shared->shader[SHADER_IMG_MASK].prog;
    int pn = 0;
 
 #if 0
    if (tex->gc->shared->info.bgra)
    {
-          prog = gc->shared->shader.img_mask.prog;
+      prog = gc->shared->shader[SHADER_IMG_MASK].prog;
    }
    else
    {
 #warning Nash: FIXME: Need two shaders?
           printf("Not good: Need other texture\n");
-          prog = gc->shared->shader.img.prog;
+          prog = gc->shared->shader[SHADER_IMG].prog;
    }
 #endif
 
@@ -1966,6 +1788,7 @@ evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
 {
    int pnum, nv, nc, nu, nt, i;
    GLfloat tx1, tx2, ty1, ty2;
+   GLuint prog = gc->shared->shader[SHADER_FONT].prog;
    int pn = 0;
 
 again:
@@ -1976,7 +1799,7 @@ again:
      {
         gc->pipe[pn].region.type = RTYPE_FONT;
         gc->pipe[pn].shader.cur_tex = tex->pt->texture;
-        gc->pipe[pn].shader.cur_prog = gc->shared->shader.font.prog;
+        gc->pipe[pn].shader.cur_prog = prog;
         gc->pipe[pn].shader.smooth = 0;
         gc->pipe[pn].shader.blend = 1;
         gc->pipe[pn].shader.render_op = gc->dc->render_op;
@@ -2000,7 +1823,7 @@ again:
           {
              if ((gc->pipe[i].region.type == RTYPE_FONT)
                  && (gc->pipe[i].shader.cur_tex == tex->pt->texture)
-                 && (gc->pipe[i].shader.cur_prog == gc->shared->shader.font.prog)
+                 && (gc->pipe[i].shader.cur_prog == prog)
                  && (gc->pipe[i].shader.smooth == 0)
                  && (gc->pipe[i].shader.blend == 1)
                  && (gc->pipe[i].shader.render_op == gc->dc->render_op)
@@ -2024,7 +1847,7 @@ again:
              gc->state.top_pipe = pn;
              gc->pipe[pn].region.type = RTYPE_FONT;
              gc->pipe[pn].shader.cur_tex = tex->pt->texture;
-             gc->pipe[pn].shader.cur_prog = gc->shared->shader.font.prog;
+             gc->pipe[pn].shader.cur_prog = prog;
              gc->pipe[pn].shader.smooth = 0;
              gc->pipe[pn].shader.blend = 1;
              gc->pipe[pn].shader.render_op = gc->dc->render_op;
@@ -2043,7 +1866,7 @@ again:
      }
 #else
    if ((gc->pipe[pn].shader.cur_tex != tex->pt->texture)
-       || (gc->pipe[pn].shader.cur_prog != gc->shared->shader.font.prog)
+       || (gc->pipe[pn].shader.cur_prog != prog)
        || (gc->pipe[pn].shader.smooth != 0)
        || (gc->pipe[pn].shader.blend != 1)
        || (gc->pipe[pn].shader.render_op != gc->dc->render_op)
@@ -2052,7 +1875,7 @@ again:
      {
         shader_array_flush(gc);
         gc->pipe[pn].shader.cur_tex = tex->pt->texture;
-        gc->pipe[pn].shader.cur_prog = gc->shared->shader.font.prog;
+        gc->pipe[pn].shader.cur_prog = prog;
         gc->pipe[pn].shader.smooth = 0;
         gc->pipe[pn].shader.blend = 1;
         gc->pipe[pn].shader.render_op = gc->dc->render_op;
@@ -2127,15 +1950,15 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
    int pnum, nv, nc, nu, nu2, nu3, nt, i;
    GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2;
    Eina_Bool blend = 0;
-   GLuint prog = gc->shared->shader.yuv.prog;
+   GLuint prog = gc->shared->shader[SHADER_YUV].prog;
    int pn = 0;
 
    if (a < 255) blend = 1;
 
    if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
-     prog = gc->shared->shader.yuv_nomul.prog;
+     prog = gc->shared->shader[SHADER_YUV_NOMUL].prog;
    else
-     prog = gc->shared->shader.yuv.prog;
+     prog = gc->shared->shader[SHADER_YUV].prog;
 
 again:
    vertex_array_size_check(gc, gc->state.top_pipe, 6);
@@ -2171,7 +1994,7 @@ again:
           {
              if ((gc->pipe[i].region.type == RTYPE_YUV)
                  && (gc->pipe[i].shader.cur_tex == tex->pt->texture)
-                 && (gc->pipe[i].shader.cur_prog == gc->shared->shader.font.prog)
+                 && (gc->pipe[i].shader.cur_prog == prog)
                  && (gc->pipe[i].shader.smooth == smooth)
                  && (gc->pipe[i].shader.blend == blend)
                  && (gc->pipe[i].shader.render_op == gc->dc->render_op)
@@ -2314,15 +2137,15 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
    int pnum, nv, nc, nu, nu2, nu3, nt, i;
    GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2;
    Eina_Bool blend = 0;
-   GLuint prog = gc->shared->shader.yuy2.prog;
+   GLuint prog = gc->shared->shader[SHADER_YUY2].prog;
    int pn = 0;
 
    if (a < 255) blend = 1;
 
    if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
-     prog = gc->shared->shader.yuy2_nomul.prog;
+     prog = gc->shared->shader[SHADER_YUY2_NOMUL].prog;
    else
-     prog = gc->shared->shader.yuy2.prog;
+     prog = gc->shared->shader[SHADER_YUY2].prog;
 
 again:
    vertex_array_size_check(gc, gc->state.top_pipe, 6);
@@ -2357,7 +2180,7 @@ again:
           {
              if ((gc->pipe[i].region.type == RTYPE_YUY2)
                  && (gc->pipe[i].shader.cur_tex == tex->pt->texture)
-                 && (gc->pipe[i].shader.cur_prog == gc->shared->shader.font.prog)
+                 && (gc->pipe[i].shader.cur_prog == prog)
                  && (gc->pipe[i].shader.smooth == smooth)
                  && (gc->pipe[i].shader.blend == blend)
                  && (gc->pipe[i].shader.render_op == gc->dc->render_op)
@@ -2496,7 +2319,7 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
    GLfloat tx[4], ty[4], t2x[4], t2y[4];
    Eina_Bool blend = 1;
    DATA32 cmul;
-   GLuint prog = gc->shared->shader.img.prog;
+   GLuint prog = gc->shared->shader[SHADER_IMG].prog;
    int pn = 0;
    int flat = 0;
 
@@ -2523,31 +2346,31 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
      }
    if (yuv)
      {
-        prog = gc->shared->shader.yuv.prog;
+        prog = gc->shared->shader[SHADER_YUV].prog;
         if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
           {
              if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
                  (p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
-                prog = gc->shared->shader.yuv_nomul.prog;
+                prog = gc->shared->shader[SHADER_YUV_NOMUL].prog;
              else
-                prog = gc->shared->shader.yuv.prog;
+                prog = gc->shared->shader[SHADER_YUV].prog;
           }
         else
-           prog = gc->shared->shader.yuv.prog;
+           prog = gc->shared->shader[SHADER_YUV].prog;
      }
    else if (yuy2)
      {
-        prog = gc->shared->shader.yuy2.prog;
+        prog = gc->shared->shader[SHADER_YUY2].prog;
         if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
           {
              if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
                  (p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
-                prog = gc->shared->shader.yuy2_nomul.prog;
+                prog = gc->shared->shader[SHADER_YUY2_NOMUL].prog;
              else
-                prog = gc->shared->shader.yuy2.prog;
+                prog = gc->shared->shader[SHADER_YUY2].prog;
           }
         else
-           prog = gc->shared->shader.yuy2.prog;
+           prog = gc->shared->shader[SHADER_YUY2].prog;
      }
    else
      {
@@ -2559,12 +2382,12 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
                     {
                        if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
                            (p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
-                          prog = gc->shared->shader.img_nomul.prog;
+                          prog = gc->shared->shader[SHADER_IMG_NOMUL].prog;
                        else
-                          prog = gc->shared->shader.img.prog;
+                          prog = gc->shared->shader[SHADER_IMG].prog;
                     }
                   else
-                     prog = gc->shared->shader.img.prog;
+                     prog = gc->shared->shader[SHADER_IMG].prog;
                }
              else
                {
@@ -2572,12 +2395,12 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
                     {
                        if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
                            (p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
-                          prog = gc->shared->shader.tex_nomul.prog;
+                          prog = gc->shared->shader[SHADER_TEX_NOMUL].prog;
                        else
-                          prog = gc->shared->shader.tex.prog;
+                          prog = gc->shared->shader[SHADER_TEX].prog;
                     }
                   else
-                     prog = gc->shared->shader.tex.prog;
+                     prog = gc->shared->shader[SHADER_TEX].prog;
                }
           }
         else
@@ -2588,12 +2411,12 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
                     {
                        if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
                            (p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
-                          prog = gc->shared->shader.img_bgra_nomul.prog;
+                          prog = gc->shared->shader[SHADER_IMG_BGRA_NOMUL].prog;
                        else
-                          prog = gc->shared->shader.img_bgra.prog;
+                          prog = gc->shared->shader[SHADER_IMG_BGRA].prog;
                     }
                   else
-                     prog = gc->shared->shader.img_bgra.prog;
+                     prog = gc->shared->shader[SHADER_IMG_BGRA].prog;
                }
              else
                {
@@ -2601,12 +2424,12 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
                     {
                        if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
                            (p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
-                          prog = gc->shared->shader.img_nomul.prog;
+                         prog = gc->shared->shader[SHADER_IMG_NOMUL].prog;
                        else
-                          prog = gc->shared->shader.img.prog;
+                          prog = gc->shared->shader[SHADER_IMG].prog;
                     }
                   else
-                     prog = gc->shared->shader.img.prog;
+                     prog = gc->shared->shader[SHADER_IMG].prog;
                }
           }
      }
index 70f452f..239f209 100644 (file)
@@ -1006,131 +1006,61 @@ _evas_gl_common_shader_program_source_init(Evas_GL_Program *p,
    return 1;
 }
 
+#define SHADER_SOURCE_LINE(Big, Small) \
+  { SHADER_##Big, &(shader_##Small##_vert_src), &(shader_##Small##_frag_src), #Small }
+
+#define SHADER_SOURCE_FILTER_LINE(Big, Small) \
+  { SHADER_##Big, &(shader_img_vert_src), &(shader_##Small##_frag_src), #Small }
+
+static const struct {
+  Evas_GL_Shader id;
+  Evas_GL_Program_Source *vert;
+  Evas_GL_Program_Source *frag;
+  const char *name;
+} _shaders_source[] = {
+  SHADER_SOURCE_LINE(RECT, rect),
+  SHADER_SOURCE_LINE(FONT, font),
+  SHADER_SOURCE_LINE(IMG, img),
+  SHADER_SOURCE_LINE(IMG_NOMUL, img_nomul),
+  SHADER_SOURCE_LINE(IMG_BGRA, img_bgra),
+  SHADER_SOURCE_LINE(IMG_BGRA_NOMUL, img_bgra_nomul),
+  SHADER_SOURCE_LINE(IMG_MASK, img_mask),
+  SHADER_SOURCE_LINE(YUV, yuv),
+  SHADER_SOURCE_LINE(YUV_NOMUL, yuv_nomul),
+  SHADER_SOURCE_LINE(YUY2, yuy2),
+  SHADER_SOURCE_LINE(YUY2_NOMUL, yuy2_nomul),
+  SHADER_SOURCE_LINE(TEX, tex),
+  SHADER_SOURCE_LINE(TEX_NOMUL, tex_nomul),
+   /* Most of the filters use the image fragment shader */
+  SHADER_SOURCE_FILTER_LINE(FILTER_INVERT, filter_invert),
+  SHADER_SOURCE_FILTER_LINE(FILTER_INVERT_NOMUL, filter_invert_nomul),
+  SHADER_SOURCE_FILTER_LINE(FILTER_INVERT_BGRA, filter_invert_bgra),
+  SHADER_SOURCE_FILTER_LINE(FILTER_INVERT_BGRA_NOMUL, filter_invert_bgra_nomul),
+  SHADER_SOURCE_FILTER_LINE(FILTER_GREYSCALE, filter_greyscale),
+  SHADER_SOURCE_FILTER_LINE(FILTER_GREYSCALE_NOMUL, filter_greyscale_nomul),
+  SHADER_SOURCE_FILTER_LINE(FILTER_GREYSCALE_BGRA, filter_greyscale_bgra),
+  SHADER_SOURCE_FILTER_LINE(FILTER_GREYSCALE_BGRA_NOMUL, filter_greyscale_bgra_nomul),
+  SHADER_SOURCE_FILTER_LINE(FILTER_SEPIA, filter_sepia),
+  SHADER_SOURCE_FILTER_LINE(FILTER_SEPIA_NOMUL, filter_sepia_nomul),
+  SHADER_SOURCE_FILTER_LINE(FILTER_SEPIA_BGRA, filter_sepia_bgra),
+  SHADER_SOURCE_FILTER_LINE(FILTER_SEPIA_BGRA_NOMUL, filter_sepia_bgra_nomul)/* , */
+  /* SHADER_SOURCE_LINE(FILTER_BLUR, filter_blur), */
+  /* SHADER_SOURCE_LINE(FILTER_BLUR_NOMUL, filter_blur_nomul), */
+  /* SHADER_SOURCE_LINE(FILTER_BLUR_BGRA, filter_blur_bgra), */
+  /* SHADER_SOURCE_LINE(FILTER_BLUR_BGRA_NOMUL, filter_blur_bgra_nomul) */
+};
+
 static int
 _evas_gl_common_shader_source_init(Evas_GL_Shared *shared)
 {
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.rect),
-                                                   &(shader_rect_vert_src),
-                                                   &(shader_rect_frag_src),
-                                                   "rect")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.font),
-                                                   &(shader_font_vert_src),
-                                                   &(shader_font_frag_src),
-                                                   "font")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.img),
-                                                   &(shader_img_vert_src),
-                                                   &(shader_img_frag_src),
-                                                   "img")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.img_nomul),
-                                                   &(shader_img_nomul_vert_src),
-                                                   &(shader_img_nomul_frag_src),
-                                                   "img_nomul")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.img_bgra),
-                                                   &(shader_img_bgra_vert_src),
-                                                &(shader_img_bgra_frag_src),
-                                                   "img_bgra")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.img_bgra_nomul),
-                                                   &(shader_img_bgra_nomul_vert_src),
-                                                   &(shader_img_bgra_nomul_frag_src),
-                                                   "img_bgra_nomul")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.img_mask),
-                                                   &(shader_img_mask_vert_src),
-                                                   &(shader_img_mask_frag_src),
-                                                   "img_mask")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.tex),
-                                                   &(shader_tex_vert_src),
-                                                   &(shader_tex_frag_src),
-                                                   "tex")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.tex_nomul),
-                                                   &(shader_tex_nomul_vert_src),
-                                                   &(shader_tex_nomul_frag_src),
-                                                   "tex_nomul")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.yuv),
-                                                   &(shader_yuv_vert_src),
-                                                   &(shader_yuv_frag_src),
-                                                   "yuv")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.yuy2),
-                                                   &(shader_yuy2_vert_src),
-                                                   &(shader_yuy2_frag_src),
-                                                   "yuy2")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.yuy2_nomul),
-                                                   &(shader_yuy2_nomul_vert_src),
-                                                   &(shader_yuy2_nomul_frag_src),
-                                                   "yuy2_nomul")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.yuv_nomul),
-                                                   &(shader_yuv_nomul_vert_src),
-                                                   &(shader_yuv_nomul_frag_src),
-                                                   "yuv_nomul")) return 0;
+  unsigned int i;
 
-   /* Most of the filters use the image fragment shader */
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_invert),
-                                                   &(shader_img_vert_src),
-                                                   &(shader_filter_invert_frag_src),
-                                                   "filter_invert")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_invert_nomul),
-                                                   &(shader_img_vert_src),
-                                                   &(shader_filter_invert_nomul_frag_src),
-                                                   "filter_invert_nomul")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_invert_bgra),
-                                                   &(shader_img_vert_src),
-                                                   &(shader_filter_invert_bgra_frag_src),
-                                                   "filter_invert_bgra")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_invert_bgra_nomul),
-                                                   &(shader_img_vert_src),
-                                                   &(shader_filter_invert_bgra_nomul_frag_src),
-                                                   "filter_invert_bgra_nomul")) return 0;
-
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_sepia),
-                                                   &(shader_img_vert_src),
-                                                   &(shader_filter_sepia_frag_src),
-                                                   "filter_sepia")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_sepia_nomul),
-                                                   &(shader_img_vert_src),
-                                                   &(shader_filter_sepia_nomul_frag_src),
-                                                   "filter_sepia_nomul")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_sepia_bgra),
-                                                   &(shader_img_vert_src),
-                                                   &(shader_filter_sepia_bgra_frag_src),
-                                                   "filter_sepia_bgra")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_sepia_bgra_nomul),
-                                                   &(shader_img_vert_src),
-                                                   &(shader_filter_sepia_bgra_nomul_frag_src),
-                                                   "filter_sepia_bgra_nomul")) return 0;
-
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_greyscale),
-                                                   &(shader_img_vert_src),
-                                                   &(shader_filter_greyscale_frag_src),
-                                                   "filter_greyscale")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_greyscale_nomul),
-                                                   &(shader_img_vert_src),
-                                                   &(shader_filter_greyscale_nomul_frag_src),
-                                                   "filter_greyscale_nomul")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_greyscale_bgra),
-                                                   &(shader_img_vert_src),
-                                                   &(shader_filter_greyscale_bgra_frag_src),
-                                                   "filter_greyscale_bgra")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_greyscale_bgra_nomul),
-                                                   &(shader_img_vert_src),
-                                                   &(shader_filter_greyscale_bgra_nomul_frag_src),
-                                                   "filter_greyscale_bgra_nomul")) return 0;
-#if 0
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_blur),
-                                                   &(shader_filter_blur_vert_src),
-                                                   &(shader_filter_blur_frag_src),
-                                                   "filter_blur")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_blur_nomul),
-                                                   &(shader_filter_blur_vert_src),
-                                                   &(shader_filter_blur_nomul_frag_src),
-                                                   "filter_blur_nomul")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_blur_bgra),
-                                                   &(shader_filter_blur_vert_src),
-                                                   &(shader_filter_blur_bgra_frag_src),
-                                                   "filter_blur_bgra")) return 0;
-   if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_blur_bgra_nomul),
-                                                   &(shader_filter_blur_vert_src),
-                                                   &(shader_filter_blur_bgra_nomul_frag_src),
-                                                   "filter_blur_bgra_nomul")) return 0;
-#endif
+  for (i = 0; i < sizeof (_shaders_source) / sizeof (_shaders_source[0]); ++i)
+    if (!_evas_gl_common_shader_program_source_init(&(shared->shader[_shaders_source[i].id]),
+                                                    _shaders_source[i].vert,
+                                                    _shaders_source[i].frag,
+                                                    _shaders_source[i].name))
+        return 0;
 
    return 1;
 }
@@ -1142,6 +1072,7 @@ _evas_gl_common_shader_binary_init(Evas_GL_Shared *shared)
    Eet_File *et = NULL;
    char bin_dir_path[PATH_MAX];
    char bin_file_path[PATH_MAX];
+   unsigned int i;
 
    if (!_evas_gl_shader_dir_check(bin_dir_path, sizeof(bin_dir_path)))
       return 0;
@@ -1155,41 +1086,11 @@ _evas_gl_common_shader_binary_init(Evas_GL_Shared *shared)
    et = eet_open(bin_file_path, EET_FILE_MODE_READ);
    if (!et) goto error;
 
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.rect), "rect", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.font), "font", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.img), "img", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.img_nomul), "img_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.img_bgra), "img_bgra", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.img_bgra_nomul), "img_bgra_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.img_mask), "img_mask", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.tex), "tex", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.tex_nomul),"tex_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.yuv), "yuv", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.yuy2), "yuy2", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.yuv_nomul), "yuv_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.yuy2_nomul), "yuy2_nomul", et)) goto error;
-
-   /* Most of the filters use the image fragment shader */
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_invert), "filter_invert", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_invert_nomul), "filter_invert_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_invert_bgra), "filter_invert_bgra", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_invert_bgra_nomul), "filter_invert_bgra_nomul", et)) goto error;
-
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_sepia), "filter_sepia", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_sepia_nomul), "filter_sepia_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_sepia_bgra), "filter_sepia_bgra", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_sepia_bgra_nomul), "filter_sepia_bgra_nomul", et)) goto error;
-
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_greyscale), "filter_greyscale", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_greyscale_nomul), "filter_greyscale_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_greyscale_bgra), "filter_greyscale_bgra", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_greyscale_bgra_nomul), "filter_greyscale_bgra_nomul", et)) goto error;
-#if 0
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_blur), "filter_blur", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_blur_nomul), "filter_blur_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_blur_bgra), "filter_blur_bgra", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_init(&(shared->shader.filter_blur_bgra_nomul), "filter_blur_bgra_nomul", et)) goto error;
-#endif
+   for (i = 0; i < sizeof (_shaders_source) / sizeof (_shaders_source[0]); ++i)
+     if (!_evas_gl_common_shader_program_binary_init(&(shared->shader[_shaders_source[i].id]),
+                                                     _shaders_source[i].name,
+                                                     et))
+       goto error;
 
    if (et) eet_close(et);
    eet_shutdown();
@@ -1211,6 +1112,7 @@ _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared)
    char bin_dir_path[PATH_MAX];
    char bin_file_path[PATH_MAX];
    char tmp_file[PATH_MAX];
+   unsigned int i;
 
    if (!_evas_gl_shader_dir_check(bin_dir_path, sizeof(bin_dir_path)))
       res = _evas_gl_shader_file_mkpath(bin_dir_path);
@@ -1231,40 +1133,11 @@ _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared)
    et = eet_open(tmp_file, EET_FILE_MODE_WRITE);
    if (!et) goto error;
 
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.rect), "rect", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.font), "font", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.img), "img", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.img_nomul), "img_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.img_bgra), "img_bgra", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.img_bgra_nomul), "img_bgra_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.img_mask), "img_mask", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.tex), "tex", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.tex_nomul),"tex_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.yuv), "yuv", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.yuy2), "yuy2", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.yuv_nomul), "yuv_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.yuy2_nomul), "yuy2_nomul", et)) goto error;
-   /* Most of the filters use the image fragment shader */
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_invert), "filter_invert", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_invert_nomul), "filter_invert_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_invert_bgra), "filter_invert_bgra", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_invert_bgra_nomul), "filter_invert_bgra_nomul", et)) goto error;
-
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_sepia), "filter_sepia", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_sepia_nomul), "filter_sepia_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_sepia_bgra), "filter_sepia_bgra", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_sepia_bgra_nomul), "filter_sepia_bgra_nomul", et)) goto error;
-
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_greyscale), "filter_greyscale", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_greyscale_nomul), "filter_greyscale_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_greyscale_bgra), "filter_greyscale_bgra", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_greyscale_bgra_nomul), "filter_greyscale_bgra_nomul", et)) goto error;
-#if 0
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_blur), "filter_blur", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_blur_nomul), "filter_blur_nomul", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_blur_bgra), "filter_blur_bgra", et)) goto error;
-   if (!_evas_gl_common_shader_program_binary_save(&(shared->shader.filter_blur_bgra_nomul), "filter_blur_bgra_nomul", et)) goto error;
-#endif
+   for (i = 0; i < sizeof (_shaders_source) / sizeof (_shaders_source[0]); ++i)
+     if (!_evas_gl_common_shader_program_binary_save(&(shared->shader[_shaders_source[i].id]),
+                                                     _shaders_source[i].name,
+                                                     et))
+       goto error;
 
    if (eet_close(et) != EET_ERROR_NONE) goto error;
    if (rename(tmp_file,bin_file_path) < 0) goto error;