e_plane: 1st implementation of e_plane corresponding to hwc overlay 29/65129/7
authorJuyeon Lee <juyeonne.lee@samsung.com>
Thu, 7 Apr 2016 10:06:24 +0000 (19:06 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Fri, 8 Apr 2016 05:22:48 +0000 (22:22 -0700)
Change-Id: Ia34898cc58e92cfb37a61864c7dffa846fa2372a

src/bin/Makefile.mk
src/bin/e_comp.c
src/bin/e_comp_hwc.c
src/bin/e_comp_hwc.h
src/bin/e_includes.h
src/bin/e_main.c
src/bin/e_plane.c [new file with mode: 0644]
src/bin/e_plane.h [new file with mode: 0644]
src/bin/e_zone.c
src/bin/e_zone.h

index 7c6b6bbec668a07bfbe5f87224d6c46e70ecbc17..2da04d18334d3db2bd4e995dd8e69948675da78c 100644 (file)
@@ -63,6 +63,7 @@ src/bin/e_object.h \
 src/bin/e_path.h \
 src/bin/e_pixmap.h \
 src/bin/e_place.h \
+src/bin/e_plane.h \
 src/bin/e_pointer.h \
 src/bin/e_prefix.h \
 src/bin/e_randr2.h \
@@ -136,6 +137,7 @@ src/bin/e_object.c \
 src/bin/e_path.c \
 src/bin/e_pixmap.c \
 src/bin/e_place.c \
+src/bin/e_plane.c \
 src/bin/e_pointer.c \
 src/bin/e_prefix.c \
 src/bin/e_randr2.c \
index b068630c869c7a7a404c44eda60d212baba8ccc9..84d5efc5ecb7feabd82ebc2ec88ca9dfef9dff55 100755 (executable)
@@ -1008,6 +1008,8 @@ e_comp_init(void)
         e_comp->hwc = e_comp_hwc_init();
         if (!e_comp->hwc)
           WRN("fail to init hwc.");
+
+        E_LIST_FOREACH(e_comp->zones, e_comp_hwc_plane_init);
      }
 #endif
 
index e26511e5fe4b35e6d81414d579a04147b31081e0..d4c135603eb36b1d0540df5d05f17eb75efba06b 100755 (executable)
@@ -1425,3 +1425,53 @@ e_comp_hwc_trace_debug(Eina_Bool onoff)
    INF("HWC: hwc trace_debug is %s", onoff?"ON":"OFF");
 }
 
+EINTERN Eina_Bool
+e_comp_hwc_plane_init(E_Zone *zone)
+{
+   E_Comp_Hwc_Output *hwc_output = NULL;
+   E_Comp_Hwc_Layer *hwc_layer;
+   Ecore_Drm_Device *dev;
+   Ecore_Drm_Output *drm_output;
+   E_Randr2_Screen *s;
+   const Eina_List *l, *ll;
+   tdm_layer_capability capa;
+
+   EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev)
+     {
+        EINA_LIST_FOREACH(e_randr2->screens, ll, s)
+          {
+             int len;
+
+             if (!s->config.enabled) continue;
+
+             drm_output = ecore_drm_device_output_name_find(dev, s->info.name);
+             if (!drm_output) continue;
+
+             len = strlen(zone->randr2_id);
+             if (strncmp(s->info.name, zone->randr2_id, len -1) != 0) continue;
+             // DSI-0/(randr2_id) DSI-0(s->info.name)
+
+             hwc_output = _e_comp_hwc_output_find(drm_output);
+             if (hwc_output) break;
+          }
+     }
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc_output, EINA_FALSE);
+
+   EINA_LIST_FOREACH_SAFE(hwc_output->hwc_layers, l, ll, hwc_layer)
+     {
+        E_Plane *ep;
+        if (!hwc_layer) continue;
+
+        ep = e_plane_new(zone);
+
+        tdm_layer_get_capabilities(hwc_layer->tlayer, &capa);
+
+        if (capa & (TDM_LAYER_CAPABILITY_PRIMARY))
+          {
+             zone->primary_plane = ep;
+          }
+     }
+
+   return EINA_TRUE;
+}
index 5e4d1a802d2e9bdbca0d50d5aa2c75e641117630..c22546ca3f809b208e8731c59dd71e56319bd7da 100644 (file)
@@ -8,6 +8,7 @@ EINTERN void      e_comp_hwc_shutdown(void);
 EINTERN Eina_Bool e_comp_hwc_mode_nocomp(E_Client *ec);
 EINTERN void      e_comp_hwc_display_client(E_Client *ec);
 EINTERN void      e_comp_hwc_trace_debug(Eina_Bool onoff);
+EINTERN Eina_Bool e_comp_hwc_plane_init(E_Zone *zone);
 
 # endif
 #endif
