[PATCH v2 1/3] compositor: Add output callbacks for rendering backend.

John Kåre Alsaker john.kare.alsaker at gmail.com
Tue Sep 11 09:57:54 PDT 2012


---
 src/compositor.c     | 12 ++++++++++++
 src/compositor.h     |  3 +++
 src/gles2-renderer.c | 24 ++++++++++++++++++++++++
 3 files changed, 39 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index 911eaba..191ce9c 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2523,6 +2523,8 @@ weston_output_destroy(struct weston_output *output)
 {
 	struct weston_compositor *c = output->compositor;
 
+	c->renderer->destroy_output(output);
+
 	pixman_region32_fini(&output->region);
 	pixman_region32_fini(&output->previous_damage);
 	output->compositor->output_id_pool &= ~(1 << output->id);
@@ -2648,6 +2650,8 @@ weston_output_transform_init(struct weston_output *output, uint32_t transform)
 WL_EXPORT void
 weston_output_move(struct weston_output *output, int x, int y)
 {
+	struct weston_compositor *ec = output->compositor;
+
 	output->x = x;
 	output->y = y;
 
@@ -2655,6 +2659,10 @@ weston_output_move(struct weston_output *output, int x, int y)
 	pixman_region32_init_rect(&output->region, x, y,
 				  output->width,
 				  output->height);
+
+	/* this function is called before renderer is setup */
+	if(ec->renderer)
+		ec->renderer->move_output(output);
 }
 
 WL_EXPORT void
@@ -2678,6 +2686,10 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c,
 	weston_output_transform_init(output, transform);
 	weston_output_init_zoom(output);
 
+	/* this function is called before renderer is setup */
+	if(c->renderer)
+		c->renderer->init_output(output);
+
 	weston_output_move(output, x, y);
 	weston_output_damage(output);
 
diff --git a/src/compositor.h b/src/compositor.h
index 2954703..dc909cf 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -268,6 +268,9 @@ struct weston_plane {
 };
 
 struct weston_renderer {
+	void (*init_output)(struct weston_output *output);
+	void (*destroy_output)(struct weston_output *output);
+	void (*move_output)(struct weston_output *output);
 	void (*repaint_output)(struct weston_output *output,
 			       pixman_region32_t *output_damage);
 	void (*flush_damage)(struct weston_surface *surface);
diff --git a/src/gles2-renderer.c b/src/gles2-renderer.c
index a19c8c5..46440cf 100644
--- a/src/gles2-renderer.c
+++ b/src/gles2-renderer.c
@@ -675,6 +675,21 @@ gles2_renderer_repaint_output(struct weston_output *output,
 }
 
 static void
+gles2_renderer_init_output(struct weston_output *output)
+{
+}
+
+static void
+gles2_renderer_destroy_output(struct weston_output *output)
+{
+}
+
+static void
+gles2_renderer_move_output(struct weston_output *output)
+{
+}
+
+static void
 gles2_renderer_flush_damage(struct weston_surface *surface)
 {
 #ifdef GL_UNPACK_ROW_LENGTH
@@ -1173,11 +1188,20 @@ gles2_renderer_init(struct weston_compositor *ec)
 			     vertex_shader, solid_fragment_shader) < 0)
 		return -1;
 
+	renderer->base.init_output = gles2_renderer_init_output;
+	renderer->base.destroy_output = gles2_renderer_destroy_output;
+	renderer->base.move_output = gles2_renderer_move_output;
 	renderer->base.repaint_output = gles2_renderer_repaint_output;
 	renderer->base.flush_damage = gles2_renderer_flush_damage;
 	renderer->base.attach = gles2_renderer_attach;
 	renderer->base.destroy_surface = gles2_renderer_destroy_surface;
 	ec->renderer = &renderer->base;
 
+	/* outputs are created before this function, so call init_output and move_output on each of them */
+	wl_list_for_each(output, &ec->output_list, link) {
+		gles2_renderer_init_output(output);
+		gles2_renderer_move_output(output);
+	}
+
 	return 0;
 }
-- 
1.7.12



More information about the wayland-devel mailing list