compositor: Remove prepare_scanout_surface callout

For the drm backend, we just refactor setup_scanout_surface into
drm_output_prepare_scanout_surface and call it from drm_output_repaint.
dev
Kristian Høgsberg 13 years ago
parent 06cf6b0238
commit 5f5e42ef50
  1. 107
      src/compositor-drm.c
  2. 9
      src/compositor-wayland.c
  3. 9
      src/compositor-x11.c
  4. 23
      src/compositor.c
  5. 2
      src/compositor.h

@ -78,6 +78,64 @@ struct drm_output {
uint32_t pending_fs_surf_fb_id; 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 static void
drm_output_repaint(struct weston_output *output_base) 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) if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
return; return;
drm_output_prepare_scanout_surface(output);
wl_list_for_each_reverse(surface, &compositor->base.surface_list, link) wl_list_for_each_reverse(surface, &compositor->base.surface_list, link)
weston_surface_draw(surface, &output->base); weston_surface_draw(surface, &output->base);
@ -141,51 +201,6 @@ page_flip_handler(int fd, unsigned int frame,
weston_output_finish_frame(&output->base, msecs); weston_output_finish_frame(&output->base, msecs);
} }
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 static int
drm_output_set_cursor(struct weston_output *output_base, drm_output_set_cursor(struct weston_output *output_base,
struct weston_input_device *eid) 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->pending_fs_surf_fb_id = 0;
output->base.repaint = drm_output_repaint; 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.set_hardware_cursor = drm_output_set_cursor;
output->base.destroy = drm_output_destroy; output->base.destroy = drm_output_destroy;

@ -198,13 +198,6 @@ wayland_output_repaint(struct weston_output *output_base)
return; return;
} }
static int
wayland_output_prepare_scanout_surface(struct weston_output *output_base,
struct weston_surface *es)
{
return -1;
}
static int static int
wayland_output_set_cursor(struct weston_output *output_base, wayland_output_set_cursor(struct weston_output *output_base,
struct weston_input_device *input) struct weston_input_device *input)
@ -283,8 +276,6 @@ wayland_compositor_create_output(struct wayland_compositor *c,
glClearColor(0, 0, 0, 0.5); glClearColor(0, 0, 0, 0.5);
output->base.repaint = wayland_output_repaint; 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.set_hardware_cursor = wayland_output_set_cursor;
output->base.destroy = wayland_output_destroy; output->base.destroy = wayland_output_destroy;

@ -221,13 +221,6 @@ finish_frame_handler(void *data)
return 1; return 1;
} }
static int
x11_output_prepare_scanout_surface(struct weston_output *output_base,
struct weston_surface *es)
{
return -1;
}
static int static int
x11_output_set_cursor(struct weston_output *output_base, x11_output_set_cursor(struct weston_output *output_base,
struct weston_input_device *input) 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); wl_event_loop_add_timer(loop, finish_frame_handler, output);
output->base.repaint = x11_output_repaint; 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.set_hardware_cursor = x11_output_set_cursor;
output->base.destroy = x11_output_destroy; output->base.destroy = x11_output_destroy;

@ -785,23 +785,6 @@ out:
pixman_region32_fini(&cursor_region); 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 static void
weston_output_repaint(struct weston_output *output) weston_output_repaint(struct weston_output *output)
{ {
@ -853,12 +836,6 @@ weston_output_repaint(struct weston_output *output)
&total_damage, &es->opaque); &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); output->repaint(output);
if (ec->fade.spring.current > 0.001) if (ec->fade.spring.current > 0.001)

@ -88,8 +88,6 @@ struct weston_output {
struct wl_listener pending_scanout_buffer_destroy_listener; struct wl_listener pending_scanout_buffer_destroy_listener;
void (*repaint)(struct weston_output *output); 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, int (*set_hardware_cursor)(struct weston_output *output,
struct weston_input_device *input); struct weston_input_device *input);
void (*destroy)(struct weston_output *output); void (*destroy)(struct weston_output *output);

Loading…
Cancel
Save