index c4c2712e5af5ce7c5f27c90ec7526c8f5e3b23a8..1934d3ff673cbadd808316cce73093eae3fe7caa 100644 (file)
@@ -51,6 +51,7 @@
 #include "e_comp_canvas.h"
 #include "e_utils.h"
 #include "e_hints.h"
+#include "e_plane.h"
 
 #ifdef HAVE_WAYLAND
 # include "e_comp_wl.h"
index e9f92aad08d27d312d5758e29604ebfb683aebe0..614d9464a261ca0a00f5decaed2bfd0f708a2010 100644 (file)
@@ -574,6 +574,7 @@ main(int argc, char **argv)
     */
    e_zone_init();
    e_desk_init();
+   e_plane_init();
 
    TS("E_Screensaver Init");
    if (!e_screensaver_init())
@@ -1105,6 +1106,7 @@ _e_main_screens_shutdown(void)
    e_comp_shutdown();
    e_client_shutdown();
 
+   e_plane_shutdown();
    e_desk_shutdown();
    e_zone_shutdown();
    return 1;
diff --git a/src/bin/e_plane.c b/src/bin/e_plane.c
new file mode 100644 (file)
index 0000000..fe4e2cf
--- /dev/null
@@ -0,0 +1,145 @@
+#include "e.h"
+
+/* E_Plane is a child object of E_Zone. There is one zone per screen
+ * in a xinerama setup. Each zone has one or more planes.
+ */
+
+E_API int E_EVENT_PLANE_ADD = 0;
+E_API int E_EVENT_PLANE_DEL = 0;
+
+///////////////////////////////////////////
+
+/* local subsystem functions */
+static void
+_e_plane_free(E_Plane *plane)
+{
+   //printf("@@@@@@@@@@ e_plane_free: %i %i | %i %i %ix%i = %p\n", zone->num, zone->id, zone->x, zone->y, zone->w, zone->h, zone);
+
+   /* Delete the object event callbacks */
+
+   /* remove clients list */
+   eina_list_free(plane->clist);
+
+   /* remove handlers */
+   E_FREE_LIST(plane->handlers, ecore_event_handler_del);
+
+   if (plane->name) eina_stringshare_del(plane->name);
+
+   free(plane);
+}
+
+static void
+_e_plane_reconfigure_clients(E_Plane *plane, int dx, int dy, int dw, int dh)
+{
+   E_Client *ec;
+
+   Eina_List *l, *ll;
+   EINA_LIST_FOREACH_SAFE(plane->clist, l, ll, ec)
+     {
+        if (!ec) break;
+        /* TODO: config ec refer to resolution */
+     }
+}
+
+///////////////////////////////////////////
+
+EINTERN int
+e_plane_init(void)
+{
+   E_EVENT_PLANE_ADD = ecore_event_type_new();
+   E_EVENT_PLANE_DEL = ecore_event_type_new();
+
+   return 1;
+}
+
+EINTERN int
+e_plane_shutdown(void)
+{
+   return 1;
+}
+
+E_API E_Plane *
+e_plane_new(E_Zone *zone)
+{
+   E_Plane *plane;
+
+   char name[40];
+
+   if (!zone) return NULL;
+
+   plane = E_OBJECT_ALLOC(E_Plane, E_PLANE_TYPE, _e_plane_free);
+   if (!plane) return NULL;
+
+   snprintf(name, sizeof(name), "Plane %d", zone->num);
+   plane->name = eina_stringshare_add(name);
+
+   plane->type = E_PLANE_TYPE_INVALID;
+   plane->zone = zone;
+
+   /* config default resolution with zone size*/
+   plane->resolution.x = zone->x;
+   plane->resolution.y = zone->y;
+   plane->resolution.w = zone->w;
+   plane->resolution.h = zone->h;
+
+   zone->planes = eina_list_append(zone->planes, plane);
+
+   printf("@@@@@@@@@@ e_plane_new: %s | %i %i %ix%i = %p\n", zone->randr2_id, plane->resolution.x , plane->resolution.y, plane->resolution.w, plane->resolution.h, zone);
+
+   return plane;
+}
+
+E_API void
+e_plane_name_set(E_Zone *zone,
+                const char *name)
+{
+   E_OBJECT_CHECK(zone);
+   E_OBJECT_TYPE_CHECK(zone, E_PLANE_TYPE);
+
+   if (zone->name) eina_stringshare_del(zone->name);
+   zone->name = eina_stringshare_add(name);
+}
+
+
+E_API Eina_Bool
+e_plane_resolution_set(E_Plane *plane,
+                   int x,
+                   int y,
+                   int w,
+                   int h)
+{
+   int dx, dy, dw, dh;
+
+   E_OBJECT_CHECK_RETURN(plane, EINA_FALSE);
+   E_OBJECT_TYPE_CHECK_RETURN(plane, E_PLANE_TYPE, EINA_FALSE);
+
+   if ((x == plane->resolution.x) && (plane->resolution.y) && (w == plane->resolution.w) && (h == plane->resolution.h))
+     return EINA_FALSE;
+
+   plane->resolution.x = x;
+   plane->resolution.y = y;
+   plane->resolution.w = w;
+   plane->resolution.h = h;
+
+   /* TODO: config clist refer to resolution */
+   _e_plane_reconfigure_clients(plane, dx, dy, dw, dh);
+   return EINA_TRUE;
+}
+
+E_API void
+e_plane_type_set(E_Plane *plane, E_Plane_Type_State type)
+{
+   E_OBJECT_CHECK(plane);
+   E_OBJECT_TYPE_CHECK(plane, E_PLANE_TYPE);
+
+   plane->type = type;
+}
+
+E_API E_Plane_Type_State
+e_plane_type_get(E_Plane *plane)
+{
+   E_OBJECT_CHECK_RETURN(plane, E_ZONE_DISPLAY_STATE_OFF);
+   E_OBJECT_TYPE_CHECK_RETURN(plane, E_PLANE_TYPE, E_ZONE_DISPLAY_STATE_OFF);
+
+   return plane->type;
+}
diff --git a/src/bin/e_plane.h b/src/bin/e_plane.h
new file mode 100644 (file)
index 0000000..191d70e
--- /dev/null
@@ -0,0 +1,48 @@
+#ifdef E_TYPEDEFS
+
+typedef struct _E_Plane                      E_Plane;
+
+#else
+#ifndef E_PLANE_H
+#define E_PLANE_H
+
+#define E_PLANE_TYPE (int)0xE0b11001
+
+typedef enum _E_Plane_Type_State
+{
+   E_PLANE_TYPE_INVALID,
+   E_PLANE_TYPE_PRIMARY,
+   E_PLANE_TYPE_SELECTIVE,
+   E_PLANE_TYPE_CURSOR
+} E_Plane_Type_State;
+
+struct _E_Plane
+{
+   E_Object     e_obj_inherit;
+
+   struct
+   {
+      int          x, y, w, h; // FIXME
+   } resolution;
+
+   const char  *name;
+   E_Plane_Type_State type;
+   E_Zone              *zone;
+   Eina_List   *clist;
+   Eina_List   *handlers;
+};
+
+extern E_API int E_EVENT_PLANE_ADD;
+extern E_API int E_EVENT_PLANE_DEL;
+
+EINTERN int    e_plane_init(void);
+EINTERN int    e_plane_shutdown(void);
+E_API E_Plane   * e_plane_new(E_Zone *zone);
+E_API void       e_plane_name_set(E_Zone *zone, const char *name);
+E_API Eina_Bool  e_plane_resolution_set(E_Plane *plane, int x, int y, int w, int h);
+E_API void       e_plane_type_set(E_Plane *plane, E_Plane_Type_State type);
+E_API E_Plane_Type_State e_plane_type_get(E_Plane *plane);
+
+
+#endif
+#endif
index ceb19626cc411853f292084ce44e71026aa28580..15aeef36b3ecc385228f88a5df7d16afcc0524c7 100644 (file)
@@ -1162,7 +1162,7 @@ static void
 _e_zone_free(E_Zone *zone)
 {
    int x, y;
-
+   E_Plane *ep;
    //printf("@@@@@@@@@@ e_zone_free: %i %i | %i %i %ix%i = %p\n", zone->num, zone->id, zone->x, zone->y, zone->w, zone->h, zone);
    /* Delete the edge windows if they exist */
    E_FREE_FUNC(zone->edge.top, evas_object_del);
@@ -1191,6 +1191,13 @@ _e_zone_free(E_Zone *zone)
    /* remove handlers */
    E_FREE_LIST(zone->handlers, ecore_event_handler_del);
 
+   /* remove planes */
+   EINA_LIST_FREE(zone->planes, ep)
+     {
+        if (!e_object_is_del(E_OBJECT(ep)))
+           e_object_free(E_OBJECT(ep));
+     }
+
    if (zone->name) eina_stringshare_del(zone->name);
    e_comp->zones = eina_list_remove(e_comp->zones, zone);
    evas_object_del(zone->bg_event_object);
index b44f88d622ff6742b6ee80a8fca454a743a800b4..7007653d665bde4622e9cc4e28f1cd84426289b7 100644 (file)
@@ -110,6 +110,9 @@ struct _E_Zone
 
    E_Zone_Display_State display_state;
    char *randr2_id; // same id we get from randr2 so look it up there
+
+   Eina_List   *planes;
+   E_Plane     *primary_plane;
 };
 
 struct _E_Event_Zone_Generic