more work putting shared bits in shared. but context seems to be a big problem.
authorCarsten Haitzler <raster@rasterman.com>
Tue, 13 Oct 2009 09:40:39 +0000 (09:40 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Tue, 13 Oct 2009 09:40:39 +0000 (09:40 +0000)
:(

SVN revision: 43048

legacy/evas/src/modules/engines/gl_common/evas_gl_common.h
legacy/evas/src/modules/engines/gl_common/evas_gl_context.c
legacy/evas/src/modules/engines/gl_common/evas_gl_font.c
legacy/evas/src/modules/engines/gl_common/evas_gl_image.c
legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c
legacy/evas/src/modules/engines/gl_x11/evas_engine.c
legacy/evas/src/modules/engines/gl_x11/evas_x_main.c

index 05684d1..e16df6f 100644 (file)
@@ -48,6 +48,7 @@
 
 typedef struct _Evas_GL_Program                      Evas_GL_Program;
 typedef struct _Evas_GL_Program_Source               Evas_GL_Program_Source;
+typedef struct _Evas_GL_Shared                       Evas_GL_Shared;
 typedef struct _Evas_GL_Context                      Evas_GL_Context;
 typedef struct _Evas_GL_Texture_Pool                 Evas_GL_Texture_Pool;
 typedef struct _Evas_GL_Texture                      Evas_GL_Texture;
@@ -73,31 +74,56 @@ struct _Evas_GL_Program_Source
    int bin_size;
 };
 
+struct _Evas_GL_Shared
+{
+   Eina_List          *images;
+   
+   struct {
+      GLint max_texture_units;
+      GLint max_texture_size;
+      Eina_Bool tex_npo2 : 1;
+      Eina_Bool tex_rect : 1;
+   } info;
+   
+   struct {
+      Eina_List       *whole;
+      Eina_List       *atlas[33][3];
+   } tex;
+   
+   struct {
+      Evas_GL_Program  rect, img, font, yuv;
+   } shader;
+   int references;
+   int w, h;
+};
+
 struct _Evas_GL_Context
 {
    int                references;
    int                w, h;
    RGBA_Draw_Context  *dc;
    
+   Evas_GL_Shared     *shared;
+/*   
    Eina_List          *images;
 
    struct {
       Eina_List       *whole;
       Eina_List       *atlas[33][3];
    } tex;
-   
    struct {
       GLint max_texture_units;
       GLint max_texture_size;
       Eina_Bool tex_npo2 : 1;
       Eina_Bool tex_rect : 1;
    } info;
+ */
    struct {
       int             x, y, w, h;
       Eina_Bool       active : 1;
    } clip;
    struct {
-      Evas_GL_Program rect, img, font, yuv;
+/*      Evas_GL_Program rect, img, font, yuv;*/
       GLuint          cur_prog;
       GLuint          cur_tex, cur_texu, cur_texv;
       Eina_Bool       smooth : 1;
@@ -121,7 +147,6 @@ struct _Evas_GL_Context
    struct {
       Eina_Bool size : 1;
    } change;
-   Eina_Bool checked : 1;
 };
 
 struct _Evas_GL_Texture_Pool
@@ -141,6 +166,7 @@ struct _Evas_GL_Texture
    Evas_GL_Context *gc;
    Evas_GL_Texture_Pool *pt, *ptu, *ptv;
    int              x, y, w, h;
+   double           sx1, sy1, sx2, sy2;
    int              references;
 };
 
index f07a5fa..0c65fe1 100644 (file)
@@ -1,9 +1,9 @@
 #include "evas_gl_private.h"
-
-static void _evas_gl_common_viewport_set(Evas_GL_Context *gc);
+  
 static void shader_array_flush(Evas_GL_Context *gc);
 
 static Evas_GL_Context *_evas_gl_common_context = NULL;
+static Evas_GL_Shared *shared = NULL;
 
 void
 glerr(const char *file, const char *func, int line, const char *op)
@@ -32,16 +32,76 @@ glerr(const char *file, const char *func, int line, const char *op)
      }
 }
 
