Revert "Upstream merge"
[framework/uifw/evas.git] / src / modules / engines / software_generic / evas_engine.c
index f0a11ba..5540b3e 100644 (file)
@@ -1,8 +1,5 @@
 #include "evas_common.h" /* Also includes international specific stuff */
 #include "evas_private.h"
-#ifdef EVAS_CSERVE2
-#include "evas_cs2_private.h"
-#endif
 
 #ifdef HAVE_DLSYM
 # include <dlfcn.h>      /* dlopen,dlclose,etc */
@@ -75,7 +72,7 @@ struct _Render_Engine_GL_Surface
    int     depth_bits;
    int     stencil_bits;
 
-   // Data 
+   // Data
    void   *buffer;
 
    Render_Engine_GL_Context   *current_ctx;
@@ -441,7 +438,11 @@ static void
 eng_rectangle_draw(void *data __UNUSED__, void *context, void *surface, int x, int y, int w, int h)
 {
 #ifdef BUILD_PIPE_RENDER
-   if ((cpunum > 1))
+   if ((cpunum > 1)
+#ifdef EVAS_FRAME_QUEUING
+        && evas_common_frameq_enabled()
+#endif
+        )
      evas_common_pipe_rectangle_draw(surface, context, x, y, w, h);
    else
 #endif
@@ -455,7 +456,11 @@ static void
 eng_line_draw(void *data __UNUSED__, void *context, void *surface, int x1, int y1, int x2, int y2)
 {
 #ifdef BUILD_PIPE_RENDER
-   if ((cpunum > 1))
+   if ((cpunum > 1)
+ #ifdef EVAS_FRAME_QUEUING
+        && evas_common_frameq_enabled()
+#endif
+        )
     evas_common_pipe_line_draw(surface, context, x1, y1, x2, y2);
    else
 #endif   
@@ -481,7 +486,11 @@ static void
 eng_polygon_draw(void *data __UNUSED__, void *context, void *surface, void *polygon, int x, int y)
 {
 #ifdef BUILD_PIPE_RENDER
-   if ((cpunum > 1))
+   if ((cpunum > 1)
+#ifdef EVAS_FRAME_QUEUING
+        && evas_common_frameq_enabled()
+#endif
+        )
      evas_common_pipe_poly_draw(surface, context, polygon, x, y);
    else
 #endif
@@ -637,8 +646,8 @@ eng_image_native_set(void *data __UNUSED__, void *image, void *native __UNUSED__
 
    if (!ns) return im;
 
-   im2 = evas_cache_image_data(evas_common_image_cache_get(), 
-                               im->w, im->h, 
+   im2 = evas_cache_image_data(evas_common_image_cache_get(),
+                               im->w, im->h,
                                ns->data.x11.visual, 1,
                                EVAS_COLORSPACE_ARGB8888);
    evas_cache_image_drop(im);
@@ -658,58 +667,24 @@ static void *
 eng_image_load(void *data __UNUSED__, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
 {
    *error = EVAS_LOAD_ERROR_NONE;
-#ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
-     {
-        Image_Entry *ie;
-        ie = evas_cache2_image_open(evas_common_image_cache2_get(),
-                                    file, key, lo, error);
-        if (ie)
-          evas_cache2_image_open_wait(ie);
-
-        return ie;
-     }
-#endif
    return evas_common_load_image_from_file(file, key, lo, error);
 }
 
 static void *
 eng_image_new_from_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
 {
-#ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
-     {
-        Evas_Cache2 *cache = evas_common_image_cache2_get();
-        return evas_cache2_image_data(cache, w, h, image_data, alpha, cspace);
-     }
-#endif
    return evas_cache_image_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
 }
 
 static void *
 eng_image_new_from_copied_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
 {
-#ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
-     {
-        Evas_Cache2 *cache = evas_common_image_cache2_get();
-        return evas_cache2_image_copied_data(cache, w, h, image_data, alpha,
-                                             cspace);
-     }
-#endif
    return evas_cache_image_copied_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
 }
 
 static void
 eng_image_free(void *data __UNUSED__, void *image)
 {
-#ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
-     {
-        evas_cache2_image_close(image);
-        return;
-     }
-#endif
    evas_cache_image_drop(image);
 }
 
@@ -728,10 +703,6 @@ eng_image_size_set(void *data __UNUSED__, void *image, int w, int h)
 {
    Image_Entry *im = image;
    if (!im) return NULL;
-#ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
-     return evas_cache2_image_size_set(im, w, h);
-#endif
    return evas_cache_image_size_set(im, w, h);
 }
 
@@ -740,10 +711,6 @@ eng_image_dirty_region(void *data __UNUSED__, void *image, int x, int y, int w,
 {
    Image_Entry *im = image;
    if (!im) return NULL;
-#ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
-     return evas_cache2_image_dirty(im, x, y, w, h);
-#endif
    return evas_cache_image_dirty(im, x, y, w, h);
 }
 
@@ -751,7 +718,7 @@ static void *
 eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **image_data, int *err)
 {
    RGBA_Image *im;
-   int error = EVAS_LOAD_ERROR_NONE;
+   int error;
 
    if (!image)
      {
@@ -759,21 +726,6 @@ eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **im
        return NULL;
      }
    im = image;
-
-#ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
-     {
-        error = evas_cache2_image_load_data(&im->cache_entry);
-        if (err) *err = error;
-
-        if (to_write)
-          im = (RGBA_Image *)evas_cache2_image_writable(&im->cache_entry);
-
-        *image_data = im->image.data;
-        return im;
-     }
-#endif
-
    error = evas_cache_image_load_data(&im->cache_entry);
    switch (im->cache_entry.space)
      {
@@ -816,14 +768,6 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data)
             im2 = eng_image_new_from_data(data, w, h, image_data,
                                           eng_image_alpha_get(data, image),
                                           eng_image_colorspace_get(data, image));
-#ifdef EVAS_CSERVE2
-             if (evas_cserve2_use_get())
-               {
-                  evas_cache2_image_close(&im->cache_entry);
-                  im = im2;
-                  break;
-               }
-#endif
              evas_cache_image_drop(&im->cache_entry);
             im = im2;
          }
@@ -854,15 +798,8 @@ static void
 eng_image_data_preload_request(void *data __UNUSED__, void *image, const void *target)
 {
    RGBA_Image *im = image;
-   if (!im) return ;
 
-#ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
-     {
-        evas_cache2_image_preload_data(&im->cache_entry, target);
-        return;
-     }
-#endif
+   if (!im) return ;
    evas_cache_image_preload_data(&im->cache_entry, target);
 }
 
@@ -870,10 +807,6 @@ static void
 eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *target)
 {
    RGBA_Image *im = image;
-#ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
-     return;
-#endif
 
    if (!im) return ;
    evas_cache_image_preload_cancel(&im->cache_entry, target);
@@ -887,12 +820,12 @@ eng_image_draw(void *data __UNUSED__, void *context, void *surface, void *image,
    if (!image) return;
    im = image;
 #ifdef BUILD_PIPE_RENDER
-   if ((cpunum > 1))
-     {
-#ifdef EVAS_CSERVE2
-        if (evas_cserve2_use_get())
-          evas_cache2_image_load_data(&im->cache_entry);
+   if ((cpunum > 1)
+#ifdef EVAS_FRAME_QUEUING
+        && evas_common_frameq_enabled()
 #endif
+        )
+     {
         evas_common_rgba_image_scalecache_prepare((Image_Entry *)(im), 
                                                   surface, context, smooth,
                                                   src_x, src_y, src_w, src_h,
@@ -905,18 +838,9 @@ eng_image_draw(void *data __UNUSED__, void *context, void *surface, void *image,
    else
 #endif
      {
-#ifdef EVAS_CSERVE2
-        if (evas_cserve2_use_get())
-          {
-             evas_cache2_image_load_data(&im->cache_entry);
-             goto image_loaded;
-          }
-#endif
-        if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
-          evas_cache_image_load_data(&im->cache_entry);
-        evas_common_image_colorspace_normalize(im);
-
-image_loaded:
+//        if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
+//          evas_cache_image_load_data(&im->cache_entry);
+//        evas_common_image_colorspace_normalize(im);
         evas_common_rgba_image_scalecache_prepare(&im->cache_entry, surface, context, smooth,
                                                   src_x, src_y, src_w, src_h,
                                                   dst_x, dst_y, dst_w, dst_h);
@@ -979,7 +903,11 @@ eng_image_map_draw(void *data __UNUSED__, void *context, void *surface, void *im
    else
      {
 #ifdef BUILD_PIPE_RENDER
-        if ((cpunum > 1))
+        if ((cpunum > 1)
+# ifdef EVAS_FRAME_QUEUING
+       && evas_common_frameq_enabled()
+# endif
+        )
           evas_common_pipe_map_draw(im, surface, context, npoints, p, smooth, level);
         else
 #endif
@@ -998,16 +926,6 @@ static void *
 eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha)
 {
    void *surface;
-#ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
-     {
-        surface = evas_cache2_image_copied_data(evas_common_image_cache2_get(),
-                                                w, h, NULL, alpha,
-                                                EVAS_COLORSPACE_ARGB8888);
-        evas_cache2_image_pixels(surface);
-        return surface;
-     }
-#endif
    surface = evas_cache_image_copied_data(evas_common_image_cache_get(), 
                                           w, h, NULL, alpha, 
                                           EVAS_COLORSPACE_ARGB8888);
@@ -1018,13 +936,6 @@ eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha)
 static void
 eng_image_map_surface_free(void *data __UNUSED__, void *surface)
 {
-#ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
-     {
-        evas_cache2_image_unload_data(surface);
-        return;
-     }
-#endif
    evas_cache_image_drop(surface);
 }
 
@@ -1276,12 +1187,18 @@ static void
 eng_font_draw(void *data __UNUSED__, void *context, void *surface, Evas_Font_Set *font, int x, int y, int w __UNUSED__, int h __UNUSED__, int ow __UNUSED__, int oh __UNUSED__, const Evas_Text_Props *text_props)
 {
 #ifdef BUILD_PIPE_RENDER
-   if ((cpunum > 1))
-     evas_common_pipe_text_draw(surface, context, x, y, text_props);
+   if ((cpunum > 1)
+#ifdef EVAS_FRAME_QUEUING
+        && evas_common_frameq_enabled()
+#endif
+        )
+     evas_common_pipe_text_draw(surface, context, (RGBA_Font *) font, x, y,
+           text_props);
    else
 #endif   
      {
-       evas_common_font_draw(surface, context, x, y, text_props);
+       evas_common_font_draw(surface, context, (RGBA_Font *) font, x, y,
+              text_props);
        evas_common_cpu_end_opt();
      }
 }
@@ -1475,7 +1392,7 @@ eng_gl_surface_create(void *data __UNUSED__, void *config, int w, int h)
          sfc->depth_bits = 0;
          break;
      }
-   
+
    // Stencil Bits
    switch (cfg->stencil_bits)
      {
@@ -1629,9 +1546,9 @@ eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
         else
            share_ctx = NULL;
 
-        ctx->context =  _sym_OSMesaCreateContextExt(sfc->internal_fmt, 
+        ctx->context =  _sym_OSMesaCreateContextExt(sfc->internal_fmt,
                                                sfc->depth_bits,
-                                               sfc->stencil_bits, 
+                                               sfc->stencil_bits,
                                                0,
                                                share_ctx);
         if (!ctx->context)
@@ -1645,7 +1562,7 @@ eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
 
 
    // Call MakeCurrent
-   ret = _sym_OSMesaMakeCurrent(ctx->context, sfc->buffer, GL_UNSIGNED_BYTE, 
+   ret = _sym_OSMesaMakeCurrent(ctx->context, sfc->buffer, GL_UNSIGNED_BYTE,
                            sfc->w, sfc->h);
 
    if (ret == GL_FALSE)
@@ -2367,9 +2284,9 @@ gl_sym_init(void)
 #undef FINDSYM
 #undef FALLBAK
 
-   // Checking to see if this function exists is a poor but reasonable way to 
+   // Checking to see if this function exists is a poor but reasonable way to
    // check if it's gles but it works for now
-   if (_sym_glGetShaderPrecisionFormat != (typeof(_sym_glGetShaderPrecisionFormat))sym_missing ) 
+   if (_sym_glGetShaderPrecisionFormat != (typeof(_sym_glGetShaderPrecisionFormat))sym_missing )
      {
         DBG("GL Library is GLES.");
         gl_lib_is_gles = 1;
@@ -2382,7 +2299,7 @@ gl_sym_init(void)
 // Wrapped GL APIs to handle desktop compatibility
 
 // Stripping precision code from GLES shader for desktop compatibility
-// Code adopted from Meego GL code. Temporary Fix.  
+// Code adopted from Meego GL code. Temporary Fix.
 static const char *
 opengl_strtok(const char *s, int *n, char **saveptr, char *prevbuf)
 {
@@ -2394,33 +2311,33 @@ opengl_strtok(const char *s, int *n, char **saveptr, char *prevbuf)
 
    if (prevbuf) free(prevbuf);
 
-   if (s) 
+   if (s)
       *saveptr = (char *)s;
-   else 
+   else
      {
         if (!(*saveptr) || !(*n))
            return NULL;
         s = *saveptr;
      }
 
-   for (; *n && strchr(delim, *s); s++, (*n)--) 
+   for (; *n && strchr(delim, *s); s++, (*n)--)
      {
-        if (*s == '/' && *n > 1) 
+        if (*s == '/' && *n > 1)
           {
-             if (s[1] == '/') 
+             if (s[1] == '/')
                {
-                  do 
+                  do
                     {
                        s++, (*n)--;
-                    } 
+                    }
                   while (*n > 1 && s[1] != '\n' && s[1] != '\r');
-               } 
-             else if (s[1] == '*') 
+               }
+             else if (s[1] == '*')
                {
-                  do 
+                  do
                     {
                        s++, (*n)--;
-                    } 
+                    }
                   while (*n > 2 && (s[1] != '*' || s[2] != '/'));
                   s++, (*n)--;
                }
@@ -2437,26 +2354,26 @@ opengl_strtok(const char *s, int *n, char **saveptr, char *prevbuf)
    ret = malloc(retlen + 1);
    p = ret;
 
-   while (retlen > 0) 
+   while (retlen > 0)
      {
-        if (*start == '/' && retlen > 1) 
+        if (*start == '/' && retlen > 1)
           {
-             if (start[1] == '/') 
+             if (start[1] == '/')
                {
-                  do 
+                  do
                     {
                        start++, retlen--;
-                    } 
+                    }
                   while (retlen > 1 && start[1] != '\n' && start[1] != '\r');
                   start++, retlen--;
                   continue;
-               } 
-             else if (start[1] == '*') 
+               }
+             else if (start[1] == '*')
                {
-                  do 
+                  do
                     {
                        start++, retlen--;
-                    } 
+                    }
                   while (retlen > 2 && (start[1] != '*' || start[2] != '/'));
                   start += 3, retlen -= 3;
                   continue;
@@ -2467,7 +2384,7 @@ opengl_strtok(const char *s, int *n, char **saveptr, char *prevbuf)
 
    *p = 0;
    return ret;
-}      
+}
 
 static char *
 patch_gles_shader(const char *source, int length, int *patched_len)
@@ -2485,55 +2402,55 @@ patch_gles_shader(const char *source, int length, int *patched_len)
    if (!patched) return NULL;
 
    p = (char *)opengl_strtok(source, &length, &saveptr, NULL);
-   for (; p; p = (char *)opengl_strtok(0, &length, &saveptr, p)) 
+   for (; p; p = (char *)opengl_strtok(0, &length, &saveptr, p))
      {
-        if (!strncmp(p, "lowp", 4) || !strncmp(p, "mediump", 7) || !strncmp(p, "highp", 5)) 
+        if (!strncmp(p, "lowp", 4) || !strncmp(p, "mediump", 7) || !strncmp(p, "highp", 5))
           {
              continue;
-          } 
-        else if (!strncmp(p, "precision", 9)) 
+          }
+        else if (!strncmp(p, "precision", 9))
           {
              while ((p = (char *)opengl_strtok(0, &length, &saveptr, p)) && !strchr(p, ';'));
-          } 
-        else 
+          }
+        else
           {
-             if (!strncmp(p, "gl_MaxVertexUniformVectors", 26)) 
+             if (!strncmp(p, "gl_MaxVertexUniformVectors", 26))
                {
                   p = "(gl_MaxVertexUniformComponents / 4)";
-               } 
-             else if (!strncmp(p, "gl_MaxFragmentUniformVectors", 28)) 
+               }
+             else if (!strncmp(p, "gl_MaxFragmentUniformVectors", 28))
                {
                   p = "(gl_MaxFragmentUniformComponents / 4)";
-               } 
-             else if (!strncmp(p, "gl_MaxVaryingVectors", 20)) 
+               }
+             else if (!strncmp(p, "gl_MaxVaryingVectors", 20))
                {
                   p = "(gl_MaxVaryingFloats / 4)";
                }
 
              int new_len = strlen(p);
-             if (*patched_len + new_len > patched_size) 
+             if (*patched_len + new_len > patched_size)
                {
                   patched_size *= 2;
                   patched = realloc(patched, patched_size + 1);
 
-                  if (!patched) 
+                  if (!patched)
                      return NULL;
                }
 
              memcpy(patched + *patched_len, p, new_len);
              *patched_len += new_len;
-          }     
+          }
      }
 
    patched[*patched_len] = 0;
    /* check that we don't leave dummy preprocessor lines */
-   for (sp = patched; *sp;) 
+   for (sp = patched; *sp;)
      {
         for (; *sp == ' ' || *sp == '\t'; sp++);
-        if (!strncmp(sp, "#define", 7)) 
+        if (!strncmp(sp, "#define", 7))
           {
              for (p = sp + 7; *p == ' ' || *p == '\t'; p++);
-             if (*p == '\n' || *p == '\r' || *p == '/') 
+             if (*p == '\n' || *p == '\r' || *p == '/')
                {
                   memset(sp, 0x20, 7);
                }
@@ -2555,21 +2472,21 @@ evgl_glShaderSource(GLuint shader, GLsizei count, const char** string, const GLi
    memset(s, 0, count * sizeof(char*));
    memset(l, 0, count * sizeof(GLint));
 
-   for (i = 0; i < count; ++i) 
+   for (i = 0; i < count; ++i)
      {
-        if (length) 
+        if (length)
           {
              len = length[i];
-             if (len < 0) 
+             if (len < 0)
                 len = string[i] ? strlen(string[i]) : 0;
           }
         else
            len = string[i] ? strlen(string[i]) : 0;
 
-        if (string[i]) 
+        if (string[i])
           {
              s[i] = patch_gles_shader(string[i], len, &l[i]);
-             if (!s[i]) 
+             if (!s[i])
                {
                   while(i)
                      free(s[--i]);
@@ -2579,8 +2496,8 @@ evgl_glShaderSource(GLuint shader, GLsizei count, const char** string, const GLi
                   DBG("Patching Shader Failed.");
                   return;
                }
-          } 
-        else 
+          }
+        else
           {
              s[i] = NULL;
              l[i] = 0;
@@ -2657,7 +2574,7 @@ override_gl_apis(Evas_GL_API *api)
    ORD(glCheckFramebufferStatus);
    ORD(glClear);
    ORD(glClearColor);
-   ORD(glClearDepthf);     
+   ORD(glClearDepthf);
    ORD(glClearStencil);
    ORD(glColorMask);
    ORD(glCompileShader);
@@ -2676,7 +2593,7 @@ override_gl_apis(Evas_GL_API *api)
    ORD(glDeleteTextures);
    ORD(glDepthFunc);
    ORD(glDepthMask);
-   ORD(glDepthRangef);     
+   ORD(glDepthRangef);
    ORD(glDetachShader);
    ORD(glDisable);
    ORD(glDisableVertexAttribArray);
@@ -2709,7 +2626,7 @@ override_gl_apis(Evas_GL_API *api)
    ORD(glGetRenderbufferParameteriv);
    ORD(glGetShaderiv);
    ORD(glGetShaderInfoLog);
-   ORD(glGetShaderPrecisionFormat);  
+   ORD(glGetShaderPrecisionFormat);
    ORD(glGetShaderSource);
    ORD(glGetString);             // FIXME
    ORD(glGetTexParameterfv);
@@ -2733,11 +2650,11 @@ override_gl_apis(Evas_GL_API *api)
    ORD(glPixelStorei);
    ORD(glPolygonOffset);
    ORD(glReadPixels);
-   ORD(glReleaseShaderCompiler); 
+   ORD(glReleaseShaderCompiler);
    ORD(glRenderbufferStorage);
    ORD(glSampleCoverage);
    ORD(glScissor);
-   ORD(glShaderBinary); 
+   ORD(glShaderBinary);
    ORD(glShaderSource);
    ORD(glStencilFunc);
    ORD(glStencilFuncSeparate);
@@ -2804,7 +2721,7 @@ static int
 gl_lib_init(void)
 {
 #ifdef EVAS_GL
-   // dlopen OSMesa 
+   // dlopen OSMesa
    gl_lib_handle = dlopen("libOSMesa.so.1", RTLD_NOW);
    if (!gl_lib_handle) gl_lib_handle = dlopen("libOSMesa.so", RTLD_NOW);
    if (!gl_lib_handle)