summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@samsung.com>2013-12-26 11:27:09 +0900
committerCedric BAIL <cedric.bail@samsung.com>2013-12-26 11:27:09 +0900
commit766bd426396e4771d2e22b83bf4110c466ad53d4 (patch)
tree3b18162a862efb1c373985662dcc4ae0fa4cd38f /src/lib
parent9749c8ff0b8a64c10bf2521f53070d8f99709d8a (diff)
evas: limit how many times we walk over items.
This does help for some textblock benchmark with a speed increase of 12% and the one that don't get better don't get slower either, so let's put that in.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c309
1 files changed, 177 insertions, 132 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 2b832c7de6..1fe0f1643b 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -10718,6 +10718,9 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED,
10718 {1, 3, 4, 3, 1}, 10718 {1, 3, 4, 3, 1},
10719 {0, 1, 2, 1, 0} 10719 {0, 1, 2, 1, 0}
10720 }; 10720 };
10721 Eina_Bool have_shadow = EINA_FALSE;
10722 Eina_Bool have_glow = EINA_FALSE;
10723 Eina_Bool have_outline = EINA_FALSE;
10721 10724
10722 /* render object to surface with context, and offxet by x,y */ 10725 /* render object to surface with context, and offxet by x,y */
10723 obj->layer->evas->engine.func->context_multiplier_unset(output, 10726 obj->layer->evas->engine.func->context_multiplier_unset(output,
@@ -10889,6 +10892,39 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED,
10889 10892
10890 ITEM_WALK() 10893 ITEM_WALK()
10891 { 10894 {
10895 /* Check which other pass are necessary to avoid useless WALK */
10896 if (!have_shadow && !have_glow && !have_outline)
10897 {
10898 Evas_Object_Textblock_Text_Item *ti;
10899
10900 ti = (itr->type == EVAS_TEXTBLOCK_ITEM_TEXT) ? _ITEM_TEXT(itr) : NULL;
10901 if (ti)
10902 {
10903 if (ti->parent.format->style & (EVAS_TEXT_STYLE_SHADOW |
10904 EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW |
10905 EVAS_TEXT_STYLE_OUTLINE_SHADOW |
10906 EVAS_TEXT_STYLE_FAR_SHADOW |
10907 EVAS_TEXT_STYLE_FAR_SOFT_SHADOW |
10908 EVAS_TEXT_STYLE_SOFT_SHADOW))
10909 {
10910 have_shadow = EINA_TRUE;
10911 }
10912 if ((ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC) ==
10913 EVAS_TEXT_STYLE_GLOW)
10914 {
10915 have_glow = EINA_TRUE;
10916 }
10917 if (((ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC) == EVAS_TEXT_STYLE_OUTLINE) ||
10918 ((ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC) == EVAS_TEXT_STYLE_OUTLINE_SHADOW) ||
10919 ((ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC) == EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW) ||
10920 (ti->parent.format->style == EVAS_TEXT_STYLE_SOFT_OUTLINE))
10921 {
10922 have_outline = EINA_TRUE;
10923 }
10924 }
10925
10926 }
10927
10892 DRAW_FORMAT(backing, 0, ln->h); 10928 DRAW_FORMAT(backing, 0, ln->h);
10893 } 10929 }
10894 ITEM_WALK_END(); 10930 ITEM_WALK_END();
@@ -10899,174 +10935,183 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED,
10899 /* prepare everything for text draw */ 10935 /* prepare everything for text draw */
10900 10936
10901 /* shadows */ 10937 /* shadows */
10902 ITEM_WALK() 10938 if (have_shadow)
10903 { 10939 {
10904 int shad_dst, shad_sz, dx, dy, haveshad; 10940 ITEM_WALK()
10905 Evas_Object_Textblock_Text_Item *ti;
10906 ti = (itr->type == EVAS_TEXTBLOCK_ITEM_TEXT) ? _ITEM_TEXT(itr) : NULL;
10907 if (!ti) continue;
10908
10909 shad_dst = shad_sz = dx = dy = haveshad = 0;
10910 switch (ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC)
10911 {
10912 case EVAS_TEXT_STYLE_SHADOW:
10913 shad_dst = 1;
10914 haveshad = 1;
10915 break;
10916 case EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW:
10917 shad_dst = 1;
10918 shad_sz = 2;
10919 haveshad = 1;
10920 break;
10921 case EVAS_TEXT_STYLE_OUTLINE_SHADOW:
10922 case EVAS_TEXT_STYLE_FAR_SHADOW:
10923 shad_dst = 2;
10924 haveshad = 1;
10925 break;
10926 case EVAS_TEXT_STYLE_FAR_SOFT_SHADOW:
10927 shad_dst = 2;
10928 shad_sz = 2;
10929 haveshad = 1;
10930 break;
10931 case EVAS_TEXT_STYLE_SOFT_SHADOW:
10932 shad_dst = 1;
10933 shad_sz = 2;
10934 haveshad = 1;
10935 break;
10936 default:
10937 break;
10938 }
10939 if (haveshad)
10940 { 10941 {
10941 if (shad_dst > 0) 10942 int shad_dst, shad_sz, dx, dy, haveshad;
10943 Evas_Object_Textblock_Text_Item *ti;
10944 ti = (itr->type == EVAS_TEXTBLOCK_ITEM_TEXT) ? _ITEM_TEXT(itr) : NULL;
10945 if (!ti) continue;
10946
10947 shad_dst = shad_sz = dx = dy = haveshad = 0;
10948 switch (ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC)
10942 { 10949 {
10943 switch (ti->parent.format->style & EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION) 10950 case EVAS_TEXT_STYLE_SHADOW:
10944 { 10951 shad_dst = 1;
10945 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT: 10952 haveshad = 1;
10946 dx = 1; 10953 break;
10947 dy = 1; 10954 case EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW:
10948 break; 10955 shad_dst = 1;
10949 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM: 10956 shad_sz = 2;
10950 dx = 0; 10957 haveshad = 1;
10951 dy = 1; 10958 break;
10952 break; 10959 case EVAS_TEXT_STYLE_OUTLINE_SHADOW:
10953 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT: 10960 case EVAS_TEXT_STYLE_FAR_SHADOW:
10954 dx = -1; 10961 shad_dst = 2;
10955 dy = 1; 10962 haveshad = 1;
10956 break; 10963 break;
10957 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT: 10964 case EVAS_TEXT_STYLE_FAR_SOFT_SHADOW:
10958 dx = -1; 10965 shad_dst = 2;
10959 dy = 0; 10966 shad_sz = 2;
10960 break; 10967 haveshad = 1;
10961 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT: 10968 break;
10962 dx = -1; 10969 case EVAS_TEXT_STYLE_SOFT_SHADOW:
10963 dy = -1; 10970 shad_dst = 1;
10964 break; 10971 shad_sz = 2;
10965 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP: 10972 haveshad = 1;
10966 dx = 0; 10973 break;
10967 dy = -1; 10974 default:
10968 break; 10975 break;
10969 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT:
10970 dx = 1;
10971 dy = -1;
10972 break;
10973 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT:
10974 dx = 1;
10975 dy = 0;
10976 default:
10977 break;
10978 }
10979 dx *= shad_dst;
10980 dy *= shad_dst;
10981 } 10976 }
10982 switch (shad_sz) 10977 if (haveshad)
10983 { 10978 {
10984 case 0: 10979 if (shad_dst > 0)
10985 COLOR_SET(shadow);
10986 DRAW_TEXT(dx, dy);
10987 break;
10988 case 2:
10989 for (j = 0; j < 5; j++)
10990 { 10980 {
10991 for (i = 0; i < 5; i++) 10981 switch (ti->parent.format->style & EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION)
10992 { 10982 {
10993 if (vals[i][j] != 0) 10983 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT:
10994 { 10984 dx = 1;
10995 COLOR_SET_AMUL(shadow, vals[i][j] * 50); 10985 dy = 1;
10996 DRAW_TEXT(i - 2 + dx, j - 2 + dy); 10986 break;
10997 } 10987 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM:
10988 dx = 0;
10989 dy = 1;
10990 break;
10991 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT:
10992 dx = -1;
10993 dy = 1;
10994 break;
10995 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT:
10996 dx = -1;
10997 dy = 0;
10998 break;
10999 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT:
11000 dx = -1;
11001 dy = -1;
11002 break;
11003 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP:
11004 dx = 0;
11005 dy = -1;
11006 break;
11007 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT:
11008 dx = 1;
11009 dy = -1;
11010 break;
11011 case EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT:
11012 dx = 1;
11013 dy = 0;
11014 default:
11015 break;
10998 } 11016 }
11017 dx *= shad_dst;
11018 dy *= shad_dst;
11019 }
11020 switch (shad_sz)
11021 {
11022 case 0:
11023 COLOR_SET(shadow);
11024 DRAW_TEXT(dx, dy);
11025 break;
11026 case 2:
11027 for (j = 0; j < 5; j++)
11028 {
11029 for (i = 0; i < 5; i++)
11030 {
11031 if (vals[i][j] != 0)
11032 {
11033 COLOR_SET_AMUL(shadow, vals[i][j] * 50);
11034 DRAW_TEXT(i - 2 + dx, j - 2 + dy);
11035 }
11036 }
11037 }
11038 break;
11039 default:
11040 break;
10999 } 11041 }
11000 break;
11001 default:
11002 break;
11003 } 11042 }
11004 } 11043 }
11044 ITEM_WALK_END();
11005 } 11045 }
11006 ITEM_WALK_END();
11007 11046
11008 /* glows */ 11047 /* glows */
11009 ITEM_WALK() 11048 if (have_glow)
11010 { 11049 {
11011 Evas_Object_Textblock_Text_Item *ti; 11050 ITEM_WALK()
11012 ti = (itr->type == EVAS_TEXTBLOCK_ITEM_TEXT) ? _ITEM_TEXT(itr) : NULL;
11013 if (!ti) continue;
11014
11015 if ((ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC) == EVAS_TEXT_STYLE_GLOW)
11016 { 11051 {
11017 for (j = 0; j < 5; j++) 11052 Evas_Object_Textblock_Text_Item *ti;
11053 ti = (itr->type == EVAS_TEXTBLOCK_ITEM_TEXT) ? _ITEM_TEXT(itr) : NULL;
11054 if (!ti) continue;
11055
11056 if ((ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC) == EVAS_TEXT_STYLE_GLOW)
11018 { 11057 {
11019 for (i = 0; i < 5; i++) 11058 for (j = 0; j < 5; j++)
11020 { 11059 {
11021 if (vals[i][j] != 0) 11060 for (i = 0; i < 5; i++)
11022 { 11061 {
11023 COLOR_SET_AMUL(glow, vals[i][j] * 50); 11062 if (vals[i][j] != 0)
11024 DRAW_TEXT(i - 2, j - 2); 11063 {
11064 COLOR_SET_AMUL(glow, vals[i][j] * 50);
11065 DRAW_TEXT(i - 2, j - 2);
11066 }
11025 } 11067 }
11026 } 11068 }
11069 COLOR_SET(glow2);
11070 DRAW_TEXT(-1, 0);
11071 DRAW_TEXT(1, 0);
11072 DRAW_TEXT(0, -1);
11073 DRAW_TEXT(0, 1);
11027 } 11074 }
11028 COLOR_SET(glow2);
11029 DRAW_TEXT(-1, 0);
11030 DRAW_TEXT(1, 0);
11031 DRAW_TEXT(0, -1);
11032 DRAW_TEXT(0, 1);
11033 } 11075 }
11076 ITEM_WALK_END();
11034 } 11077 }
11035 ITEM_WALK_END();
11036 11078
11037 /* outlines */ 11079 /* outlines */
11038 ITEM_WALK() 11080 if (have_outline)
11039 { 11081 {
11040 Evas_Object_Textblock_Text_Item *ti; 11082 ITEM_WALK()
11041 ti = (itr->type == EVAS_TEXTBLOCK_ITEM_TEXT) ? _ITEM_TEXT(itr) : NULL;
11042 if (!ti) continue;
11043
11044 if (((ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC) == EVAS_TEXT_STYLE_OUTLINE) ||
11045 ((ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC) == EVAS_TEXT_STYLE_OUTLINE_SHADOW) ||
11046 ((ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC) == EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW))
11047 {
11048 COLOR_SET(outline);
11049 DRAW_TEXT(-1, 0);
11050 DRAW_TEXT(1, 0);
11051 DRAW_TEXT(0, -1);
11052 DRAW_TEXT(0, 1);
11053 }
11054 else if (ti->parent.format->style == EVAS_TEXT_STYLE_SOFT_OUTLINE)
11055 { 11083 {
11056 for (j = 0; j < 5; j++) 11084 Evas_Object_Textblock_Text_Item *ti;
11085 ti = (itr->type == EVAS_TEXTBLOCK_ITEM_TEXT) ? _ITEM_TEXT(itr) : NULL;
11086 if (!ti) continue;
11087
11088 if (((ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC) == EVAS_TEXT_STYLE_OUTLINE) ||
11089 ((ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC) == EVAS_TEXT_STYLE_OUTLINE_SHADOW) ||
11090 ((ti->parent.format->style & EVAS_TEXT_STYLE_MASK_BASIC) == EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW))
11091 {
11092 COLOR_SET(outline);
11093 DRAW_TEXT(-1, 0);
11094 DRAW_TEXT(1, 0);
11095 DRAW_TEXT(0, -1);
11096 DRAW_TEXT(0, 1);
11097 }
11098 else if (ti->parent.format->style == EVAS_TEXT_STYLE_SOFT_OUTLINE)
11057 { 11099 {
11058 for (i = 0; i < 5; i++) 11100 for (j = 0; j < 5; j++)
11059 { 11101 {
11060 if (((i != 2) || (j != 2)) && (vals[i][j] != 0)) 11102 for (i = 0; i < 5; i++)
11061 { 11103 {
11062 COLOR_SET_AMUL(outline, vals[i][j] * 50); 11104 if (((i != 2) || (j != 2)) && (vals[i][j] != 0))
11063 DRAW_TEXT(i - 2, j - 2); 11105 {
11106 COLOR_SET_AMUL(outline, vals[i][j] * 50);
11107 DRAW_TEXT(i - 2, j - 2);
11108 }
11064 } 11109 }
11065 } 11110 }
11066 } 11111 }
11067 } 11112 }
11113 ITEM_WALK_END();
11068 } 11114 }
11069 ITEM_WALK_END();
11070 11115
11071 /* normal text and lines */ 11116 /* normal text and lines */
11072 /* Get the thickness and position, and save them for non-text items. */ 11117 /* Get the thickness and position, and save them for non-text items. */