pepper: Add view create/destroy code for subsurface 06/52906/1
authorJaehoon Jeong <jh01.j@samsung.com>
Mon, 23 Nov 2015 05:16:20 +0000 (14:16 +0900)
committerTaekyun Kim <tkq.kim@samsung.com>
Fri, 27 Nov 2015 10:27:54 +0000 (19:27 +0900)
Change-Id: I6f327ec72e3be02eab593c55805ca1b574708c74

src/lib/pepper/pepper-internal.h
src/lib/pepper/subsurface.c
src/lib/pepper/view.c

index d9e3d91..e27098e 100644 (file)
@@ -322,6 +322,12 @@ pepper_subsurface_commit(pepper_subsurface_t *subsurface);
 void
 pepper_subsurface_destroy(pepper_subsurface_t *subsurface);
 
+void
+subsurface_destroy_children_views(pepper_subsurface_t *subsurface, pepper_view_t *parent_view);
+
+void
+subsurface_create_children_views(pepper_subsurface_t *subsurface, pepper_view_t *parent_view);
+
 /* Input */
 struct pepper_pointer
 {
index 29c3c83..165a1ab 100644 (file)
@@ -576,3 +576,61 @@ pepper_subsurface_commit(pepper_subsurface_t *subsurface)
 
     return PEPPER_FALSE;
 }
+
+void
+subsurface_destroy_children_views(pepper_subsurface_t *subsurface, pepper_view_t *parent_view)
+{
+    pepper_list_t *list;
+
+    if (!subsurface)
+        return ;
+
+    pepper_list_for_each_list(list, &subsurface->children_list)
+    {
+        pepper_subsurface_t *child = list->item;
+
+        /* Except its own */
+        if(child && (child != subsurface))
+        {
+            pepper_view_t *view;
+
+            pepper_list_for_each(view, &subsurface->surface->view_list, surface_link)
+            {
+                if (view->parent == parent_view)
+                {
+                    /* FIXME: need this ? */
+                    pepper_view_set_surface(view, NULL);
+                    pepper_view_destroy(view);
+                }
+            }
+        }
+    }
+}
+
+void
+subsurface_create_children_views(pepper_subsurface_t *subsurface, pepper_view_t *parent_view)
+{
+    pepper_list_t *list;
+
+    if (!subsurface)
+        return ;
+
+    pepper_list_for_each_list(list, &subsurface->children_list)
+    {
+        pepper_subsurface_t *child = list->item;
+
+        /* Except its own */
+        if(child && (child != subsurface))
+        {
+            pepper_view_t *view = pepper_compositor_add_view(subsurface->surface->compositor);
+            pepper_view_set_surface(view, child->surface);
+            pepper_view_set_parent(view, parent_view);
+            pepper_view_set_transform_inherit(view, PEPPER_TRUE);
+
+            /* FIXME */
+            pepper_view_map(view);
+        }
+    }
+
+    subsurface->need_restack = PEPPER_TRUE;
+}
index 3da8756..cea3e8e 100644 (file)
@@ -308,6 +308,22 @@ pepper_compositor_add_view(pepper_compositor_t *compositor)
     return view;
 }
 
+static void
+view_unlink_from_surface(pepper_view_t *view)
+{
+    pepper_list_remove(&view->surface_link);
+
+    subsurface_destroy_children_views(view->surface->sub, view);
+}
+
+static void
+view_link_to_surface(pepper_view_t *view)
+{
+    pepper_list_insert(&view->surface->view_list, &view->surface_link);
+
+    subsurface_create_children_views(view->surface->sub, view);
+}
+
 PEPPER_API pepper_bool_t
 pepper_view_set_surface(pepper_view_t *view, pepper_surface_t *surface)
 {
@@ -315,12 +331,12 @@ pepper_view_set_surface(pepper_view_t *view, pepper_surface_t *surface)
         return PEPPER_TRUE;
 
     if (view->surface)
-        pepper_list_remove(&view->surface_link);
+        view_unlink_from_surface(view);
 
     view->surface = surface;
 
     if (view->surface)
-        pepper_list_insert(&surface->view_list, &view->surface_link);
+        view_link_to_surface(view);
 
     pepper_view_mark_dirty(view, PEPPER_VIEW_GEOMETRY_DIRTY);
     return PEPPER_TRUE;