drm: implement overlay assignment
authorJunghoon <jh13.son@samsung.com>
Tue, 27 Oct 2015 04:23:57 +0000 (13:23 +0900)
committerJunghoon <jh13.son@samsung.com>
Tue, 27 Oct 2015 07:56:16 +0000 (16:56 +0900)
Change-Id: I2c3ae72e04fac638568b15b0b7518febc0724840

src/lib/drm/drm-common.c
src/lib/drm/drm-output.c
src/lib/drm/drm-plane.c

index b322ad1b024361b0fc502aff014104618b2b22ef..81017073c038bc9165ac03d2f83b3541cf304870 100644 (file)
@@ -167,8 +167,8 @@ pepper_drm_create(pepper_compositor_t *compositor, struct udev *udev, const char
     drm->resources = drmModeGetResources(drm->fd);
     PEPPER_CHECK(drm->resources, goto error, "drmModeGetResources() failed.\n");
 
-    drm_init_connectors(drm);
     drm_init_planes(drm);
+    drm_init_connectors(drm);
     udev_device_unref(udev_device);
 
     /* Try to set clock. */
index 61ed17c183f7825c00df393eb01006b1bb45c8c0..3f5fdc8a0ecefdadc6716c21a128a981f723dfda 100644 (file)
@@ -156,7 +156,58 @@ assign_fb_plane(drm_output_t *output, pepper_view_t *view)
 static pepper_plane_t *
 assign_overlay_plane(drm_output_t *output, pepper_view_t *view)
 {
-    /* TODO: */
+    drm_plane_t        *plane;
+    pepper_surface_t   *surface;
+    pepper_buffer_t    *buffer;
+    struct wl_resource *resource;
+
+    double              x, y;
+    int                 w, h;
+
+    if (!output->drm->gbm_device)
+        return NULL;
+
+    surface = pepper_view_get_surface(view);
+    if (!surface)
+        return NULL;
+
+    buffer = pepper_surface_get_buffer(surface);
+    if (!buffer)
+        return NULL;
+
+    resource = pepper_buffer_get_resource(buffer);
+    if (!resource)
+        return NULL;
+
+    if (wl_shm_buffer_get(resource))
+        return NULL;
+
+    pepper_list_for_each(plane, &output->drm->plane_list, link)
+    {
+        if (!plane->back && (plane->plane->possible_crtcs & (1 << output->crtc_index)))
+        {
+            plane->back = drm_buffer_create_pepper(output->drm, buffer);
+            PEPPER_CHECK(plane->back, return NULL, "failed to create drm_buffer\n");
+
+            /* set position  */
+            pepper_view_get_position(view, &x, &y);
+            pepper_view_get_size(view, &w, &h);
+            plane->dx = (int)x;
+            plane->dy = (int)y;
+            plane->dw = w;
+            plane->dh = h;
+
+            plane->sx = 0 << 16;
+            plane->sy = 0 << 16;
+            plane->sw = w << 16;
+            plane->sh = h << 16;
+
+            plane->output = output;
+
+            return plane->base;
+        }
+    }
+
     return NULL;
 }
 
index 57a95ff947b6823a3c033e44ae2ec746d8ed507d..d06754cbc4eb9160a02c824a1db82776c79f2723 100644 (file)
@@ -20,6 +20,8 @@ drm_init_planes(pepper_drm_t *drm)
             free(plane);
             continue;
         }
+        plane->drm = drm;
+        plane->id = plane->plane->plane_id;
 
         pepper_list_insert(drm->plane_list.prev, &plane->link);
     }