Evas textblock + font engine: add an optimized way of doing a cut-off on the text...
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 30 Jan 2011 10:38:15 +0000 (10:38 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 30 Jan 2011 10:38:15 +0000 (10:38 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@56470 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/canvas/evas_object_textblock.c
src/lib/engines/common/evas_font_ot.c
src/lib/engines/common/evas_font_ot.h
src/lib/engines/common/evas_text_utils.c
src/lib/engines/common/evas_text_utils.h

index 71a4918..9b84343 100644 (file)
@@ -2296,9 +2296,7 @@ _layout_item_text_cutoff(Ctxt *c __UNUSED__, Evas_Object_Textblock_Text_Item *ti
    ts[cut] = 0;
    ti->text = eina_unicode_strdup(ts);
    free(ts);
-   c->ENFN->font_shape(c->ENDT, ti->format->font.font, ti->text,
-         &ti->parent.text_props, ti->parent.text_node->bidi_props,
-         ti->parent.text_pos, cut);
+   evas_common_text_props_cutoff(&ti->parent.text_props, cut);
 }
 
 /**
index fb1e7ec..3a77afe 100644 (file)
@@ -112,6 +112,28 @@ _evas_common_font_ot_shape(hb_buffer_t *buffer, RGBA_Font_Source *src)
    hb_font_destroy(hb_font);
 }
 
+/* Won't work in the middle of ligatures */
+EAPI void
+evas_common_font_ot_cutoff_text_props(Evas_Text_Props *props, int cutoff)
+{
+   Evas_Font_OT_Data_Item *tmp;
+   if ((cutoff <= 0) || (!props->ot_data) ||
+         (((size_t) cutoff) >= props->ot_data->len))
+     return;
+
+   if (props->bidi.dir == EVAS_BIDI_DIRECTION_RTL)
+     {
+        memmove(props->ot_data->items,
+              props->ot_data->items + (props->ot_data->len - cutoff),
+              cutoff * sizeof(Evas_Font_OT_Data_Item));
+     }
+   tmp = realloc(props->ot_data->items,
+         cutoff * sizeof(Evas_Font_OT_Data_Item));
+   props->ot_data->items = tmp;
+   props->ot_data->len = cutoff;
+
+}
+
 EAPI Eina_Bool
 evas_common_font_ot_populate_text_props(void *_fn, const Eina_Unicode *text,
       Evas_Text_Props *props, int len)
index 5aa560a..5ec19ce 100644 (file)
@@ -75,5 +75,8 @@ evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_i
 EAPI Eina_Bool
 evas_common_font_ot_populate_text_props(void *fn, const Eina_Unicode *text,
       Evas_Text_Props *props, int len);
+
+EAPI void
+evas_common_font_ot_cutoff_text_props(Evas_Text_Props *props, int cutoff);
 #endif
 
index e5fd81c..50ca45e 100644 (file)
@@ -57,3 +57,13 @@ evas_common_text_props_content_unref(Evas_Text_Props *props)
 #endif
 }
 
+/* Won't work in the middle of ligatures */
+EAPI void
+evas_common_text_props_cutoff(Evas_Text_Props *props, int cutoff)
+{
+#ifdef OT_SUPPORT
+   evas_common_font_ot_cutoff_text_props(props, cutoff);
+#endif
+}
+
+
index ccc4d20..ecc6a93 100644 (file)
@@ -29,4 +29,7 @@ evas_common_text_props_content_copy_and_ref(Evas_Text_Props *dst,
 void
 evas_common_text_props_content_unref(Evas_Text_Props *props);
 
+EAPI void
+evas_common_text_props_cutoff(Evas_Text_Props *props, int cutoff);
+
 #endif