compositor: Remove prepare_scanout_surface callout
authorKristian Høgsberg <krh@bitplanet.net>
Thu, 26 Jan 2012 04:59:42 +0000 (23:59 -0500)
committerKristian Høgsberg <krh@bitplanet.net>
Thu, 26 Jan 2012 04:59:44 +0000 (23:59 -0500)
For the drm backend, we just refactor setup_scanout_surface into
drm_output_prepare_scanout_surface and call it from drm_output_repaint.

src/compositor-drm.c
src/compositor-wayland.c
src/compositor-x11.c
src/compositor.c
src/compositor.h

index 53163e2..adfea93 100644 (file)
@@ -78,6 +78,64 @@ struct drm_output {
        uint32_t pending_fs_surf_fb_id;
 };
 
+static int
+drm_output_prepare_scanout_surface(struct drm_output *output)
+{
+       struct drm_compositor *c =
+               (struct drm_compositor *) output->base.compositor;
+       struct weston_surface *es;
+       EGLint handle, stride;
+       int ret;
+       uint32_t fb_id = 0;
+       struct gbm_bo *bo;
+
+       es = container_of(c->base.surface_list.next,
+                         struct weston_surface, link);
+
+       if (es->visual != WESTON_RGB_VISUAL ||
+           es->x != output->base.x ||
+           es->y != output->base.y ||
+           es->width != output->base.current->width ||
+           es->height != output->base.current->height ||
+           es->image == EGL_NO_IMAGE_KHR)
+               return -1;
+
+       bo = gbm_bo_create_from_egl_image(c->gbm,
+                                         c->base.display, es->image,
+                                         es->width, es->height,
+                                         GBM_BO_USE_SCANOUT);
+
+       handle = gbm_bo_get_handle(bo).s32;
+       stride = gbm_bo_get_pitch(bo);
+
+       gbm_bo_destroy(bo);
+
+       if (handle == 0)
+               return -1;
+
+       ret = drmModeAddFB(c->drm.fd,
+                          output->base.current->width,
+                          output->base.current->height,
+                          24, 32, stride, handle, &fb_id);
+
+       if (ret)
+               return -1;
+
+       output->pending_fs_surf_fb_id = fb_id;
+
+       /* assert output->pending_scanout_buffer == NULL */
+       output->base.pending_scanout_buffer = es->buffer;
+       output->base.pending_scanout_buffer->busy_count++;
+
+       wl_list_insert(output->base.pending_scanout_buffer->resource.destroy_listener_list.prev,
+                      &output->base.pending_scanout_buffer_destroy_listener.link);
+
+       pixman_region32_fini(&es->damage);
+       pixman_region32_init(&es->damage);
+
+       return 0;
+}
+
 static void
 drm_output_repaint(struct weston_output *output_base)
 {
@@ -95,6 +153,8 @@ drm_output_repaint(struct weston_output *output_base)
        if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
                return;
 
+       drm_output_prepare_scanout_surface(output);
+
        wl_list_for_each_reverse(surface, &compositor->base.surface_list, link)
                weston_surface_draw(surface, &output->base);
 
@@ -142,51 +202,6 @@ page_flip_handler(int fd, unsigned int frame,
 }
 
 static int
-drm_output_prepare_scanout_surface(struct weston_output *output_base,
-                                  struct weston_surface *es)
-{
-       struct drm_output *output = (struct drm_output *) output_base;
-       struct drm_compositor *c =
-               (struct drm_compositor *) output->base.compositor;
-       EGLint handle, stride;
-       int ret;
-       uint32_t fb_id = 0;
-       struct gbm_bo *bo;
-
-       if (es->x != output->base.x ||
-           es->y != output->base.y ||
-           es->width != output->base.current->width ||
-           es->height != output->base.current->height ||
-           es->image == EGL_NO_IMAGE_KHR)
-               return -1;
-
-       bo = gbm_bo_create_from_egl_image(c->gbm,
-                                         c->base.display, es->image,
-                                         es->width, es->height,
-                                         GBM_BO_USE_SCANOUT);
-
-       handle = gbm_bo_get_handle(bo).s32;
-       stride = gbm_bo_get_pitch(bo);
-
-       gbm_bo_destroy(bo);
-
-       if (handle == 0)
-               return -1;
-
-       ret = drmModeAddFB(c->drm.fd,
-                          output->base.current->width,
-                          output->base.current->height,
-                          24, 32, stride, handle, &fb_id);
-
-       if (ret)
-               return -1;
-
-       output->pending_fs_surf_fb_id = fb_id;
-
-       return 0;
-}
-
-static int
 drm_output_set_cursor(struct weston_output *output_base,
                      struct weston_input_device *eid)
 {
@@ -550,8 +565,6 @@ create_output_for_connector(struct drm_compositor *ec,
 
        output->pending_fs_surf_fb_id = 0;
        output->base.repaint = drm_output_repaint;
-       output->base.prepare_scanout_surface =
-               drm_output_prepare_scanout_surface;
        output->base.set_hardware_cursor = drm_output_set_cursor;
        output->base.destroy = drm_output_destroy;
 
index 48ccd0e..6eb0cd0 100644 (file)
@@ -199,13 +199,6 @@ wayland_output_repaint(struct weston_output *output_base)
 }
 
 static int
-wayland_output_prepare_scanout_surface(struct weston_output *output_base,
-                                      struct weston_surface *es)
-{
-       return -1;
-}
-
-static int
 wayland_output_set_cursor(struct weston_output *output_base,
                          struct weston_input_device *input)
 {
@@ -283,8 +276,6 @@ wayland_compositor_create_output(struct wayland_compositor *c,
        glClearColor(0, 0, 0, 0.5);
 
        output->base.repaint = wayland_output_repaint;
-       output->base.prepare_scanout_surface =
-               wayland_output_prepare_scanout_surface;
        output->base.set_hardware_cursor = wayland_output_set_cursor;
        output->base.destroy = wayland_output_destroy;
 
index 08306b9..0e58229 100644 (file)
@@ -222,13 +222,6 @@ finish_frame_handler(void *data)
 }
 
 static int
-x11_output_prepare_scanout_surface(struct weston_output *output_base,
-                                  struct weston_surface *es)
-{
-       return -1;
-}
-
-static int
 x11_output_set_cursor(struct weston_output *output_base,
                      struct weston_input_device *input)
 {
@@ -453,8 +446,6 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
                wl_event_loop_add_timer(loop, finish_frame_handler, output);
 
        output->base.repaint = x11_output_repaint;
-       output->base.prepare_scanout_surface =
-               x11_output_prepare_scanout_surface;
        output->base.set_hardware_cursor = x11_output_set_cursor;
        output->base.destroy = x11_output_destroy;
 
index b6a1418..ea03c44 100644 (file)
@@ -785,23 +785,6 @@ out:
        pixman_region32_fini(&cursor_region);
 }
 
-static int
-setup_scanout_surface(struct weston_output *output, struct weston_surface *es)
-{
-       if (es->visual != WESTON_RGB_VISUAL ||
-           output->prepare_scanout_surface(output, es) != 0)
-               return -1;
-
-       /* assert output->pending_scanout_buffer == NULL */
-       output->pending_scanout_buffer = es->buffer;
-       output->pending_scanout_buffer->busy_count++;
-
-       wl_list_insert(output->pending_scanout_buffer->resource.destroy_listener_list.prev,
-                      &output->pending_scanout_buffer_destroy_listener.link);
-
-       return 0;
-}
-
 static void
 weston_output_repaint(struct weston_output *output)
 {
@@ -853,12 +836,6 @@ weston_output_repaint(struct weston_output *output)
                                         &total_damage, &es->opaque);
        }
 
-       es = container_of(ec->surface_list.next, struct weston_surface, link);
-
-       if (setup_scanout_surface(output, es) == 0)
-               /* We're drawing nothing, just let the damage accumulate */
-               return;
-
        output->repaint(output);
 
        if (ec->fade.spring.current > 0.001)
index da37a0a..8a75d56 100644 (file)
@@ -88,8 +88,6 @@ struct weston_output {
        struct wl_listener pending_scanout_buffer_destroy_listener;
 
        void (*repaint)(struct weston_output *output);
-       int (*prepare_scanout_surface)(struct weston_output *output,
-                                      struct weston_surface *es);
        int (*set_hardware_cursor)(struct weston_output *output,
                                   struct weston_input_device *input);
        void (*destroy)(struct weston_output *output);