+static void
+matrix_ident(GLfloat *m)
+{
+   memset(m, 0, 16 * sizeof(GLfloat));
+   m[0] = m[5] = m[10] = m[15] = 1.0;
+}
+
+static void
+matrix_ortho(GLfloat *m, GLfloat l, GLfloat r, GLfloat t, GLfloat b, GLfloat near, GLfloat far)
+{
+   m[0] = 2.0 / (r - l);
+   m[1] = m[2] = m[3] = 0.0;
+   
+   m[4] = 0.0;
+   m[5] = 2.0 / (t - b);
+   m[6] = m[7] = 0.0;
+   
+   m[8] = m[9] = 0.0;
+   m[10] = -(2.0 / (far - near));
+   m[11] = 0.0;
+   
+   m[12] = -((r + l)/(r - l));
+   m[13] = -((t + b)/(t - b));
+   m[14] = -((near + far)/(far - near));
+   m[15] = 1.0;
+}
+
+static void
+_evas_gl_common_viewport_set(Evas_GL_Context *gc)
+{
+   GLfloat proj[16];
+
+   if ((!gc->change.size) || 
+       ((gc->shared->w == gc->w) && (gc->shared->h == gc->h)))
+     return;
+   gc->shared->w = gc->w;
+   gc->shared->h = gc->h;
+   gc->change.size = 0;
+   
+   glViewport(0, 0, gc->w, gc->h);
+   
+   matrix_ident(proj);
+   matrix_ortho(proj, 0, gc->w, 0, gc->h, -1.0, 1.0);
+   
+   glUseProgram(gc->shared->shader.rect.prog);
+   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.rect.prog, "mvp"), 1,
+                      GL_FALSE, proj);
+   glUseProgram(gc->shared->shader.img.prog);
+   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.img.prog, "mvp"), 1,
+                      GL_FALSE, proj);
+   glUseProgram(gc->shared->shader.font.prog);
+   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.font.prog, "mvp"), 1,
+                      GL_FALSE, proj);
+   glUseProgram(gc->shared->shader.yuv.prog);
+   glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.yuv.prog, "mvp"), 1,
+                      GL_FALSE, proj);
+}
+
 Evas_GL_Context *
 evas_gl_common_context_new(void)
 {
    Evas_GL_Context *gc;
 
+#if 1
    if (_evas_gl_common_context)
      {
        _evas_gl_common_context->references++;
        return _evas_gl_common_context;
      }
+#endif   
    gc = calloc(1, sizeof(Evas_GL_Context));
    if (!gc) return NULL;
 
@@ -49,37 +109,38 @@ evas_gl_common_context_new(void)
    
    _evas_gl_common_context = gc;
 
-   if (!gc->checked)
+   if (!shared)
      {
         GLint linked;
         unsigned int pixel = 0xffffffff;
         const GLubyte *ext;
-        
+
+        shared = calloc(1, sizeof(Evas_GL_Shared));
         ext = glGetString(GL_EXTENSIONS);
         if (ext)
           {
              fprintf(stderr, "EXT:\n%s\n", ext);
              if ((strstr(ext, "GL_ARB_texture_non_power_of_two")) ||
                  (strstr(ext, "OES_texture_npot")))
-               gc->info.tex_npo2 = 1;
+               shared->info.tex_npo2 = 1;
              if ((strstr(ext, "GL_NV_texture_rectangle")) ||
                  (strstr(ext, "GL_EXT_texture_rectangle")))
-               gc->info.tex_rect = 1;
+               shared->info.tex_rect = 1;
           }
         glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,
-                      &(gc->info.max_texture_units));
+                      &(shared->info.max_texture_units));
         glGetIntegerv(GL_MAX_TEXTURE_SIZE,
-                      &(gc->info.max_texture_size));
+                      &(shared->info.max_texture_size));
         
         fprintf(stderr, "max tex size %ix%i\n"
                 "max units %i\n"
                 "non-power-2 tex %i\n"
                 "rect tex %i\n"
                 , 
-                gc->info.max_texture_size, gc->info.max_texture_size,
-                gc->info.max_texture_units,
-                (int)gc->info.tex_npo2,
-                (int)gc->info.tex_rect
+                shared->info.max_texture_size, shared->info.max_texture_size,
+                shared->info.max_texture_units,
+                (int)shared->info.tex_npo2,
+                (int)shared->info.tex_rect
                 );
         
         glDisable(GL_DEPTH_TEST);
@@ -101,29 +162,32 @@ evas_gl_common_context_new(void)
         glEnableVertexAttribArray(SHAD_COLOR);
         glEnableVertexAttribArray(SHAD_TEXUV);
         
