pepper: Attach surface to outputs on surface.commit().
authorTaekyun Kim <tkq.kim@samsung.com>
Thu, 2 Jul 2015 08:41:28 +0000 (17:41 +0900)
committerTaekyun Kim <tkq.kim@samsung.com>
Tue, 7 Jul 2015 06:56:51 +0000 (15:56 +0900)
Attaching a surface is a process of notifying output backends so that they can
prepare for reading it and allocate resources for it.

For some types of buffers like EGL, the size is not known until it is queried
to the native library. although we can get the size of a shm buffer using
wl_shm, we basically assume that the buffer size should be queried to output
backends. If the backend uses pepper_render, then it can simply redirect the
request to the renderer.

Change-Id: Ie145f9029447605116a81984431cdc5235dc1eca

drm/src/drm-output.c
fbdev/src/fbdev-output.c
pepper/src/pepper-internal.h
pepper/src/pepper.h
pepper/src/surface.c
wayland/src/wayland-output.c
x11/src/x11-output.c

index 1c95c45..4bd10a8 100644 (file)
@@ -282,6 +282,12 @@ drm_output_repaint(void *o, const pepper_list_t *view_list, const pixman_region3
 }
 
 static void
+drm_output_attach_surface(void *o, pepper_object_t *surface, int *w, int *h)
+{
+    pepper_renderer_attach_surface(((drm_output_t *)o)->renderer, surface, w, h);
+}
+
+static void
 drm_output_add_frame_listener(void *o, struct wl_listener *listener)
 {
     drm_output_t *output = (drm_output_t *)o;
@@ -303,6 +309,7 @@ struct pepper_output_interface drm_output_interface =
     drm_output_set_mode,
 
     drm_output_repaint,
+    drm_output_attach_surface,
     drm_output_add_frame_listener,
 };
 
index ecb74e2..4114de9 100644 (file)
@@ -179,6 +179,12 @@ fbdev_output_repaint(void *o, const pepper_list_t *view_list, const pixman_regio
 }
 
 static void
+fbdev_output_attach_surface(void *o, pepper_object_t *surface, int *w, int *h)
+{
+    pepper_renderer_attach_surface(((fbdev_output_t *)o)->renderer, surface, w, h);
+}
+
+static void
 fbdev_output_add_frame_listener(void *o, struct wl_listener *listener)
 {
     fbdev_output_t *output = (fbdev_output_t *)o;
@@ -200,6 +206,7 @@ struct pepper_output_interface fbdev_output_interface =
     fbdev_output_set_mode,
 
     fbdev_output_repaint,
+    fbdev_output_attach_surface,
     fbdev_output_add_frame_listener,
 };
 
index a895309..02914f8 100644 (file)
@@ -147,6 +147,9 @@ struct pepper_buffer
     int32_t                 w, h;
 };
 
+pepper_buffer_t *
+pepper_buffer_from_resource(struct wl_resource *resource);
+
 struct pepper_surface_state
 {
     pepper_buffer_t    *buffer;
@@ -225,9 +228,6 @@ pepper_region_create(pepper_compositor_t *compositor,
 void
 pepper_region_destroy(pepper_region_t *region);
 
-pepper_buffer_t *
-pepper_buffer_from_resource(struct wl_resource *resource);
-
 /* Input */
 struct pepper_seat
 {
index 06c2c57..e8d1005 100644 (file)
@@ -68,6 +68,7 @@ struct pepper_output_interface
 
     void            (*repaint)(void *output,
                                const pepper_list_t *view_list, const pixman_region32_t *damage);
+    void            (*attach_surface)(void *output, pepper_object_t *surface, int *w, int *h);
 
     void            (*add_frame_listener)(void *output, struct wl_listener *listener);
 };
index a02f13c..fcc5382 100644 (file)
@@ -335,7 +335,16 @@ surface_update_size(pepper_surface_t *surface)
 static void
 attach_surface_to_outputs(pepper_surface_t *surface)
 {
-    /* TODO: */
+    pepper_output_t *output;
+    int              w, h;
+
+    wl_list_for_each(output, &surface->compositor->output_list, link)
+    {
+        output->interface->attach_surface(output->data, &surface->base, &w, &h);
+
+        surface->buffer.buffer->w = w;
+        surface->buffer.buffer->h = h;
+    }
 }
 
 void
index 7cb3942..3565975 100644 (file)
@@ -184,6 +184,12 @@ wayland_output_repaint(void *o, const pepper_list_t *view_list, const pixman_reg
 }
 
 static void
+wayland_output_attach_surface(void *o, pepper_object_t *surface, int *w, int *h)
+{
+    pepper_renderer_attach_surface(((wayland_output_t *)o)->renderer, surface, w, h);
+}
+
+static void
 wayland_output_add_frame_listener(void *o, struct wl_listener *listener)
 {
     wayland_output_t *output = o;
@@ -205,6 +211,7 @@ static const pepper_output_interface_t wayland_output_interface =
     wayland_output_set_mode,
 
     wayland_output_repaint,
+    wayland_output_attach_surface,
     wayland_output_add_frame_listener,
 };
 
index 96959af..091605c 100644 (file)
@@ -486,6 +486,12 @@ x11_output_repaint(void *o, const pepper_list_t *view_list, const pixman_region3
 }
 
 static void
+x11_output_attach_surface(void *o, pepper_object_t *surface, int *w, int *h)
+{
+    pepper_renderer_attach_surface(((x11_output_t *)o)->renderer, surface, w, h);
+}
+
+static void
 x11_output_add_frame_listener(void *o, struct wl_listener *listener)
 {
     x11_output_t *output = o;
@@ -508,6 +514,7 @@ static const pepper_output_interface_t x11_output_interface =
     x11_output_set_mode,
 
     x11_output_repaint,
+    x11_output_attach_surface,
     x11_output_add_frame_listener,
 };