diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2012-01-25 23:47:45 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-01-25 23:47:45 -0500 |
commit | 06cf6b0238ed6c7a38bd6e8706e7058929c04e61 (patch) | |
tree | 5e900f0a737ff3d97b73a2aea84c232438a4898a /src | |
parent | 68c479af05e4d85985a92b31827cb3e5b44c72e1 (diff) |
compositor: Pull prepare_render and present callouts into repaint
This dramatically simplifies the backend repaint abstractions and paves
the way for moving overlay and cursor setup into the backend.
Diffstat (limited to 'src')
-rw-r--r-- | src/compositor-drm.c | 43 | ||||
-rw-r--r-- | src/compositor-openwfd.c | 33 | ||||
-rw-r--r-- | src/compositor-wayland.c | 48 | ||||
-rw-r--r-- | src/compositor-x11.c | 47 | ||||
-rw-r--r-- | src/compositor.c | 3 | ||||
-rw-r--r-- | src/compositor.h | 2 |
6 files changed, 47 insertions, 129 deletions
diff --git a/src/compositor-drm.c b/src/compositor-drm.c index b987a12..53163e2 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -78,10 +78,14 @@ struct drm_output { uint32_t pending_fs_surf_fb_id; }; -static int -drm_output_prepare_render(struct weston_output *output_base) +static void +drm_output_repaint(struct weston_output *output_base) { struct drm_output *output = (struct drm_output *) output_base; + struct drm_compositor *compositor = + (struct drm_compositor *) output->base.compositor; + struct weston_surface *surface; + uint32_t fb_id = 0; glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, @@ -89,31 +93,10 @@ drm_output_prepare_render(struct weston_output *output_base) output->rbo[output->current]); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) - return -1; - - return 0; -} - -static void -drm_output_repaint(struct weston_output *output) -{ - struct weston_compositor *compositor = output->compositor; - struct weston_surface *surface; - - surface = container_of(compositor->surface_list.next, - struct weston_surface, link); + return; - wl_list_for_each_reverse(surface, &compositor->surface_list, link) - weston_surface_draw(surface, output); -} - -static int -drm_output_present(struct weston_output *output_base) -{ - struct drm_output *output = (struct drm_output *) output_base; - struct drm_compositor *c = - (struct drm_compositor *) output->base.compositor; - uint32_t fb_id = 0; + wl_list_for_each_reverse(surface, &compositor->base.surface_list, link) + weston_surface_draw(surface, &output->base); glFlush(); @@ -125,14 +108,14 @@ drm_output_present(struct weston_output *output_base) fb_id = output->fb_id[output->current ^ 1]; } - if (drmModePageFlip(c->drm.fd, output->crtc_id, + if (drmModePageFlip(compositor->drm.fd, output->crtc_id, fb_id, DRM_MODE_PAGE_FLIP_EVENT, output) < 0) { fprintf(stderr, "queueing pageflip failed: %m\n"); - return -1; + return; } - return 0; + return; } static void @@ -566,9 +549,7 @@ create_output_for_connector(struct drm_compositor *ec, wl_list_insert(ec->base.output_list.prev, &output->base.link); output->pending_fs_surf_fb_id = 0; - output->base.prepare_render = drm_output_prepare_render; output->base.repaint = drm_output_repaint; - output->base.present = drm_output_present; output->base.prepare_scanout_surface = drm_output_prepare_scanout_surface; output->base.set_hardware_cursor = drm_output_set_cursor; diff --git a/src/compositor-openwfd.c b/src/compositor-openwfd.c index a5bb265..aa4e5a9 100644 --- a/src/compositor-openwfd.c +++ b/src/compositor-openwfd.c @@ -85,10 +85,13 @@ union wfd_geometry { WFDint array[4]; }; -static int -wfd_output_prepare_render(struct weston_output *output_base) +static void +wfd_output_repaint(struct weston_output *output_base) { struct wfd_output *output = (struct wfd_output *) output_base; + struct weston_surface *surface; + struct wfd_compositor *compositor = + (struct wfd_compositor *) output->base.compositor; glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, @@ -98,37 +101,19 @@ wfd_output_prepare_render(struct weston_output *output_base) if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) return -1; - return 0; -} - -static void -wfd_output_repaint(struct weston_output *output) -{ - struct weston_compositor *compositor; - struct weston_surface *surface; - wl_list_for_each_reverse(surface, &compositor->surface_list, link) weston_surface_draw(surface, output); -} -static int -wfd_output_present(struct weston_output *output_base) -{ - struct wfd_output *output = (struct wfd_output *) output_base; - struct wfd_compositor *c = - (struct wfd_compositor *) output->base.compositor; - - if (wfd_output_prepare_render(&output->base)) - return -1; glFlush(); output->current ^= 1; - wfdBindSourceToPipeline(c->dev, output->pipeline, + wfdBindSourceToPipeline(compositor->dev, output->pipeline, output->source[output->current ^ 1], WFD_TRANSITION_AT_VSYNC, NULL); - wfdDeviceCommit(c->dev, WFD_COMMIT_PIPELINE, output->pipeline); + wfdDeviceCommit(compositor->dev, + WFD_COMMIT_PIPELINE, output->pipeline); return 0; } @@ -416,9 +401,7 @@ create_output_for_port(struct wfd_compositor *ec, wfdDeviceCommit(ec->dev, WFD_COMMIT_ENTIRE_DEVICE, WFD_INVALID_HANDLE); - output->base.prepare_render = wfd_output_prepare_render; output->base.repaint = wfd_output_repaint; - output->base.present = wfd_output_present; output->base.prepare_scanout_surface = wfd_output_prepare_scanout_surface; output->base.set_hardware_cursor = wfd_output_set_cursor; diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c index c909253..48ccd0e 100644 --- a/src/compositor-wayland.c +++ b/src/compositor-wayland.c @@ -161,31 +161,6 @@ wayland_compositor_init_egl(struct wayland_compositor *c) return 0; } -static int -wayland_output_prepare_render(struct weston_output *output_base) -{ - struct wayland_output *output = (struct wayland_output *) output_base; - struct weston_compositor *ec = output->base.compositor; - - if (!eglMakeCurrent(ec->display, output->egl_surface, - output->egl_surface, ec->context)) { - fprintf(stderr, "failed to make current\n"); - return -1; - } - - return 0; -} - -static void -wayland_output_repaint(struct weston_output *output) -{ - struct weston_compositor *compositor = output->compositor; - struct weston_surface *surface; - - wl_list_for_each_reverse(surface, &compositor->surface_list, link) - weston_surface_draw(surface, output); -} - static void frame_done(void *data, struct wl_callback *wl_callback, uint32_t time) { @@ -198,22 +173,29 @@ static const struct wl_callback_listener frame_listener = { frame_done }; -static int -wayland_output_present(struct weston_output *output_base) +static void +wayland_output_repaint(struct weston_output *output_base) { struct wayland_output *output = (struct wayland_output *) output_base; - struct wayland_compositor *c = + struct wayland_compositor *compositor = (struct wayland_compositor *) output->base.compositor; struct wl_callback *callback; + struct weston_surface *surface; - if (wayland_output_prepare_render(&output->base)) - return -1; + if (!eglMakeCurrent(compositor->base.display, output->egl_surface, + output->egl_surface, compositor->base.context)) { + fprintf(stderr, "failed to make current\n"); + return; + } - eglSwapBuffers(c->base.display, output->egl_surface); + wl_list_for_each_reverse(surface, &compositor->base.surface_list, link) + weston_surface_draw(surface, &output->base); + + eglSwapBuffers(compositor->base.display, output->egl_surface); callback = wl_surface_frame(output->parent.surface); wl_callback_add_listener(callback, &frame_listener, output); - return 0; + return; } static int @@ -300,9 +282,7 @@ wayland_compositor_create_output(struct wayland_compositor *c, glClearColor(0, 0, 0, 0.5); - output->base.prepare_render = wayland_output_prepare_render; output->base.repaint = wayland_output_repaint; - output->base.present = wayland_output_present; output->base.prepare_scanout_surface = wayland_output_prepare_scanout_surface; output->base.set_hardware_cursor = wayland_output_set_cursor; diff --git a/src/compositor-x11.c b/src/compositor-x11.c index 771bf69..08306b9 100644 --- a/src/compositor-x11.c +++ b/src/compositor-x11.c @@ -185,29 +185,26 @@ x11_compositor_fini_egl(struct x11_compositor *compositor) eglReleaseThread(); } -static int -x11_output_prepare_render(struct weston_output *output_base) +static void +x11_output_repaint(struct weston_output *output_base) { - struct x11_output *output = (struct x11_output *) output_base; - struct weston_compositor *ec = output->base.compositor; + struct x11_output *output = (struct x11_output *)output_base; + struct x11_compositor *compositor = + (struct x11_compositor *)output->base.compositor; + struct weston_surface *surface; - if (!eglMakeCurrent(ec->display, output->egl_surface, - output->egl_surface, ec->context)) { + if (!eglMakeCurrent(compositor->base.display, output->egl_surface, + output->egl_surface, compositor->base.context)) { fprintf(stderr, "failed to make current\n"); - return -1; + return; } - return 0; -} + wl_list_for_each_reverse(surface, &compositor->base.surface_list, link) + weston_surface_draw(surface, &output->base); -static void -x11_output_repaint(struct weston_output *output) -{ - struct weston_compositor *compositor = output->compositor; - struct weston_surface *surface; + eglSwapBuffers(compositor->base.display, output->egl_surface); - wl_list_for_each_reverse(surface, &compositor->surface_list, link) - weston_surface_draw(surface, output); + wl_event_source_timer_update(output->finish_frame_timer, 10); } static int @@ -225,22 +222,6 @@ finish_frame_handler(void *data) } static int -x11_output_present(struct weston_output *output_base) -{ - struct x11_output *output = (struct x11_output *) output_base; - struct weston_compositor *ec = output->base.compositor; - - if (x11_output_prepare_render(&output->base)) - return -1; - - eglSwapBuffers(ec->display, output->egl_surface); - - wl_event_source_timer_update(output->finish_frame_timer, 10); - - return 0; -} - -static int x11_output_prepare_scanout_surface(struct weston_output *output_base, struct weston_surface *es) { @@ -471,9 +452,7 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y, output->finish_frame_timer = wl_event_loop_add_timer(loop, finish_frame_handler, output); - output->base.prepare_render = x11_output_prepare_render; output->base.repaint = x11_output_repaint; - output->base.present = x11_output_present; output->base.prepare_scanout_surface = x11_output_prepare_scanout_surface; output->base.set_hardware_cursor = x11_output_set_cursor; diff --git a/src/compositor.c b/src/compositor.c index 93c76c7..b6a1418 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -810,8 +810,6 @@ weston_output_repaint(struct weston_output *output) pixman_region32_t opaque, new_damage, total_damage, overlap, surface_overlap; - output->prepare_render(output); - glViewport(0, 0, output->current->width, output->current->height); weston_output_set_cursor(output, ec->input_device, @@ -884,7 +882,6 @@ repaint(struct weston_output *output, int msecs) weston_output_repaint(output); output->repaint_needed = 0; output->repaint_scheduled = 1; - output->present(output); wl_list_for_each_safe(cb, cnext, &output->frame_callback_list, link) { wl_resource_post_event(&cb->resource, WL_CALLBACK_DONE, msecs); diff --git a/src/compositor.h b/src/compositor.h index d7eeae7..da37a0a 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -87,9 +87,7 @@ struct weston_output { struct wl_buffer *pending_scanout_buffer; struct wl_listener pending_scanout_buffer_destroy_listener; - int (*prepare_render)(struct weston_output *output); void (*repaint)(struct weston_output *output); - int (*present)(struct weston_output *output); int (*prepare_scanout_surface)(struct weston_output *output, struct weston_surface *es); int (*set_hardware_cursor)(struct weston_output *output, |