-        evas_gl_common_shader_program_init(&(gc->shader.rect), 
+        evas_gl_common_shader_program_init(&(shared->shader.rect), 
                                            &(shader_rect_vert_src), 
                                            &(shader_rect_frag_src),
                                            "rect");
-        evas_gl_common_shader_program_init(&(gc->shader.img),
+        evas_gl_common_shader_program_init(&(shared->shader.img),
                                            &(shader_img_vert_src),
                                            &(shader_img_frag_src),
                                            "img");
-        evas_gl_common_shader_program_init(&(gc->shader.font),
+        evas_gl_common_shader_program_init(&(shared->shader.font),
                                            &(shader_font_vert_src), 
                                            &(shader_font_frag_src),
                                            "font");
 #if defined (GLES_VARIETY_S3C6410)
-        evas_gl_common_shader_program_init(&(gc->shader.yuv),
+        evas_gl_common_shader_program_init(&(shared->shader.yuv),
                                            &(shader_img_vert_src),
                                            &(shader_img_frag_src),
                                            "yuv");
 #else        
-        evas_gl_common_shader_program_init(&(gc->shader.yuv),
+        evas_gl_common_shader_program_init(&(shared->shader.yuv),
                                            &(shader_yuv_vert_src), 
                                            &(shader_yuv_frag_src),
                                            "yuv");
-        glUseProgram(gc->shader.yuv.prog);
+        glUseProgram(shared->shader.yuv.prog);
+        glUniform1i(glGetUniformLocation(shared->shader.yuv.prog, "tex"), 0);
+        glUniform1i(glGetUniformLocation(shared->shader.yuv.prog, "texu"), 1);
+        glUniform1i(glGetUniformLocation(shared->shader.yuv.prog, "texv"), 2);
 #endif        
         // in shader:
         // uniform sampler2D tex[8];
@@ -132,13 +196,10 @@ evas_gl_common_context_new(void)
         // GLuint texes[8];
         // GLint loc = glGetUniformLocation(prog, "tex");
         // glUniform1iv(loc, 8, texes);
-        
-        glUniform1i(glGetUniformLocation(gc->shader.yuv.prog, "tex"), 0);
-        glUniform1i(glGetUniformLocation(gc->shader.yuv.prog, "texu"), 1);
-        glUniform1i(glGetUniformLocation(gc->shader.yuv.prog, "texv"), 2);
-        _evas_gl_common_viewport_set(gc);
-        gc->checked = 1;
      }
+   gc->shared = shared;
+   gc->shared->references++;
+   _evas_gl_common_viewport_set(gc);
    
    return gc;
 }
@@ -150,23 +211,29 @@ evas_gl_common_context_free(Evas_GL_Context *gc)
    
    gc->references--;
    if (gc->references > 0) return;
-   while (gc->images)
+   gc->shared->references--;
+   if (gc->shared->references == 0)
      {
-        evas_gl_common_image_free(gc->images->data);
-     }
-   while (gc->tex.whole)
-     {
-        evas_gl_common_texture_free(gc->tex.whole->data);
-     }
-   for (i = 0; i < 33; i++)
-     {
-        for (j = 0; j < 3; j++)
+        while (gc->shared->images)
           {
-             while (gc->tex.atlas[i][j])
-               evas_gl_common_texture_free(gc->tex.atlas[i][j]);
+             evas_gl_common_image_free(gc->shared->images->data);
           }
+        while (gc->shared->tex.whole)
+          {
+             evas_gl_common_texture_free(gc->shared->tex.whole->data);
+          }
+        for (i = 0; i < 33; i++)
+          {
+             for (j = 0; j < 3; j++)
+               {
+                  while (gc->shared->tex.atlas[i][j])
+                    evas_gl_common_texture_free(gc->shared->tex.atlas[i][j]);
+               }
+          }
+        free(gc->shared);
+        shared = NULL;
+        // FIXME: free shader.rect.prog etc. etc.
      }
-   // FIXME: free shader.rect.prog etc. etc.
    
    free(gc->array.vertex);
    free(gc->array.color);
@@ -181,8 +248,9 @@ evas_gl_common_context_free(Evas_GL_Context *gc)
 void
 evas_gl_common_context_use(Evas_GL_Context *gc)
 {
-   if (_evas_gl_common_context == gc) return;
-//   _evas_gl_common_context = gc;
+//   if (_evas_gl_common_context == gc) return;
+   _evas_gl_common_context = gc;
+   _evas_gl_common_viewport_set(gc);
 }
 
 void
@@ -247,13 +315,13 @@ evas_gl_common_context_rectangle_push(Evas_GL_Context *gc,
    
    if (a < 255) blend = 1;
    if ((gc->shader.cur_tex != 0)
-       || (gc->shader.cur_prog != gc->shader.rect.prog)
+       || (gc->shader.cur_prog != gc->shared->shader.rect.prog)
        || (gc->shader.blend != blend)
        )
      {
         shader_array_flush(gc);
         gc->shader.cur_tex = 0;
-        gc->shader.cur_prog = gc->shader.rect.prog;
+        gc->shader.cur_prog = gc->shared->shader.rect.prog;
         gc->shader.blend = blend;
      }
    
@@ -297,14 +365,14 @@ evas_gl_common_context_image_push(Evas_GL_Context *gc,
    if (a < 255) blend = 1;
    
    if ((gc->shader.cur_tex != tex->pt->texture)
-       || (gc->shader.cur_prog != gc->shader.img.prog)
+       || (gc->shader.cur_prog != gc->shared->shader.img.prog)
        || (gc->shader.smooth != smooth)
        || (gc->shader.blend != blend)
        )
      {
         shader_array_flush(gc);
         gc->shader.cur_tex = tex->pt->texture;
-        gc->shader.cur_prog = gc->shader.img.prog;
+        gc->shader.cur_prog = gc->shared->shader.img.prog;
         gc->shader.smooth = smooth;
         gc->shader.blend = blend;
      }
@@ -353,14 +421,14 @@ evas_gl_common_context_font_push(Evas_GL_Context *gc,
    GLfloat rr, gg, bb, aa, tx1, tx2, ty1, ty2;
 
    if ((gc->shader.cur_tex != tex->pt->texture)
-       || (gc->shader.cur_prog != gc->shader.font.prog)
+       || (gc->shader.cur_prog != gc->shared->shader.font.prog)
        || (gc->shader.smooth != 0)
        || (gc->shader.blend != 1)
        )
      {
         shader_array_flush(gc);
         gc->shader.cur_tex = tex->pt->texture;
-        gc->shader.cur_prog = gc->shader.font.prog;
+        gc->shader.cur_prog = gc->shared->shader.font.prog;
         gc->shader.smooth = 0;
         gc->shader.blend = 1;
      }
@@ -370,10 +438,20 @@ evas_gl_common_context_font_push(Evas_GL_Context *gc,
    gc->array.num += 6;
    _evas_gl_common_context_array_alloc(gc);
 
-   tx1 = ((double)(tex->x) + sx) / (double)tex->pt->w;
-   ty1 = ((double)(tex->y) + sy) / (double)tex->pt->h;
-   tx2 = ((double)(tex->x) + sx + sw) / (double)tex->pt->w;
-   ty2 = ((double)(tex->y) + sy + sh) / (double)tex->pt->h;
+   if (sw == 0.0)
+     {
+        tx1 = tex->sx1;
+        ty1 = tex->sy1;
+        tx2 = tex->sx2;
+        ty2 = tex->sy2;
+     }
+   else
+     {
+        tx1 = ((double)(tex->x) + sx) / (double)tex->pt->w;
+        ty1 = ((double)(tex->y) + sy) / (double)tex->pt->h;
+        tx2 = ((double)(tex->x) + sx + sw) / (double)tex->pt->w;
+        ty2 = ((double)(tex->y) + sy + sh) / (double)tex->pt->h;
+     }
    
    PUSH_VERTEX(x    , y    , 0);
    PUSH_VERTEX(x + w, y    , 0);
@@ -413,7 +491,7 @@ evas_gl_common_context_yuv_push(Evas_GL_Context *gc,
    if (a < 255) blend = 1;
    
    if ((gc->shader.cur_tex != tex->pt->texture)
-       || (gc->shader.cur_prog != gc->shader.yuv.prog)
+       || (gc->shader.cur_prog != gc->shared->shader.yuv.prog)
        || (gc->shader.smooth != smooth)
        || (gc->shader.blend != blend)
        )
@@ -422,7 +500,7 @@ evas_gl_common_context_yuv_push(Evas_GL_Context *gc,
         gc->shader.cur_tex = tex->pt->texture;
         gc->shader.cur_texu = tex->ptu->texture;
         gc->shader.cur_texv = tex->ptv->texture;
-        gc->shader.cur_prog = gc->shader.yuv.prog;
+        gc->shader.cur_prog = gc->shared->shader.yuv.prog;
         gc->shader.smooth = smooth;
         gc->shader.blend = blend;
      }
@@ -578,57 +656,3 @@ shader_array_flush(Evas_GL_Context *gc)
    gc->array.num = 0;
    gc->array.alloc = 0;
 }
-
-static void
-matrix_ident(GLfloat *m)
-{
-   memset(m, 0, 16 * sizeof(GLfloat));
-   m[0] = m[5] = m[10] = m[15] = 1.0;
-}
-
-static void
-matrix_ortho(GLfloat *m, GLfloat l, GLfloat r, GLfloat t, GLfloat b, GLfloat near, GLfloat far)
-{
-   m[0] = 2.0 / (r - l);
-   m[1] = m[2] = m[3] = 0.0;
-   
-   m[4] = 0.0;
-   m[5] = 2.0 / (t - b);
-   m[6] = m[7] = 0.0;
-   
-   m[8] = m[9] = 0.0;
-   m[10] = -(2.0 / (far - near));
-   m[11] = 0.0;
-   
-   m[12] = -((r + l)/(r - l));
-   m[13] = -((t + b)/(t - b));
-   m[14] = -((near + far)/(far - near));
-   m[15] = 1.0;
-}
-
-static void
-_evas_gl_common_viewport_set(Evas_GL_Context *gc)
-{
-   GLfloat proj[16];
-   
-   if (!gc->change.size) return;
-   gc->change.size = 0;
-   
-   glViewport(0, 0, gc->w, gc->h);
-   
-   matrix_ident(proj);
-   matrix_ortho(proj, 0, gc->w, 0, gc->h, -1.0, 1.0);
-   
-   glUseProgram(gc->shader.rect.prog);
-   glUniformMatrix4fv(glGetUniformLocation(gc->shader.rect.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   glUseProgram(gc->shader.img.prog);
-   glUniformMatrix4fv(glGetUniformLocation(gc->shader.img.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   glUseProgram(gc->shader.font.prog);
-   glUniformMatrix4fv(glGetUniformLocation(gc->shader.font.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-   glUseProgram(gc->shader.yuv.prog);
-   glUniformMatrix4fv(glGetUniformLocation(gc->shader.yuv.prog, "mvp"), 1,
-                      GL_FALSE, proj);
-}
index 439a72d..ee27564 100644 (file)
@@ -19,8 +19,7 @@ evas_gl_font_texture_new(Evas_GL_Context *gc, RGBA_Font_Glyph *fg)
    j = fg->glyph_out->bitmap.pitch;
    if (j < w) j = w;
 
-   /* bug bug! glTexSubImage2D need a multiple of 4 pixels horizontally! :( */
-   nw = ((w + 3) / 4 ) * 4;
+   nw = w;
    ndata = alloca(nw *h);
    if (!ndata) return NULL;
    if (fg->glyph_out->bitmap.num_grays == 256)
@@ -82,6 +81,10 @@ evas_gl_font_texture_new(Evas_GL_Context *gc, RGBA_Font_Glyph *fg)
 //   fh = h;
    fh = fg->fi->max_h;
    tex = evas_gl_common_texture_alpha_new(gc, ndata, w, h, fh);
+   tex->sx1 = ((double)(tex->x)) / (double)tex->pt->w;
+   tex->sy1 = ((double)(tex->y)) / (double)tex->pt->h;
+   tex->sx2 = ((double)(tex->x + tex->w)) / (double)tex->pt->w;
+   tex->sy2 = ((double)(tex->y + tex->h)) / (double)tex->pt->h;
    return tex;
 }
 
@@ -129,7 +132,8 @@ evas_gl_font_texture_draw(Evas_GL_Context *gc, void *surface __UNUSED__, RGBA_Dr
              if ((nx == x) && (ny == y) && (nw == tex->w) && (nh == tex->h))
                {
                   evas_gl_common_context_font_push(gc, tex,
-                                                   sx, sy, sw, sh,
+                                                   0.0, 0.0, 0.0, 0.0,
+//                                                   sx, sy, sw, sh,
                                                    x, y, tex->w, tex->h,
                                                    r, g, b, a);
                   return;
@@ -146,7 +150,8 @@ evas_gl_font_texture_draw(Evas_GL_Context *gc, void *surface __UNUSED__, RGBA_Dr
         else
           {
              evas_gl_common_context_font_push(gc, tex, 
-                                              sx, sy, sw, sh,
+                                              0.0, 0.0, 0.0, 0.0,
+//                                              sx, sy, sw, sh,
                                               x, y, tex->w, tex->h,
                                               r, g, b, a);
           }
@@ -174,7 +179,8 @@ evas_gl_font_texture_draw(Evas_GL_Context *gc, void *surface __UNUSED__, RGBA_Dr
         if ((nx == x) && (ny == y) && (nw == tex->w) && (nh == tex->h))
           {
              evas_gl_common_context_font_push(gc, tex,
-                                              sx, sy, sw, sh,
+                                              0.0, 0.0, 0.0, 0.0,
+//                                              sx, sy, sw, sh,
                                               x, y, tex->w, tex->h,
                                               r, g, b, a);
              continue;
index f1b12a1..71a7fe5 100644 (file)
@@ -10,13 +10,13 @@ evas_gl_common_image_load(Evas_GL_Context *gc, const char *file, const char *key
    im_im = evas_common_load_image_from_file(file, key, lo);
    if (!im_im) return NULL;
 
-   EINA_LIST_FOREACH(gc->images, l, im)
+   EINA_LIST_FOREACH(gc->shared->images, l, im)
      {
        if (im->im == im_im)
          {
              evas_cache_image_drop(&im_im->cache_entry);
-            gc->images = eina_list_remove_list(gc->images, l);
-            gc->images = eina_list_prepend(gc->images, im);
+            gc->shared->images = eina_list_remove_list(gc->shared->images, l);
+            gc->shared->images = eina_list_prepend(gc->shared->images, im);
             im->references++;
             return im;
          }
@@ -31,7 +31,7 @@ evas_gl_common_image_load(Evas_GL_Context *gc, const char *file, const char *key
    im->cached = 1;
    im->cs.space = EVAS_COLORSPACE_ARGB8888;
    if (lo) im->load_opts = *lo;
-   gc->images = eina_list_prepend(gc->images, im);
+   gc->shared->images = eina_list_prepend(gc->shared->images, im);
    return im;
 }
 
@@ -41,14 +41,14 @@ evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, DATA32 *da
    Evas_GL_Image *im;
    Eina_List *l;
 
-   EINA_LIST_FOREACH(gc->images, l, im)
+   EINA_LIST_FOREACH(gc->shared->images, l, im)
      {
        if (((void *)(im->im->image.data) == (void *)data) &&
            (im->im->cache_entry.w == w) &&
            (im->im->cache_entry.h == h))
          {
-            gc->images = eina_list_remove_list(gc->images, l);
-            gc->images = eina_list_prepend(gc->images, im);
+            gc->shared->images = eina_list_remove_list(gc->shared->images, l);
+            gc->shared->images = eina_list_prepend(gc->shared->images, im);
             im->references++;
             return im;
          }
@@ -82,7 +82,7 @@ evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, DATA32 *da
      }
    /*
     im->cached = 1;
-    gc->images = eina_list_prepend(gc->images, im);
+    gc->shared->images = eina_list_prepend(gc->shared->images, im);
     */
    return im;
 }
@@ -171,7 +171,7 @@ evas_gl_common_image_free(Evas_GL_Image *im)
      {
        if (!im->cs.no_free) free(im->cs.data);
      }
-   if (im->cached) im->gc->images = eina_list_remove(im->gc->images, im);
+   if (im->cached) im->gc->shared->images = eina_list_remove(im->gc->shared->images, im);
    if (im->im) evas_cache_image_drop(&im->im->cache_entry);
    if (im->tex) evas_gl_common_texture_free(im->tex);
    free(im);
index 4a4b652..6aa936b 100644 (file)
@@ -18,8 +18,8 @@ _tex_adjust(Evas_GL_Context *gc, int *w, int *h)
    unsigned int n;
    
 // disable - has a bug somewhere   
-//   if (gc->info.tex_npo2) return;
-   /*if (gc->info.tex_rect) return;*/
+//   if (gc->shared->info.tex_npo2) return;
+   /*if (gc->shared->info.tex_rect) return;*/
    *w = _nearest_pow2(*w);
    *h = _nearest_pow2(*h);
 }
@@ -28,7 +28,7 @@ static int
 _tex_round_slot(Evas_GL_Context *gc, int h)
 {
 // disable. has a bug somewhere   
-//   if (!gc->info.tex_npo2)
+//   if (!gc->shared->info.tex_npo2)
      h = _nearest_pow2(h);
    return (h + 15) >> 4;
 }
@@ -132,7 +132,7 @@ _pool_tex_find(Evas_GL_Context *gc, int w, int h, GLuint format, int *u, int *v,
    if ((w > 512) || (h > 512))
      {
         pt = _pool_tex_new(gc, w + 2, h + 1, format);
-        gc->tex.whole = eina_list_prepend(gc->tex.whole, pt);
+        gc->shared->tex.whole = eina_list_prepend(gc->shared->tex.whole, pt);
         pt->slot = -1;
         pt->fslot = -1;
         pt->whole = 1;
@@ -144,19 +144,19 @@ _pool_tex_find(Evas_GL_Context *gc, int w, int h, GLuint format, int *u, int *v,
    
    th = _tex_round_slot(gc, h);
    th2 = _tex_format_index(format);
-   EINA_LIST_FOREACH(gc->tex.atlas[th][th2], l, pt)
+   EINA_LIST_FOREACH(gc->shared->tex.atlas[th][th2], l, pt)
      {
         if (_pool_tex_alloc(pt, format, w, h, u, v, l_after))
           {
-             gc->tex.atlas[th][th2] = 
-               eina_list_remove_list(gc->tex.atlas[th][th2], l);
-             gc->tex.atlas[th][th2] = 
-               eina_list_prepend(gc->tex.atlas[th][th2], pt);
+             gc->shared->tex.atlas[th][th2] = 
+               eina_list_remove_list(gc->shared->tex.atlas[th][th2], l);
+             gc->shared->tex.atlas[th][th2] = 
+               eina_list_prepend(gc->shared->tex.atlas[th][th2], pt);
              return pt;
           }
      }
    pt = _pool_tex_new(gc, atlas_w, h, format);
-   gc->tex.atlas[th][th2] = eina_list_prepend(gc->tex.atlas[th][th2], pt);
+   gc->shared->tex.atlas[th][th2] = eina_list_prepend(gc->shared->tex.atlas[th][th2], pt);
    pt->slot = th;
    pt->fslot = th2;
    *u = 0;
@@ -284,12 +284,12 @@ pt_unref(Evas_GL_Texture_Pool *pt)
    if (pt->references > 0) return;
    if (pt->whole)
      {
-        pt->gc->tex.whole = eina_list_remove(pt->gc->tex.whole, pt);
+        pt->gc->shared->tex.whole = eina_list_remove(pt->gc->shared->tex.whole, pt);
      }
    else
      {
-        pt->gc->tex.atlas [pt->slot][pt->fslot] =
-          eina_list_remove(pt->gc->tex.atlas[pt->slot][pt->fslot], pt);
+        pt->gc->shared->tex.atlas [pt->slot][pt->fslot] =
+          eina_list_remove(pt->gc->shared->tex.atlas[pt->slot][pt->fslot], pt);
      }
    glDeleteTextures(1, &(pt->texture));
    free(pt);
@@ -321,7 +321,8 @@ evas_gl_common_texture_alpha_new(Evas_GL_Context *gc, DATA8 *pixels, int w, int
    
    tex->gc = gc;
    tex->references = 1;
-   if (tw > gc->info.max_texture_size) tw = gc->info.max_texture_size;
+   if (tw > gc->shared->info.max_texture_size)
+     tw = gc->shared->info.max_texture_size;
    tex->pt = _pool_tex_find(gc, w + 3, fh, GL_ALPHA,
                             &u, &v, &l_after, tw);
    if (!tex->pt)
@@ -349,7 +350,7 @@ evas_gl_common_texture_alpha_update(Evas_GL_Texture *tex, DATA8 *pixels, int w,
 #ifdef GL_UNPACK_ROW_LENGTH   
    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
 #endif   
-   glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    glTexSubImage2D(GL_TEXTURE_2D, 0,
                   tex->x, tex->y, w, h,
                   GL_ALPHA, GL_UNSIGNED_BYTE,
@@ -373,17 +374,17 @@ evas_gl_common_texture_yuv_new(Evas_GL_Context *gc, DATA8 **rows, int w, int h)
    tex->gc = gc;
    tex->references = 1;
    tex->pt = _pool_tex_new(gc, w + 1, h  + 1, GL_LUMINANCE);
-   gc->tex.whole = eina_list_prepend(gc->tex.whole, tex->pt);
+   gc->shared->tex.whole = eina_list_prepend(gc->shared->tex.whole, tex->pt);
    tex->pt->slot = -1;
    tex->pt->fslot = -1;
    tex->pt->whole = 1;
    tex->ptu = _pool_tex_new(gc, (w / 2) + 1, (h / 2)  + 1, GL_LUMINANCE);
-   gc->tex.whole = eina_list_prepend(gc->tex.whole, tex->ptu);
+   gc->shared->tex.whole = eina_list_prepend(gc->shared->tex.whole, tex->ptu);
    tex->ptu->slot = -1;
    tex->ptu->fslot = -1;
    tex->ptu->whole = 1;
    tex->ptv = _pool_tex_new(gc, (w / 2) + 1, (h / 2)  + 1, GL_LUMINANCE);
-   gc->tex.whole = eina_list_prepend(gc->tex.whole, tex->ptv);
+   gc->shared->tex.whole = eina_list_prepend(gc->shared->tex.whole, tex->ptv);
    tex->ptv->slot = -1;
    tex->ptv->fslot = -1;
    tex->ptv->whole = 1;
index 35715a7..d4314a9 100644 (file)
@@ -103,12 +103,14 @@ eng_setup(Evas *e, void *in)
                                 info->info.depth,
                                 e->output.w,
                                 e->output.h);
+        
      }
    if (!e->engine.data.output) return 0;
    if (!e->engine.data.context)
      e->engine.data.context =
      e->engine.func->context_new(e->engine.data.output);
-
+   eng_window_use(re->win);
+   
    return 1;
 }
 
@@ -133,6 +135,7 @@ eng_output_resize(void *data, int w, int h)
    re = (Render_Engine *)data;
    re->win->w = w;
    re->win->h = h;
+   eng_window_use(re->win);
    evas_gl_common_context_resize(re->win->gl_context, w, h);
 }
 
@@ -275,6 +278,7 @@ eng_output_flush(void *data)
    re->win->draw.drew = 0;
    eng_window_use(re->win);
 
+//   glFlush();
 # if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
    eglSwapBuffers(re->win->egl_disp, re->win->egl_surface[0]);
 #else
index 6ebd10c..a41012b 100644 (file)
@@ -6,7 +6,7 @@ static Evas_GL_X11_Window *_evas_gl_x11_window = NULL;
 static EGLContext context = EGL_NO_CONTEXT;
 #else
 // FIXME: this will only work for 1 display connection (glx land can have > 1)
-static GLXContext context = NULL;
+static GLXContext context = 0;
 #endif
 
 XVisualInfo *_evas_gl_x11_vi = NULL;
@@ -133,11 +133,19 @@ eng_window_new(Display *disp,
      }
 // GLX   
 #else
+
+#if 1
    if (!context)
      context = glXCreateContext(disp, gw->visualinfo, NULL, GL_TRUE);
    gw->context = context;
+#else   
+   gw->context = glXCreateContext(disp, gw->visualinfo, context, GL_TRUE);
+   if (!context) context = gw->context;
+#endif   
+   
    glXMakeCurrent(gw->disp, gw->win, gw->context);
 #endif
+   _evas_gl_x11_window = gw;
    
    gw->gl_context = evas_gl_common_context_new();
    if (!gw->gl_context)
@@ -145,6 +153,7 @@ eng_window_new(Display *disp,
        free(gw);
        return NULL;
      }
+   evas_gl_common_context_use(gw->gl_context);
    evas_gl_common_context_resize(gw->gl_context, w, h);
    return gw;
 }
@@ -157,7 +166,7 @@ eng_window_free(Evas_GL_X11_Window *gw)
 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
    if (gw->egl_surface[0] != EGL_NO_SURFACE)
      eglDestroySurface(gw->egl_disp, gw->egl_surface[0]);
-#else   
+#else
    // FIXME: refcount context   
    //   glXDestroyContext(gw->disp, gw->context);
 #endif