fix slowdown - drew empty shadow when didnt need to.
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 13 Apr 2011 09:29:45 +0000 (09:29 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 13 Apr 2011 09:29:45 +0000 (09:29 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@58623 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/canvas/evas_object_text.c
src/lib/canvas/evas_object_textblock.c

index fe75108..b396345 100644 (file)
@@ -1630,93 +1630,100 @@ evas_object_text_render(Evas_Object *obj, void *output, void *context, void *sur
                     it->text, &it->text_props);
    EINA_INLIST_FOREACH(EINA_INLIST_GET(o->items), it)
      {
-        int shad_dst, shad_sz, dx, dy;
+        int shad_dst, shad_sz, dx, dy, haveshad;
 
         /* shadows */
-        shad_dst = shad_sz = dx = dy = 0;
+        shad_dst = shad_sz = dx = dy = haveshad = 0;
         switch (o->cur.style & EVAS_TEXT_STYLE_MASK_BASIC)
           {
            case EVAS_TEXT_STYLE_SHADOW:
            case EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW:
              shad_dst = 1;
+             haveshad = 1;
              break;
            case EVAS_TEXT_STYLE_OUTLINE_SHADOW:
            case EVAS_TEXT_STYLE_FAR_SHADOW:
              shad_dst = 2;
+             haveshad = 1;
              break;
            case EVAS_TEXT_STYLE_FAR_SOFT_SHADOW:
              shad_dst = 2;
              shad_sz = 2;
+             haveshad = 1;
              break;
            case EVAS_TEXT_STYLE_SOFT_SHADOW:
              shad_dst = 1;
              shad_sz = 2;
+             haveshad = 1;
              break;
            default:
              break;
           }
-        if (shad_dst > 0)
+        if (haveshad)
           {
-             switch (o->cur.style & EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION)
+             if (shad_dst > 0)
                {
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT:
-                  dx = 1;
-                  dy = 1;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM:
-                  dx = 0;
-                  dy = 1;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT:
-                  dx = -1;
-                  dy = 1;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT:
-                  dx = -1;
-                  dy = 0;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT:
-                  dx = -1;
-                  dy = -1;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP:
-                  dx = 0;
-                  dy = -1;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT:
-                  dx = 1;
-                  dy = -1;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT:
-                  dx = 1;
-                  dy = 0;
-                default:
-                  break;
+                  switch (o->cur.style & EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION)
+                    {
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT:
+                       dx = 1;
+                       dy = 1;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM:
+                       dx = 0;
+                       dy = 1;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT:
+                       dx = -1;
+                       dy = 1;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT:
+                       dx = -1;
+                       dy = 0;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT:
+                       dx = -1;
+                       dy = -1;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP:
+                       dx = 0;
+                       dy = -1;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT:
+                       dx = 1;
+                       dy = -1;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT:
+                       dx = 1;
+                       dy = 0;
+                     default:
+                       break;
+                    }
+                  dx *= shad_dst;
+                  dy *= shad_dst;
                }
-             dx *= shad_dst;
-             dy *= shad_dst;
-          }
-        switch (shad_sz)
-          {
-           case 0:
-             COLOR_SET(o, cur, shadow);
-             DRAW_TEXT(dx, dy);
-             break;
-           case 2:
-             for (j = 0; j < 5; j++)
+             switch (shad_sz)
                {
-                  for (i = 0; i < 5; i++)
+                case 0:
+                  COLOR_SET(o, cur, shadow);
+                  DRAW_TEXT(dx, dy);
+                  break;
+                case 2:
+                  for (j = 0; j < 5; j++)
                     {
-                       if (vals[i][j] != 0)
+                       for (i = 0; i < 5; i++)
                          {
-                            COLOR_SET_AMUL(o, cur, shadow, vals[i][j] * 50);
-                            DRAW_TEXT(i - 2 + dx, j - 2 + dy);
+                            if (vals[i][j] != 0)
+                              {
+                                 COLOR_SET_AMUL(o, cur, shadow, vals[i][j] * 50);
+                                 DRAW_TEXT(i - 2 + dx, j - 2 + dy);
+                              }
                          }
                     }
+                  break;
+                default:
+                  break;
                }
-             break;
-           default:
-             break;
           }
         
         /* glows */
index aa02d26..406eedb 100644 (file)
@@ -1371,7 +1371,7 @@ _format_command(Evas_Object *obj, Evas_Object_Textblock_Format *fmt, const char
    else if (cmd == stylestr)
      {
         char *p1, *p2, *p, *pp;
-        
+
         p1 = alloca(len + 1);
         *p1 = 0;
         p2 = alloca(len + 1);
@@ -2583,8 +2583,7 @@ _text_item_update_sizes(Ctxt *c, Evas_Object_Textblock_Text_Item *ti)
 
    /* These adjustments are calculated and thus heavily linked to those in
     * textblock_render!!! Don't change one without the other. */
-   
-   // XXX: YYY: handle EVAS_TEXT_STYLE_SHADOW_DIRECTION*
+
    switch (ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC)
      {
       case EVAS_TEXT_STYLE_SHADOW:
@@ -8004,96 +8003,103 @@ evas_object_textblock_render(Evas_Object *obj, void *output, void *context, void
    /* shadows */
    ITEM_WALK()
      {
-        int shad_dst, shad_sz, dx, dy;
+        int shad_dst, shad_sz, dx, dy, haveshad;
         Evas_Object_Textblock_Text_Item *ti;
         ITEM_WALK_LINE_SKIP_DROP();
         ti = (itr->type == EVAS_TEXTBLOCK_ITEM_TEXT) ? _ITEM_TEXT(itr) : NULL;
         if (!ti) continue;
 
-        shad_dst = shad_sz = dx = dy = 0;
+        shad_dst = shad_sz = dx = dy = haveshad = 0;
         switch (ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC)
           {
            case EVAS_TEXT_STYLE_SHADOW:
            case EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW:
              shad_dst = 1;
+             haveshad = 1;
              break;
            case EVAS_TEXT_STYLE_OUTLINE_SHADOW:
            case EVAS_TEXT_STYLE_FAR_SHADOW:
              shad_dst = 2;
+             haveshad = 1;
              break;
            case EVAS_TEXT_STYLE_FAR_SOFT_SHADOW:
              shad_dst = 2;
              shad_sz = 2;
+             haveshad = 1;
              break;
            case EVAS_TEXT_STYLE_SOFT_SHADOW:
              shad_dst = 1;
              shad_sz = 2;
+             haveshad = 1;
              break;
            default:
              break;
           }
-        if (shad_dst > 0)
+        if (haveshad)
           {
-             switch (ti->parent.format->style & EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION)
+             if (shad_dst > 0)
                {
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT:
-                  dx = 1;
-                  dy = 1;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM:
-                  dx = 0;
-                  dy = 1;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT:
-                  dx = -1;
-                  dy = 1;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT:
-                  dx = -1;
-                  dy = 0;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT:
-                  dx = -1;
-                  dy = -1;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP:
-                  dx = 0;
-                  dy = -1;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT:
-                  dx = 1;
-                  dy = -1;
-                  break;
-                case EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT:
-                  dx = 1;
-                  dy = 0;
-                default:
-                  break;
+                  switch (ti->parent.format->style & EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION)
+                    {
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT:
+                       dx = 1;
+                       dy = 1;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM:
+                       dx = 0;
+                       dy = 1;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT:
+                       dx = -1;
+                       dy = 1;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT:
+                       dx = -1;
+                       dy = 0;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT:
+                       dx = -1;
+                       dy = -1;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP:
+                       dx = 0;
+                       dy = -1;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT:
+                       dx = 1;
+                       dy = -1;
+                       break;
+                     case EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT:
+                       dx = 1;
+                       dy = 0;
+                     default:
+                       break;
+                    }
+                  dx *= shad_dst;
+                  dy *= shad_dst;
                }
-             dx *= shad_dst;
-             dy *= shad_dst;
-          }
-        switch (shad_sz)
-          {
-           case 0:
-             COLOR_SET(shadow);
-             DRAW_TEXT(dx, dy);
-             break;
-           case 2:
-             for (j = 0; j < 5; j++)
+             switch (shad_sz)
                {
-                  for (i = 0; i < 5; i++)
+                case 0:
+                  COLOR_SET(shadow);
+                  DRAW_TEXT(dx, dy);
+                  break;
+                case 2:
+                  for (j = 0; j < 5; j++)
                     {
-                       if (vals[i][j] != 0)
+                       for (i = 0; i < 5; i++)
                          {
-                            COLOR_SET_AMUL(shadow, vals[i][j] * 50);
-                            DRAW_TEXT(i - 2 + dx, j - 2 + dy);
+                            if (vals[i][j] != 0)
+                              {
+                                 COLOR_SET_AMUL(shadow, vals[i][j] * 50);
+                                 DRAW_TEXT(i - 2 + dx, j - 2 + dy);
+                              }
                          }
                     }
+                  break;
+                default:
+                  break;
                }
-             break;
-           default:
-             break;
           }
      }
    ITEM_WALK_END();