summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHermet Park <hermetpark@gmail.com>2018-08-02 09:22:59 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-08-02 09:25:27 -0400
commit868e3308b12c6279a9ea46d3a5670375251c796e (patch)
treebca5eba269829b2175b5792941b8bb8891634161
parenta92274f81184cd06b398a0930110f2a4bee49e76 (diff)
elementary image: apply lazy calculation and guarantee retained method.
Summary: Image couldn't gurantee retained concept status. This patch change to setting up image object on the request time, recovering image status, removing unencessary jobs. Reviewers: #committers Subscribers: cedric, #committers, zmike Tags: #efl Differential Revision: https://phab.enlightenment.org/D6726
-rw-r--r--src/lib/elementary/efl_ui_image.c104
-rw-r--r--src/lib/elementary/efl_ui_widget_image.h2
2 files changed, 53 insertions, 53 deletions
diff --git a/src/lib/elementary/efl_ui_image.c b/src/lib/elementary/efl_ui_image.c
index 9d83ce37f8..ca1dbb0ec5 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -77,6 +77,19 @@ _prev_img_del(Efl_Ui_Image_Data *sd)
77} 77}
78 78
79static void 79static void
80_recover_status(Eo *obj, Efl_Ui_Image_Data *sd)
81{
82 int r, g, b, a;
83 Evas_Object *pclip = efl_canvas_object_clip_get(obj);
84 if (pclip) efl_canvas_object_clip_set(sd->img, pclip);
85
86 efl_gfx_color_get(obj, &r, &g, &b, &a);
87 efl_gfx_color_set(sd->img, r, g, b, a);
88
89 efl_gfx_entity_visible_set(sd->img, sd->show);
90}
91
92static void
80_on_image_preloaded(void *data, 93_on_image_preloaded(void *data,
81 Evas *e EINA_UNUSED, 94 Evas *e EINA_UNUSED,
82 Evas_Object *obj, 95 Evas_Object *obj,
@@ -143,7 +156,6 @@ _img_new(Evas_Object *obj)
143 evas_object_image_scale_hint_set(img, EVAS_IMAGE_SCALE_HINT_STATIC); 156 evas_object_image_scale_hint_set(img, EVAS_IMAGE_SCALE_HINT_STATIC);
144 evas_object_event_callback_add 157 evas_object_event_callback_add
145 (img, EVAS_CALLBACK_IMAGE_PRELOADED, _on_image_preloaded, sd); 158 (img, EVAS_CALLBACK_IMAGE_PRELOADED, _on_image_preloaded, sd);
146
147 evas_object_smart_member_add(img, obj); 159 evas_object_smart_member_add(img, obj);
148 elm_widget_sub_object_add(obj, img); 160 elm_widget_sub_object_add(obj, img);
149 161
@@ -170,7 +182,6 @@ _image_sizing_eval(Efl_Ui_Image_Data *sd, Evas_Object *img)
170 182
171 //1. Get the original image size (iw x ih) 183 //1. Get the original image size (iw x ih)
172 evas_object_image_size_get(img, &iw, &ih); 184 evas_object_image_size_get(img, &iw, &ih);
173
174 iw = ((double)iw) * sd->scale; 185 iw = ((double)iw) * sd->scale;
175 ih = ((double)ih) * sd->scale; 186 ih = ((double)ih) * sd->scale;
176 187
@@ -275,14 +286,6 @@ done:
275 evas_object_resize(sd->hit_rect, w, h); 286 evas_object_resize(sd->hit_rect, w, h);
276} 287}
277 288
278static void
279_efl_ui_image_internal_sizing_eval(Evas_Object *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
280{
281 if (!sd->img) return;
282 _image_sizing_eval(sd, sd->img);
283 if (sd->prev_img) _image_sizing_eval(sd, sd->prev_img);
284}
285
286static inline void 289static inline void
287_async_open_data_free(Async_Open_Data *data) 290_async_open_data_free(Async_Open_Data *data)
288{ 291{
@@ -472,27 +475,23 @@ _efl_ui_image_edje_file_set(Evas_Object *obj,
472 const Eina_File *f, 475 const Eina_File *f,
473 const char *group) 476 const char *group)
474{ 477{
475 Evas_Object *pclip;
476
477 EFL_UI_IMAGE_DATA_GET(obj, sd); 478 EFL_UI_IMAGE_DATA_GET(obj, sd);
478 479
479 _prev_img_del(sd); 480 _prev_img_del(sd);
480 481
481 if (!sd->edje) 482 if (!sd->edje)
482 { 483 {
483 pclip = evas_object_clip_get(sd->img);
484 evas_object_del(sd->img); 484 evas_object_del(sd->img);
485 485
486 /* Edje object instead */ 486 /* Edje object instead */
487 sd->img = edje_object_add(evas_object_evas_get(obj)); 487 sd->img = edje_object_add(evas_object_evas_get(obj));
488 _recover_status(obj, sd);
489 sd->edje = EINA_TRUE;
488 evas_object_smart_member_add(sd->img, obj); 490 evas_object_smart_member_add(sd->img, obj);
489 if (sd->show) evas_object_show(sd->img);
490 evas_object_clip_set(sd->img, pclip);
491 } 491 }
492 492
493 _async_cancel(sd); 493 _async_cancel(sd);
494 494
495 sd->edje = EINA_TRUE;
496 if (!sd->async_enable) 495 if (!sd->async_enable)
497 { 496 {
498 if (f) 497 if (f)
@@ -572,9 +571,6 @@ _efl_ui_image_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Image_Data *priv)
572 evas_object_event_callback_add 571 evas_object_event_callback_add
573 (priv->hit_rect, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up, obj); 572 (priv->hit_rect, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up, obj);
574 573
575 /* starts as an Evas image. may switch to an Edje object */
576 priv->img = _img_new(obj);
577
578 priv->smooth = EINA_TRUE; 574 priv->smooth = EINA_TRUE;
579 priv->fill_inside = EINA_TRUE; 575 priv->fill_inside = EINA_TRUE;
580 priv->aspect_fixed = EINA_TRUE; 576 priv->aspect_fixed = EINA_TRUE;
@@ -586,8 +582,6 @@ _efl_ui_image_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Image_Data *priv)
586 priv->align_y = 0.5; 582 priv->align_y = 0.5;
587 583
588 elm_widget_can_focus_set(obj, EINA_FALSE); 584 elm_widget_can_focus_set(obj, EINA_FALSE);
589
590 _efl_ui_image_sizing_eval(obj);
591} 585}
592 586
593EOLIAN static void 587EOLIAN static void
@@ -596,6 +590,7 @@ _efl_ui_image_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Image_Data *sd)
596 if (elm_widget_is_legacy(obj)) 590 if (elm_widget_is_legacy(obj))
597 efl_event_callback_del(obj, EFL_GFX_ENTITY_EVENT_CHANGE_SIZE_HINTS, 591 efl_event_callback_del(obj, EFL_GFX_ENTITY_EVENT_CHANGE_SIZE_HINTS,
598 _on_size_hints_changed, sd); 592 _on_size_hints_changed, sd);
593 ecore_job_del(sd->sizing_job);
599 ecore_timer_del(sd->anim_timer); 594 ecore_timer_del(sd->anim_timer);
600 evas_object_del(sd->img); 595 evas_object_del(sd->img);
601 _prev_img_del(sd); 596 _prev_img_del(sd);
@@ -657,7 +652,7 @@ _efl_ui_image_show(Eo *obj, Efl_Ui_Image_Data *sd)
657 efl_gfx_entity_visible_set(efl_super(obj, MY_CLASS), EINA_TRUE); 652 efl_gfx_entity_visible_set(efl_super(obj, MY_CLASS), EINA_TRUE);
658 653
659 if (sd->preload_status == EFL_UI_IMAGE_PRELOADING) return; 654 if (sd->preload_status == EFL_UI_IMAGE_PRELOADING) return;
660 efl_gfx_entity_visible_set(sd->img, EINA_TRUE); 655 if (sd->img) efl_gfx_entity_visible_set(sd->img, EINA_TRUE);
661 _prev_img_del(sd); 656 _prev_img_del(sd);
662} 657}
663 658
@@ -666,7 +661,7 @@ _efl_ui_image_hide(Eo *obj, Efl_Ui_Image_Data *sd)
666{ 661{
667 sd->show = EINA_FALSE; 662 sd->show = EINA_FALSE;
668 efl_gfx_entity_visible_set(efl_super(obj, MY_CLASS), EINA_FALSE); 663 efl_gfx_entity_visible_set(efl_super(obj, MY_CLASS), EINA_FALSE);
669 efl_gfx_entity_visible_set(sd->img, EINA_FALSE); 664 if (sd->img) efl_gfx_entity_visible_set(sd->img, EINA_FALSE);
670 _prev_img_del(sd); 665 _prev_img_del(sd);
671} 666}
672 667
@@ -698,7 +693,7 @@ _efl_ui_image_efl_gfx_color_color_set(Eo *obj, Efl_Ui_Image_Data *sd, int r, int
698 efl_gfx_color_set(efl_super(obj, MY_CLASS), r, g, b, a); 693 efl_gfx_color_set(efl_super(obj, MY_CLASS), r, g, b, a);
699 694
700 evas_object_color_set(sd->hit_rect, 0, 0, 0, 0); 695 evas_object_color_set(sd->hit_rect, 0, 0, 0, 0);
701 evas_object_color_set(sd->img, r, g, b, a); 696 if (sd->img) evas_object_color_set(sd->img, r, g, b, a);
702 if (sd->prev_img) evas_object_color_set(sd->prev_img, r, g, b, a); 697 if (sd->prev_img) evas_object_color_set(sd->prev_img, r, g, b, a);
703} 698}
704 699
@@ -710,7 +705,7 @@ _efl_ui_image_efl_canvas_object_clip_set(Eo *obj, Efl_Ui_Image_Data *sd, Evas_Ob
710 705
711 efl_canvas_object_clip_set(efl_super(obj, MY_CLASS), clip); 706 efl_canvas_object_clip_set(efl_super(obj, MY_CLASS), clip);
712 707
713 evas_object_clip_set(sd->img, clip); 708 if (sd->img) evas_object_clip_set(sd->img, clip);
714 if (sd->prev_img) evas_object_clip_set(sd->prev_img, clip); 709 if (sd->prev_img) evas_object_clip_set(sd->prev_img, clip);
715} 710}
716 711
@@ -737,31 +732,23 @@ _key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
737 return EINA_TRUE; 732 return EINA_TRUE;
738} 733}
739 734
740// TODO: remove this function after using the widget's scale value instead of image's scale value,
741
742static void 735static void
743_efl_ui_image_internal_scale_set(Evas_Object *obj, Efl_Ui_Image_Data *sd, double scale) 736_sizing_eval_cb(void *data)
744{
745 sd->scale = scale;
746 _efl_ui_image_internal_sizing_eval(obj, sd);
747}
748
749void
750_efl_ui_image_sizing_eval(Evas_Object *obj)
751{ 737{
738 Evas_Object *obj = data;
752 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1; 739 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
753 Eina_Size2D sz; 740 Eina_Size2D sz;
754 double ts; 741 double ts;
755 742
756 EFL_UI_IMAGE_DATA_GET_OR_RETURN(obj, sd); 743 EFL_UI_IMAGE_DATA_GET_OR_RETURN(obj, sd);
757 744
758 _efl_ui_image_internal_sizing_eval(obj, sd); 745 sd->sizing_job = NULL;
759 efl_gfx_image_smooth_scale_set(obj, sd->smooth);
760 746
747 // TODO: remove this function after using the widget's scale value instead of image's scale value,
761 if (sd->no_scale) 748 if (sd->no_scale)
762 _efl_ui_image_internal_scale_set(obj, sd, 1.0); 749 sd->scale = 1.0;
763 else 750 else
764 _efl_ui_image_internal_scale_set(obj, sd, efl_gfx_entity_scale_get(obj) * elm_config_scale_get()); 751 sd->scale = efl_gfx_entity_scale_get(obj) * elm_config_scale_get();
765 752
766 ts = sd->scale; 753 ts = sd->scale;
767 sd->scale = 1.0; 754 sd->scale = 1.0;
@@ -801,6 +788,21 @@ _efl_ui_image_sizing_eval(Evas_Object *obj)
801 788
802 evas_object_size_hint_min_set(obj, minw, minh); 789 evas_object_size_hint_min_set(obj, minw, minh);
803 evas_object_size_hint_max_set(obj, maxw, maxh); 790 evas_object_size_hint_max_set(obj, maxw, maxh);
791
792 if (sd->img)
793 {
794 _image_sizing_eval(sd, sd->img);
795 if (sd->prev_img) _image_sizing_eval(sd, sd->prev_img);
796 }
797}
798
799void
800_efl_ui_image_sizing_eval(Evas_Object *obj)
801{
802 EFL_UI_IMAGE_DATA_GET_OR_RETURN(obj, sd);
803
804 if (sd->sizing_job) ecore_job_del(sd->sizing_job);
805 sd->sizing_job = ecore_job_add(_sizing_eval_cb, obj);
804} 806}
805 807
806static void 808static void
@@ -816,25 +818,17 @@ _efl_ui_image_load_size_set_internal(Evas_Object *obj, Efl_Ui_Image_Data *sd)
816static void 818static void
817_efl_ui_image_file_set_do(Evas_Object *obj) 819_efl_ui_image_file_set_do(Evas_Object *obj)
818{ 820{
819 Evas_Object *pclip = NULL;
820
821 EFL_UI_IMAGE_DATA_GET(obj, sd); 821 EFL_UI_IMAGE_DATA_GET(obj, sd);
822 822
823 ELM_SAFE_FREE(sd->prev_img, evas_object_del); 823 ELM_SAFE_FREE(sd->prev_img, evas_object_del);
824 if (sd->img)
825 {
826 pclip = evas_object_clip_get(sd->img);
827 sd->prev_img = sd->img;
828 }
829 824
825 sd->prev_img = sd->img;
830 sd->img = _img_new(obj); 826 sd->img = _img_new(obj);
831 827 _recover_status(obj, sd);
832 evas_object_image_load_orientation_set(sd->img, EINA_TRUE);
833
834 evas_object_clip_set(sd->img, pclip);
835 828
836 sd->edje = EINA_FALSE; 829 sd->edje = EINA_FALSE;
837 830 evas_object_image_smooth_scale_set(sd->img, sd->smooth);
831 evas_object_image_load_orientation_set(sd->img, EINA_TRUE);
838 _efl_ui_image_load_size_set_internal(obj, sd); 832 _efl_ui_image_load_size_set_internal(obj, sd);
839} 833}
840 834
@@ -1242,7 +1236,11 @@ _efl_ui_image_efl_gfx_view_view_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image
1242{ 1236{
1243 int tw, th; 1237 int tw, th;
1244 1238
1245 if (efl_isa(sd->img, EFL_CANVAS_LAYOUT_CLASS)) 1239 if (!sd->img)
1240 {
1241 tw = 0; th = 0;
1242 }
1243 else if (efl_isa(sd->img, EFL_CANVAS_LAYOUT_CLASS))
1246 edje_object_size_min_get(sd->img, &tw, &th); 1244 edje_object_size_min_get(sd->img, &tw, &th);
1247 else 1245 else
1248 evas_object_image_size_get(sd->img, &tw, &th); 1246 evas_object_image_size_get(sd->img, &tw, &th);
@@ -1253,7 +1251,7 @@ _efl_ui_image_efl_gfx_view_view_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image
1253EOLIAN static Eina_Size2D 1251EOLIAN static Eina_Size2D
1254_efl_ui_image_efl_gfx_image_image_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd) 1252_efl_ui_image_efl_gfx_image_image_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
1255{ 1253{
1256 if (sd->edje) 1254 if (!sd->img || sd->edje)
1257 return EINA_SIZE2D(0, 0); 1255 return EINA_SIZE2D(0, 0);
1258 1256
1259 return efl_gfx_image_size_get(sd->img); 1257 return efl_gfx_image_size_get(sd->img);
diff --git a/src/lib/elementary/efl_ui_widget_image.h b/src/lib/elementary/efl_ui_widget_image.h
index 159f6ce232..8fae00f950 100644
--- a/src/lib/elementary/efl_ui_widget_image.h
+++ b/src/lib/elementary/efl_ui_widget_image.h
@@ -92,6 +92,8 @@ struct _Efl_Ui_Image_Data
92 Eina_Bool use : 1; 92 Eina_Bool use : 1;
93 } freedesktop; 93 } freedesktop;
94 94
95 Ecore_Job *sizing_job;
96
95 Eina_Bool aspect_fixed : 1; 97 Eina_Bool aspect_fixed : 1;
96 Eina_Bool fill_inside : 1; 98 Eina_Bool fill_inside : 1;
97 Eina_Bool no_scale : 1; 99 Eina_Bool no_scale : 1;