* evas: make map work with threaded rendering.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 24 Mar 2010 16:39:39 +0000 (16:39 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 24 Mar 2010 16:39:39 +0000 (16:39 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@47429 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/engines/common/evas_map_image.h
src/lib/engines/common/evas_pipe.c
src/lib/engines/common/evas_pipe.h
src/lib/include/evas_common.h
src/modules/engines/buffer/evas_engine.c
src/modules/engines/fb/evas_engine.c
src/modules/engines/software_ddraw/evas_engine.c
src/modules/engines/software_gdi/evas_engine.c
src/modules/engines/software_generic/evas_engine.c
src/modules/engines/software_qtopia/evas_engine.c
src/modules/engines/software_x11/evas_engine.c

index 24209db..1e33771 100644 (file)
@@ -5,26 +5,6 @@
 #ifndef _EVAS_MAP_H
 #define _EVAS_MAP_H
 
-typedef struct _RGBA_Map_Point RGBA_Map_Point;
-
-// all coords are 20.12
-// fp type - an int for now
-typedef int FPc;
-// fp # of bits of float accuracy
-#define FP 8
-// fp half (half of an fp unit)
-#define FPH (1 << (FP - 1))
-// one fp unit
-#define FP1 (1 << (FP))
-
-struct _RGBA_Map_Point
-{
-   FPc x, y; // x, y screenspace
-   FPc z; // z in world space. optional
-   FPc u, v; // u, v in tex coords
-   DATA32 col; // color at this point
-};
-
 EAPI void
 evas_common_map4_rgba(RGBA_Image *src, RGBA_Image *dst,
                       RGBA_Draw_Context *dc,
index 1187183..7841951 100644 (file)
@@ -676,4 +676,100 @@ evas_common_pipe_image_draw(RGBA_Image *src, RGBA_Image *dst,
    op->free_func = evas_common_pipe_op_image_free;
    evas_common_pipe_draw_context_copy(dc, op);
 }
+
+static void
+evas_common_pipe_op_map4_free(RGBA_Pipe_Op *op)
+{
+   op->op.map4.src->ref--;
+   if (op->op.map4.src->ref == 0)
+     evas_cache_image_drop(&op->op.map4.src->cache_entry);
+   free(op->op.map4.p);
+   evas_common_pipe_op_free(op);
+}
+
+static void
+evas_common_pipe_map4_draw_do(RGBA_Image *dst, RGBA_Pipe_Op *op, RGBA_Pipe_Thread_Info *info)
+{
+   if (info)
+     {
+       RGBA_Draw_Context context;
+
+       memcpy(&(context), &(op->context), sizeof(RGBA_Draw_Context));
+#ifdef EVAS_SLI
+       evas_common_draw_context_set_sli(&(context), info->y, info->h);
+#else
+       evas_common_draw_context_clip_clip(&(context), info->x, info->y, info->w, info->h);
+#endif
+
+       evas_common_map4_rgba(op->op.map4.src, dst,
+                             &context, op->op.map4.p,
+                             op->op.map4.smooth, op->op.map4.level);
+     }
+   else
+     {
+       evas_common_map4_rgba(op->op.map4.src, dst,
+                             &(op->context), op->op.map4.p,
+                             op->op.map4.smooth, op->op.map4.level);
+     }
+}
+
+EAPI void
+evas_common_pipe_map4_draw(RGBA_Image *src, RGBA_Image *dst,
+                          RGBA_Draw_Context *dc, RGBA_Map_Point *p,
+                          int smooth, int level)
+{
+   RGBA_Pipe_Op *op;
+   RGBA_Map_Point *pts_copy;
+   int i;
+
+   if (!src) return;
+   pts_copy = malloc(sizeof (RGBA_Map_Point) * 4);
+   if (!pts_copy) return;
+   dst->pipe = evas_common_pipe_add(dst->pipe, &op);
+   if (!dst->pipe) 
+     {
+       free(pts_copy);
+       return; 
+     }
+
+   for (i = 0; i < 4; ++i)
+     pts_copy[i] = p[i];
+
+   op->op.map4.smooth = smooth;
+   op->op.map4.level = level;
+   src->ref++;
+   op->op.map4.src = src;
+   op->op.map4.p = pts_copy;
+   op->op_func = evas_common_pipe_map4_draw_do;
+   op->free_func = evas_common_pipe_op_map4_free;
+   evas_common_pipe_draw_context_copy(dc, op);
+}
+
+EAPI void
+evas_common_pipe_map4_begin(RGBA_Image *root)
+{
+  RGBA_Pipe *p;
+  int i;
+
+  /* Map imply that we need to process them recursively first. */
+  for (p = root->pipe; p; p = (RGBA_Pipe *)(EINA_INLIST_GET(p))->next)
+    {
+      for (i = 0; i < p->op_num; i++) 
+       {
+         if (p->op[i].op_func == evas_common_pipe_map4_draw_do)
+           {
+             if (p->op[i].op.map4.src->pipe)
+               evas_common_pipe_map4_begin(p->op[i].op.map4.src);
+           }
+         else if (p->op[i].op_func == evas_common_pipe_image_draw_do)
+           {
+             if (p->op[i].op.image.src->pipe)
+               evas_common_pipe_map4_begin(p->op[i].op.image.src);
+           }
+       }
+    }
+
+  evas_common_pipe_begin(root);
+  evas_common_pipe_flush(root);
+}
 #endif
index 43f02a6..92e1721 100644 (file)
@@ -16,6 +16,8 @@ EAPI void evas_common_pipe_grad_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int
 EAPI void evas_common_pipe_grad2_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, int w, int h, RGBA_Gradient2 *gr);
 EAPI void evas_common_pipe_text_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int x, int y, const char *text);
 EAPI void evas_common_pipe_image_draw(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int smooth, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h);
-
+EAPI void evas_common_pipe_map4_draw(RGBA_Image *src, RGBA_Image *dst,
+                                    RGBA_Draw_Context *dc, RGBA_Map_Point *p,
+                                    int smooth, int level);
 
 #endif /* _EVAS_PIPE_H */
index 3f1e7e5..926c486 100644 (file)
@@ -362,6 +362,7 @@ typedef struct _RGBA_Gradient2         RGBA_Gradient2;
 typedef struct _RGBA_Gradient2_Type    RGBA_Gradient2_Type;
 typedef struct _RGBA_Gradient2_Color_Np_Stop   RGBA_Gradient2_Color_Np_Stop;
 typedef struct _RGBA_Polygon_Point    RGBA_Polygon_Point;
+typedef struct _RGBA_Map_Point        RGBA_Map_Point;
 typedef struct _RGBA_Font             RGBA_Font;
 typedef struct _RGBA_Font_Int         RGBA_Font_Int;
 typedef struct _RGBA_Font_Source      RGBA_Font_Source;
@@ -379,6 +380,17 @@ typedef struct _Tilebuf_Rect               Tilebuf_Rect;
 
 typedef struct _Evas_Common_Transform        Evas_Common_Transform;
 
+// RGBA_Map_Point
+// all coords are 20.12
+// fp type - an int for now
+typedef int FPc;
+// fp # of bits of float accuracy
+#define FP 8
+// fp half (half of an fp unit)
+#define FPH (1 << (FP - 1))
+// one fp unit
+#define FP1 (1 << (FP))
+
 /*
 typedef struct _Regionbuf             Regionbuf;
 typedef struct _Regionspan            Regionspan;
@@ -652,6 +664,12 @@ struct _RGBA_Pipe_Op
         int                 smooth;
         char               *text;
       } image;
+      struct {
+        RGBA_Image         *src;
+        RGBA_Map_Point     *p;
+        int                 smooth;
+        int                 level;
+      } map4;
    } op;
 };
 
@@ -853,6 +871,14 @@ struct _RGBA_Polygon_Point
    int               x, y;
 };
 
+struct _RGBA_Map_Point
+{
+   FPc x, y; // x, y screenspace
+   FPc z; // z in world space. optional
+   FPc u, v; // u, v in tex coords
+   DATA32 col; // color at this point
+};
+
 // for fonts...
 /////
 typedef struct _Fash_Item_Index_Map Fash_Item_Index_Map;
index 9f599be..1c6abc0 100644 (file)
@@ -306,8 +306,7 @@ eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int
 
    re = (Render_Engine *)data;
 #ifdef BUILD_PIPE_RENDER
-   evas_common_pipe_begin(surface);
-   evas_common_pipe_flush(surface);
+   evas_common_pipe_map4_begin(surface);
 #endif   
    evas_buffer_outbuf_buf_push_updated_region(re->ob, surface, x, y, w, h);
    evas_buffer_outbuf_buf_free_region_for_update(re->ob, surface);
index 76398a7..47386ba 100644 (file)
@@ -223,8 +223,7 @@ eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int
 
    re = (Render_Engine *)data;
 #ifdef BUILD_PIPE_RENDER
-   evas_common_pipe_begin(surface);
-   evas_common_pipe_flush(surface);
+   evas_common_pipe_map4_begin(surface);
 #endif   
    evas_fb_outbuf_fb_push_updated_region(re->ob, surface, x, y, w, h);
    evas_fb_outbuf_fb_free_region_for_update(re->ob, surface);
index 17573fb..426f949 100644 (file)
@@ -287,8 +287,7 @@ eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int
 
    re = (Render_Engine *)data;
 #ifdef BUILD_PIPE_RENDER
-   evas_common_pipe_begin(surface);
-   evas_common_pipe_flush(surface);
+   evas_common_pipe_map4_begin(surface);
 #endif   
    evas_software_ddraw_outbuf_push_updated_region(re->ob, surface, x, y, w, h);
    evas_software_ddraw_outbuf_free_region_for_update(re->ob, surface);
index e1f7237..d635147 100644 (file)
@@ -294,8 +294,7 @@ eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int
 
    re = (Render_Engine *)data;
 #ifdef BUILD_PIPE_RENDER
-   evas_common_pipe_begin(surface);
-   evas_common_pipe_flush(surface);
+   evas_common_pipe_map4_begin(surface);
 #endif
    evas_software_gdi_outbuf_push_updated_region(re->ob, surface, x, y, w, h);
    evas_software_gdi_outbuf_free_region_for_update(re->ob, surface);
index 568bcdd..ffda08f 100644 (file)
@@ -814,7 +814,12 @@ eng_image_map4_draw(void *data __UNUSED__, void *context, void *surface, void *i
            dx, dy, dw, dh, smooth);
      }
    else
-     evas_common_map4_rgba(im, surface, context, p, smooth, level);
+#ifdef BUILD_PIPE_RENDER
+     if (cpunum > 1)
+       evas_common_pipe_map4_draw(im, surface, context, p, smooth, level);
+     else
+#endif
+       evas_common_map4_rgba(im, surface, context, p, smooth, level);
    evas_common_cpu_end_opt();
 }
 
index 9a24189..89b139a 100644 (file)
@@ -237,8 +237,7 @@ eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int
 
    re = (Render_Engine *)data;
 #ifdef BUILD_PIPE_RENDER
-   evas_common_pipe_begin(surface);
-   evas_common_pipe_flush(surface);
+   evas_common_pipe_map4_begin(surface);
 #endif   
    evas_qtopia_outbuf_software_qtopia_push_updated_region(re->ob, surface, x, y, w, h);
    evas_qtopia_outbuf_software_qtopia_free_region_for_update(re->ob, surface);
index 9cd0ef2..69d4108 100644 (file)
@@ -661,8 +661,7 @@ eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int
 
    re = (Render_Engine *)data;
 #ifdef BUILD_PIPE_RENDER
-   evas_common_pipe_begin(surface);
-   evas_common_pipe_flush(surface);
+   evas_common_pipe_map4_begin(surface);
 #endif   
    re->outbuf_push_updated_region(re->ob, surface, x, y, w, h);
    re->outbuf_free_region_for_update(re->ob, surface);