[PATCH 8/9] compositor: Move arrays used by wayland backend rendering into the wayland backend.

John Kåre Alsaker john.kare.alsaker at gmail.com
Sat Sep 15 11:34:06 PDT 2012


---
 src/compositor-wayland.c | 21 +++++++++++++++------
 src/compositor.c         |  1 -
 src/compositor.h         |  1 -
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 71031ff..a12a90a 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -60,6 +60,10 @@ struct wayland_compositor {
 		uint32_t event_mask;
 	} parent;
 
+	/* Repaint state. */
+	struct wl_array vertices;
+	struct wl_array indices;
+
 	struct {
 		int32_t top, bottom, left, right;
 		GLuint texture;
@@ -126,8 +130,8 @@ texture_border(struct wayland_output *output)
 	v[3] = 1.0;
 
 	n = 8;
-	d = wl_array_add(&c->base.vertices, n * 16 * sizeof *d);
-	p = wl_array_add(&c->base.indices, n * 6 * sizeof *p);
+	d = wl_array_add(&c->vertices, n * 16 * sizeof *d);
+	p = wl_array_add(&c->indices, n * 6 * sizeof *p);
 
 	k = 0;
 	for (i = 0; i < 3; i++)
@@ -187,20 +191,20 @@ draw_border(struct wayland_output *output)
 
 	glBindTexture(GL_TEXTURE_2D, c->border.texture);
 
-	v = c->base.vertices.data;
+	v = c->vertices.data;
 	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[0]);
 	glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[2]);
 	glEnableVertexAttribArray(0);
 	glEnableVertexAttribArray(1);
 
 	glDrawElements(GL_TRIANGLES, n * 6,
-		       GL_UNSIGNED_INT, c->base.indices.data);
+		       GL_UNSIGNED_INT, c->indices.data);
 
 	glDisableVertexAttribArray(1);
 	glDisableVertexAttribArray(0);
 
-	c->base.vertices.size = 0;
-	c->base.indices.size = 0;
+	c->vertices.size = 0;
+	c->indices.size = 0;
 }
 
 static void
@@ -750,8 +754,13 @@ wayland_restore(struct weston_compositor *ec)
 static void
 wayland_destroy(struct weston_compositor *ec)
 {
+	struct wayland_compositor *c = (struct wayland_compositor *)ec;
+
 	gles2_renderer_destroy(ec);
 
+	wl_array_release(&c->vertices);
+	wl_array_release(&c->indices);
+
 	weston_compositor_shutdown(ec);
 
 	free(ec);
diff --git a/src/compositor.c b/src/compositor.c
index 2fb89b6..45eeb5f 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2814,7 +2814,6 @@ weston_compositor_shutdown(struct weston_compositor *ec)
 	weston_plane_release(&ec->primary_plane);
 
 	wl_array_release(&ec->vertices);
-	wl_array_release(&ec->indices);
 	wl_array_release(&ec->vtxcnt);
 
 	wl_event_loop_destroy(ec->input_loop);
diff --git a/src/compositor.h b/src/compositor.h
index 1088f09..776048f 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -333,7 +333,6 @@ struct weston_compositor {
 
 	/* Repaint state. */
 	struct wl_array vertices;
-	struct wl_array indices; /* only used in compositor-wayland */
 	struct wl_array vtxcnt;
 	struct weston_plane primary_plane;
 	int fan_debug;
-- 
1.7.12



More information about the wayland-devel mailing list