1 #include "e_mod_effect_rotation.h"
3 #include <tbm_bufmgr.h>
4 #include <tbm_surface.h>
5 #include <tbm_surface_internal.h>
6 #include <tdm_helper.h>
7 #include <wayland-tbm-server.h>
10 #define e_util_size_debug_set(x, y)
13 typedef struct _Rotation_Effect_Object
18 struct wl_shm_pool *data_pool;
20 } Rotation_Effect_Object;
22 typedef struct _Rotation_Effect_Begin_Context
29 } Rotation_Effect_Begin_Context;
31 typedef struct _Rotation_Effect_End_Context
38 } Rotation_Effect_End_Context;
40 typedef struct _Rotation_Effect
46 Eina_List *waiting_list;
48 Rotation_Effect_Begin_Context *ctx_begin;
49 Rotation_Effect_End_Context *ctx_end;
51 Ecore_Animator *animator;
54 Eina_Bool wait_for_buffer;
57 typedef struct _Rotation_Zone
60 Eina_List *event_hdlrs;
62 Rotation_Effect *effect;
68 static Rotation_Zone *_rotation_zone = NULL;
71 _rotation_effect_ready_send(E_Zone *zone)
73 E_Event_Zone_Rotation_Effect_Ready *ev;
75 ev = E_NEW(E_Event_Zone_Rotation_Effect_Ready, 1);
79 ecore_event_add(E_EVENT_ZONE_ROTATION_EFFECT_READY, ev, NULL, NULL);
81 EFFINF("Rotation Effect Event Ready", NULL, NULL);
85 _rotation_effect_cancel_send(E_Zone *zone)
87 E_Event_Zone_Rotation_Effect_Cancel *ev;
89 ev = E_NEW(E_Event_Zone_Rotation_Effect_Cancel, 1);
93 ecore_event_add(E_EVENT_ZONE_ROTATION_EFFECT_CANCEL, ev, NULL, NULL);
95 EFFINF("Rotation Effect Event Cancel", NULL, NULL);
99 _rotation_effect_done_send(E_Zone *zone)
101 E_Event_Zone_Rotation_Effect_Done *ev;
103 ev = E_NEW(E_Event_Zone_Rotation_Effect_Done, 1);
107 ecore_event_add(E_EVENT_ZONE_ROTATION_EFFECT_DONE, ev, NULL, NULL);
109 EFFINF("Rotation Effect Event Done", NULL, NULL);
113 _rotation_effect_available(const E_Client *ec, int ang)
115 Eina_Bool ret = EINA_FALSE;
118 if (ang < 0) return EINA_FALSE;
119 if (!ec->e.state.rot.support)
122 if (ec->e.state.rot.preferred_rot == -1)
124 if (ec->e.state.rot.available_rots &&
125 ec->e.state.rot.count)
127 for (i = 0; i < ec->e.state.rot.count; i++)
129 if (ec->e.state.rot.available_rots[i] == ang)
139 else if (ec->e.state.rot.preferred_rot == ang)
148 _rotation_effect_targets_get(Rotation_Effect *effect, E_Desk *desk)
158 if (!effect) return NULL;
160 if (effect->zone->display_state == E_ZONE_DISPLAY_STATE_OFF)
165 t = eina_tiler_new(effect->zone->w + edge, effect->zone->h + edge);
166 eina_tiler_tile_size_set(t, 1, 1);
168 EINA_RECTANGLE_SET(&r, effect->zone->x, effect->zone->y, effect->zone->w, effect->zone->h);
169 eina_tiler_rect_add(t, &r);
171 o = evas_object_top_get(e_comp->evas);
172 for (; o; o = evas_object_below_get(o))
174 if (!evas_object_visible_get(o)) continue;
175 if (o == effect->zone->over) continue;
176 if (o == effect->bg) continue;
177 if (evas_object_layer_get(o) > E_LAYER_EFFECT) continue;
178 if (!e_util_strcmp(evas_object_name_get(o), "layer_obj")) continue;
180 evas_object_geometry_get(o, &x, &y, &w, &h);
181 ec = evas_object_data_get(o, "E_Client");
184 if (ec->desk != desk) continue;
185 if (e_object_is_del(E_OBJECT(ec))) continue;
186 if (!E_INTERSECTS(ec->x, ec->y, ec->w, ec->h, ec->zone->x, ec->zone->y, ec->zone->w, ec->zone->h))
188 if ((ec->visibility.obscured != E_VISIBILITY_UNOBSCURED) &&
192 if ((!ec->animatable) ||
193 (e_client_video_client_has(ec)) ||
194 (!_rotation_effect_available(ec, effect->zone->rot.curr)) ||
195 (ec->e.state.rot.ang.curr == effect->zone->rot.curr))
197 if (l) eina_list_free(l);
203 l = eina_list_append(l, o);
205 if ((ec) && (ec->argb))
207 if (ec->visibility.opaque <= 0) continue;
210 if (ec->parent) continue;
214 EINA_RECTANGLE_SET(&r, x, y, w + edge, h + edge);
215 eina_tiler_rect_del(t, &r);
217 if (eina_tiler_empty(t)) break;
225 _rotation_effect_object_free(Rotation_Effect_Object *eobj)
231 evas_object_image_data_set(eobj->img, NULL);
234 if (eobj->img) evas_object_del(eobj->img);
235 if (eobj->data_pool) wl_shm_pool_unref(eobj->data_pool);
240 static Rotation_Effect_Object *
241 _rotation_effect_object_create(Evas_Object *o)
243 Rotation_Effect_Object *eobj;
244 E_Comp_Wl_Buffer *buffer = NULL;
245 Evas_Object *img = NULL;
249 void *data = NULL, *pix = NULL;
251 if (!evas_object_visible_get(o)) return NULL;
253 ec = evas_object_data_get(o, "E_Client");
256 if (e_object_is_del(E_OBJECT(ec))) return NULL;
258 eobj = E_NEW(Rotation_Effect_Object, 1);
259 if (!eobj) goto fail;
263 buffer = e_pixmap_resource_get(ec->pixmap);
264 if (!buffer) goto fail;
266 img = evas_object_image_filled_add(e_comp->evas);
267 e_util_size_debug_set(img, 1);
268 evas_object_image_colorspace_set(img, EVAS_COLORSPACE_ARGB8888);
269 evas_object_image_smooth_scale_set(img, e_comp_config_get()->smooth_windows);
271 if (buffer->type == E_COMP_WL_BUFFER_TYPE_SHM)
273 if (!buffer->shm_buffer) goto fail;
278 pix = wl_shm_buffer_get_data(buffer->shm_buffer);
282 wl_shm_pool_unref(eobj->data_pool);
283 eobj->data_pool = wl_shm_buffer_ref_pool(buffer->shm_buffer);
285 else if (buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE)
287 tbm_surface_info_s surface_info;
288 tbm_surface_h tbm_surface = wayland_tbm_server_get_surface(NULL, buffer->resource);
289 memset(&surface_info, 0, sizeof(tbm_surface_info_s));
290 tbm_surface_map(tbm_surface, TBM_SURF_OPTION_READ, &surface_info);
292 data = surface_info.planes[0].ptr;
293 if (!data) goto fail;
295 w = surface_info.width;
296 h = surface_info.height;
298 pix = eobj->data = malloc(w * h * 4);
299 for (i = 0; i < h; i++)
301 memcpy(pix, data, surface_info.width * 4);
302 pix += surface_info.width * 4;
303 data += surface_info.planes[0].stride;
307 tbm_surface_unmap(tbm_surface);
309 else if (buffer->type == E_COMP_WL_BUFFER_TYPE_TBM)
311 tbm_surface_info_s surface_info;
312 tbm_surface_h tbm_surface = buffer->tbm_surface;
314 memset(&surface_info, 0, sizeof(tbm_surface_info_s));
315 tbm_surface_map(tbm_surface, TBM_SURF_OPTION_READ, &surface_info);
317 data = surface_info.planes[0].ptr;
318 if (!data) goto fail;
320 w = surface_info.width;
321 h = surface_info.height;
323 pix = eobj->data = malloc(w * h * 4);
324 for (i = 0; i < h; i++)
326 memcpy(pix, data, surface_info.width * 4);
327 pix += surface_info.width * 4;
328 data += surface_info.planes[0].stride;
332 tbm_surface_unmap(tbm_surface);
339 evas_object_image_alpha_set(img, 1);
340 evas_object_image_size_set(img, w, h);
341 evas_object_image_data_set(img, pix);
342 evas_object_image_data_update_add(img, 0, 0, w, h);
344 evas_object_name_set(img, "rotation-effect-image");
345 evas_object_move(img, ec->x, ec->y);
346 evas_object_resize(img, ec->w, ec->h);
351 EFFINF("Rotation EFFECT Object Created E_Client:%p",
359 eobj = E_NEW(Rotation_Effect_Object, 1);
360 if (!eobj) return NULL;
364 evas_object_geometry_get(o, &x, &y, &w, &h);
366 img = evas_object_image_filled_add(e_comp->evas);
367 e_util_size_debug_set(img, 1);
369 evas_object_image_colorspace_set(img, EVAS_COLORSPACE_ARGB8888);
370 evas_object_image_smooth_scale_set(img, e_comp_config_get()->smooth_windows);
371 evas_object_image_alpha_set(img, 1);
372 evas_object_image_size_set(img, w, h);
373 evas_object_image_source_set(img, o);
375 evas_object_name_set(img, "rotation-effect-image");
376 evas_object_move(img, x, y);
377 evas_object_resize(img, w, h);
381 EFFINF("Rotation EFFECT Object Created Object:%p",
390 evas_object_image_data_set(img, NULL);
391 evas_object_del(img);
397 wl_shm_pool_unref(eobj->data_pool);
405 static Rotation_Effect_Begin_Context *
406 _rotation_effect_begin_create(Rotation_Effect *effect, Eina_List *targets, E_Desk *desk)
408 Rotation_Effect_Begin_Context *ctx_begin = NULL;
409 Rotation_Effect_Object *eobj = NULL;
414 ctx_begin = E_NEW(Rotation_Effect_Begin_Context, 1);
415 if (!ctx_begin) return NULL;
417 ctx_begin->layout = e_layout_add(e_comp->evas);
418 e_util_size_debug_set(ctx_begin->layout, 1);
419 evas_object_name_set(ctx_begin->layout, "rotation-begin-effect-layout");
420 e_layout_virtual_size_set(ctx_begin->layout, effect->zone->w, effect->zone->h);
421 evas_object_move(ctx_begin->layout, effect->zone->x, effect->zone->y);
422 evas_object_resize(ctx_begin->layout, effect->zone->w, effect->zone->h);
423 evas_object_layer_set(ctx_begin->layout, E_LAYER_EFFECT);
425 EINA_LIST_REVERSE_FOREACH(targets, l, target)
427 eobj = _rotation_effect_object_create(target);
430 ctx_begin->objects = eina_list_append(ctx_begin->objects, eobj);
432 effect->waiting_list = eina_list_append(effect->waiting_list, eobj->ec);
434 evas_object_geometry_get(target, &x, &y, &w, &h);
436 e_layout_pack(ctx_begin->layout, eobj->img);
437 e_layout_child_move(eobj->img, x, y);
438 e_layout_child_resize(eobj->img, w, h);
439 e_layout_child_raise(eobj->img);
440 evas_object_show(eobj->img);
443 if (!ctx_begin->objects)
445 evas_object_del(ctx_begin->layout);
450 e_desk_smart_member_add(desk, ctx_begin->layout);
452 EFFINF("Rotation Begin Created", NULL, NULL);
454 int diff = effect->zone->rot.prev - effect->zone->rot.curr;
455 if (diff == 270) diff = - 90;
456 else if (diff == -270) diff = 90;
457 ctx_begin->src = 0.0;
458 ctx_begin->dest = diff;
464 static Rotation_Effect_End_Context *
465 _rotation_effect_end_create(Rotation_Effect *effect, Eina_List *targets, E_Desk *desk)
467 Rotation_Effect_End_Context *ctx_end = NULL;
468 Rotation_Effect_Object *eobj = NULL;
473 ctx_end = E_NEW(Rotation_Effect_End_Context, 1);
474 if (!ctx_end) return NULL;
476 ctx_end->layout = e_layout_add(e_comp->evas);
477 e_util_size_debug_set(ctx_end->layout, 1);
478 evas_object_name_set(ctx_end->layout, "rotation-end-effect-layout");
479 e_layout_virtual_size_set(ctx_end->layout, effect->zone->w, effect->zone->h);
480 evas_object_move(ctx_end->layout, effect->zone->x, effect->zone->y);
481 evas_object_resize(ctx_end->layout, effect->zone->w, effect->zone->h);
482 evas_object_layer_set(ctx_end->layout, E_LAYER_EFFECT);
484 EINA_LIST_REVERSE_FOREACH(targets, l, target)
486 eobj = _rotation_effect_object_create(target);
489 evas_object_geometry_get(target, &x, &y, &w, &h);
491 ctx_end->objects = eina_list_append(ctx_end->objects, eobj);
493 e_layout_pack(ctx_end->layout, eobj->img);
494 e_layout_child_move(eobj->img, x, y);
495 e_layout_child_resize(eobj->img, w, h);
496 e_layout_child_raise(eobj->img);
497 evas_object_show(eobj->img);
500 if (!ctx_end->objects)
502 evas_object_del(ctx_end->layout);
507 e_desk_smart_member_add(desk, ctx_end->layout);
509 EFFINF("Rotation End Created", NULL, NULL);
511 int diff = _rotation_zone->curr_angle - _rotation_zone->prev_angle;
512 if (diff == 270) diff = - 90;
513 else if (diff == -270) diff = 90;
521 _rotation_effect_animator_begin_context_free(Rotation_Effect_Begin_Context *ctx_begin)
523 Rotation_Effect_Object *eobj;
525 if (!ctx_begin) return;
527 EFFINF("Rotation Begin Free", NULL, NULL);
529 if (ctx_begin->layout)
530 evas_object_hide(ctx_begin->layout);
532 EINA_LIST_FREE(ctx_begin->objects, eobj)
534 e_layout_unpack(eobj->img);
535 _rotation_effect_object_free(eobj);
538 if (ctx_begin->layout)
539 evas_object_del(ctx_begin->layout);
545 _rotation_effect_animator_end_context_free(Rotation_Effect_End_Context *ctx_end)
547 Rotation_Effect_Object *eobj;
549 if (!ctx_end) return;
551 EFFINF("Rotation End Free", NULL, NULL);
554 evas_object_hide(ctx_end->layout);
556 EINA_LIST_FREE(ctx_end->objects, eobj)
558 e_layout_unpack(eobj->img);
559 _rotation_effect_object_free(eobj);
563 evas_object_del(ctx_end->layout);
569 _rotation_effect_clear(Rotation_Effect *effect)
573 EFFINF("Rotation Effect Clear", NULL, NULL);
575 effect->targets = eina_list_free(effect->targets);
576 effect->waiting_list = eina_list_free(effect->waiting_list);
578 if (effect->animator)
579 ecore_animator_del(effect->animator);
581 evas_object_hide(effect->bg);
583 if (effect->ctx_begin)
585 _rotation_effect_animator_begin_context_free(effect->ctx_begin);
586 e_comp_override_del();
591 _rotation_effect_animator_end_context_free(effect->ctx_end);
592 _rotation_effect_done_send(effect->zone);
595 effect->running = EINA_FALSE;
596 effect->wait_for_buffer = EINA_FALSE;
597 effect->animator = NULL;
598 effect->ctx_begin = NULL;
599 effect->ctx_end = NULL;
603 _rotation_effect_animator_cb_update(void *data, double pos)
605 Rotation_Effect *effect;
606 Rotation_Effect_Begin_Context *ctx_begin;
607 Rotation_Effect_End_Context *ctx_end;
609 double curr, col, progress;
610 Evas_Coord x, y, w, h;
612 effect = (Rotation_Effect *)data;
613 ctx_begin = effect->ctx_begin;
614 ctx_end = effect->ctx_end;
618 ecore_animator_del(effect->animator);
619 effect->animator = NULL;
621 _rotation_effect_animator_begin_context_free(effect->ctx_begin);
622 effect->ctx_begin = NULL;
624 _rotation_effect_animator_end_context_free(effect->ctx_end);
625 effect->ctx_end = NULL;
627 effect->wait_for_buffer = EINA_FALSE;
628 effect->running = EINA_FALSE;
629 evas_object_hide(effect->bg);
631 e_comp_override_del();
632 _rotation_effect_done_send(effect->zone);
634 return ECORE_CALLBACK_CANCEL;
637 progress = ecore_animator_pos_map(pos, ECORE_POS_MAP_DECELERATE, 0, 0);
639 if (progress < 0.0) progress = 0.0;
642 curr = (progress * ctx_begin->dest);
643 col = 255 - (255 * progress);
645 evas_object_geometry_get(ctx_begin->layout, &x, &y, &w, &h);
647 Evas_Map *m = evas_map_new(4);
648 evas_map_util_points_populate_from_object(m, ctx_begin->layout);
649 evas_map_util_rotate(m, curr, x + (w/2), y + (h/2));
650 evas_map_alpha_set(m, EINA_TRUE);
651 evas_map_util_points_color_set(m, col, col, col, col);
652 evas_object_map_set(ctx_begin->layout, m);
653 evas_object_map_enable_set(ctx_begin->layout, EINA_TRUE);
657 curr = ((-1.0f * progress * ctx_end->src) + ctx_end->src);
659 evas_object_geometry_get(ctx_end->layout, &x, &y, &w, &h);
662 evas_map_util_points_populate_from_object(m, ctx_end->layout);
663 evas_map_util_rotate(m, curr, x + (w/2), y + (h/2));
664 evas_object_map_set(ctx_end->layout, m);
665 evas_object_map_enable_set(ctx_end->layout, EINA_TRUE);
668 return ECORE_CALLBACK_RENEW;
672 _rotation_effect_start(Rotation_Effect *effect)
674 if ((!effect->ctx_begin) || (!effect->ctx_end)) return;
675 if (effect->running) return;
677 EFFINF("Rotation Effect Start", NULL, NULL);
679 effect->running = EINA_TRUE;
681 evas_object_raise(effect->ctx_begin->layout);
682 evas_object_show(effect->ctx_begin->layout);
683 evas_object_show(effect->ctx_end->layout);
685 evas_object_move(effect->bg, 0, 0);
686 evas_object_resize(effect->bg, effect->zone->w, effect->zone->h);
687 evas_object_lower(effect->bg);
688 evas_object_show(effect->bg);
690 effect->animator = ecore_animator_timeline_add(0.3f,
691 _rotation_effect_animator_cb_update,
696 _rotation_effect_animator_begin_prepare(Rotation_Effect *effect, E_Desk *desk)
700 _rotation_effect_clear(effect);
702 effect->targets = _rotation_effect_targets_get(effect, desk);
703 if (!effect->targets) return;
705 effect->ctx_begin = _rotation_effect_begin_create(effect, effect->targets, desk);
706 if (!effect->ctx_begin)
708 _rotation_effect_clear(effect);
712 EFFINF("Rotation Begin Prepared", NULL, NULL);
714 /* add hwc override */
715 e_comp_override_add();
719 _rotation_effect_animator_end_prepare(Rotation_Effect *effect, E_Desk *desk)
722 if (!effect->targets) return;
723 if (!effect->ctx_begin) return;
725 /* clear previous context */
727 _rotation_effect_animator_end_context_free(effect->ctx_end);
728 effect->ctx_end = NULL;
730 effect->ctx_end = _rotation_effect_end_create(effect, effect->targets, desk);
731 if (!effect->ctx_end) return;
733 EFFINF("Rotation End Prepared", NULL, NULL);
735 effect->targets = eina_list_free(effect->targets);
739 _rotation_effect_cb_zone_rotation_begin(void *data, int type, void *event)
741 Rotation_Effect *effect;
742 E_Event_Zone_Rotation_Change_Begin *ev = event;
746 effect = (Rotation_Effect *)data;
747 if (!effect) return ECORE_CALLBACK_PASS_ON;
750 if (!zone) return ECORE_CALLBACK_PASS_ON;
752 EFFINF("Zone rotation begin zone(prev:%d cur:%d)",
754 zone->rot.prev, zone->rot.curr);
756 if (zone->rot.prev == zone->rot.curr) return ECORE_CALLBACK_PASS_ON;
758 _rotation_zone->curr_angle = zone->rot.curr;
759 _rotation_zone->prev_angle = zone->rot.prev;
761 desk = e_desk_current_get(zone);
762 _rotation_effect_animator_begin_prepare(effect, desk);
765 _rotation_effect_ready_send(zone);
767 return ECORE_CALLBACK_PASS_ON;
771 _rotation_effect_cb_zone_rotation_end(void *data, int type, void *event)
773 Rotation_Effect *effect;
774 E_Event_Zone_Rotation_Change_End *ev = event;
778 effect = (Rotation_Effect *)data;
779 if (!effect) return ECORE_CALLBACK_PASS_ON;
782 if (!zone) return ECORE_CALLBACK_PASS_ON;
784 EFFINF("Zone rotation end angle(prev:%d cur:%d)", NULL, NULL,
785 zone->rot.prev, zone->rot.curr);
787 if (effect->running) return ECORE_CALLBACK_PASS_ON;
788 if (effect->waiting_list)
790 effect->wait_for_buffer = EINA_TRUE;
791 return ECORE_CALLBACK_PASS_ON;
794 if (!effect->ctx_end)
796 desk = e_desk_current_get(zone);
797 _rotation_effect_animator_end_prepare(effect, desk);
799 if (!effect->ctx_end)
800 _rotation_effect_clear(effect);
802 if (effect->ctx_end) _rotation_effect_start(effect);
804 return ECORE_CALLBACK_PASS_ON;
808 _rotation_effect_cb_zone_rotation_cancel(void *data, int type, void *event)
810 E_Event_Zone_Rotation_Change_Cancel *ev = event;
811 Rotation_Effect *effect;
815 if (!zone) return ECORE_CALLBACK_PASS_ON;
817 effect = (Rotation_Effect *)data;
818 if (!effect) return ECORE_CALLBACK_PASS_ON;
820 EFFINF("Zone Rotation Cancelled", NULL, NULL);
822 if (effect->running) return ECORE_CALLBACK_PASS_ON;
823 if (effect->targets) _rotation_effect_cancel_send(zone);
824 _rotation_effect_clear(effect);
826 return ECORE_CALLBACK_PASS_ON;
830 _rotation_effect_cb_buffer_change(void *data, int ev_type, void *event)
832 E_Event_Client *ev = event;
835 Rotation_Effect *effect;
838 if (!ec) return ECORE_CALLBACK_PASS_ON;
840 effect = (Rotation_Effect *)data;
841 if (!effect) return ECORE_CALLBACK_PASS_ON;
842 if (!effect->ctx_begin) return ECORE_CALLBACK_PASS_ON;
843 if (!effect->waiting_list) return ECORE_CALLBACK_PASS_ON;
845 effect->waiting_list = eina_list_remove(effect->waiting_list, ec);
846 if (effect->waiting_list) return ECORE_CALLBACK_PASS_ON;
848 if (!effect->wait_for_buffer) return ECORE_CALLBACK_PASS_ON;
850 if (!effect->ctx_end)
852 desk = e_desk_current_get(ec->zone);
853 _rotation_effect_animator_end_prepare(effect, desk);
855 if (effect->ctx_end) _rotation_effect_start(effect);
857 return ECORE_CALLBACK_PASS_ON;
861 _rotation_effect_cb_client_hide(void *data, int ev_type, void *event)
863 E_Event_Client *ev = event;
865 Rotation_Effect *effect;
869 if (!ec) return ECORE_CALLBACK_PASS_ON;
871 effect = (Rotation_Effect *)data;
872 if (!effect) return ECORE_CALLBACK_PASS_ON;
873 if (!effect->ctx_begin) return ECORE_CALLBACK_PASS_ON;
874 if (!effect->waiting_list) return ECORE_CALLBACK_PASS_ON;
876 effect->waiting_list = eina_list_remove(effect->waiting_list, ec);
877 if (effect->waiting_list) return ECORE_CALLBACK_PASS_ON;
879 if (!effect->wait_for_buffer) return ECORE_CALLBACK_PASS_ON;
881 if (!effect->ctx_end)
883 desk = e_desk_current_get(ec->zone);
884 _rotation_effect_animator_end_prepare(effect, desk);
886 if (effect->ctx_end) _rotation_effect_start(effect);
888 return ECORE_CALLBACK_PASS_ON;
892 _rotation_effect_cb_client_remove(void *data, int ev_type, void *event)
894 E_Event_Client *ev = event;
896 Rotation_Effect *effect;
897 Rotation_Effect_Object *eobj;
899 Eina_Bool clear = EINA_FALSE;
902 if (!ec) return ECORE_CALLBACK_PASS_ON;
904 effect = (Rotation_Effect *)data;
905 if (!effect) return ECORE_CALLBACK_PASS_ON;
906 if (effect->ctx_begin)
908 EINA_LIST_FOREACH(effect->ctx_begin->objects, l, eobj)
918 _rotation_effect_clear(effect);
921 return ECORE_CALLBACK_PASS_ON;
925 _rotation_effect_free(Rotation_Effect *effect)
929 _rotation_effect_clear(effect);
930 evas_object_del(effect->bg);
934 static Rotation_Effect *
935 _rotation_effect_create(E_Zone *zone)
937 Rotation_Effect *rotation_effect;
939 rotation_effect = E_NEW(Rotation_Effect, 1);
940 if (!rotation_effect) return NULL;
942 rotation_effect->zone = zone;
944 rotation_effect->bg = evas_object_rectangle_add(e_comp->evas);
945 e_util_size_debug_set(rotation_effect->bg, 1);
946 evas_object_color_set(rotation_effect->bg, 0, 0, 0, 255);
947 evas_object_layer_set(rotation_effect->bg, E_LAYER_EFFECT);
948 evas_object_name_set(rotation_effect->bg, "rotation-bg");
950 return rotation_effect;
954 _rotation_zone_free(Rotation_Zone *rotation_zone)
956 if (!rotation_zone) return;
958 E_FREE_LIST(rotation_zone->event_hdlrs, ecore_event_handler_del);
960 _rotation_effect_free(rotation_zone->effect);
962 E_FREE(rotation_zone);
967 static Rotation_Zone *
968 _rotation_zone_create(E_Zone *zone)
970 Rotation_Zone *rotation_zone = NULL;
972 if (!zone) return NULL;
973 if ((zone->w == 0) || (zone->h == 0)) return NULL;
975 rotation_zone = E_NEW(Rotation_Zone, 1);
976 if (!rotation_zone) return NULL;
978 /* create rotation effect data */
979 rotation_zone->effect = _rotation_effect_create(zone);
980 if (!rotation_zone->effect)
982 E_FREE(rotation_zone);
986 rotation_zone->zone = zone;
987 rotation_zone->curr_angle = zone->rot.curr;
988 rotation_zone->prev_angle = zone->rot.prev;
990 E_LIST_HANDLER_APPEND(rotation_zone->event_hdlrs,
991 E_EVENT_ZONE_ROTATION_CHANGE_BEGIN,
992 _rotation_effect_cb_zone_rotation_begin, rotation_zone->effect);
994 E_LIST_HANDLER_APPEND(rotation_zone->event_hdlrs,
995 E_EVENT_ZONE_ROTATION_CHANGE_END,
996 _rotation_effect_cb_zone_rotation_end, rotation_zone->effect);
998 E_LIST_HANDLER_APPEND(rotation_zone->event_hdlrs,
999 E_EVENT_ZONE_ROTATION_CHANGE_CANCEL,
1000 _rotation_effect_cb_zone_rotation_cancel, rotation_zone->effect);
1002 E_LIST_HANDLER_APPEND(rotation_zone->event_hdlrs,
1003 E_EVENT_CLIENT_BUFFER_CHANGE,
1004 _rotation_effect_cb_buffer_change, rotation_zone->effect);
1006 E_LIST_HANDLER_APPEND(rotation_zone->event_hdlrs,
1007 E_EVENT_CLIENT_HIDE,
1008 _rotation_effect_cb_client_hide, rotation_zone->effect);
1010 E_LIST_HANDLER_APPEND(rotation_zone->event_hdlrs,
1011 E_EVENT_CLIENT_REMOVE,
1012 _rotation_effect_cb_client_remove, rotation_zone->effect);
1014 return rotation_zone;
1018 e_mod_effect_rotation_init(void)
1020 _rotation_zone = _rotation_zone_create(e_zone_current_get());
1021 if (!_rotation_zone) return EINA_FALSE;
1027 e_mod_effect_rotation_shutdown(void)
1030 _rotation_zone_free(_rotation_zone);
1032 _rotation_zone = NULL;